@Override public final String getLiteralLexicalForm() { return getLiteral().getLexicalForm(); }
/** Answer true iff <i>this</i> and <i>other</i> have the same lexical form and [ignoring case] language code. [Note: both typed literals and plain literals have the empty string as language code.] */ private boolean sameByFormAndLanguage( LiteralLabel other ) { String lex1 = getLexicalForm() ; String lex2 = other.getLexicalForm() ; return lex1.equals( lex2 ) && lang.equalsIgnoreCase( other.language() ); }
/** * Test whether the given LiteralLabel is a valid instance * of this datatype. This takes into accound typing information * as well as lexical form - for example an xsd:string is * never considered valid as an xsd:integer (even if it is * lexically legal like "1"). */ @Override public boolean isValidLiteral(LiteralLabel lit) { if (isBaseTypeCompatible(lit)) { String lex = lit.getLexicalForm(); if (JenaParameters.enableWhitespaceCheckingOfTypedLiterals) { if (lex.trim().equals(lex)) { return isValid(lit.getLexicalForm()); } else { return false; } } else { return isValid(lit.getLexicalForm()); } } else { return false; } }
/** * Test whether the given LiteralLabel is a valid instance * of this datatype. This takes into accound typing information * as well as lexical form - for example an xsd:string is * never considered valid as an xsd:integer (even if it is * lexically legal like "1"). */ @Override public boolean isValidLiteral(LiteralLabel lit) { return isBaseTypeCompatible(lit) && isValid(lit.getLexicalForm()); }
@Override public int getHashCode( LiteralLabel lit ) { // Can't use super.getHashCode as that does "value.hashCode" // Java arrays are not equal by value and their hash code of the sameValue array are different. if ( lit.isWellFormed() ) return getHashCode( (byte []) lit.getValue() ); else return lit.getLexicalForm().hashCode() ; } }
/** * Returns a {@link String} representation of the given literal. * * @param literal the literal node. * @return a {@link String} representation of the given literal. */ public static String asNtLiteral(final Node literal) { final StringBuilder buffer = new StringBuilder("\""); escapeAndAppend(String.valueOf(literal.getLiteral().getLexicalForm()), buffer); buffer.append("\""); final String language = literal.getLiteralLanguage(); if (isNotNullOrEmptyString(language)) { buffer.append("@").append(language); } final String datatypeURI = literal.getLiteralDatatypeURI(); if (datatypeURI != null) { buffer.append("^^"); escapeAndAppend(datatypeURI, buffer); } return buffer.toString(); }
/** Answer true iff this literal is syntactically equal to <code>other</code>. Note: this is <i>not</i> <code>sameValueAs</code>. */ @Override public boolean equals(Object other) { if ( this == other ) return true ; if (other == null || !(other instanceof LiteralLabel)) { return false; } LiteralLabel otherLiteral = (LiteralLabel) other; boolean typeEqual = (dtype == null ? otherLiteral.getDatatype() == null : dtype.equals(otherLiteral.getDatatype())); boolean langEqual = (dtype == null ? lang.equals(otherLiteral.language()) : true); return typeEqual && langEqual && getLexicalForm().equals(otherLiteral.getLexicalForm()); }
sBuff.append(l.getLexicalForm()) ; sBuff.append('"') ;
Node tmpNode = ((NodeClauseEntry) clauseEntry2).getNode(); LiteralLabel literalLabel = tmpNode.getLiteral(); String lexicalForm = literalLabel.getLexicalForm();
source.add(field, literalValue.toString()); } else if(!ll.getLexicalForm().isEmpty()){ source.add(field, literalValue); ll.getLexicalForm(),ll.getDatatype()); literalValue = ll.getLexicalForm(); String lexicalForm = ll.getLexicalForm(); if(lexicalForm != null && !lexicalForm.isEmpty()){ String language = ll.language();
source.add(field, literalValue.toString()); } else if(!ll.getLexicalForm().isEmpty()){ source.add(field, literalValue); ll.getLexicalForm(),ll.getDatatype()); literalValue = ll.getLexicalForm(); String lexicalForm = ll.getLexicalForm(); if(lexicalForm != null && !lexicalForm.isEmpty()){ String language = ll.language();
Node tmpNode = ((NodeClauseEntry) clauseEntry2).getNode(); LiteralLabel literalLabel = tmpNode.getLiteral(); String lexicalForm = literalLabel.getLexicalForm();
static public ATermAppl makeLiteral(LiteralLabel jenaLiteral) { String lexicalValue = jenaLiteral.getLexicalForm(); String datatypeURI = jenaLiteral.getDatatypeURI(); ATermAppl literalValue = null; if( datatypeURI != null ) literalValue = ATermUtils.makeTypedLiteral( lexicalValue, datatypeURI ); else if( jenaLiteral.language() != null ) literalValue = ATermUtils.makePlainLiteral( lexicalValue, jenaLiteral.language() ); else literalValue = ATermUtils.makePlainLiteral( lexicalValue ); return literalValue; }
@Override public void write(Kryo kryo, Output output, Node_Literal object) { final LiteralLabel label = object.getLiteral(); output.writeString(label.getLexicalForm()); output.writeString(label.language()); output.writeString(label.getDatatypeURI()); }
@Override public void write(Kryo kryo, Output output, Node_Literal object) { final LiteralLabel label = object.getLiteral(); output.writeString(label.getLexicalForm()); output.writeString(label.language()); output.writeString(label.getDatatypeURI()); }
return new DatatypeLiteralImpl(lit.getLexicalForm(), new URIImpl( lit.getDatatypeURI())); return new LanguageTagLiteralImpl(lit.getLexicalForm(), lit.language()); return new PlainLiteralImpl(lit.getLexicalForm());
} else if (jenaNodeInst.isLiteral()) { LiteralLabel label = jenaNodeInst.getLiteral(); String value = label.getLexicalForm(); String type = jenaNodeInst.getLiteralDatatypeURI(); String language = jenaNodeInst.getLiteralLanguage();
public static String str(Node node) { if ( node.isLiteral() ) return node.getLiteral().getLexicalForm() ; if ( node.isURI() ) return node.getURI() ; // if ( node.isBlank() ) return node.getBlankNodeId().getLabelString() ; // if ( node.isBlank() ) return "" ; if ( node.isBlank() ) NodeValue.raise(new ExprTypeException("Blank node: " + node)) ; NodeValue.raise(new ExprEvalException("Not a string: " + node)) ; return "[undef]" ; }
public static String str(Node node) { if ( node.isLiteral() ) return node.getLiteral().getLexicalForm() ; if ( node.isURI() ) return node.getURI() ; // if ( node.isBlank() ) return node.getBlankNodeId().getLabelString() ; // if ( node.isBlank() ) return "" ; if ( node.isBlank() ) NodeValue.raise(new ExprTypeException("Blank node: "+node)) ; NodeValue.raise(new ExprEvalException("Not a string: "+node)) ; return "[undef]" ; }
return new NodeValueString(lit.getLexicalForm(), node) ; BigDecimal decimal = new BigDecimal(lit.getLexicalForm()) ; return new NodeValueDecimal(decimal, node) ; Object obj = RomanNumeralDatatype.get().parse(lit.getLexicalForm()) ; if ( obj instanceof Integer ) return new NodeValueInteger(((Integer)obj).longValue()) ;