Package com.stardog.stark
Class Values
- java.lang.Object
-
- com.stardog.stark.Values
-
public final class Values extends java.lang.Object
Utility functions for creating and working with RDF values
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Michael Grove
-
-
Field Summary
Fields Modifier and Type Field Description static IRI
ALL_GRAPHS
Special IRI representing the union of the local and virtual graphsstatic javax.xml.datatype.DatatypeFactory
DATATYPE_FACTORY
Datatype factory that will be used for date/time literals.static IRI
DEFAULT_GRAPH
Special IRI representing the default (no) context.static IRI
LOCAL_GRAPHS
Special IRI representing the union of the local (non-virtual) default graph and all local named graphsstatic IRI
NAMED_GRAPHS
Special IRI representing only local named graphs; this excludes the default graphstatic IRI
VIRTUAL_GRAPHS
Special IRI representing the union of the virtual graphsstatic java.lang.String
VIRTUAL_NAMESPACE
Namespace reserved for virtual graph names
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BNode
bnode()
Create a newBNode
static BNode
bnode(java.lang.String theId)
Create a newBNode
static boolean
containsInvalidIRICharacters(java.lang.String theIRI)
static boolean
containsLeadingOrTrailingWhitespace(java.lang.String theIRI)
static IRI
iri(java.lang.String theIRI)
Create a newIRI
static IRI
iri(java.lang.String theNS, java.lang.String theLocalName)
Create a newIRI
from a namespace and a local namestatic boolean
isAll(Resource theContext)
Return whether or not the resource represents the meta-contextALL_GRAPHS
static boolean
isDefaultGraph(Resource theContext)
Return whether or not the givenResource
denotes the default graphstatic boolean
isInDefaultGraph(Statement theStmt)
Return whether or not the givenStatement
is in the default graphstatic boolean
isNamed(Resource theContext)
Return whether or not the resource represents the meta-contextNAMED_GRAPHS
static boolean
isValid(IRI theIRI)
Verifies that the given IRI is valid.static boolean
isValid(Literal theLiteral)
Verifies that the given literal is valid.static boolean
isValid(Value theValue)
Verifies that the given value is valid.static boolean
isVirtual(Resource theContext)
Return whether or not the resource represents a virtual graph (starts withVIRTUAL_NAMESPACE
static Literal
literal(boolean theValue)
Create a new `xsd:boolean`Literal
static Literal
literal(byte theValue)
Create a new `xsd:byte`Literal
static Literal
literal(double theValue)
Create a new `xsd:double`Literal
static Literal
literal(float theValue)
Create a new `xsd:float`Literal
static Literal
literal(int theValue)
Create a new `xsd:int`Literal
static Literal
literal(int theLabel, Datatype theDatatype)
Create a newLiteral
static Literal
literal(long theValue)
Create a new `xsd:long`Literal
static Literal
literal(long theLabel, Datatype theDatatype)
Create a newLiteral
static Literal
literal(short theValue)
Create a new `xsd:short`Literal
static Literal
literal(java.lang.Number theNumber)
static Literal
literal(java.lang.String theLabel)
Create a new `xsd:string`Literal
static Literal
literal(java.lang.String theLabel, Datatype theDatatype)
Create a newLiteral
static Literal
literal(java.lang.String theLabel, IRI theDatatype)
Create a new typedLiteral
static Literal
literal(java.lang.String theLabel, java.lang.String theLanguage)
Create a new languageLiteral
static Literal
literal(java.math.BigDecimal theBigDecimal)
static Literal
literal(java.math.BigInteger theInt)
static Literal
literal(java.util.Date theDate)
Create a newLiteral
for the given `Date` value.static Literal
literal(java.util.GregorianCalendar theDate)
Create a newcalendar
basedLiteral
.static Literal
literal(javax.xml.datatype.Duration theDuration)
Create a Duration typed literal.static Literal
literal(javax.xml.datatype.Duration theCalendar, Datatype theDatatype)
static Literal
literal(javax.xml.datatype.Duration theDuration, IRI theDurationType)
Create a Duration typed literal.static Literal
literal(javax.xml.datatype.XMLGregorianCalendar theCalendar)
Create a newcalendar
basedLiteral
.static Literal
literal(javax.xml.datatype.XMLGregorianCalendar theCalendar, Datatype theDatatype)
static Namespace
namespace(java.lang.String thePrefix, java.lang.String theIRI)
Create aNamespace
static Resource
resource(java.lang.String id)
Treats IDs starting with "_:" as stable bnodes and createsBNode
objects for them, otherwise creates IRIs.static Statement
statement(Resource theSubject, IRI thePredicate, Value theObject)
Create a newStatement
in thedefault graph
static Statement
statement(Resource theSubject, IRI thePredicate, Value theObject, Resource theContext)
Create a newStatement
-
-
-
Field Detail
-
DEFAULT_GRAPH
public static final IRI DEFAULT_GRAPH
Special IRI representing the default (no) context.
-
LOCAL_GRAPHS
public static final IRI LOCAL_GRAPHS
Special IRI representing the union of the local (non-virtual) default graph and all local named graphs
-
NAMED_GRAPHS
public static final IRI NAMED_GRAPHS
Special IRI representing only local named graphs; this excludes the default graph
-
ALL_GRAPHS
public static final IRI ALL_GRAPHS
Special IRI representing the union of the local and virtual graphs
-
VIRTUAL_GRAPHS
public static final IRI VIRTUAL_GRAPHS
Special IRI representing the union of the virtual graphs
-
DATATYPE_FACTORY
public static final javax.xml.datatype.DatatypeFactory DATATYPE_FACTORY
Datatype factory that will be used for date/time literals. Cached to boost performance.
-
VIRTUAL_NAMESPACE
public static final java.lang.String VIRTUAL_NAMESPACE
Namespace reserved for virtual graph names- See Also:
- Constant Field Values
-
-
Method Detail
-
namespace
@Nonnull public static Namespace namespace(@Nonnull java.lang.String thePrefix, @Nonnull java.lang.String theIRI)
Create aNamespace
- Parameters:
thePrefix
- the prefixtheIRI
- the IRI- Returns:
- the new `Namespace`
-
iri
@Nonnull public static IRI iri(@Nonnull java.lang.String theNS, @Nonnull java.lang.String theLocalName)
Create a newIRI
from a namespace and a local name- Parameters:
theNS
- the namespace IRItheLocalName
- the local name- Returns:
- the new `IRI`
-
iri
@Nonnull public static IRI iri(@Nonnull java.lang.String theIRI)
Create a newIRI
- Parameters:
theIRI
- the IRI string- Returns:
- the new `IRI`
-
bnode
@Nonnull public static BNode bnode(@Nonnull java.lang.String theId)
Create a newBNode
- Parameters:
theId
- the id of the bnode- Returns:
- the new `BNode`
-
literal
@Nonnull public static Literal literal(@Nonnull java.lang.String theLabel)
Create a new `xsd:string`Literal
- Parameters:
theLabel
- the label- Returns:
- the new `Literal`
-
literal
@Nonnull public static Literal literal(boolean theValue)
Create a new `xsd:boolean`Literal
- Parameters:
theValue
- the value- Returns:
- the new `Literal`
-
literal
@Nonnull public static Literal literal(int theValue)
Create a new `xsd:int`Literal
- Parameters:
theValue
- the value- Returns:
- the new `Literal`
-
literal
@Nonnull public static Literal literal(long theValue)
Create a new `xsd:long`Literal
- Parameters:
theValue
- the value- Returns:
- the new `Literal`
-
literal
@Nonnull public static Literal literal(float theValue)
Create a new `xsd:float`Literal
- Parameters:
theValue
- the value- Returns:
- the new `Literal`
-
literal
@Nonnull public static Literal literal(double theValue)
Create a new `xsd:double`Literal
- Parameters:
theValue
- the value- Returns:
- the new `Literal`
-
literal
@Nonnull public static Literal literal(short theValue)
Create a new `xsd:short`Literal
- Parameters:
theValue
- the value- Returns:
- the new `Literal`
-
literal
@Nonnull public static Literal literal(byte theValue)
Create a new `xsd:byte`Literal
- Parameters:
theValue
- the value- Returns:
- the new `Literal`
-
literal
@Nonnull public static Literal literal(@Nonnull java.lang.String theLabel, @Nonnull IRI theDatatype)
Create a new typedLiteral
- Parameters:
theLabel
- the label of the literaltheDatatype
- the datatype- Returns:
- the new `Literal`
-
literal
@Nonnull public static Literal literal(@Nonnull java.lang.String theLabel, @Nonnull java.lang.String theLanguage)
Create a new languageLiteral
- Parameters:
theLabel
- the label of the literaltheLanguage
- the language of the literal- Returns:
- the new `Literal`
-
literal
@Nonnull public static Literal literal(int theLabel, @Nonnull Datatype theDatatype)
Create a newLiteral
- Parameters:
theLabel
- the label of the literal valuetheDatatype
- the datatype- Returns:
- the literal
- Throws:
java.lang.IllegalArgumentException
- if the provided value `theLabel` is not syntactically correct wrt to its Datatype
-
literal
@Nonnull public static Literal literal(long theLabel, @Nonnull Datatype theDatatype)
Create a newLiteral
- Parameters:
theLabel
- the label of the literal valuetheDatatype
- the datatype- Returns:
- the literal
- Throws:
java.lang.IllegalArgumentException
- if the provided value `theLabel` is not syntactically correct wrt to its Datatype
-
literal
@Nonnull public static Literal literal(@Nonnull java.lang.Number theNumber)
-
literal
@Nonnull public static Literal literal(@Nonnull java.lang.String theLabel, @Nonnull Datatype theDatatype)
Create a newLiteral
- Parameters:
theLabel
- the label of the literal valuetheDatatype
- the datatype- Returns:
- the literal
- Throws:
java.lang.NumberFormatException
- if the literal is declared as a number, such as an `int` but is not syntactically correct.java.lang.IllegalArgumentException
- if the provided value `theLabel` is not syntactically correct wrt to its Datatype
-
literal
@Nonnull public static Literal literal(@Nonnull java.util.Date theDate)
Create a newLiteral
for the given `Date` value.- Parameters:
theDate
- the value of the literal- Returns:
- the new literal
- See Also:
CalendarLiteral
-
literal
@Nonnull public static Literal literal(@Nonnull java.util.GregorianCalendar theDate)
Create a newcalendar
basedLiteral
.- Parameters:
theDate
- the value of the literal- Returns:
- the new literal
- See Also:
CalendarLiteral
-
literal
@Nonnull public static Literal literal(@Nonnull javax.xml.datatype.Duration theDuration)
Create a Duration typed literal.- Parameters:
theDuration
- the duration- Returns:
- the new duration literal
-
literal
@Nonnull public static Literal literal(@Nonnull javax.xml.datatype.Duration theDuration, @Nonnull IRI theDurationType)
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
@Nonnull public static Literal literal(@Nonnull javax.xml.datatype.XMLGregorianCalendar theCalendar)
Create a newcalendar
basedLiteral
.- Parameters:
theCalendar
- the value of the literal- Returns:
- the new literal
- See Also:
CalendarLiteral
-
literal
@Nonnull public static Literal literal(@Nonnull javax.xml.datatype.XMLGregorianCalendar theCalendar, @Nonnull Datatype theDatatype)
-
literal
@Nonnull public static Literal literal(@Nonnull javax.xml.datatype.Duration theCalendar, @Nonnull Datatype theDatatype)
-
literal
@Nonnull public static Literal literal(@Nonnull java.math.BigDecimal theBigDecimal)
-
literal
@Nonnull public static Literal literal(@Nonnull java.math.BigInteger theInt)
-
statement
@Nonnull public static Statement statement(@Nonnull Resource theSubject, @Nonnull IRI thePredicate, @Nonnull Value theObject)
Create a newStatement
in thedefault graph
- Parameters:
theSubject
- the subject of the statementthePredicate
- the predicate of the statementtheObject
- the object of the statement- Returns:
- the new `Statement`
-
isValid
public static boolean isValid(Literal theLiteral)
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
public static boolean isValid(IRI theIRI)
Verifies that the given IRI is valid.- Parameters:
theIRI
- the IRI to validate- Returns:
- true if it is a valid IRI, false otherwise
-
containsInvalidIRICharacters
public static boolean containsInvalidIRICharacters(java.lang.String theIRI)
-
containsLeadingOrTrailingWhitespace
public static boolean containsLeadingOrTrailingWhitespace(java.lang.String theIRI)
-
isValid
public static boolean isValid(Value theValue)
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_GRAPH
should be used.- Returns:
- the new `Statement`
-
isDefaultGraph
public static boolean isDefaultGraph(Resource theContext)
Return whether or not the givenResource
denotes the default graph- Parameters:
theContext
- the graph- Returns:
- `true` if the default graph, false otherwise
-
isVirtual
public static boolean isVirtual(Resource theContext)
Return whether or not the resource represents a virtual graph (starts withVIRTUAL_NAMESPACE
-
isInDefaultGraph
public static boolean isInDefaultGraph(@Nonnull Statement theStmt)
Return whether or not the givenStatement
is in the default graph- Parameters:
theStmt
- the graph- Returns:
- `true` if the default graph, false otherwise
-
isAll
public static boolean isAll(@Nonnull Resource theContext)
Return whether or not the resource represents the meta-contextALL_GRAPHS
- Parameters:
theContext
- the context- Returns:
- true if its
ALL
, false otherwise
-
isNamed
public static boolean isNamed(@Nonnull Resource theContext)
Return whether or not the resource represents the meta-contextNAMED_GRAPHS
- Parameters:
theContext
- the context- Returns:
- true if its
NAMED
, false otherwise
-
-