1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package gov.nasa.pds.tools.label;
17
18 /***
19 * This class represents an attribute assignment in a PDS label file.
20 * @author pramirez
21 * @version $Revision: 3302 $
22 *
23 */
24 public class AttributeStatement extends Statement {
25 private Value value;
26 private String namespace;
27 private String elementIdentifier;
28 private CommentStatement comment;
29
30 /***
31 * Constructs a new attribute statement with no value
32 * @param lineNumber Line on which the statement starts
33 * @param identifier Uniquely identifies the statement
34 */
35 protected AttributeStatement(int lineNumber, String identifier) {
36 this(lineNumber, identifier, null);
37 }
38
39 /***
40 * Constructs a new attribute statement with no line number or value
41 * @param identifier Uniquely identifies the statement
42 */
43 public AttributeStatement(String identifier) {
44 this(identifier, null);
45 }
46
47 /***
48 * Constructs a new attribute statement with no line number
49 * @param identifier Uniquely identifies the statement
50 * @param value {@link Value} of the attribute
51 */
52 public AttributeStatement(String identifier, Value value) {
53 this(-1, identifier, value);
54 }
55
56 /***
57 *
58 * @param lineNumber Line on which the statement starts
59 * @param identifier Uniquely identifies the statement
60 * @param value {@link Value} of the attribute
61 */
62 public AttributeStatement(int lineNumber, String identifier, Value value) {
63 super(lineNumber, identifier);
64
65 namespace = "";
66 if (identifier.indexOf(":") != -1)
67 namespace = identifier.substring(0, identifier.indexOf(":"));
68
69 if (identifier.indexOf(":") == -1)
70 elementIdentifier = identifier;
71 else
72 elementIdentifier = identifier.substring(identifier.indexOf(":") + 1);
73
74 this.value = value;
75
76 comment = null;
77 }
78
79 /***
80 * Gets the namespace for this attribute
81 * @return The namespace or "" if none is found.
82 */
83 public String getNamespace() {
84 return namespace;
85 }
86
87 /***
88 * Gets the unqualified identifier for the att
89 * @return Returns the element identifier.
90 */
91 public String getElementIdentifier() {
92 return elementIdentifier;
93 }
94
95 /***
96 * Retrieves the value of the attribute
97 * @return {@link Value} of the attribute
98 */
99 public Value getValue() {
100 return value;
101 }
102
103 /***
104 * Sets the value for this attribute
105 * @param value {@link Value} of the attribute
106 */
107 public void setValue(Value value) {
108 this.value = value;
109 }
110
111 public void attachComment(CommentStatement comment) {
112 this.comment = comment;
113 }
114
115 public boolean hasNamespace() {
116 if ("".equals(namespace))
117 return false;
118 return true;
119 }
120
121 }