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

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

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

revision 1.6 by gnu_andrew, Sun Apr 17 18:35:32 2005 UTC revision 1.7 by gnu_andrew, Thu May 19 10:51:48 2005 UTC
# Line 49  public class RDFURI Line 49  public class RDFURI
49     * Constructs an <code>RDFURI</code> using the specified URI.     * Constructs an <code>RDFURI</code> using the specified URI.
50     *     *
51     * @param uri the URI to use for this RDF URI.     * @param uri the URI to use for this RDF URI.
52       * @throws URISyntaxException if the supplied <code>String</code>
53       *                            does not form a valid URI.
54       */
55      public RDFURI(String uri)
56        throws URISyntaxException
57      {
58        this(new URI(uri));
59      }
60    
61      /**
62       * Constructs an <code>RDFURI</code> using the specified URI.
63       *
64       * @param uri the URI to use for this RDF URI.
65     */     */
66    public RDFURI(URI uri)    public RDFURI(URI uri)
67    {    {
# Line 70  public class RDFURI Line 83  public class RDFURI
83    }    }
84    
85    /**    /**
86     * Returns a clone of the URI used by this RDF URI.     * Returns he URI used by this RDF URI.
87     *     *
88     * @return a clone of the URI.     * @return the URI.
89     */     */
90    public URI getURI()    public URI getURI()
91    {    {
92      try      /* URIs are immutable, so we don't need to clone */
93        {      return uri;
         return new URI(uri.toString());  
       }  
     catch (URISyntaxException e)  
       {  
         throw new IllegalStateException("The URI is invalid.", e);  
       }  
94    }    }
95    
96    /**    /**
# Line 93  public class RDFURI Line 100  public class RDFURI
100     */     */
101    public RDFURI clone()    public RDFURI clone()
102    {    {
103      Object clonedObject = super.clone();      try
104      RDFURI clone = (RDFURI) clonedObject;        {
105      clone.setURI(getURI());          Object clonedObject = super.clone();
106      return clone;          RDFURI clone = (RDFURI) clonedObject;
107            clone.setURI(new URI(uri.toString()));
108            return clone;
109          }
110        catch (URISyntaxException e)
111          {
112            throw new IllegalStateException("Invalid URI detected in cloning.",e);
113          }
114    }    }
115    
116    /**    /**
# Line 109  public class RDFURI Line 123  public class RDFURI
123      this.uri = uri;      this.uri = uri;
124    }    }
125    
126      /**
127       * Returns true if the specified object is a RDF URI and
128       * is equal to this one.
129       *
130       * @param object the object to compare.
131       */
132      public boolean equals(Object obj)
133      {
134        if (super.equals(obj))
135          {
136            RDFURI rdfUri = (RDFURI) obj;
137            return uri.equals(rdfUri.getURI());
138          }
139        return false;
140      }
141    
142      /**
143       * Returns the hashcode of this RDF URI. This is calculated using
144       * the uri's hash code and that of the superclass.
145       *
146       * @return the hashcode for this RDF URI.
147       */
148      public int hashCode()
149      {
150        return super.hashCode() + 17 * uri.hashCode();
151      }
152    
153  }  }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

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