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      public static final String ID = XsdModelMetadata.class.getName();
30  
31      private String namespace;
32  
33      private String targetNamespace;
34  
35      public String getNamespace() {
36          return namespace;
37      }
38  
39      public void setNamespace(String namespace) {
40          this.namespace = namespace;
41      }
42  
43      public String getTargetNamespace() {
44          return targetNamespace;
45      }
46  
47      public void setTargetNamespace(String targetNamespace) {
48          this.targetNamespace = targetNamespace;
49      }
50  
51      public String getNamespace(Version version) {
52          String namespace = this.namespace;
53  
54          if (version != null) {
55              namespace = StringUtils.replace(namespace, "${version}", version.toString());
56          }
57  
58          return namespace;
59      }
60  
61      public String getTargetNamespace(Version version) {
62          String targetNamespace = this.targetNamespace;
63  
64          if (version != null) {
65              targetNamespace = StringUtils.replace(targetNamespace, "${version}", version.toString());
66          }
67  
68          return targetNamespace;
69      }
70  }