/** Answer true iff <i>L</i> has type XSD string and we're treating plain literals and xsd string literals as "the same". */ private boolean looksLikePlainString( LiteralLabel L ) { return L.getDatatype().equals( XSDDatatype.XSDstring ) && JenaParameters.enablePlainLiteralSameAsString; }
/** * 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) { // default is that only literals with the same type are valid return equals(lit.getDatatype()); }
/** * {@inheritDoc} */ @Override public boolean isEqual(LiteralLabel value1, LiteralLabel value2) { return value1.getDatatype() == value2.getDatatype() && value1.getValue().equals(value2.getValue()); }
/** * Compares two instances of values of the given datatype. * This ignores lang tags and just uses the java.lang.Number * equality. */ @Override public boolean isEqual(LiteralLabel value1, LiteralLabel value2) { return value1.getDatatype() == value2.getDatatype() && Arrays.equals((byte[])value1.getValue(), (byte[])value2.getValue()); // && value1.getLexicalForm().equals(value2.getLexicalForm()); // bug tracking, not real code }
/** The default for equality - same datatype, same value */ protected static boolean isEqualPlain(LiteralLabel litLabel1, LiteralLabel litLabel2) { return litLabel1.getDatatype() == litLabel2.getDatatype() && litLabel1.getValue().equals(litLabel2.getValue()); }
/** * Compares two instances of values of the given datatype. * This ignores lang tags and just uses the java.lang.Number * equality. */ @Override public boolean isEqual(LiteralLabel value1, LiteralLabel value2) { return value1.getDatatype() == value2.getDatatype() && value1.getValue().equals(value2.getValue()); } }
/** * Compares two instances of values of the given datatype. * This ignores lang tags and just uses the java.lang.Number * equality. */ @Override public boolean isEqual(LiteralLabel value1, LiteralLabel value2) { return value1.getDatatype() == value2.getDatatype() && value1.getValue().equals(value2.getValue()); } }
@Override public final RDFDatatype getLiteralDatatype() { return getLiteral().getDatatype(); }
/** * Compares two instances of values of the given datatype. * This ignores lang tags and optionally allows plain literals to * equate to strings. The latter option is currently set by a static * global flag in LiteralLabel. */ @Override public boolean isEqual(LiteralLabel value1, LiteralLabel value2) { // value1 will have been used to dispatch here so we know value1 is an xsdstring or extension if ((value2.getDatatype() == null && JenaParameters.enablePlainLiteralSameAsString) || (value2.getDatatype() instanceof XSDBaseStringType)) { return value1.getValue().equals(value2.getValue()); } else { return false; } }
/** * Compares two instances of values of the given datatype. * This ignores lang tags and just uses the java.lang.Number * equality. */ @Override public boolean isEqual(LiteralLabel value1, LiteralLabel value2) { if (value1.getDatatype() instanceof XSDBaseNumericType && value2.getDatatype() instanceof XSDBaseNumericType) { Number n1 = (Number)value1.getValue(); Number n2 = (Number)value2.getValue(); // The cannonicalization step should take care of all cross-type cases, leaving // us just that equals doesn't work on BigDecimals in the way you expect if (n1 instanceof BigDecimal && n2 instanceof BigDecimal) { return ((BigDecimal)n1).compareTo((BigDecimal)n2) == 0; } return n1.equals(n2); } else { // At least one arg is not part of the integer hierarchy return false; } } }
/** 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()); }
private boolean isPlainLiteralSameValueAsOther( LiteralLabel other ) { return other.getDatatype() == null || looksLikePlainString( other ) ? sameByFormAndLanguage( other ) : false; }
return value1.getDatatype() == value2.getDatatype() && value1.getValue().equals(value2.getValue());
/** * Test if the given typed value is in the right partition of the XSD type space. * If this test passes then if the typed value has a legal lexical form for * this type then it is a legal instance. */ public boolean isBaseTypeCompatible(LiteralLabel lit) { XSTypeDefinition base = getFoundingType(); RDFDatatype litDT = lit.getDatatype(); if (litDT instanceof XSDDatatype) { XSTypeDefinition litBase = ((XSDDatatype)litDT).getFoundingType(); return base.equals(litBase); } else if (litDT == null && lit.language().equals("")) { // Special RDF case, a plain literal is type compatible with and xsd:string-based type return base.equals(XSDstring.typeDeclaration); } else { return false; } }
return a.getDatatype().getURI().equals( b.getDatatype().getURI() ) && a.getValue().equals(b.getValue());
private boolean isTypedLiteralSameValueAsOther( LiteralLabel other ) { return other.getDatatype() == null ? looksLikePlainString( this ) && sameByFormAndLanguage( other ) : dtype.isEqual( this, other ); }
RDFDatatype dataType = ll.getDatatype(); if(dataType != null){ //add a value Object literalValue; ll.getLexicalForm(),ll.getDatatype()); literalValue = ll.getLexicalForm();
if (n.getLiteral().getDatatype() != null)
if (n.getLiteral().getDatatype() != null)
/** * Check if a literal value node is a legal value for the given datatype. * @param val the literal value node * @param dt the Node designating a datatype URI */ public static boolean isTypeOK(Node val, Node dt) { if (!dt.isURI()) return false; if (val.isBlank()) return true; if (val.isLiteral()) { LiteralLabel ll = val.getLiteral(); if (ll.getDatatype() != null && (! ll.isWellFormed())) return false; if (dt.equals(RDFS.Nodes.Literal)) { return true; } else { RDFDatatype dtype = TypeMapper.getInstance().getSafeTypeByName(dt.getURI()); return dtype.isValidLiteral(val.getLiteral()); } } return false; }