edu.stanford.db.rdf.model.i
Class ModelImpl

java.lang.Object
  |
  +--edu.stanford.db.rdf.model.i.ModelImpl
All Implemented Interfaces:
Digest, Digestable, Model, RDFNode, Resource

public class ModelImpl
extends java.lang.Object
implements Model, Digestable, Digest


Field Summary
static int ALL_INDEX
           
static int OP_INDEX
           
static int P_INDEX
           
static int SPO_INDEX
           
 
Fields inherited from interface org.w3c.rdf.digest.Digest
MD5, SHA1
 
Constructor Summary
  ModelImpl()
           
  ModelImpl(NodeFactory f)
           
protected ModelImpl(java.lang.String uri, java.util.Hashtable triples, FindIndex findIndex, boolean shared)
           
 
Method Summary
 void add(Resource subject, Resource predicate, RDFNode object)
          Adds a new triple to the model.
 void add(Resource subject, Resource predicate, java.lang.String object)
          Adds a new triple to the model.
 void add(Statement t)
          Adds a new triple to the model.
 java.lang.Object clone()
           
 boolean contains(Statement t)
          Tests if the model contains the given triple.
 Model create()
          Creates empty model of the same Class
 Model duplicate()
          Clone the model.
 java.util.Enumeration elements()
          Enumerate triples
 Model find(Resource subject, Resource predicate, RDFNode object)
          General method to search for triples.
 Digest getDigest()
           
 java.lang.String getDigestAlgorithm()
           
 byte[] getDigestBytes()
           
 java.lang.String getLabel()
          The formal string label of the node.
 java.lang.String getLocalName()
          Returns the local name of the resource.
 java.lang.String getNamespace()
          Returns the namespace of the resource.
 NodeFactory getNodeFactory()
          Returns the node factory for this model
 java.lang.String getSourceURI()
          Returns current base URI setting.
 java.lang.String getURI()
          Returns the URI of the resource.
 boolean isEmpty()
          true if the model contains no triples
 boolean isMutable()
          True if the model supports add() and remove() methods.
 void remove(Statement t)
          Removes the triple from the model.
 void setSourceURI(java.lang.String uri)
          Set a base URI for the message.
 int size()
          Number of triples in the model
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SPO_INDEX

public static final int SPO_INDEX

OP_INDEX

public static final int OP_INDEX

P_INDEX

public static final int P_INDEX

ALL_INDEX

public static final int ALL_INDEX
Constructor Detail

ModelImpl

public ModelImpl()

ModelImpl

public ModelImpl(NodeFactory f)

ModelImpl

protected ModelImpl(java.lang.String uri,
                    java.util.Hashtable triples,
                    FindIndex findIndex,
                    boolean shared)
Method Detail

setSourceURI

public void setSourceURI(java.lang.String uri)
Set a base URI for the message. Affects creating of new resources and serialization syntax. null is just alright, meaning that the serializer will use always rdf:about and never rdf:ID
Specified by:
setSourceURI in interface Model

getSourceURI

public java.lang.String getSourceURI()
Returns current base URI setting.
Specified by:
getSourceURI in interface Model

size

public int size()
Number of triples in the model
Specified by:
size in interface Model
Returns:
number of triples

isEmpty

public boolean isEmpty()
Description copied from interface: Model
true if the model contains no triples
Specified by:
isEmpty in interface Model

elements

public java.util.Enumeration elements()
Enumerate triples
Specified by:
elements in interface Model

contains

public boolean contains(Statement t)
Tests if the model contains the given triple.
Specified by:
contains in interface Model
Returns:
true if the triple belongs to the model; false otherwise.
See Also:
Statement

add

public void add(Resource subject,
                Resource predicate,
                java.lang.String object)
         throws ModelException
Adds a new triple to the model. A literal is created out of the string parameter object. This method is just a shortcut.
See Also:
Resource

add

public void add(Resource subject,
                Resource predicate,
                RDFNode object)
         throws ModelException
Adds a new triple to the model. The object of the triple is an RDFNode.
See Also:
Resource, RDFNode

add

public void add(Statement t)
         throws ModelException
Adds a new triple to the model.
Specified by:
add in interface Model
See Also:
Statement

remove

public void remove(Statement t)
            throws ModelException
Removes the triple from the model.
Specified by:
remove in interface Model
See Also:
Statement

find

public Model find(Resource subject,
                  Resource predicate,
                  RDFNode object)
           throws ModelException
General method to search for triples. null input for any parameter will match anything.

Example: Model result = m.find( null, RDF.type, new Resource("http://...#MyClass") )

finds all instances of the class MyClass

Specified by:
find in interface Model
See Also:
Resource, RDFNode

duplicate

public Model duplicate()
Clone the model.
Specified by:
duplicate in interface Model

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

create

public Model create()
Creates empty model of the same Class
Specified by:
create in interface Model

getNodeFactory

public NodeFactory getNodeFactory()
Description copied from interface: Model
Returns the node factory for this model
Specified by:
getNodeFactory in interface Model

getLabel

public java.lang.String getLabel()
                          throws ModelException
Description copied from interface: RDFNode
The formal string label of the node. URI in case of a resource, string in case of a literal.
Specified by:
getLabel in interface RDFNode

getNamespace

public java.lang.String getNamespace()
Description copied from interface: Resource
Returns the namespace of the resource. May return null.
Specified by:
getNamespace in interface Resource
Following copied from interface: org.w3c.rdf.model.Resource
Returns:
the namespace of the resource
See Also:
Statement, Model

getLocalName

public java.lang.String getLocalName()
                              throws ModelException
Description copied from interface: Resource
Returns the local name of the resource. May not return null.
Specified by:
getLocalName in interface Resource
Following copied from interface: org.w3c.rdf.model.Resource
Returns:
the local name of the resource
See Also:
Statement, Model

getDigest

public Digest getDigest()
Specified by:
getDigest in interface Digestable
Following copied from interface: org.w3c.rdf.digest.Digestable
Returns:
a Digest

isMutable

public boolean isMutable()
Description copied from interface: Model
True if the model supports add() and remove() methods. A model may change behavior of this function over time.
Specified by:
isMutable in interface Model

getURI

public java.lang.String getURI()
                        throws ModelException
Description copied from interface: Resource
Returns the URI of the resource. Triples and models must implement this method in a standard way.
Specified by:
getURI in interface Resource
Following copied from interface: org.w3c.rdf.model.Resource
Returns:
the URI of the resource
See Also:
Statement, Model

getDigestAlgorithm

public java.lang.String getDigestAlgorithm()
Specified by:
getDigestAlgorithm in interface Digest

getDigestBytes

public byte[] getDigestBytes()
                      throws DigestException
Specified by:
getDigestBytes in interface Digest

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object