View Javadoc
1   package org.codehaus.modello.plugin.xsd.metadata;
2   
3   /*
4    * Copyright 2001-2007 The Codehaus.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * 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, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import javax.inject.Named;
20  import javax.inject.Singleton;
21  
22  import java.util.Map;
23  
24  import org.codehaus.modello.ModelloException;
25  import org.codehaus.modello.metadata.AbstractMetadataPlugin;
26  import org.codehaus.modello.metadata.AssociationMetadata;
27  import org.codehaus.modello.metadata.ClassMetadata;
28  import org.codehaus.modello.metadata.FieldMetadata;
29  import org.codehaus.modello.metadata.InterfaceMetadata;
30  import org.codehaus.modello.metadata.ModelMetadata;
31  import org.codehaus.modello.model.Model;
32  import org.codehaus.modello.model.ModelAssociation;
33  import org.codehaus.modello.model.ModelClass;
34  import org.codehaus.modello.model.ModelField;
35  import org.codehaus.modello.model.ModelInterface;
36  
37  /**
38   * XsdMetadataPlugin
39   *
40   * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
41   */
42  @Named("xdoc")
43  @Singleton
44  public class XsdMetadataPlugin extends AbstractMetadataPlugin {
45      public static final String NAMESPACE = "xsd.namespace";
46  
47      public static final String TARGET_NAMESPACE = "xsd.targetNamespace";
48  
49      public static final String COMPOSITOR = "xsd.compositor";
50  
51      public AssociationMetadata getAssociationMetadata(ModelAssociation association, Map<String, String> data)
52              throws ModelloException {
53          return new XsdAssociationMetadata();
54      }
55  
56      public ClassMetadata getClassMetadata(ModelClass clazz, Map<String, String> data) throws ModelloException {
57          XsdClassMetadata metadata = new XsdClassMetadata();
58  
59          metadata.setCompositor(getString(data, COMPOSITOR));
60  
61          return metadata;
62      }
63  
64      public InterfaceMetadata getInterfaceMetadata(ModelInterface iface, Map<String, String> data)
65              throws ModelloException {
66          return new XsdInterfaceMetadata();
67      }
68  
69      public FieldMetadata getFieldMetadata(ModelField field, Map<String, String> data) throws ModelloException {
70          return new XsdFieldMetadata();
71      }
72  
73      public ModelMetadata getModelMetadata(Model model, Map<String, String> data) throws ModelloException {
74          XsdModelMetadata metadata = new XsdModelMetadata();
75  
76          metadata.setNamespace(getString(data, NAMESPACE));
77  
78          metadata.setTargetNamespace(getString(data, TARGET_NAMESPACE));
79  
80          return metadata;
81      }
82  }