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 org.codehaus.modello.ModelloException;
20  import org.codehaus.modello.metadata.AbstractMetadataPlugin;
21  import org.codehaus.modello.metadata.AssociationMetadata;
22  import org.codehaus.modello.metadata.ClassMetadata;
23  import org.codehaus.modello.metadata.FieldMetadata;
24  import org.codehaus.modello.metadata.InterfaceMetadata;
25  import org.codehaus.modello.metadata.ModelMetadata;
26  import org.codehaus.modello.model.Model;
27  import org.codehaus.modello.model.ModelAssociation;
28  import org.codehaus.modello.model.ModelClass;
29  import org.codehaus.modello.model.ModelField;
30  import org.codehaus.modello.model.ModelInterface;
31  
32  import java.util.Map;
33  
34  /**
35   * XsdMetadataPlugin
36   *
37   * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
38   */
39  public class XsdMetadataPlugin
40      extends AbstractMetadataPlugin
41  {
42      public static final String NAMESPACE = "xsd.namespace";
43  
44      public static final String TARGET_NAMESPACE = "xsd.targetNamespace";
45  
46      public static final String COMPOSITOR = "xsd.compositor";
47  
48      public AssociationMetadata getAssociationMetadata( ModelAssociation association, Map<String, String> data )
49          throws ModelloException
50      {
51          return new XsdAssociationMetadata();
52      }
53  
54      public ClassMetadata getClassMetadata( ModelClass clazz, Map<String, String> data )
55          throws ModelloException
56      {
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      {
67          return new XsdInterfaceMetadata();
68      }
69  
70      public FieldMetadata getFieldMetadata( ModelField field, Map<String, String> data )
71          throws ModelloException
72      {
73          return new XsdFieldMetadata();
74      }
75  
76      public ModelMetadata getModelMetadata( Model model, Map<String, String> data )
77          throws ModelloException
78      {
79          XsdModelMetadata metadata = new XsdModelMetadata();
80  
81          metadata.setNamespace( getString( data, NAMESPACE ) );
82  
83          metadata.setTargetNamespace( getString( data, TARGET_NAMESPACE ) );
84  
85          return metadata;
86      }
87  }