com.bigdata.rdf.model
Class BigdataStatementImpl

java.lang.Object
  extended by com.bigdata.rdf.model.BigdataStatementImpl
All Implemented Interfaces:
BigdataStatement, ISPO, Serializable, Statement

public class BigdataStatementImpl
extends Object
implements BigdataStatement

Implementation reveals whether a statement is explicit, inferred, or an axiom and the internal term identifiers for the subject, predicate, object, the context bound on that statement (when present). When statement identifiers are enabled, the context position (if bound) will be a blank node that represents the statement having that subject, predicate, and object and its term identifier, when assigned, will report true for AbstractTripleStore.isStatement(long). When used to model a quad, the 4th position will be a BigdataValue but its term identifier will report false for AbstractTripleStore.isStatement(long).

Note: The ctors are intentionally protected. Use the BigdataValueFactory to create instances of this class - it will ensure that term identifiers are propagated iff the backing lexicon is the same.

Version:
$Id: BigdataStatementImpl.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface com.bigdata.rdf.spo.ISPO
NULL
 
Constructor Summary
protected BigdataStatementImpl(BigdataResource subject, BigdataURI predicate, BigdataValue object, BigdataResource context, StatementEnum type)
          Used by BigdataValueFactory
 
Method Summary
 long c()
          The term identifier for the SID/context position (slot 3) -or- ISPO.NULL.
 boolean equals(Object o)
           
 boolean equals(Statement stmt)
          Note: implementation per Statement interface, which specifies that only the (s,p,o) positions are to be considered.
 long get(int index)
          Return the s,p,o, or c value corresponding to the given index.
 BigdataResource getContext()
          Specialized return type.
 BigdataValue getObject()
          Specialized return type.
 BigdataURI getPredicate()
          Specialized return type.
 long getStatementIdentifier()
          The statement identifier (optional).
 StatementEnum getStatementType()
          Whether the statement is StatementEnum.Explicit, StatementEnum.Inferred or an StatementEnum.Axiom.
 BigdataResource getSubject()
          Specialized return type.
 int hashCode()
          Note: implementation per Statement interface, which does not consider the context position.
 boolean hasStatementIdentifier()
          true IFF AbstractTripleStore.isStatement(long) returns true for ISPO.c().
 boolean hasStatementType()
          Return true iff the statement type is known.
 boolean isAxiom()
          true if the statement is an axiom that is not present as an explicit assertion.
 boolean isExplicit()
          true if the statement is an explicit assertion.
 boolean isFullyBound()
          Return true iff all position (s,p,o) are non-ISPO.NULL.
 boolean isInferred()
          true if the statement is an inference that is not present as an explicit assertion or an axiom.
 boolean isOverride()
          When true the statement will be written onto the database with exactly its current ISPO.getStatementType() (default false).
 long o()
          The term identifier for the object position (slot 2) -or- ISPO.NULL.
 long p()
          The term identifier for the predicate position (slot 1) -or- ISPO.NULL.
 long s()
          The term identifier for the subject position (slot 0) -or- ISPO.NULL.
 byte[] serializeValue(ByteArrayBuffer buf)
          Return the byte[] that would be written into a statement index for this ISPO, including the optional StatementEnum.MASK_OVERRIDE bit.
 void setOverride(boolean override)
          Set the override flag.
 void setStatementIdentifier(long sid)
          Set the statement identifier.
 void setStatementType(StatementEnum type)
          Set the statement type for this statement.
 String toString()
           
 String toString(IRawTripleStore storeIsIgnored)
          Note: this implementation is equivalent to toString() since the Values are already resolved.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BigdataStatementImpl

protected BigdataStatementImpl(BigdataResource subject,
                               BigdataURI predicate,
                               BigdataValue object,
                               BigdataResource context,
                               StatementEnum type)
Used by BigdataValueFactory

Method Detail

getSubject

public final BigdataResource getSubject()
Description copied from interface: BigdataStatement
Specialized return type.

Specified by:
getSubject in interface BigdataStatement
Specified by:
getSubject in interface Statement

getPredicate

public final BigdataURI getPredicate()
Description copied from interface: BigdataStatement
Specialized return type.

Specified by:
getPredicate in interface BigdataStatement
Specified by:
getPredicate in interface Statement

getObject

public final BigdataValue getObject()
Description copied from interface: BigdataStatement
Specialized return type.

Specified by:
getObject in interface BigdataStatement
Specified by:
getObject in interface Statement

getContext

public final BigdataResource getContext()
Description copied from interface: BigdataStatement
Specialized return type.

Specified by:
getContext in interface BigdataStatement
Specified by:
getContext in interface Statement

hasStatementType

public final boolean hasStatementType()
Description copied from interface: ISPO
Return true iff the statement type is known. true iff the statement type is known for this statement.

Specified by:
hasStatementType in interface ISPO

getStatementType

public final StatementEnum getStatementType()
Description copied from interface: ISPO
Whether the statement is StatementEnum.Explicit, StatementEnum.Inferred or an StatementEnum.Axiom.

Specified by:
getStatementType in interface ISPO
Returns:
The StatementEnum type -or- null if the statement type has not been specified.

setStatementType

public final void setStatementType(StatementEnum type)
Description copied from interface: ISPO
Set the statement type for this statement.

Specified by:
setStatementType in interface ISPO
Parameters:
type - The statement type.

isAxiom

public final boolean isAxiom()
Description copied from interface: BigdataStatement
true if the statement is an axiom that is not present as an explicit assertion.

