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

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

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

revision 1.4 by gnu_andrew, Mon Mar 28 19:29:21 2005 UTC revision 1.5 by gnu_andrew, Mon Apr 4 00:59:33 2005 UTC
# Line 22  Line 22 
22  package nongnu.cashews.rdf;  package nongnu.cashews.rdf;
23    
24  import java.io.Serializable;  import java.io.Serializable;
25    import java.util.HashSet;
26  import java.util.Set;  import java.util.Set;
27    
28  /**  /**
# Line 55  public class Graph Line 56  public class Graph
56    private Set<Triple> graph;    private Set<Triple> graph;
57    
58    /**    /**
59       * Constructs a new empty graph.
60       */
61      public Graph()
62      {
63        graph = new HashSet<Triple>();
64      }
65    
66      /**
67     * Returns true if the specified object is either of type <code>Graph</code>,     * Returns true if the specified object is either of type <code>Graph</code>,
68     * or a sub-type, and contains an equivalent set of triples. If the specified     * or a sub-type, and contains an equivalent set of triples. If the specified
69     * object is null, false is returned.     * object is null, false is returned.
# Line 88  public class Graph Line 97  public class Graph
97    }    }
98    
99    /**    /**
100     * Returns the graph of RDF triples.     * Returns a clone of the graph of RDF triples.
101     *     *
102     * @return a graph of RDF triples.     * @return a clone of the RDF triple graph.
103     */     */
104    public Set<Triple> getGraph()    public Set<Triple> getGraph()
105    {    {
106      return graph;      Set<Triple> clonedSet = new HashSet<Triple>();
107        for (Triple triple : graph)
108          clonedSet.add(triple.clone());
109        return clonedSet;
110      }
111    
112      /**
113       * Adds a triple to the graph.
114       *
115       * @param triple the triple to add.
116       */
117      public void addTriple(Triple triple)
118      {
119        graph.add(triple);
120    }    }
121    
122      /**
123       * Returns a textual representation of the graph.
124       *
125       * @return a textual representation.
126       */
127      public String toString()
128      {
129        return getClass().getName() +
130          "[graph = " +
131          graph +
132          "]";
133      }
134    
135  }  }

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

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