com.franz.ag
Class Triple

java.lang.Object
  extended bycom.franz.ag.ValueObject
      extended bycom.franz.ag.Triple
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable, Statement

public class Triple
extends ValueObject
implements Statement

This class implements in Java a representation of an AllegroGraph triple.

The AllegroGraph instance has 5 components, id, subject, predicate, object and context. All 4 are copied to the Java instance.

The components are copied when a Triple instance is created. The associated URI or literal strings may or may not be filled at creation time.

Triple instances are not unique. There may be multiple Triple instances associated with one triple in the triple store.

See Also:
Serialized Form

Method Summary
 boolean add()
          Add a triple to the triple store.
 int compareTo(Triple to)
           
 boolean equals(java.lang.Object other)
           
 UPI getC()
           
 Value getContext()
          Create a Resource instance that describes the context component of the triple.
 java.lang.String getContextLabel()
           
 UPI getO()
          Retrieve the object slot of the Triple instance.
 Value getObject()
          Create a Value instance that describes the object component of the triple.
 java.lang.String getObjectLabel()
          Retrieve the URI string associated with the object component of this Triple.
 UPI getP()
          Retrieve the predicate slot of the Triple instance.
 URI getPredicate()
          Create a URI instance that describes the predicate component of the triple.
 Value getPredicateInstance()
           
 java.lang.String getPredicateLabel()
          Retrieve the URI string associated with the predicate component of this Triple.
 UPI getS()
          Retrieve the subject slot of the Triple instance.
 Resource getSubject()
          Create a Resource instance that describes the subject component of the triple.
 Value getSubjectInstance()
           
 java.lang.String getSubjectLabel()
          Retrieve the URI string associated with the subject component of this Triple.
 int hashCode()
           
 long queryAGId()
          Return the unique integer identifier of the object.
 java.lang.String queryContext()
           
 UPI queryO()
          Retrieve the object slot of the Triple instance.
 java.lang.String queryObject()
          Retrieve the object slot of the Triple instance.
 UPI queryP()
          Retrieve the predicate slot of the Triple instance.
 java.lang.String queryPredicate()
          Retrieve the predicate slot of the Triple instance.
 UPI queryS()
          Retrieve the subject slot of the Triple instance.
 java.lang.String querySubject()
          Retrieve the subject slot of the Triple instance.
 java.lang.String toString()
          This method overrides the generic toString method.
 
Methods inherited from class com.franz.ag.ValueObject
compareTo
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

queryAGId

public long queryAGId()
Return the unique integer identifier of the object.

Returns:
An integer object id. If the value is negative, then the object has not been stored in the triple store and is simply a place holder for a label.

add

public boolean add()
            throws AllegroGraphException
Add a triple to the triple store. The Triple instance must have been created with AllegroGraph.createStatement(Resource, URI, Value) or with AllegroGraph.createStatement(Resource, URI, Value, Resource).

Returns:
true if the triple was added, false if the triple was already added and therefore nothing was done.
Throws:
AllegroGraphException

queryS

public UPI queryS()
Retrieve the subject slot of the Triple instance.

Returns:
A UPI instance that identifies the subject node. A null value means that the subject is not in the local cache, and must be obtained from the server with a call to getS();

getS

public UPI getS()
Retrieve the subject slot of the Triple instance. If the value is not in the local cache, this call will require a round-trip to the AllegroGraph server.

Returns:
An integer subject node number.

querySubject

public java.lang.String querySubject()
Retrieve the subject slot of the Triple instance.

Returns:
A string containg the URI of the subject node. If the returned value is null, the method getSubjectLabel() must be used to get the true value.

getSubjectLabel

public java.lang.String getSubjectLabel()
                                 throws AllegroGraphException
Retrieve the URI string associated with the subject component of this Triple.

Returns:
A string containg the URI of the subject node.
Throws:
AllegroGraphException

getSubject

public Resource getSubject()
Create a Resource instance that describes the subject component of the triple. This method must return a Resource instance as specified in the openrdf model specification. Since AllegroGraph is more general, the subject slot can be a more general object. In those cases, this method will throw a CLassCastException. Use the more general method getSubjectInstance() to retrieve any type.

Specified by:
getSubject in interface Statement
Returns:
The statement's subject.

getSubjectInstance

public Value getSubjectInstance()

queryP

public UPI queryP()
Retrieve the predicate slot of the Triple instance.

Returns:
A UPI instance that identifies the predicate node. A null value means that the predicate is not in the local cache, and must be obtained from the server with a call to getP();

getP

public UPI getP()
Retrieve the predicate slot of the Triple instance. If the value is not in the local cache, this call will require a round-trip to the AllegroGraph server.

Returns:
A UPI instance that identifies the predicate node.

queryPredicate

public java.lang.String queryPredicate()
Retrieve the predicate slot of the Triple instance.

Returns:
The string form of the predicate node or null if the string form is not available. Use getPredicateLabel() to always return a string.

getPredicateLabel

public java.lang.String getPredicateLabel()
                                   throws AllegroGraphException
Retrieve the URI string associated with the predicate component of this Triple.

Returns:
A string containg the URI of the predicate node.
Throws:
AllegroGraphException

getPredicate

public URI getPredicate()
Create a URI instance that describes the predicate component of the triple. This method must return a Resource instance as specified in the openrdf model specification. Since AllegroGraph is more general, the subject slot can be a more general object. In those cases, this method will throw a CLassCastException. Use the more general method getPredicateInstance() to retrieve any type.

Specified by:
getPredicate in interface Statement
Returns:
The statement's predicate.

getPredicateInstance

public Value getPredicateInstance()

queryO

public UPI queryO()
Retrieve the object slot of the Triple instance.

Returns:
A UPI instance that identifies the object node. A null value means that the subject is not in the local cache, and must be obtained from the server with a vcall to getS();

getO

public UPI getO()
Retrieve the object slot of the Triple instance. If the value is not in the local cache, this call will require a round-trip to the AllegroGraph server.

Returns:
An integer object node number.

queryObject

public java.lang.String queryObject()
Retrieve the object slot of the Triple instance.

Returns:
A string or null. Use getObjectLabel() to always return a string.

getObjectLabel

public java.lang.String getObjectLabel()
                                throws AllegroGraphException
Retrieve the URI string associated with the object component of this Triple.

Returns:
A string containg the URI of the object node.
Throws:
AllegroGraphException

getObject

public Value getObject()
Create a Value instance that describes the object component of the triple.

Specified by:
getObject in interface Statement
Returns:
The statement's object.

getC

public UPI getC()

queryContext

public java.lang.String queryContext()

getContextLabel

public java.lang.String getContextLabel()

getContext

public Value getContext()
Create a Resource instance that describes the context component of the triple.


toString

public java.lang.String toString()
This method overrides the generic toString method. This method generates a more readable output string.


equals

public boolean equals(java.lang.Object other)

hashCode

public int hashCode()

compareTo

public int compareTo(Triple to)