1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 package org.apache.openoffice.comp.sdbc.dbtools.sdbcx; 23 24 import org.apache.openoffice.comp.sdbc.dbtools.comphelper.CompHelper; 25 import org.apache.openoffice.comp.sdbc.dbtools.comphelper.PropertySetAdapter.PropertyGetter; 26 import org.apache.openoffice.comp.sdbc.dbtools.sdbcx.descriptors.SdbcxIndexColumnDescriptor; 27 import org.apache.openoffice.comp.sdbc.dbtools.util.PropertyIds; 28 29 import com.sun.star.beans.PropertyAttribute; 30 import com.sun.star.beans.XPropertySet; 31 import com.sun.star.lang.XServiceInfo; 32 import com.sun.star.uno.Type; 33 34 public class OIndexColumn extends OColumn implements XServiceInfo { 35 36 private static final String[] services = { 37 "com.sun.star.sdbcx.IndexColumn" 38 }; 39 40 protected boolean isAscending; 41 OIndexColumn( final boolean isAscending, final String name, final String typeName, final String defaultValue, final String description, final int isNullable, final int precision, final int scale, final int type, final boolean isAutoIncrement, final boolean isRowVersion, final boolean isCurrency, final boolean isCaseSensitive)42 public OIndexColumn( 43 final boolean isAscending, 44 final String name, 45 final String typeName, 46 final String defaultValue, 47 final String description, 48 final int isNullable, 49 final int precision, 50 final int scale, 51 final int type, 52 final boolean isAutoIncrement, 53 final boolean isRowVersion, 54 final boolean isCurrency, 55 final boolean isCaseSensitive) { 56 super(name, typeName, defaultValue, description, isNullable, 57 precision, scale, type, isAutoIncrement, isRowVersion, isCurrency, isCaseSensitive); 58 this.isAscending = isAscending; 59 registerProperties(); 60 } 61 registerProperties()62 private void registerProperties() { 63 registerProperty(PropertyIds.ISASCENDING.name, PropertyIds.ISASCENDING.id, Type.BOOLEAN, PropertyAttribute.READONLY, 64 new PropertyGetter() { 65 @Override 66 public Object getValue() { 67 return isAscending; 68 69 } 70 }, null); 71 } 72 73 // XServiceInfo 74 getImplementationName()75 public String getImplementationName() { 76 return getClass().getName(); 77 } 78 79 @Override getSupportedServiceNames()80 public String[] getSupportedServiceNames() { 81 return services.clone(); 82 } 83 84 @Override supportsService(String serviceName)85 public boolean supportsService(String serviceName) { 86 for (String service : getSupportedServiceNames()) { 87 if (service.equals(serviceName)) { 88 return true; 89 } 90 } 91 return false; 92 } 93 94 // XDataDescriptorFactory 95 96 @Override createDataDescriptor()97 public XPropertySet createDataDescriptor() { 98 SdbcxIndexColumnDescriptor descriptor = new SdbcxIndexColumnDescriptor(isCaseSensitive()); 99 synchronized (this) { 100 CompHelper.copyProperties(this, descriptor); 101 } 102 return descriptor; 103 } 104 } 105