Package org.eclipse.rdf4j.model.util
Class Values
- java.lang.Object
-
- org.eclipse.rdf4j.model.util.Values
-
public class Values extends Object
Factory methods to quickly createValue
objects (IRI
,Literal
,BNode
, andTriple
) without having to create aValueFactory
first.Example usage:
import static org.eclipse.rdf4j.model.util.Values.iri; ... IRI foo = iri("http://example.org/foo");
- Since:
- 3.5.0
- Author:
- Jeen Broekstra
- See Also:
Statements
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BNode
bnode()
Creates a newBNode
static BNode
bnode(String nodeId)
Creates a newBNode
with the supplied node identifier.static BNode
bnode(ValueFactory vf)
Creates a newBNode
static BNode
bnode(ValueFactory vf, String nodeId)
Creates a newBNode
with the supplied node identifier.static ValueFactory
getValueFactory()
Get aValueFactory
.static IRI
iri(Iterable<Namespace> namespaces, String prefixedName)
Create a newIRI
from a supplied prefixed name, using the suppliednamespaces
static IRI
iri(String iri)
Create a newIRI
using the supplied iri stringstatic IRI
iri(String namespace, String localName)
Create a newIRI
using the supplied namespace name and local namestatic IRI
iri(Namespace namespace, String localName)
static IRI
iri(ValueFactory vf, String iri)
Create a newIRI
using the supplied iri stringstatic IRI
iri(ValueFactory vf, String namespace, String localName)
Create a newIRI
using the supplied namespace and local namestatic Literal
literal(boolean booleanValue)
Creates a newLiteral
with the supplied boolean valuestatic Literal
literal(byte byteValue)
Creates a newLiteral
with the supplied byte valuestatic Literal
literal(double doubleValue)
Creates a newLiteral
with the supplied double valuestatic Literal
literal(float floatValue)
Creates a newLiteral
with the supplied float valuestatic Literal
literal(int intValue)
Creates a newLiteral
with the supplied int valuestatic Literal
literal(long longValue)
Creates a newLiteral
with the supplied long valuestatic Literal
literal(short shortValue)
Creates a newLiteral
with the supplied short valuestatic Literal
literal(Object object)
static Literal
literal(Object object, boolean failOnUnknownType)
static Literal
literal(String lexicalValue)
Creates a newLiteral
with the supplied lexical value.static Literal
literal(String lexicalValue, String languageTag)
Creates a newLiteral
with the supplied lexical value.static Literal
literal(String lexicalValue, CoreDatatype datatype)
Creates a newLiteral
with the supplied lexical value and datatype.static Literal
literal(String lexicalValue, IRI datatype)
Creates a newLiteral
with the supplied lexical value and datatype.static Literal
literal(BigDecimal bigDecimal)
Creates a newLiteral
with the suppliedBigDecimal
valuestatic Literal
literal(BigInteger bigInteger)
Creates a newLiteral
with the suppliedBigInteger
valuestatic Literal
literal(TemporalAccessor value)
Creates a newLiteral
with the suppliedTemporalAccessor
valuestatic Literal
literal(ValueFactory vf, boolean booleanValue)
Creates a newLiteral
with the supplied boolean valuestatic Literal
literal(ValueFactory vf, byte byteValue)
Creates a newLiteral
with the supplied byte valuestatic Literal
literal(ValueFactory vf, double doubleValue)
Creates a newLiteral
with the supplied double valuestatic Literal
literal(ValueFactory vf, float floatValue)
Creates a newLiteral
with the supplied float valuestatic Literal
literal(ValueFactory vf, int intValue)
Creates a newLiteral
with the supplied int valuestatic Literal
literal(ValueFactory vf, long longValue)
Creates a newLiteral
with the supplied long valuestatic Literal
literal(ValueFactory vf, short shortValue)
Creates a newLiteral
with the supplied short valuestatic Literal
literal(ValueFactory vf, Object object, boolean failOnUnknownType)
static Literal
literal(ValueFactory vf, String lexicalValue)
Creates a newLiteral
with the supplied lexical value.static Literal
literal(ValueFactory vf, String lexicalValue, String languageTag)
Creates a newLiteral
with the supplied lexical value.static Literal
literal(ValueFactory vf, String lexicalValue, CoreDatatype datatype)
Creates a newLiteral
with the supplied lexical value and datatype.static Literal
literal(ValueFactory vf, String lexicalValue, IRI datatype)
Creates a newLiteral
with the supplied lexical value and datatype.static Literal
literal(ValueFactory vf, BigDecimal bigDecimal)
Creates a newLiteral
with the suppliedBigDecimal
valuestatic Literal
literal(ValueFactory vf, BigInteger bigInteger)
Creates a newLiteral
with the suppliedBigInteger
valuestatic Literal
literal(ValueFactory vf, TemporalAccessor value)
Creates a newLiteral
with the suppliedTemporalAccessor
valuestatic Namespace
namespace(String prefix, String name)
Create a newNamespace
object.static Triple
triple(Resource subject, IRI predicate, Value object)
Creates a newRDF-star embedded triple
with the supplied subject, predicate, and object.static Triple
triple(Statement statement)
Creates a newRDF-star embedded triple
using the subject, predicate and object from the suppliedStatement
.static Triple
triple(ValueFactory vf, Resource subject, IRI predicate, Value object)
Creates a newRDF-star embedded triple
with the supplied subject, predicate, and object.static Triple
triple(ValueFactory vf, Statement statement)
Creates a newRDF-star embedded triple
using the subject, predicate and object from the suppliedStatement
.
-
-
-
Method Detail
-
iri
public static IRI iri(String iri) throws IllegalArgumentException
Create a newIRI
using the supplied iri string- Parameters:
iri
- a string representing a valid (absolute) iri- Returns:
- an
IRI
object for the supplied iri string. - Throws:
NullPointerException
- if the suppplied iri isnull
IllegalArgumentException
- if the supplied iri string can not be parsed as a legal IRI.
-
iri
public static IRI iri(ValueFactory vf, String iri) throws IllegalArgumentException
Create a newIRI
using the supplied iri string- Parameters:
vf
- theValueFactory
to use for creation of the IRI.iri
- a string representing a valid (absolute) iri- Returns:
- an
IRI
object for the supplied iri string. - Throws:
NullPointerException
- if any of the input parameters isnull
IllegalArgumentException
- if the supplied iri string can not be parsed as a legal IRI by the suppliedValueFactory
.
-
iri
public static IRI iri(String namespace, String localName) throws IllegalArgumentException
Create a newIRI
using the supplied namespace name and local name- Parameters:
namespace
- the IRI's namespace namelocalName
- the IRI's local name- Returns:
- an
IRI
object for the supplied IRI namespace name and localName. - Throws:
NullPointerException
- if any of the input parameters isnull
IllegalArgumentException
- if the supplied iri string can not be parsed as a legal IRI.
-
iri
public static IRI iri(Namespace namespace, String localName) throws IllegalArgumentException
- Parameters:
namespace
- the IRI'sNamespace
localName
- the IRI's local name- Returns:
- an
IRI
object for the supplied IRI namespace and localName. - Throws:
NullPointerException
- if any of the input parameters isnull
IllegalArgumentException
- if the supplied iri string can not be parsed as a legal IRI.- Since:
- 3.6.0
-
iri
public static IRI iri(Iterable<Namespace> namespaces, String prefixedName) throws IllegalArgumentException
Create a newIRI
from a supplied prefixed name, using the suppliednamespaces
- Parameters:
namespaces
- the Namespaces from which to find the correct namespace to map the prefixed name toprefixedName
- a prefixed name that is a shorthand for a full iri, using syntax formprefix:localName
. For example,rdf:type
is a prefixed name whererdf
is the prefix. If the correctNamespace
definition is also supplied this expands to the full namespace namehttp://www.w3.org/1999/02/22-rdf-syntax-ns#
, leading to a full IRIhttp://www.w3.org/1999/02/22-rdf-syntax-ns#type
.- Returns:
- an
IRI
object for the supplied IRI namespace and localName. - Throws:
NullPointerException
- if any of the input parameters isnull
IllegalArgumentException
- if the supplied prefixed name can not be transformed to a legal IRI.- Since:
- 3.6.0
-
iri
public static IRI iri(ValueFactory vf, String namespace, String localName) throws IllegalArgumentException
Create a newIRI
using the supplied namespace and local name- Parameters:
vf
- theValueFactory
to use for creation of the IRI.namespace
- the IRI's namespacelocalName
- the IRI's local name- Returns:
- an
IRI
object for the supplied IRI namespace and localName. - Throws:
NullPointerException
- if any of the input parameters isnull
IllegalArgumentException
- if the supplied iri string can not be parsed as a legal IRI by the suppliedValueFactory
-
bnode
public static BNode bnode(ValueFactory vf)
Creates a newBNode
- Parameters:
vf
- theValueFactory
to use for creation of theBNode
- Returns:
- a new
BNode
- Throws:
NullPointerException
- if any of the input parameters isnull
-
bnode
public static BNode bnode(String nodeId) throws IllegalArgumentException
Creates a newBNode
with the supplied node identifier.- Parameters:
nodeId
- the node identifier- Returns:
- a new
BNode
- Throws:
NullPointerException
- if the supplied node identifier isnull
.IllegalArgumentException
- if the supplied node identifier is not valid
-
bnode
public static BNode bnode(ValueFactory vf, String nodeId) throws IllegalArgumentException
Creates a newBNode
with the supplied node identifier.- Parameters:
vf
- theValueFactory
to use for creation of theBNode
nodeId
- the node identifier- Returns:
- a new
BNode
- Throws:
NullPointerException
- if any of the input parameters isnull
IllegalArgumentException
- if the supplied node identifier is not valid
-
literal
public static Literal literal(String lexicalValue)
Creates a newLiteral
with the supplied lexical value.- Parameters:
lexicalValue
- the lexical value for the literal- Returns:
- a new
Literal
of typeXSD.STRING
- Throws:
NullPointerException
- if the supplied lexical value isnull
.
-
literal
public static Literal literal(ValueFactory vf, String lexicalValue)
Creates a newLiteral
with the supplied lexical value.- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
lexicalValue
- the lexical value for the literal- Returns:
- a new
Literal
of typeXSD.STRING
- Throws:
NullPointerException
- if any of the input parameters isnull
-
literal
public static Literal literal(String lexicalValue, String languageTag)
Creates a newLiteral
with the supplied lexical value.- Parameters:
lexicalValue
- the lexical value for the literallanguageTag
- the language tag for the literal.- Returns:
- a new
Literal
of typeRDF.LANGSTRING
- Throws:
NullPointerException
- if the supplied lexical value or language tag isnull
.
-
literal
public static Literal literal(ValueFactory vf, String lexicalValue, String languageTag)
Creates a newLiteral
with the supplied lexical value.- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
lexicalValue
- the lexical value for the literallanguageTag
- the language tag for the literal.- Returns:
- a new
Literal
of typeRDF.LANGSTRING
- Throws:
NullPointerException
- if any of the input parameters isnull
-
literal
public static Literal literal(String lexicalValue, IRI datatype) throws IllegalArgumentException
Creates a newLiteral
with the supplied lexical value and datatype.- Parameters:
lexicalValue
- the lexical value for the literaldatatype
- the datatype IRI- Returns:
- a new
Literal
with the supplied lexical value and datatype - Throws:
NullPointerException
- if the supplied lexical value or datatype isnull
.IllegalArgumentException
- if the supplied lexical value is not valid for the given datatype
-
literal
public static Literal literal(String lexicalValue, CoreDatatype datatype) throws IllegalArgumentException
Creates a newLiteral
with the supplied lexical value and datatype.- Parameters:
lexicalValue
- the lexical value for the literaldatatype
- the CoreDatatype- Returns:
- a new
Literal
with the supplied lexical value and datatype - Throws:
NullPointerException
- if the supplied lexical value or datatype isnull
.IllegalArgumentException
- if the supplied lexical value is not valid for the given datatype
-
literal
public static Literal literal(ValueFactory vf, String lexicalValue, IRI datatype) throws IllegalArgumentException
Creates a newLiteral
with the supplied lexical value and datatype.- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
lexicalValue
- the lexical value for the literaldatatype
- the datatype IRI- Returns:
- a new
Literal
with the supplied lexical value and datatype - Throws:
NullPointerException
- if any of the input parameters isnull
.IllegalArgumentException
- if the supplied lexical value is not valid for the given datatype
-
literal
public static Literal literal(ValueFactory vf, String lexicalValue, CoreDatatype datatype) throws IllegalArgumentException
Creates a newLiteral
with the supplied lexical value and datatype.- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
lexicalValue
- the lexical value for the literaldatatype
- the CoreDatatype- Returns:
- a new
Literal
with the supplied lexical value and datatype - Throws:
NullPointerException
- if any of the input parameters isnull
.IllegalArgumentException
- if the supplied lexical value is not valid for the given datatype
-
literal
public static Literal literal(boolean booleanValue)
Creates a newLiteral
with the supplied boolean value- Parameters:
booleanValue
- a boolean value- Returns:
- a
Literal
of typeXSD.BOOLEAN
with the supplied value
-
literal
public static Literal literal(ValueFactory vf, boolean booleanValue)
Creates a newLiteral
with the supplied boolean value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
booleanValue
- a boolean value- Returns:
- a
Literal
of typeXSD.BOOLEAN
with the supplied value - Throws:
NullPointerException
- if any of the input parameters isnull
.
-
literal
public static Literal literal(byte byteValue)
Creates a newLiteral
with the supplied byte value
-
literal
public static Literal literal(ValueFactory vf, byte byteValue)
Creates a newLiteral
with the supplied byte value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
byteValue
- a byte value- Returns:
- a
Literal
of typeXSD.BYTE
with the supplied value - Throws:
NullPointerException
- if any of the input parameters isnull
.
-
literal
public static Literal literal(short shortValue)
Creates a newLiteral
with the supplied short value
-
literal
public static Literal literal(ValueFactory vf, short shortValue)
Creates a newLiteral
with the supplied short value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
shortValue
- a short value- Returns:
- a
Literal
of typeXSD.SHORT
with the supplied value - Throws:
NullPointerException
- if any of the input parameters isnull
.
-
literal
public static Literal literal(int intValue)
Creates a newLiteral
with the supplied int value
-
literal
public static Literal literal(ValueFactory vf, int intValue)
Creates a newLiteral
with the supplied int value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
intValue
- an int value- Returns:
- a
Literal
of typeXSD.INT
with the supplied value - Throws:
NullPointerException
- if any of the input parameters isnull
.
-
literal
public static Literal literal(long longValue)
Creates a newLiteral
with the supplied long value
-
literal
public static Literal literal(ValueFactory vf, long longValue)
Creates a newLiteral
with the supplied long value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
longValue
- a long value- Returns:
- a
Literal
of typeXSD.LONG
with the supplied value - Throws:
NullPointerException
- if any of the input parameters isnull
.
-
literal
public static Literal literal(float floatValue)
Creates a newLiteral
with the supplied float value
-
literal
public static Literal literal(ValueFactory vf, float floatValue)
Creates a newLiteral
with the supplied float value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
floatValue
- a float value- Returns:
- a
Literal
of typeXSD.FLOAT
with the supplied value - Throws:
NullPointerException
- if any of the input parameters isnull
.
-
literal
public static Literal literal(double doubleValue)
Creates a newLiteral
with the supplied double value- Parameters:
doubleValue
- a double value- Returns:
- a
Literal
of typeXSD.DOUBLE
with the supplied value
-
literal
public static Literal literal(ValueFactory vf, double doubleValue)
Creates a newLiteral
with the supplied double value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
doubleValue
- a double value- Returns:
- a
Literal
of typeXSD.DOUBLE
with the supplied value - Throws:
NullPointerException
- if any of the input parameters isnull
.
-
literal
public static Literal literal(BigDecimal bigDecimal)
Creates a newLiteral
with the suppliedBigDecimal
value- Parameters:
bigDecimal
- aBigDecimal
value- Returns:
- a
Literal
of typeXSD.DECIMAL
with the supplied value - Throws:
NullPointerException
- if the supplied bigDecimal isnull
.
-
literal
public static Literal literal(ValueFactory vf, BigDecimal bigDecimal)
Creates a newLiteral
with the suppliedBigDecimal
value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
bigDecimal
- aBigDecimal
value- Returns:
- a
Literal
of typeXSD.DECIMAL
with the supplied value - Throws:
NullPointerException
- if any of the input parameters isnull
.
-
literal
public static Literal literal(BigInteger bigInteger)
Creates a newLiteral
with the suppliedBigInteger
value- Parameters:
bigInteger
- aBigInteger
value- Returns:
- a
Literal
of typeXSD.INTEGER
with the supplied value - Throws:
NullPointerException
- if the supplied bigInteger isnull
.
-
literal
public static Literal literal(ValueFactory vf, BigInteger bigInteger)
Creates a newLiteral
with the suppliedBigInteger
value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
bigInteger
- aBigInteger
value- Returns:
- a
Literal
of typeXSD.INTEGER
with the supplied value - Throws:
NullPointerException
- if any of the input parameters isnull
.
-
literal
public static Literal literal(TemporalAccessor value) throws IllegalArgumentException
Creates a newLiteral
with the suppliedTemporalAccessor
value- Parameters:
value
- aTemporalAccessor
value.- Returns:
- a
Literal
with the supplied calendar value and the appropriateXSD
date/time datatype for the specific value. - Throws:
NullPointerException
- if the suppliedTemporalAccessor
value isnull
.IllegalArgumentException
- if value cannot be represented by an XML Schema date/time datatype
-
literal
public static Literal literal(ValueFactory vf, TemporalAccessor value) throws IllegalArgumentException
Creates a newLiteral
with the suppliedTemporalAccessor
value- Parameters:
vf
- theValueFactory
to use for creation of theLiteral
value
- aTemporalAccessor
value.- Returns:
- a
Literal
with the supplied calendar value and the appropriateXSD
date/time datatype for the specific value. - Throws:
NullPointerException
- if any of the input parameters isnull
..IllegalArgumentException
- if value cannot be represented by an XML Schema date/time datatype
-
literal
public static Literal literal(Object object)
Creates a new typedLiteral
out of the supplied object, mapping the runtime type of the object to the appropriateXSD
datatype. If no mapping is available, the method returns a literal with the string representation of the supplied object as the value, andXSD.STRING
as the datatype.Recognized types are
Boolean
,Byte
,Double
,Float
,Integer
,Long
,Short
,XMLGregorianCalendar
,TemporalAccessor
andDate
.- Parameters:
object
- an object to be converted to a typed literal.- Returns:
- a typed literal representation of the supplied object.
- Throws:
NullPointerException
- if the input parameter isnull
..
-
literal
public static Literal literal(Object object, boolean failOnUnknownType)
Creates a new typedLiteral
out of the supplied object, mapping the runtime type of the object to the appropriateXSD
datatype.Recognized types are
Boolean
,Byte
,Double
,Float
,BigDecimal
,Integer
,BigInteger
,Long
,Short
,XMLGregorianCalendar
,TemporalAccessor
,TemporalAmpount
andDate
.- Parameters:
object
- an object to be converted to a typed literal.failOnUnknownType
- If no mapping is available andfailOnUnknownType
isfalse
the method returns a literal with the string representation of the supplied object as the value, andXSD.STRING
as the datatype. If set totrue
the method throws anIllegalArgumentException
if no mapping available.- Returns:
- a typed literal representation of the supplied object.
- Throws:
NullPointerException
- if the input parameter isnull
..
-
literal
public static Literal literal(ValueFactory vf, Object object, boolean failOnUnknownType)
Creates a new typedLiteral
out of the supplied object, mapping the runtime type of the object to the appropriateXSD
datatype.Recognized types are
Boolean
,Byte
,Double
,Float
,Integer
,Long
,Short
,XMLGregorianCalendar
,TemporalAccessor
andDate
.- Parameters:
valueFactory
- theValueFactory
to use for creation of theLiteral
object
- an object to be converted to a typed literal.failOnUnknownType
- If no mapping is available andfailOnUnknownType
isfalse
the method returns a literal with the string representation of the supplied object as the value, andXSD.STRING
as the datatype. If set totrue
the method throws anIllegalArgumentException
if no mapping available.- Returns:
- a typed literal representation of the supplied object.
- Throws:
NullPointerException
- if any of the input parameters isnull
.IllegalArgumentException
- iffailOnUnknownType
is set totrue
and the runtime type of the supplied object could not be mapped.
-
triple
public static Triple triple(Resource subject, IRI predicate, Value object)
Creates a newRDF-star embedded triple
with the supplied subject, predicate, and object.- Parameters:
subject
- the Triple subjectpredicate
- the Triple predicateobject
- the Triple object- Returns:
- a
Triple
with the supplied subject, predicate, and object. - Throws:
NullPointerException
- if any of the supplied input parameters isnull
.
-
triple
public static Triple triple(ValueFactory vf, Resource subject, IRI predicate, Value object)
Creates a newRDF-star embedded triple
with the supplied subject, predicate, and object.- Parameters:
vf
- theValueFactory
to use for creation of theTriple
subject
- the Triple subjectpredicate
- the Triple predicateobject
- the Triple object- Returns:
- a
Triple
with the supplied subject, predicate, and object. - Throws:
NullPointerException
- if any of the supplied input parameters isnull
.
-
triple
public static Triple triple(Statement statement)
Creates a newRDF-star embedded triple
using the subject, predicate and object from the suppliedStatement
.- Parameters:
statement
- theStatement
from which to construct aTriple
- Returns:
- a
Triple
with the same subject, predicate, and object as the supplied Statement. - Throws:
NullPointerException
- if statement isnull
.
-
triple
public static Triple triple(ValueFactory vf, Statement statement)
Creates a newRDF-star embedded triple
using the subject, predicate and object from the suppliedStatement
.- Parameters:
vf
- theValueFactory
to use for creation of theTriple
statement
- theStatement
from which to construct aTriple
- Returns:
- a
Triple
with the same subject, predicate, and object as the supplied Statement. - Throws:
NullPointerException
- if any of the supplied input parameters isnull
.
-
namespace
public static Namespace namespace(String prefix, String name)
Create a newNamespace
object.- Parameters:
prefix
- the prefix associated with the namespacename
- the namespace name (typically an IRI) for the namespace.- Returns:
- a
Namespace
object. - Since:
- 3.6.0
-
getValueFactory
public static ValueFactory getValueFactory()
Get aValueFactory
.- Returns:
- a
ValueFactory
.
-
-