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.metadata.ModelMetadata;
20  import org.codehaus.modello.model.Version;
21  import org.codehaus.plexus.util.StringUtils;
22  
23  /**
24   * XsdModelMetadata
25   *
26   * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
27   */
28  public class XsdModelMetadata implements ModelMetadata
29  {
30      public static final String ID = XsdModelMetadata.class.getName();
31  
32      private String namespace;
33  
34      private String targetNamespace;
35  
36      public String getNamespace()
37      {
38          return namespace;
39      }
40  
41      public void setNamespace( String namespace )
42      {
43          this.namespace = namespace;
44      }
45  
46      public String getTargetNamespace()
47      {
48          return targetNamespace;
49      }
50  
51      public void setTargetNamespace( String targetNamespace )
52      {
53          this.targetNamespace = targetNamespace;
54      }
55  
56      public String getNamespace( Version version )
57      {
58          String namespace = this.namespace;
59  
60          if ( version != null )
61          {
62              namespace = StringUtils.replace( namespace, "${version}", version.toString() );
63          }
64  
65          return namespace;
66      }
67  
68      public String getTargetNamespace( Version version )
69      {
70          String targetNamespace = this.targetNamespace;
71  
72          if ( version != null )
73          {
74              targetNamespace = StringUtils.replace( targetNamespace, "${version}", version.toString() );
75          }
76  
77          return targetNamespace;
78      }
79  }