Package com.stardog.stark
Class Values
- java.lang.Object
-
- com.stardog.stark.Values
-
public final class Values extends java.lang.ObjectUtility 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 IRIALL_GRAPHSSpecial IRI representing the union of the local and virtual graphsstatic javax.xml.datatype.DatatypeFactoryDATATYPE_FACTORYDatatype factory that will be used for date/time literals.static IRIDEFAULT_GRAPHSpecial IRI representing the default (no) context.static IRILOCAL_GRAPHSSpecial IRI representing the union of the local (non-virtual) default graph and all local named graphsstatic IRINAMED_GRAPHSSpecial IRI representing only local named graphs; this excludes the default graphstatic IRIVIRTUAL_GRAPHSSpecial IRI representing the union of the virtual graphsstatic java.lang.StringVIRTUAL_NAMESPACENamespace reserved for virtual graph names
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BNodebnode()Create a newBNodestatic BNodebnode(java.lang.String theId)Create a newBNodestatic booleancontainsInvalidIRICharacters(java.lang.String theIRI)static booleancontainsLeadingOrTrailingWhitespace(java.lang.String theIRI)static IRIiri(java.lang.String theIRI)Create a newIRIstatic IRIiri(java.lang.String theNS, java.lang.String theLocalName)Create a newIRIfrom a namespace and a local namestatic booleanisAll(Resource theContext)Return 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 booleanisLocal(Resource theContext)static booleanisNamed(Resource theContext)Return whether or not the resource represents the meta-contextNAMED_GRAPHSstatic booleanisValid(IRI theIRI)Verifies that the given IRI is valid.static booleanisValid(Literal theLiteral)Verifies that the given literal is valid.static booleanisValid(Value theValue)Verifies that the given value is valid.static booleanisVirtual(Resource theContext)Return 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 Literalliteral(int theLabel, Datatype theDatatype)Create a newLiteralstatic Literalliteral(long theValue)Create a new `xsd:long`Literalstatic Literalliteral(long theLabel, Datatype theDatatype)Create a newLiteralstatic Literalliteral(short theValue)Create a new `xsd:short`Literalstatic Literalliteral(java.lang.Number theNumber)static Literalliteral(java.lang.String theLabel)Create a new `xsd:string`Literalstatic Literalliteral(java.lang.String theLabel, Datatype theDatatype)Create a newLiteralstatic Literalliteral(java.lang.String theLabel, IRI theDatatype)Create a new typedLiteralstatic Literalliteral(java.lang.String theLabel, java.lang.String theLanguage)Create a new languageLiteralstatic Literalliteral(java.math.BigDecimal theBigDecimal)static Literalliteral(java.math.BigInteger theInt)static Literalliteral(java.util.Date theDate)Create a newLiteralfor the given `Date` value.static Literalliteral(java.util.GregorianCalendar theDate)Create a newcalendarbasedLiteral.static Literalliteral(javax.xml.datatype.Duration theDuration)Create a Duration typed literal.static Literalliteral(javax.xml.datatype.Duration theDuration, Datatype theDatatype)static Literalliteral(javax.xml.datatype.Duration theDuration, IRI theDurationType)Create a Duration typed literal.static Literalliteral(javax.xml.datatype.XMLGregorianCalendar theCalendar)Create a newcalendarbasedLiteral.static Literalliteral(javax.xml.datatype.XMLGregorianCalendar theCalendar, Datatype theDatatype)static Namespacenamespace(java.lang.String thePrefix, java.lang.String theIRI)Create aNamespacestatic Resourceresource(java.lang.String id)Treats IDs starting with "_:" as stable bnodes and createsBNodeobjects for them, otherwise creates IRIs.static Statementstatement(Resource theSubject, IRI thePredicate, Value theObject)Create a newStatementin thedefault graphstatic Statementstatement(Resource theSubject, IRI thePredicate, Value theObject, Resource theContext)Create a newStatementstatic IRIuniqueIri(java.lang.String prefix)Create a newIRIthat is guaranteed to be unique.
-
-
-
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 newIRIfrom 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`
-
uniqueIri
public static IRI uniqueIri(java.lang.String prefix)
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
@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 newLiteralfor 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 newcalendarbasedLiteral.- 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 newcalendarbasedLiteral.- 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 theDuration, @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 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
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_GRAPHshould be used.- Returns:
- the new `Statement`
-
isDefaultGraph
public static boolean isDefaultGraph(Resource theContext)
Return whether or not the givenResourcedenotes the default graph- Parameters:
theContext- the graph- Returns:
- `true` if the default graph, false otherwise
-
isVirtual
public static boolean isVirtual(Resource theContext)
Return whether the resource represents a virtual graph (starts withVIRTUAL_NAMESPACE
-
isInDefaultGraph
public static boolean isInDefaultGraph(@Nonnull Statement theStmt)Return whether or not the givenStatementis 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
-
isLocal
public static boolean isLocal(@Nonnull Resource theContext)
-
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
-
-