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

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.chemistry.opencmis.client.parser;
20  
21  import java.util.HashMap;
22  import java.util.Map;
23  
24  import org.apache.chemistry.opencmis.client.mapper.MapperException;
25  import org.apache.chemistry.opencmis.client.mapper.PropertyMapper;
26  import org.apache.chemistry.opencmis.commons.PropertyIds;
27  
28  public abstract class AbstractMetadataParser implements MetadataParser {
29      
30      // private static final Log LOG = LogFactory.getLog(AbstractMetadataParser.class.getName());
31  
32      protected Map<String, Object> cmisProperties;
33      protected PropertyMapper mapper = null;
34      
35      protected AbstractMetadataParser() {
36      }
37  
38      public void initialize(PropertyMapper mapper, String contentType) {
39          this.mapper = mapper;
40          reset();
41      }
42  
43      public Map<String, Object> getCmisProperties() {
44          return cmisProperties;
45      }
46      
47      public void reset() {
48          String typeId = mapper.getMappedTypeId();
49          cmisProperties = new HashMap<String, Object>();
50          mapper.reset();
51  
52          if (null == typeId)
53              throw new MapperException("No CMIS Type configured in this parser.");
54          cmisProperties.put(PropertyIds.OBJECT_TYPE_ID, typeId);
55      }
56      
57      public String[] getContentTypes() {
58          return mapper.getContentTypes();
59      }
60      
61      public String getMappedTypeId() {
62          return mapper.getMappedTypeId();
63      }
64      
65      public PropertyMapper getMapper() {
66          return mapper;
67      }
68  }