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 package org.apache.openoffice.comp.sdbc.dbtools.sdbcx.descriptors;
22 
23 import org.apache.openoffice.comp.sdbc.dbtools.comphelper.PropertySetAdapter.PropertyGetter;
24 import org.apache.openoffice.comp.sdbc.dbtools.comphelper.PropertySetAdapter.PropertySetter;
25 import org.apache.openoffice.comp.sdbc.dbtools.sdbcx.ODescriptor;
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 SdbcxViewDescriptor extends ODescriptor implements XServiceInfo {
32 
33     private static final String[] services = {
34             "com.sun.star.sdbcx.ViewDescriptor"
35     };
36 
37     protected String catalogName;
38     protected String schemaName;
39     protected String command;
40     protected int checkOption;
41 
SdbcxViewDescriptor(boolean isCaseSensitive)42     public SdbcxViewDescriptor(boolean isCaseSensitive) {
43         super("", isCaseSensitive, false);
44         registerProperties();
45     }
46 
registerProperties()47     private void registerProperties() {
48         registerProperty(PropertyIds.CATALOGNAME.name, PropertyIds.CATALOGNAME.id, Type.STRING, (short)0,
49                 new PropertyGetter() {
50                     @Override
51                     public Object getValue() {
52                         return catalogName;
53 
54                     }
55                 },
56                 new PropertySetter() {
57                     @Override
58                     public void setValue(Object value) {
59                         catalogName = (String) value;
60                     }
61                 });
62         registerProperty(PropertyIds.SCHEMANAME.name, PropertyIds.SCHEMANAME.id, Type.STRING, (short)0,
63                 new PropertyGetter() {
64                     @Override
65                     public Object getValue() {
66                         return schemaName;
67 
68                     }
69                 },
70                 new PropertySetter() {
71                     @Override
72                     public void setValue(Object value) {
73                         schemaName = (String) value;
74                     }
75                 });
76         registerProperty(PropertyIds.COMMAND.name, PropertyIds.COMMAND.id, Type.STRING, (short)0,
77                 new PropertyGetter() {
78                     @Override
79                     public Object getValue() {
80                         return command;
81 
82                     }
83                 },
84                 new PropertySetter() {
85                     @Override
86                     public void setValue(Object value) {
87                         command = (String) value;
88                     }
89                 });
90         registerProperty(PropertyIds.CHECKOPTION.name, PropertyIds.CHECKOPTION.id, Type.LONG, (short)0,
91                 new PropertyGetter() {
92                     @Override
93                     public Object getValue() {
94                         return checkOption;
95 
96                     }
97                 },
98                 new PropertySetter() {
99                     @Override
100                     public void setValue(Object value) {
101                         checkOption = (int) value;
102                     }
103                 });
104     }
105 
106     // XServiceInfo
107 
getImplementationName()108     public String getImplementationName() {
109         return getClass().getName();
110     }
111 
112     @Override
getSupportedServiceNames()113     public String[] getSupportedServiceNames() {
114         return services.clone();
115     }
116 
117     @Override
supportsService(String serviceName)118     public boolean supportsService(String serviceName) {
119         for (String service : getSupportedServiceNames()) {
120             if (service.equals(serviceName)) {
121                 return true;
122             }
123         }
124         return false;
125     }
126 }
127