This project has retired. For details please refer to its Attic page.
AbstractPropertyMapper xref

1   /*
2    * Li
3   censed 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  package org.apache.chemistry.opencmis.client.mapper;
21  
22  import java.util.Properties;
23  
24  public abstract class AbstractPropertyMapper implements PropertyMapper {
25      
26      private static String DEFAULT_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
27  
28      protected String[] contentTypes;
29      protected String cmisTypeId;
30      protected String propPrefix;
31      protected String dateFormat = DEFAULT_DATE_FORMAT;    
32  
33      public boolean initialize(String cfgPrefix, String typeKey, Properties properties) {
34          propPrefix = cfgPrefix + "." + typeKey;
35          cmisTypeId =   properties.getProperty(propPrefix + ".typeId");
36          String contentTypeEntry = properties.getProperty(propPrefix);
37           
38          contentTypes = contentTypeEntry.split("\\:");
39          for (int i=0; i<contentTypes.length; i++) {
40              contentTypes[i] = contentTypes[i].trim();
41          }
42  
43          String df = properties.getProperty(propPrefix + ".dateFormat");
44          if (null!=df)
45              dateFormat = df;
46                  
47          if (null == cmisTypeId) 
48              throw new MapperException("Missingt type id in properties: " + propPrefix + ".typeId");
49          
50          return true;
51      }
52  
53      public String getMappedTypeId() {
54          return cmisTypeId;
55      }
56      
57      public String[] getContentTypes() {
58          return contentTypes;
59      }
60  
61  }