/** Answer the default hash value, suitable for datatypes which have values which support hashCode() naturally: it is derived from its value if it is well-formed and otherwise from its lexical form. */ @Override public int getDefaultHashcode() { return (wellformed ? value : getLexicalForm()).hashCode(); }
/** Answer the value used to index this literal TODO Consider pushing indexing decisions down to the datatype */ @Override public Object getIndexingValue() { return isXML() ? this : !lang.equals( "" ) ? getLexicalForm() + "@" + lang.toLowerCase(Locale.ENGLISH) : wellformed ? getValue() : getLexicalForm() ; }
/** Answer a human-acceptable representation of this literal value. This is NOT intended for a machine-processed result. */ @Override public String toString(boolean quoting) { StringBuffer b = new StringBuffer(); if (quoting) b.append('"'); b.append(getLexicalForm()); if (quoting) b.append('"'); if (lang != null && !lang.equals( "" )) b.append( "@" ).append(lang); if (dtype != null) b.append( "^^" ).append(dtype.getURI()); return b.toString(); }
/** 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() ); }
/** 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()); }