/[cashew-s-editor]/cashews/src/nongnu/cashews/rdf/Node.java
ViewVC logotype

Diff of /cashews/src/nongnu/cashews/rdf/Node.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by gnu_andrew, Sun Apr 17 18:35:32 2005 UTC revision 1.4 by gnu_andrew, Thu May 19 10:51:48 2005 UTC
# Line 62  public abstract class Node Line 62  public abstract class Node
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     *     *
# Line 73  public abstract class Node Line 74  public abstract class Node
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    /**    /**
# Line 107  public abstract class Node Line 102  public abstract class Node
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    {    {
# Line 120  public abstract class Node Line 117  public abstract class Node
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  }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26