Package com.stardog.stark
Class Values
java.lang.Object
com.stardog.stark.Values
Utility functions for creating and working with RDF values
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Michael Grove
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IRISpecial IRI representing the union of the local and virtual graphsstatic final DatatypeFactoryDatatype factory that will be used for date/time literals.static final IRISpecial IRI representing the default (no) context.static final IRISpecial IRI representing the union of the local (non-virtual) default graph and all local named graphsstatic final IRISpecial IRI representing only local named graphs; this excludes the default graphstatic final IRISpecial IRI representing the union of the virtual graphsstatic final StringNamespace reserved for virtual graph names -
Method Summary
Modifier and TypeMethodDescriptionstatic BNodebnode()Create a newBNodestatic BNodeCreate a newBNodestatic booleancontainsInvalidIRICharacters(String theIRI) static booleanstatic IRICreate a newIRIstatic IRICreate a newIRIfrom a namespace and a local namestatic booleanReturn whether or not the resource represents the meta-contextALL_GRAPHSstatic booleanisDefaultGraph(Resource theContext) Return whether or not the givenResourcedenotes the default graphstatic booleanisInDefaultGraph(Statement theStmt) Return whether or not the givenStatementis in the default graphstatic booleanstatic booleanReturn whether or not the resource represents the meta-contextNAMED_GRAPHSstatic booleanVerifies that the given IRI is valid.static booleanVerifies that the given literal is valid.static booleanVerifies that the given value is valid.static booleanReturn whether the resource represents a virtual graph (starts withVIRTUAL_NAMESPACEstatic Literalliteral(boolean theValue) Create a new `xsd:boolean`Literalstatic Literalliteral(byte theValue) Create a new `xsd:byte`Literalstatic Literalliteral(double theValue) Create a new `xsd:double`Literalstatic Literalliteral(float theValue) Create a new `xsd:float`Literalstatic Literalliteral(int theValue) Create a new `xsd:int`Literalstatic LiteralCreate a newLiteralstatic Literalliteral(long theValue) Create a new `xsd:long`Literalstatic LiteralCreate a newLiteralstatic Literalliteral(short theValue) Create a new `xsd:short`Literalstatic Literalstatic LiteralCreate a new `xsd:string`Literalstatic LiteralCreate a newLiteralstatic LiteralCreate a new typedLiteralstatic LiteralCreate a new languageLiteralstatic Literalliteral(BigDecimal theBigDecimal) static Literalliteral(BigInteger theInt) static LiteralCreate a newLiteralfor the given `Date` value.static Literalliteral(GregorianCalendar theDate) static LiteralCreate a Duration typed literal.static Literalstatic LiteralCreate a Duration typed literal.static Literalliteral(XMLGregorianCalendar theCalendar) static Literalliteral(XMLGregorianCalendar theCalendar, Datatype theDatatype) static NamespaceCreate aNamespacestatic ResourceTreats IDs starting with "_:" as stable bnodes and createsBNodeobjects for them, otherwise creates IRIs.static StatementCreate a newStatementin thedefault graphstatic StatementCreate a newStatementstatic IRICreate a newIRIthat is guaranteed to be unique.
-
Field Details
-
DEFAULT_GRAPH
Special IRI representing the default (no) context. -
LOCAL_GRAPHS
Special IRI representing the union of the local (non-virtual) default graph and all local named graphs -
NAMED_GRAPHS
Special IRI representing only local named graphs; this excludes the default graph -
ALL_GRAPHS
Special IRI representing the union of the local and virtual graphs -
VIRTUAL_GRAPHS
Special IRI representing the union of the virtual graphs -
DATATYPE_FACTORY
Datatype factory that will be used for date/time literals. Cached to boost performance. -
VIRTUAL_NAMESPACE
Namespace reserved for virtual graph names- See Also:
-
-
Method Details
-
namespace
Create aNamespace- Parameters:
thePrefix- the prefixtheIRI- the IRI- Returns:
- the new `Namespace`
-
iri
Create a newIRIfrom a namespace and a local name- Parameters:
theNS- the namespace IRItheLocalName- the local name- Returns:
- the new `IRI`
-
iri
Create a newIRI- Parameters:
theIRI- the IRI string- Returns:
- the new `IRI`
-
uniqueIri
Create a newIRIthat is guaranteed to be unique.- Parameters:
prefix- Prefix to begin the IRI with. Must contain a colon not as the first character.- Returns:
- the new `IRI`
-
bnode
Create a newBNode- Returns:
- the new `BNode`
-
bnode
Create a newBNode- Parameters:
theId- the id of the bnode- Returns:
- the new `BNode`
-
literal
Create a new `xsd:string`Literal- Parameters:
theLabel- the label- Returns:
- the new `Literal`
-
literal
Create a new `xsd:boolean`Literal- Parameters:
theValue- the value- Returns:
- the new `Literal`
-
literal
Create a new `xsd:int`Literal- Parameters:
theValue- the value- Returns:
- the new `Literal`
-
literal
Create a new `xsd:long`Literal- Parameters:
theValue- the value- Returns:
- the new `Literal`
-
literal
Create a new `xsd:float`Literal- Parameters:
theValue- the value- Returns:
- the new `Literal`
-
literal
Create a new `xsd:double`Literal- Parameters:
theValue- the value- Returns:
- the new `Literal`
-
literal
Create a new `xsd:short`Literal- Parameters:
theValue- the value- Returns:
- the new `Literal`
-
literal
Create a new `xsd:byte`Literal- Parameters:
theValue- the value- Returns:
- the new `Literal`
-
literal
Create a new typedLiteral- Parameters:
theLabel- the label of the literaltheDatatype- the datatype- Returns:
- the new `Literal`
-
literal
Create a new languageLiteral- Parameters:
theLabel- the label of the literaltheLanguage- the language of the literal- Returns:
- the new `Literal`
-
literal
Create a newLiteral- Parameters:
theLabel- the label of the literal valuetheDatatype- the datatype- Returns:
- the literal
- Throws:
IllegalArgumentException- if the provided value `theLabel` is not syntactically correct wrt to its Datatype
-
literal
Create a newLiteral- Parameters:
theLabel- the label of the literal valuetheDatatype- the datatype- Returns:
- the literal
- Throws:
IllegalArgumentException- if the provided value `theLabel` is not syntactically correct wrt to its Datatype
-
literal
-
literal
Create a newLiteral- Parameters:
theLabel- the label of the literal valuetheDatatype- the datatype- Returns:
- the literal
- Throws:
NumberFormatException- if the literal is declared as a number, such as an `int` but is not syntactically correct.IllegalArgumentException- if the provided value `theLabel` is not syntactically correct wrt to its Datatype
-
literal
Create a newLiteralfor the given `Date` value.- Parameters:
theDate- the value of the literal- Returns:
- the new literal
- See Also:
-
literal
- Parameters:
theDate- the value of the literal- Returns:
- the new literal
- See Also:
-
literal
Create a Duration typed literal.- Parameters:
theDuration- the duration- Returns:
- the new duration literal
-
literal
Create a Duration typed literal. Uses the datatype specified in the method; care should be used to ensure that it's one of the xsd duration types. If not, comparison results could be indeterminate or incorrect.- Parameters:
theDuration- the durationtheDurationType- the duration datatype- Returns:
- the new duration literal
-
literal
- Parameters:
theCalendar- the value of the literal- Returns:
- the new literal
- See Also:
-
literal
@Nonnull public static Literal literal(@Nonnull XMLGregorianCalendar theCalendar, @Nonnull Datatype theDatatype) -
literal
-
literal
-
literal
-
statement
@Nonnull public static Statement statement(@Nonnull Resource theSubject, @Nonnull IRI thePredicate, @Nonnull Value theObject) Create a newStatementin thedefault graph- Parameters:
theSubject- the subject of the statementthePredicate- the predicate of the statementtheObject- the object of the statement- Returns:
- the new `Statement`
-
isValid
Verifies that the given literal is valid. Checks if the supplied lexical value is valid for the given datatype. For language literals, it is checked if the language tag conforms to the RFC3066 spec.- Parameters:
theLiteral- the literal to validate- Returns:
- true if it is a valid literal, false otherwise
-
isValid
Verifies that the given IRI is valid.- Parameters:
theIRI- the IRI to validate- Returns:
- true if it is a valid IRI, false otherwise
-
containsInvalidIRICharacters
-
containsLeadingOrTrailingWhitespace
-
isValid
Verifies that the given value is valid.- Parameters:
theValue- the value to validate- Returns:
- true if it is a valid value, false otherwise
-
statement
@Nonnull public static Statement statement(@Nonnull Resource theSubject, @Nonnull IRI thePredicate, @Nonnull Value theObject, Resource theContext) Create a newStatement- Parameters:
theSubject- the subject of the statementthePredicate- the predicate of the statementtheObject- the object of the statementtheContext- the context of the statement. if the statement is intended to be in the default graph,DEFAULT_GRAPHshould be used.- Returns:
- the new `Statement`
-
isDefaultGraph
Return whether or not the givenResourcedenotes the default graph- Parameters:
theContext- the graph- Returns:
- `true` if the default graph, false otherwise
-
isVirtual
Return whether the resource represents a virtual graph (starts withVIRTUAL_NAMESPACE -
isInDefaultGraph
Return whether or not the givenStatementis in the default graph- Parameters:
theStmt- the graph- Returns:
- `true` if the default graph, false otherwise
-
isAll
Return whether or not the resource represents the meta-contextALL_GRAPHS- Parameters:
theContext- the context- Returns:
- true if its
ALL, false otherwise
-
isLocal
-
isNamed
Return whether or not the resource represents the meta-contextNAMED_GRAPHS- Parameters:
theContext- the context- Returns:
- true if its
NAMED, false otherwise
-
resource
Treats IDs starting with "_:" as stable bnodes and createsBNodeobjects for them, otherwise creates IRIs.- Parameters:
id- resource ID- Returns:
- IRI or bnode
-