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.descriptors; 23 24 import org.apache.openoffice.comp.sdbc.dbtools.comphelper.PropertySetAdapter.PropertyGetter; 25 import org.apache.openoffice.comp.sdbc.dbtools.comphelper.PropertySetAdapter.PropertySetter; 26 import org.apache.openoffice.comp.sdbc.dbtools.util.PropertyIds; 27 28 import com.sun.star.lang.XServiceInfo; 29 import com.sun.star.uno.Type; 30 31 public class SdbcxKeyColumnDescriptor extends SdbcxColumnDescriptor implements XServiceInfo { 32 private static final String[] services = { 33 "com.sun.star.sdbcx.KeyColumnDescriptor" 34 }; 35 36 protected String relatedColumn; 37 SdbcxKeyColumnDescriptor(boolean isCaseSensitive)38 public SdbcxKeyColumnDescriptor(boolean isCaseSensitive) { 39 super(isCaseSensitive); 40 registerProperties(); 41 } 42 registerProperties()43 private void registerProperties() { 44 registerProperty(PropertyIds.RELATEDCOLUMN.name, PropertyIds.RELATEDCOLUMN.id, Type.STRING, (short)0, 45 new PropertyGetter() { 46 @Override 47 public Object getValue() { 48 return relatedColumn; 49 50 } 51 }, 52 new PropertySetter() { 53 @Override 54 public void setValue(Object value) { 55 relatedColumn = (String) value; 56 } 57 }); 58 } 59 60 // XServiceInfo 61 getImplementationName()62 public String getImplementationName() { 63 return getClass().getName(); 64 } 65 66 @Override getSupportedServiceNames()67 public String[] getSupportedServiceNames() { 68 return services.clone(); 69 } 70 71 @Override supportsService(String serviceName)72 public boolean supportsService(String serviceName) { 73 for (String service : getSupportedServiceNames()) { 74 if (service.equals(serviceName)) { 75 return true; 76 } 77 } 78 return false; 79 } 80 } 81