62 |
throw new IllegalStateException("Unexpected exception: " + e, e); |
throw new IllegalStateException("Unexpected exception: " + e, e); |
63 |
} |
} |
64 |
} |
} |
65 |
|
|
66 |
/** |
/** |
67 |
* Sets the type of this node to that supplied. |
* Sets the type of this node to that supplied. |
68 |
* |
* |
74 |
} |
} |
75 |
|
|
76 |
/** |
/** |
77 |
* Retrieves a clone of the current type of this node. |
* Retrieves the current type of this node. |
78 |
* |
* |
79 |
* @return a clone of the current type. |
* @return the current type. |
80 |
*/ |
*/ |
81 |
public URI getType() |
public URI getType() |
82 |
{ |
{ |
83 |
try |
/* URIs are immutable, so we don't need to clone */ |
84 |
{ |
return type; |
|
return (type == null ? null : new URI(type.toString())); |
|
|
} |
|
|
catch (URISyntaxException e) |
|
|
{ |
|
|
throw new IllegalStateException("The URI is invalid.", e); |
|
|
} |
|
85 |
} |
} |
86 |
|
|
87 |
/** |
/** |
102 |
* <code>String</code>. |
* <code>String</code>. |
103 |
* |
* |
104 |
* @param type the new type of the subject, in <code>String</code> form. |
* @param type the new type of the subject, in <code>String</code> form. |
105 |
|
* @throws IllegalArgumentException if the supplied argument was not a |
106 |
|
* valid URI. |
107 |
*/ |
*/ |
108 |
public void setType(String type) |
public void setType(String type) |
109 |
{ |
{ |
117 |
} |
} |
118 |
} |
} |
119 |
|
|
120 |
|
/** |
121 |
|
* Returns true if the specified object is a node and |
122 |
|
* is equal to this one. |
123 |
|
* |
124 |
|
* @param object the object to compare. |
125 |
|
*/ |
126 |
|
public boolean equals(Object obj) |
127 |
|
{ |
128 |
|
if (obj == null) |
129 |
|
return false; |
130 |
|
if (obj == this) |
131 |
|
return true; |
132 |
|
if (obj.getClass() == getClass()) |
133 |
|
{ |
134 |
|
Node node = (Node) obj; |
135 |
|
return type.equals(node.getType()); |
136 |
|
} |
137 |
|
return false; |
138 |
|
} |
139 |
|
|
140 |
|
/** |
141 |
|
* Returns the hashcode of this node. This is calculated using |
142 |
|
* the type's hash code. |
143 |
|
* |
144 |
|
* @return the hashcode for the node. |
145 |
|
*/ |
146 |
|
public int hashCode() |
147 |
|
{ |
148 |
|
return (type == null ? 0 : 13 * type.hashCode()); |
149 |
|
} |
150 |
|
|
151 |
} |
} |