edu.ucsb.nceas.morpho.datapackage
Class TripleCollection

java.lang.Object
  |
  +--edu.ucsb.nceas.morpho.datapackage.TripleCollection

public class TripleCollection
extends java.lang.Object

This class implements a collection of triples which make up all of the relationships in a package.


Constructor Summary
TripleCollection()
          Default Constructor
TripleCollection(java.io.File triplesFile, ClientFramework framework)
          parses an xml document and pulls any triples out of it.
TripleCollection(java.io.Reader xml)
          read an xml file, build the collection from any triples in the xml file.
TripleCollection(java.io.Reader xml, com.arbortext.catalog.CatalogEntityResolver cer)
          read an xml file, build the collection from any triples in the xml file.
TripleCollection(TripleCollection tc)
          Copy constructor.
TripleCollection(java.util.Vector triples)
          create a collection of triples from a vector of Triple objects.
 
Method Summary
 void addTriple(Triple triple)
          Add a single triple to this collection
 boolean containsTriple(Triple triple)
          returns true if the collection contains triple, false otherwise
 java.util.Vector getCollection()
          return a vector of Triple objects that represent this collection.
 java.util.Vector getCollectionByObject(java.lang.String object)
          returns a vector of triples with the given object
 java.util.Vector getCollectionByRelationship(java.lang.String relationship)
          returns a vector of triples with the given relationship
 java.util.Vector getCollectionBySubject(java.lang.String subject)
          returns a vector of triples with the given subject
 org.w3c.dom.NodeList getNodeList()
           
static void main(java.lang.String[] args)
           
 Triple removeTriple(Triple triple)
          removes the specified triple from the collection and returns it.
 java.lang.String toFormatedXML()
          returns a nicely formatted string representation of this collection in xml the xml looks like this:
 java.lang.String toString()
          return this collection as a string
 java.lang.String toXML()
           
 java.lang.String toXML(java.lang.String root)
          returns a string representation of this collection in xml format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TripleCollection

public TripleCollection()
Default Constructor

TripleCollection

public TripleCollection(java.io.File triplesFile,
                        ClientFramework framework)
parses an xml document and pulls any triples out of it.

TripleCollection

public TripleCollection(TripleCollection tc)
Copy constructor. instantiate this object from the given TripleCollection

TripleCollection

public TripleCollection(java.io.Reader xml)
read an xml file, build the collection from any triples in the xml file.

TripleCollection

public TripleCollection(java.io.Reader xml,
                        com.arbortext.catalog.CatalogEntityResolver cer)
read an xml file, build the collection from any triples in the xml file.

TripleCollection

public TripleCollection(java.util.Vector triples)
create a collection of triples from a vector of Triple objects.
Method Detail

addTriple

public void addTriple(Triple triple)
Add a single triple to this collection

containsTriple

public boolean containsTriple(Triple triple)
returns true if the collection contains triple, false otherwise

removeTriple

public Triple removeTriple(Triple triple)
removes the specified triple from the collection and returns it. If the triple was not in the collection null is returned.

getCollectionBySubject

public java.util.Vector getCollectionBySubject(java.lang.String subject)
returns a vector of triples with the given subject

getCollectionByRelationship

public java.util.Vector getCollectionByRelationship(java.lang.String relationship)
returns a vector of triples with the given relationship

getCollectionByObject

public java.util.Vector getCollectionByObject(java.lang.String object)
returns a vector of triples with the given object

getCollection

public java.util.Vector getCollection()
return a vector of Triple objects that represent this collection.

toXML

public java.lang.String toXML()

toXML

public java.lang.String toXML(java.lang.String root)
returns a string representation of this collection in xml format. the xml looks like this:
 <triple><subject>some content 1</subject>
 <relationship>some content 2</relationship><object>
 some content 3</object></triple><triple>
 <subject>some content 1</subject><relationship>
 some content 2</relationship><object>some content 3
 </object></triple>
 .....
 <triple><subject>some content 1</subject>
 <relationship>some content 2</relationship><object>
 some content 3</object></triple>
 

getNodeList

public org.w3c.dom.NodeList getNodeList()

toFormatedXML

public java.lang.String toFormatedXML()
returns a nicely formatted string representation of this collection in xml the xml looks like this:
 <triple>
   <subject>some content 1</subject>
   <relationship>some content 2</relationship>
   <object>some content 3</object>
 </triple>
 <triple>
   <subject>some content 1</subject>
   <relationship>some content 2</relationship>
   <object>some content 3</object>
 </triple>
 .....
 <triple>
   <subject>some content 1</subject>
   <relationship>some content 2</relationship>
   <object>some content 3</object>
 </triple>
 
without the formatting (i.e. no indents or extra spaces)

toString

public java.lang.String toString()
return this collection as a string
Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)


Copyright © 2000 National Center for Ecological Analysis and Synthesis. All Rights Reserved.