Package org.apache.jena.rdf.model.impl
Class LiteralImpl
- java.lang.Object
-
- org.apache.jena.enhanced.Polymorphic<RDFNode>
-
- org.apache.jena.enhanced.EnhNode
-
- org.apache.jena.rdf.model.impl.LiteralImpl
-
- All Implemented Interfaces:
FrontsNode
,Literal
,RDFNode
public class LiteralImpl extends EnhNode implements Literal
An implementation of Literal.
-
-
Field Summary
Fields Modifier and Type Field Description static Implementation
factory
-
Constructor Summary
Constructors Constructor Description LiteralImpl(Node n, EnhGraph m)
LiteralImpl(Node n, ModelCom m)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Literal
asLiteral()
If this node is a Literal, answer that literal; otherwise throw an exception.Resource
asResource()
If this node is a Resource, answer that resource; otherwise throw an exception.boolean
getBoolean()
If the literal is interpretable as a Boolean return its value as a boolean.byte
getByte()
If the literal is interpretable as a Byte return its value.char
getChar()
If the literal is interpretable as a Char return its value.RDFDatatype
getDatatype()
Return the datatype of the literal.java.lang.String
getDatatypeURI()
Return the uri of the datatype of the literal.double
getDouble()
If the literal is interpretable as a Double return its value.float
getFloat()
If the literal is interpretable as a Float return its value.int
getInt()
If the literal is interpretable as a Integer return its value.java.lang.String
getLanguage()
If a language is defined for this literal return itjava.lang.String
getLexicalForm()
Return the lexical form of the literal.long
getLong()
If the literal is interpretable as a Long return its value.Model
getModel()
Answer the model this literal was created in, if any, otherwise null.short
getShort()
If the literal is interpretable as a Short return its value.java.lang.String
getString()
If the literal is interpretable as a string return its value.java.lang.Object
getValue()
Return the value of the literal.Literal
inModel(Model m)
Literals are not in any particular model, and so inModel can return this.boolean
isWellFormedXML()
Answer true iff this literal is (or claims to be) well-formed XML.boolean
sameValueAs(Literal other)
Test that two literals are semantically equivalent.java.lang.String
toString()
Answer a String representation of the node.java.lang.Object
visitWith(RDFVisitor rv)
Apply the appropriate method of the visitor to this node's content and return the result.-
Methods inherited from class org.apache.jena.enhanced.EnhNode
as, asNode, canAs, equals, getGraph, hashCode, isAnon, isLiteral, isResource, isStmtResource, isURIResource, isValid, viewAs
-
Methods inherited from class org.apache.jena.enhanced.Polymorphic
addView, supports
-
Methods inherited from interface org.apache.jena.graph.FrontsNode
asNode
-
Methods inherited from interface org.apache.jena.rdf.model.RDFNode
as, canAs, isAnon, isLiteral, isResource, isStmtResource, isURIResource
-
-
-
-
Field Detail
-
factory
public static final Implementation factory
-
-
Method Detail
-
visitWith
public java.lang.Object visitWith(RDFVisitor rv)
Description copied from interface:RDFNode
Apply the appropriate method of the visitor to this node's content and return the result.
-
inModel
public Literal inModel(Model m)
Literals are not in any particular model, and so inModel can return this.
-
asLiteral
public Literal asLiteral()
Description copied from interface:RDFNode
If this node is a Literal, answer that literal; otherwise throw an exception.
-
asResource
public Resource asResource()
Description copied from interface:RDFNode
If this node is a Resource, answer that resource; otherwise throw an exception.- Specified by:
asResource
in interfaceRDFNode
-
getModel
public Model getModel()
Answer the model this literal was created in, if any, otherwise null.
-
toString
public java.lang.String toString()
Description copied from interface:RDFNode
Answer a String representation of the node. The form of the string depends on the type of the node and is intended for human consumption, not machine analysis.
-
getValue
public java.lang.Object getValue()
Return the value of the literal. In the case of plain literals this will return the literal string. In the case of typed literals it will return a java object representing the value. In the case of typed literals representing a java primitive then the appropriate java wrapper class (Integer etc) will be returned.
-
getDatatype
public RDFDatatype getDatatype()
Return the datatype of the literal. This will be null in the case of plain literals.- Specified by:
getDatatype
in interfaceLiteral
-
getDatatypeURI
public java.lang.String getDatatypeURI()
Return the uri of the datatype of the literal. This will be null in the case of plain literals.- Specified by:
getDatatypeURI
in interfaceLiteral
-
getLexicalForm
public java.lang.String getLexicalForm()
Return the lexical form of the literal.- Specified by:
getLexicalForm
in interfaceLiteral
-
getBoolean
public boolean getBoolean()
Description copied from interface:Literal
If the literal is interpretable as a Boolean return its value as a boolean. Plain literals are interpreted by parsing their lexical representation, typed literals are interpreted by coercion of the java object representing their value.- Specified by:
getBoolean
in interfaceLiteral
- Returns:
- the literal interpeted as a boolean
-
getByte
public byte getByte()
Description copied from interface:Literal
If the literal is interpretable as a Byte return its value. Plain literals are interpreted by parsing their lexical representation, typed literals are interpreted by coercion of the java object representing their value.
-
getShort
public short getShort()
Description copied from interface:Literal
If the literal is interpretable as a Short return its value. Plain literals are interpreted by parsing their lexical representation, typed literals are interpreted by coercion of the java object representing their value.
-
getInt
public int getInt()
Description copied from interface:Literal
If the literal is interpretable as a Integer return its value. Plain literals are interpreted by parsing their lexical representation, typed literals are interpreted by coercion of the java object representing their value.
-
getLong
public long getLong()
Description copied from interface:Literal
If the literal is interpretable as a Long return its value. Plain literals are interpreted by parsing their lexical representation, typed literals are interpreted by coercion of the java object representing their value.
-
getChar
public char getChar()
Description copied from interface:Literal
If the literal is interpretable as a Char return its value. Plain literals are interpreted by parsing their lexical representation, typed literals are interpreted by coercion of the java object representing their value.
-
getFloat
public float getFloat()
Description copied from interface:Literal
If the literal is interpretable as a Float return its value. Plain literals are interpreted by parsing their lexical representation, typed literals are interpreted by coercion of the java object representing their value.
-
getDouble
public double getDouble()
Description copied from interface:Literal
If the literal is interpretable as a Double return its value. Plain literals are interpreted by parsing their lexical representation, typed literals are interpreted by coercion of the java object representing their value.
-
getString
public java.lang.String getString()
Description copied from interface:Literal
If the literal is interpretable as a string return its value. For typed literals this will throw an error for non string literals and one needs to use getLexicalForm to return the string form of other datatypes.
-
getLanguage
public java.lang.String getLanguage()
Description copied from interface:Literal
If a language is defined for this literal return it- Specified by:
getLanguage
in interfaceLiteral
- Returns:
- the language for this literal if it exists, or empty string if none
-
isWellFormedXML
public boolean isWellFormedXML()
Description copied from interface:Literal
Answer true iff this literal is (or claims to be) well-formed XML.- Specified by:
isWellFormedXML
in interfaceLiteral
-
sameValueAs
public boolean sameValueAs(Literal other)
Test that two literals are semantically equivalent. In some cases this may be the same as equals, in others equals is stricter. For example, two xsd:int literals with the same value but different language tag are semantically equivalent but distinguished by the java equality function in order to support round tripping.- Specified by:
sameValueAs
in interfaceLiteral
-
-