View Javadoc

1   // Copyright 2006-2008, by the California Institute of 
2   // Technology. ALL RIGHTS RESERVED. United States Government 
3   // Sponsorship acknowledged. Any commercial use must be negotiated with 
4   // the Office of Technology Transfer at the California Institute of 
5   // Technology.
6   //
7   // This software may be subject to U.S. export control laws. By 
8   // accepting this software, the user agrees to comply with all 
9   // applicable U.S. export laws and regulations. User has the 
10  // responsibility to obtain export licenses, or other export authority 
11  // as may be required before exporting such information to foreign 
12  // countries or providing access to foreign persons.
13  //
14  // $Id: Alias.java 3461 2008-08-07 17:43:26Z pramirez $ 
15  //
16  
17  package gov.nasa.pds.tools.dict;
18  
19  import gov.nasa.pds.tools.label.Identifier;
20  
21  /***
22   * @author pramirez
23   * @version $Revision: 3461 $
24   * 
25   */
26  public class Alias {
27      private String context;
28      private Identifier identifier;
29      
30      public Alias(String identifier) {
31          this("", new Identifier(identifier));
32      }
33      
34      public Alias(Identifier identifier) {
35          this("", identifier);
36      }
37      
38      public Alias(String context, String identifier) {
39          this(context, new Identifier(identifier));
40      }
41      
42      public Alias(String context, Identifier identifier) {
43          this.context = context;
44          this.identifier = identifier;
45      }
46      
47      public boolean hasContext() {
48          return ("".equals(context)) ? false : true;
49      }
50      
51      public String getContext() {
52          return context;
53      }
54      
55      public Identifier getIdentifier() {
56          return identifier;
57      }
58      
59      public String toString() {
60          if (!"".equals(context))
61              return context + "." + identifier.toString();
62          return identifier.toString();
63      }
64  }