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.dict;
8   
9   import gov.nasa.pds.tools.label.Identifier;
10  
11  /***
12   * @author pramirez
13   * @version $Revision$
14   * 
15   */
16  public class Alias {
17      private String context;
18      private Identifier identifier;
19      
20      public Alias(String identifier) {
21          this("", new Identifier(identifier));
22      }
23      
24      public Alias(Identifier identifier) {
25          this("", identifier);
26      }
27      
28      public Alias(String context, String identifier) {
29          this(context, new Identifier(identifier));
30      }
31      
32      public Alias(String context, Identifier identifier) {
33          this.context = context;
34          this.identifier = identifier;
35      }
36      
37      public boolean hasContext() {
38          return ("".equals(context)) ? false : true;
39      }
40      
41      public String getContext() {
42          return context;
43      }
44      
45      public Identifier getIdentifier() {
46          return identifier;
47      }
48      
49      public String toString() {
50          if (!"".equals(context))
51              return context + "." + identifier.toString();
52          return identifier.toString();
53      }
54  }