public class NTriplesUtil extends Object
Constructor and Description |
---|
NTriplesUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
append(BNode bNode,
Appendable appendable)
Appends the N-Triples representation of the given
BNode to the given Appendable . |
static void |
append(IRI uri,
Appendable appendable)
Appends the N-Triples representation of the given
IRI to the given Appendable . |
static void |
append(IRI uri,
Appendable appendable,
boolean escapeUnicode)
Appends the N-Triples representation of the given
IRI to the given Appendable . |
static void |
append(Literal lit,
Appendable appendable)
Appends the N-Triples representation of the given
Literal to the given Appendable . |
static void |
append(Literal lit,
Appendable appendable,
boolean xsdStringToPlainLiteral,
boolean escapeUnicode)
Appends the N-Triples representation of the given
Literal to the given Appendable , optionally
ignoring the xsd:string datatype as it is implied for RDF-1.1. |
static void |
append(Resource resource,
Appendable appendable)
Appends the N-Triples representation of the given
Resource to the given Appendable . |
static void |
append(Triple triple,
Appendable appendable)
Appends the N-Triples (non-standard) representation of the given
Triple to the given Appendable . |
static void |
append(Value value,
Appendable appendable)
Appends the N-Triples representation of the given
Value to the given Appendable . |
static void |
append(Value value,
Appendable appendable,
boolean xsdStringToPlainLiteral,
boolean escapeUnicode)
Appends the N-Triples representation of the given
Value to the given Appendable , optionally not
serializing the datatype a Literal with the xsd:string datatype as it is implied for RDF-1.1. |
static String |
escapeString(String label)
Escapes a Unicode string to an all-ASCII character sequence.Any special characters are escaped using backslashes
( " becomes \", etc.), and non-ascii/non-printable characters are escaped using Unicode escapes
( \uxxxx and \Uxxxxxxxx).
|
static void |
escapeString(String label,
Appendable appendable)
Escapes a Unicode string to an all-ASCII character sequence.
|
static void |
escapeString(String label,
Appendable appendable,
boolean escapeUnicode)
Escapes a Unicode string to an N-Triples compatible character sequence.Any special characters are escaped using
backslashes (" becomes \", etc.), and non-ascii/non-printable characters are escaped using
Unicode escapes (\uxxxx and \Uxxxxxxxx) if the option is selected.
|
static boolean |
isDot(int c)
Checks whether the supplied character is Dot '.'.
|
static boolean |
isLetter(int c)
Deprecated.
|
static boolean |
isLetterOrNumber(int c)
Deprecated.
|
static boolean |
isLiberalCharactersButNotDot(int c)
Checks whether the supplied character is in list of liberal characters according to the N-Triples specification
except Dot.
|
static boolean |
isNumber(int c)
Deprecated.
|
static boolean |
isUnderscore(int c)
Checks whether the supplied character is Underscore.
|
static boolean |
isValidCharacterForBNodeLabel(int c)
Checks whether the supplied character is valid character as per N-Triples specification.
|
static BNode |
parseBNode(String nTriplesBNode,
ValueFactory valueFactory)
Parses an N-Triples bNode, creates an object for it using the supplied ValueFactory and returns this object.
|
static Literal |
parseLiteral(String nTriplesLiteral,
ValueFactory valueFactory)
Parses an N-Triples literal, creates an object for it using the supplied ValueFactory and returns this object.
|
static Resource |
parseResource(String nTriplesResource,
ValueFactory valueFactory)
Parses an N-Triples resource, creates an object for it using the supplied ValueFactory and returns this object.
|
static Triple |
parseTriple(String nTriplesTriple,
ValueFactory valueFactory)
Parses an RDF* triple (non-standard N-Triples), creates an object for it using the supplied ValueFactory and
returns this object.
|
static IRI |
parseURI(String nTriplesURI,
ValueFactory valueFactory)
Parses an N-Triples URI, creates an object for it using the supplied ValueFactory and returns this object.
|
static Value |
parseValue(String nTriplesValue,
ValueFactory valueFactory)
Parses an N-Triples value, creates an object for it using the supplied ValueFactory and returns this object.
|
static String |
toHexString(int decimal,
int stringLength)
Converts a decimal value to a hexadecimal string representation of the specified length.
|
static String |
toNTriplesString(BNode bNode)
Creates an N-Triples string for the supplied blank node.
|
static String |
toNTriplesString(IRI uri)
Creates an N-Triples string for the supplied URI.
|
static String |
toNTriplesString(Literal lit)
Creates an N-Triples string for the supplied literal.
|
static String |
toNTriplesString(Literal lit,
boolean xsdStringToPlainLiteral)
Creates an N-Triples string for the supplied literal, optionally ignoring the xsd:string datatype as it is
implied for RDF-1.1.
|
static String |
toNTriplesString(Resource resource)
Creates an N-Triples string for the supplied resource.
|
static String |
toNTriplesString(Triple triple)
Creates an N-Triples (non-standard) string for the supplied RDF* triple.
|
static String |
toNTriplesString(Value value)
Creates an N-Triples string for the supplied value.
|
static String |
toNTriplesString(Value value,
boolean xsdStringToPlainLiteral)
Creates an N-Triples string for the supplied value.If the supplied value is a
Literal , it optionally
ignores the xsd:string datatype, since this datatype is implicit in RDF-1.1. |
static String |
unescapeString(String s)
Unescapes an escaped Unicode string.
|
public static Value parseValue(String nTriplesValue, ValueFactory valueFactory) throws IllegalArgumentException
nTriplesValue
- The N-Triples value to parse.valueFactory
- The ValueFactory to use for creating the object.IllegalArgumentException
- If the supplied value could not be parsed correctly.public static Resource parseResource(String nTriplesResource, ValueFactory valueFactory) throws IllegalArgumentException
nTriplesResource
- The N-Triples resource to parse.valueFactory
- The ValueFactory to use for creating the object.IllegalArgumentException
- If the supplied resource could not be parsed correctly.public static IRI parseURI(String nTriplesURI, ValueFactory valueFactory) throws IllegalArgumentException
nTriplesURI
- The N-Triples URI to parse.valueFactory
- The ValueFactory to use for creating the object.IllegalArgumentException
- If the supplied URI could not be parsed correctly.public static BNode parseBNode(String nTriplesBNode, ValueFactory valueFactory) throws IllegalArgumentException
nTriplesBNode
- The N-Triples bNode to parse.valueFactory
- The ValueFactory to use for creating the object.IllegalArgumentException
- If the supplied bNode could not be parsed correctly.public static Literal parseLiteral(String nTriplesLiteral, ValueFactory valueFactory) throws IllegalArgumentException
nTriplesLiteral
- The N-Triples literal to parse.valueFactory
- The ValueFactory to use for creating the object.IllegalArgumentException
- If the supplied literal could not be parsed correctly.public static Triple parseTriple(String nTriplesTriple, ValueFactory valueFactory)
nTriplesTriple
- The RDF* triple to parse.valueFactory
- The ValueFactory to use for creating the object.IllegalArgumentException
- If the supplied triple could not be parsed correctly.public static String toNTriplesString(Value value)
value
- public static String toNTriplesString(Value value, boolean xsdStringToPlainLiteral)
Literal
, it optionally
ignores the xsd:string datatype, since this datatype is implicit in RDF-1.1.value
- The value to write.xsdStringToPlainLiteral
- True to omit serialising the xsd:string datatype and false to always serialise the
datatype for literals.public static void append(Value value, Appendable appendable) throws IOException
Value
to the given Appendable
.value
- The value to write.appendable
- The object to append to.IOException
public static void append(Value value, Appendable appendable, boolean xsdStringToPlainLiteral, boolean escapeUnicode) throws IOException
Value
to the given Appendable
, optionally not
serializing the datatype a Literal
with the xsd:string datatype as it is implied for RDF-1.1.value
- The value to write.appendable
- The object to append to.xsdStringToPlainLiteral
- True to omit serializing the xsd:string datatype and false to always serialize the
datatype for literals.escapeUnicode
- IOException
public static String toNTriplesString(Resource resource)
resource
- public static void append(Resource resource, Appendable appendable) throws IOException
Resource
to the given Appendable
.resource
- The resource to write.appendable
- The object to append to.IOException
public static String toNTriplesString(IRI uri)
uri
- public static void append(IRI uri, Appendable appendable) throws IOException
IRI
to the given Appendable
.uri
- The IRI to write.appendable
- The object to append to.IOException
public static void append(IRI uri, Appendable appendable, boolean escapeUnicode) throws IOException
IRI
to the given Appendable
.uri
- appendable
- escapeUnicode
- IOException
public static String toNTriplesString(BNode bNode)
bNode
- public static void append(BNode bNode, Appendable appendable) throws IOException
BNode
to the given Appendable
.bNode
- appendable
- IOException
public static String toNTriplesString(Literal lit)
lit
- public static String toNTriplesString(Literal lit, boolean xsdStringToPlainLiteral)
lit
- The literal to write.xsdStringToPlainLiteral
- True to omit serializing the xsd:string datatype and false to always serialize the
datatype for literals.public static void append(Literal lit, Appendable appendable) throws IOException
Literal
to the given Appendable
.lit
- appendable
- IOException
public static void append(Literal lit, Appendable appendable, boolean xsdStringToPlainLiteral, boolean escapeUnicode) throws IOException
Literal
to the given Appendable
, optionally
ignoring the xsd:string datatype as it is implied for RDF-1.1.lit
- The literal to write.appendable
- The object to append to.xsdStringToPlainLiteral
- True to omit serializing the xsd:string datatype and false to always serialize the
datatype for literals.escapeUnicode
- True to escape non-ascii/non-printable characters using Unicode escapes
(\uxxxx and \Uxxxxxxxx), false to print without
escaping.IOException
public static String toNTriplesString(Triple triple)
triple
- public static void append(Triple triple, Appendable appendable) throws IOException
Triple
to the given Appendable
.triple
- appendable
- IOException
@Deprecated public static boolean isLetterOrNumber(int c)
ASCIIUtil.isLetterOrNumber(int)
c
- isLetter(int)
,
isNumber(int)
@Deprecated public static boolean isLetter(int c)
ASCIIUtil.isLetter(int)
c
- @Deprecated public static boolean isNumber(int c)
ASCIIUtil.isNumber(int)
c
- public static boolean isValidCharacterForBNodeLabel(int c)
c
- public static boolean isLiberalCharactersButNotDot(int c)
c
- public static boolean isUnderscore(int c)
c
- public static boolean isDot(int c)
c
- public static String escapeString(String label)
label
- public static void escapeString(String label, Appendable appendable) throws IOException
label
- appendable
- IOException
public static void escapeString(String label, Appendable appendable, boolean escapeUnicode) throws IOException
label
- appendable
- escapeUnicode
- IOException
public static String unescapeString(String s)
s
- An escaped Unicode string.IllegalArgumentException
- If the supplied string is not a correctly escaped N-Triples string.public static String toHexString(int decimal, int stringLength)
decimal
- A decimal value.stringLength
- The length of the resulting string.Copyright © 2015-2020 Eclipse Foundation. All Rights Reserved.