Specified by:
isAxiom in interface BigdataStatement
Specified by:
isAxiom in interface ISPO

isInferred

public final boolean isInferred()
Description copied from interface: BigdataStatement
true if the statement is an inference that is not present as an explicit assertion or an axiom.

Specified by:
isInferred in interface BigdataStatement
Specified by:
isInferred in interface ISPO

isExplicit

public final boolean isExplicit()
Description copied from interface: BigdataStatement
true if the statement is an explicit assertion.

Specified by:
isExplicit in interface BigdataStatement
Specified by:
isExplicit in interface ISPO

equals

public boolean equals(Object o)
Specified by:
equals in interface Statement
Overrides:
equals in class Object

equals

public final boolean equals(Statement stmt)
Note: implementation per Statement interface, which specifies that only the (s,p,o) positions are to be considered.


hashCode

public final int hashCode()
Note: implementation per Statement interface, which does not consider the context position.

Specified by:
hashCode in interface Statement
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

s

public final long s()
Description copied from interface: ISPO
The term identifier for the subject position (slot 0) -or- ISPO.NULL.

Specified by:
s in interface ISPO

p

public final long p()
Description copied from interface: ISPO
The term identifier for the predicate position (slot 1) -or- ISPO.NULL.

Specified by:
p in interface ISPO

o

public final long o()
Description copied from interface: ISPO
The term identifier for the object position (slot 2) -or- ISPO.NULL.

Specified by:
o in interface ISPO

c

public final long c()
Description copied from interface: ISPO
The term identifier for the SID/context position (slot 3) -or- ISPO.NULL. The semantics of the returned value depend on the database mode. For triples, it is unused. For triples+SIDs, it is the statement identifier as assigned by the lexicon. For quads, it is the context (aka named graph) and ISPO.NULL iff the context was not bound.

Specified by:
c in interface ISPO
See Also:
AbstractTripleStore.Options#STATEMENT_IDENTIFIERS, AbstractTripleStore.Options#QUADS

get

public long get(int index)
Description copied from interface: ISPO
Return the s,p,o, or c value corresponding to the given index.

Specified by:
get in interface ISPO
Parameters:
index - The legal values are: s=0, p=1, o=2, c=3.

isFullyBound

public final boolean isFullyBound()
Description copied from interface: ISPO
Return true iff all position (s,p,o) are non-ISPO.NULL.

Note: SPOs are sometimes used to represent triple patterns, e.g., in the tail of a Justification. This method will return true if the "triple pattern" is fully bound and false if there are any unbound positions.

Note: BigdataStatements are not fully bound when they are instantiated during parsing until their term identifiers have been resolved against a database's lexicon. FIXME quads : this method might need to be aware of the database mode, e.g., pass in [boolean quads]. if its semantics are restricted to whether the triple pattern is fully bound, then clarify that here.

Specified by:
isFullyBound in interface ISPO

setStatementIdentifier

public final void setStatementIdentifier(long sid)
Description copied from interface: ISPO
Set the statement identifier. This sets the 4th position of the quad, but some constraints are imposed on its argument.

Specified by:
setStatementIdentifier in interface ISPO
Parameters:
sid - The statement identifier.

getStatementIdentifier

public final long getStatementIdentifier()
Description copied from interface: ISPO
The statement identifier (optional). This has nearly identical semantics to ISPO.c(), but will throw an exception if the 4th position is not bound.

Statement identifiers are a unique per-triple identifier assigned when a statement is first asserted against the database and are are defined iff AbstractTripleStore.Options#STATEMENT_IDENTIFIERS was specified.

Specified by:
getStatementIdentifier in interface ISPO

hasStatementIdentifier

public final boolean hasStatementIdentifier()
Description copied from interface: ISPO
true IFF AbstractTripleStore.isStatement(long) returns true for ISPO.c().

Specified by:
hasStatementIdentifier in interface ISPO

isOverride

public final boolean isOverride()
Description copied from interface: ISPO
When true the statement will be written onto the database with exactly its current ISPO.getStatementType() (default false).

Note: This feature is used by TruthMaintenance when we need to downgrade an ISPO from "Explicit" to "Inferred". Normally, a statement is automatically upgraded from "Inferred" to "Explicit" so without ISPO.setOverride(boolean) you could not downgrade the StatementEnum in the database without first deleting the statement (which would also delete its justifications).

Specified by:
isOverride in interface ISPO

setOverride

public final void setOverride(boolean override)
Description copied from interface: ISPO
Set the override flag.

Specified by:
setOverride in interface ISPO
Parameters:
override - the new value.

serializeValue

public byte[] serializeValue(ByteArrayBuffer buf)
Description copied from interface: ISPO
Return the byte[] that would be written into a statement index for this ISPO, including the optional StatementEnum.MASK_OVERRIDE bit. If the ISPO.hasStatementIdentifier() would return true, then the SID will be included in the returned byte[]. Note that ISPO.hasStatementIdentifier() is defined in terms of the bit pattern of the SID identifiers and therefore will be true ONLY for a statement identifier and NOT for an RDF Value identifier.

Specified by:
serializeValue in interface ISPO
Parameters:
buf - A buffer supplied by the caller. The buffer will be reset before the value is written on the buffer.
Returns:
The value that would be written into a statement index for this ISPO.

toString

public String toString(IRawTripleStore storeIsIgnored)
Note: this implementation is equivalent to toString() since the Values are already resolved.

Specified by:
toString in interface ISPO
Parameters:
storeIsIgnored - The database whose lexicon will be used.


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.