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 booleanSTRICT_TYPESSystem setting that controls whether the casting methods ofLiteralsuch 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 booleanbooleanValue(Literal theLiteral)Get the value of theLiteralas a `boolean`.static bytebyteValue(Literal theLiteral)static javax.xml.datatype.XMLGregorianCalendarcalendarValue(Literal theLiteral)Get the value of theLiteralas acalendar.Datatypedatatype()The datatype of the `Literal`.default IRIdatatypeIRI()The IRI of theDatatypeof the `Literal`.static java.math.BigDecimaldecimalValue(Literal theLiteral)Get the value of theLiteralas aBigDecimal.static doubledoubleValue(Literal theLiteral)Get the value of theLiteralas a `double`.static javax.xml.datatype.DurationdurationValue(Literal theLiteral)static floatfloatValue(Literal theLiteral)Get the value of theLiteralas a `float`.static java.math.BigIntegerintegerValue(Literal theLiteral)Get the value of theLiteralas aBigInteger.static intintValue(Literal theLiteral)static booleanisLanguageLiteral(Literal theLiteral)Sugar for `Literal.lang().isPresent()`java.lang.Stringlabel()The lexical value of the literaldefault java.util.Optional<java.lang.String>lang()Optionally, the language of the lexical value of the `Literal`.static longlongValue(Literal theLiteral)static intshortValue(Literal theLiteral)static java.lang.Stringstr(Literal theLiteral)Return the `String` serialization of theLiteralstatic XMLCalendarxmlCalendarValue(Literal theLiteral)
-
-
-
Field Detail
-
STRICT_TYPES
static final boolean STRICT_TYPES
System setting that controls whether the casting methods ofLiteralsuch asintValue(Literal)are strict about the conversion. When `true`, if you try to get the `int` value of `"5"^^xsd:string` it will throw aNumberFormatExceptionbecause 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 theDatatypeof the `Literal`. Often, this is syntactic sugar for `datatype().iri()` however, in the case where it is a user defined datatype, egDatatype.UDFthis 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 theLiteralas 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 theLiteralas 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 theLiteralas 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 theLiteralas 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 theLiteralas aBigInteger.- Parameters:
theLiteral- the literal- Returns:
- the value
- Throws:
java.lang.NumberFormatException- if the literal is not a numeric datatype
-
-