View Javadoc

1   //Copyright (c) 2005, California Institute of Technology.
2   //ALL RIGHTS RESERVED. U.S. Government sponsorship acknowledged.
3   //
4   // $Id$ 
5   //
6   
7   package gov.nasa.pds.tools.label;
8   
9   /***
10   * @author pramirez
11   * @version $Revision$
12   * 
13   */
14  public class Identifier {
15      private String namespace;
16      private String localName;
17      
18      public Identifier(String namespace, String localName) {
19          this.namespace = namespace;
20          this.localName = localName;
21      }
22      
23      public Identifier(String identifier) {
24          namespace = "";
25          if (identifier.indexOf(":") != -1)
26              namespace = identifier.substring(0, identifier.indexOf(":"));
27          
28          if (identifier.indexOf(":") == -1)
29              localName = identifier;
30          else
31              localName = identifier.substring(identifier.indexOf(":") + 1);
32      }
33      
34      public String toString() {
35          if ("".equals(namespace))
36              return localName;
37          else
38              return namespace + ":" + localName;
39      }
40      
41      public String getLocalName() {
42          return localName;
43      }
44      
45      public String getNamespace() {
46          return namespace;
47      }
48  }
49