-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataNameNode.java
More file actions
96 lines (84 loc) · 2.57 KB
/
DataNameNode.java
File metadata and controls
96 lines (84 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package EDU.bmrb.starlibj;
import java.lang.*;
import java.util.*;
/** This is a simple class that holds a single tag name (either
* a free tag/value pair or a name in a loop). This is a very
* simple class that exists mainly for orthogonality.
*/
public class DataNameNode extends StarNode implements Cloneable
{
/** Returns the string contained in this name. This is identical to
* <TT>getLabel()</TT>.
*/
public String getValue()
{
return myStrVal;
}
/** Returns the string contained in this name. This is identical to
* <TT>getValue()</TT>.
*/
public String getLabel()
{
return myStrVal;
}
/** Sets the string name for this node. This is identical
* to <TT>setLabel()</TT>.
*/
public void setValue( String newVal )
throws NameViolatesStarSyntax
{
if( StarValidity.isValidTagName( newVal ) )
myStrVal = newVal;
else
throw new NameViolatesStarSyntax(newVal,"tag name");
}
/** Sets the string name for this node. This is identical
* to <TT>setValue()</TT>.
*/
public void setLabel( String newVal )
throws NameViolatesStarSyntax
{
if( StarValidity.isValidTagName( newVal ) )
myStrVal = newVal;
else
throw new NameViolatesStarSyntax(newVal, "tag name");
}
/** Constructor - all DataNameNodes must have a string value,
* so no provisions are made for a 'default' no-args constructor.
* @exception NameViolatesStarSyntax thrown when the string given
* is not a valid STAR tag name.
*/
public DataNameNode( String str )
throws NameViolatesStarSyntax
{
super();
myStrVal = str;
if( ! StarValidity.isValidTagName( str ) )
throw new NameViolatesStarSyntax(str, "tag name");
}
/** Constructor - copy another DataValueNode. */
public DataNameNode( DataNameNode copyMe )
{
super( copyMe );
myStrVal = (copyMe.myStrVal == null ) ?
null : new String( copyMe.myStrVal );
}
/** Allocates a new copy of me and returns a reference to it.
* This is a deep copy, meaning that all children are copied
* instead of linked.
*/
public Object clone()
{
return new DataNameNode( this );
}
/** Unparse prints the contents of the StarNode object out to the
* given stream. This is essentially the inverse of the CS term
* to "parse", hence the name "Unparse". The parameter given is
* the indentation level to print things.
*/
public void Unparse( int indent )
{
// Fill this messy thing in later.
}
protected String myStrVal;
}