Package com.stardog.stark
Interface Literal
-
- All Superinterfaces:
java.io.Serializable
,Value
- All Known Implementing Classes:
ArrayLiteral
public interface Literal extends Value
A literal value in an RDF graph
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Michael Grove
- See Also:
- RDF Literal
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
STRICT_TYPES
System setting that controls whether the casting methods ofLiteral
such asintValue(Literal)
are strict about the conversion.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static boolean
booleanValue(Literal theLiteral)
Get the value of theLiteral
as a `boolean`.static byte
byteValue(Literal theLiteral)
static javax.xml.datatype.XMLGregorianCalendar
calendarValue(Literal theLiteral)
Get the value of theLiteral
as acalendar
.Datatype
datatype()
The datatype of the `Literal`.default IRI
datatypeIRI()
The IRI of theDatatype
of the `Literal`.static java.math.BigDecimal
decimalValue(Literal theLiteral)
Get the value of theLiteral
as aBigDecimal
.static double
doubleValue(Literal theLiteral)
Get the value of theLiteral
as a `double`.static javax.xml.datatype.Duration
durationValue(Literal theLiteral)
static float
floatValue(Literal theLiteral)
Get the value of theLiteral
as a `float`.static java.math.BigInteger
integerValue(Literal theLiteral)
Get the value of theLiteral
as aBigInteger
.static int
intValue(Literal theLiteral)
static boolean
isLanguageLiteral(Literal theLiteral)
Sugar for `Literal.lang().isPresent()`java.lang.String
label()
The lexical value of the literaldefault java.util.Optional<java.lang.String>
lang()
Optionally, the language of the lexical value of the `Literal`.static long
longValue(Literal theLiteral)
static int
shortValue(Literal theLiteral)
static java.lang.String
str(Literal theLiteral)
Return the `String` serialization of theLiteral
static XMLCalendar
xmlCalendarValue(Literal theLiteral)
-
-
-
Field Detail
-
STRICT_TYPES
static final boolean STRICT_TYPES
System setting that controls whether the casting methods ofLiteral
such asintValue(Literal)
are strict about the conversion. When `true`, if you try to get the `int` value of `"5"^^xsd:string` it will throw aNumberFormatException
because the datatype of the `Literal` is incompatible with `int`. If `false` thelabel()
will be used and passed to, in this example, `Integer.parseInt(String)
which still may throw a `NumberFormatException` if the value of the `Literal` is not a valid numeric value. The default value is `false`.
-
-
Method Detail
-
label
@Nonnull java.lang.String label()
The lexical value of the literal- Returns:
- the lexical value
-
lang
@Nonnull default java.util.Optional<java.lang.String> lang()
Optionally, the language of the lexical value of the `Literal`. When present, thedatatype()
isRDF.LANG_STRING
.- Returns:
- the language of the literal
- See Also:
- RDF Language
-
datatypeIRI
@Nonnull default IRI datatypeIRI()
The IRI of theDatatype
of the `Literal`. Often, this is syntactic sugar for `datatype().iri()` however, in the case where it is a user defined datatype, egDatatype.UDF
this will return the specific IRI of the datatype.- Returns:
- the datatype IRI of the lexical value
-
datatype
@Nonnull Datatype datatype()
The datatype of the `Literal`. Some serializations of RDF use a "simple literal" which is a literal with no explicit datatype. That is just syntactic sugar for `xsd:string` typed literals.- Returns:
- the Datatype
-
str
@Nonnull static java.lang.String str(@Nonnull Literal theLiteral)
Return the `String` serialization of theLiteral
- Parameters:
theLiteral
- the `Literal` to serialize- Returns:
- the serialized `Literal`
-
isLanguageLiteral
static boolean isLanguageLiteral(@Nonnull Literal theLiteral)
Sugar for `Literal.lang().isPresent()`- Parameters:
theLiteral
- the literal- Returns:
- whether or not it's a language tagged literal
-
booleanValue
static boolean booleanValue(@Nonnull Literal theLiteral)
Get the value of theLiteral
as a `boolean`.- Parameters:
theLiteral
- the literal- Returns:
- the value
- See Also:
BooleanLiteral
-
calendarValue
static javax.xml.datatype.XMLGregorianCalendar calendarValue(@Nonnull Literal theLiteral)
Get the value of theLiteral
as acalendar
.- Parameters:
theLiteral
- the literal- Returns:
- the value
- Throws:
java.lang.IllegalArgumentException
- if the literal is not a calendar datatype- See Also:
CalendarLiteral
,XMLDatatypes.isCalendarDatatype(Datatype)
-
xmlCalendarValue
static XMLCalendar xmlCalendarValue(@Nonnull Literal theLiteral)
- Parameters:
theLiteral
- the literal- Returns:
- the value
- Throws:
java.lang.IllegalArgumentException
- if the literal is not a calendar datatype- See Also:
CalendarLiteral
,XMLDatatypes.isCalendarDatatype(Datatype)
-
intValue
static int intValue(@Nonnull Literal theLiteral)
-
byteValue
static byte byteValue(@Nonnull Literal theLiteral)
-
shortValue
static int shortValue(@Nonnull Literal theLiteral)
-
longValue
static long longValue(@Nonnull Literal theLiteral)
-
durationValue
@Nonnull static javax.xml.datatype.Duration durationValue(@Nonnull Literal theLiteral)
-
floatValue
static float floatValue(@Nonnull Literal theLiteral)
Get the value of theLiteral
as a `float`.- Parameters:
theLiteral
- the literal- Returns:
- the value
- Throws:
java.lang.NumberFormatException
- if the literal is not a numeric datatype
-
doubleValue
static double doubleValue(@Nonnull Literal theLiteral)
Get the value of theLiteral
as a `double`.- Parameters:
theLiteral
- the literal- Returns:
- the value
- Throws:
java.lang.NumberFormatException
- if the literal is not a numeric datatype
-
integerValue
static java.math.BigInteger integerValue(@Nonnull Literal theLiteral)
Get the value of theLiteral
as aBigInteger
.- Parameters:
theLiteral
- the literal- Returns:
- the value
- Throws:
java.lang.NumberFormatException
- if the literal is not a numeric datatype
-
-