@Override public ATermAppl getLiteral(final Object value) { if (dataRange.contains(value)) return ATermUtils.makeTypedLiteral(OWLRealUtils.print((Number) value), getName()); else throw new IllegalArgumentException(); }
@Override public ATermAppl getLiteral(final Object value) { if (dataRange.contains(value)) return ATermUtils.makeTypedLiteral(OWLRealUtils.print((Number) value), getName()); else throw new IllegalArgumentException(); }
@Override public ATermAppl getCanonicalRepresentation(final ATermAppl input) throws InvalidLiteralException { final String lexicalForm = getLexicalForm(input); try { final BigDecimal d = DatatypeConverter.parseDecimal(lexicalForm); /* * TODO: Determine if this is, in fact a functional mapping */ final String canonicalForm = DatatypeConverter.printDecimal(d); if (canonicalForm.equals(lexicalForm)) return input; else return ATermUtils.makeTypedLiteral(canonicalForm, getName()); } catch (final NumberFormatException e) { _logger.severe(format("Number format exception (%s) cause while parsing decimal %s", e.getMessage(), lexicalForm)); throw new InvalidLiteralException(getName(), lexicalForm); } }
@Override public ATermAppl getCanonicalRepresentation(final ATermAppl input) throws InvalidLiteralException { final String lexicalForm = getLexicalForm(input); try { final BigDecimal d = DatatypeConverter.parseDecimal(lexicalForm); /* * TODO: Determine if this is, in fact a functional mapping */ final String canonicalForm = DatatypeConverter.printDecimal(d); if (canonicalForm.equals(lexicalForm)) return input; else return ATermUtils.makeTypedLiteral(canonicalForm, getName()); } catch (final NumberFormatException e) { _logger.severe(format("Number format exception (%s) cause while parsing decimal %s", e.getMessage(), lexicalForm)); throw new InvalidLiteralException(getName(), lexicalForm); } }
@Override public Number getValue(final ATermAppl literal) throws InvalidLiteralException { final String lexicalForm = getLexicalForm(literal); try { return OWLRealUtils.getCanonicalObject(DatatypeConverter.parseDecimal(lexicalForm)); } catch (final NumberFormatException e) { throw new InvalidLiteralException(getName(), lexicalForm, e); } }
@Override public ATermAppl getCanonicalRepresentation(final ATermAppl input) throws InvalidLiteralException { final String lexicalForm = getLexicalForm(input); fromLexicalForm(lexicalForm); return XSD_DECIMAL.getCanonicalRepresentation(ATermUtils.makeTypedLiteral(lexicalForm, XSD_DECIMAL.getName())); }
@Override public ATermAppl getCanonicalRepresentation(final ATermAppl input) throws InvalidLiteralException { final String lexicalForm = getLexicalForm(input); fromLexicalForm(lexicalForm); return XSD_DECIMAL.getCanonicalRepresentation(ATermUtils.makeTypedLiteral(lexicalForm, XSD_DECIMAL.getName())); }
@Override public void visitLiteral(final ATermAppl term) { final ATermAppl lexicalValue = (ATermAppl) term.getArgument(ATermUtils.LIT_VAL_INDEX); final ATermAppl lang = (ATermAppl) term.getArgument(ATermUtils.LIT_LANG_INDEX); final ATermAppl datatypeURI = (ATermAppl) term.getArgument(ATermUtils.LIT_URI_INDEX); if (datatypeURI.equals(XSDInteger.getInstance().getName()) || datatypeURI.equals(XSDDecimal.getInstance().getName())) _out.print(lexicalValue.getName()); else if (datatypeURI.equals(XSDFloat.getInstance().getName())) { _out.print(lexicalValue.getName()); _out.print("f"); } else if (!datatypeURI.equals(ATermUtils.PLAIN_LITERAL_DATATYPE)) { _out.print(lexicalValue.getName()); _out.print("^^"); _out.print(datatypeURI.getName()); } else { _out.print("\"" + lexicalValue.getName() + "\""); if (!lang.equals(ATermUtils.EMPTY)) _out.print("@" + lang); } }
@Override public void visitLiteral(final ATermAppl term) { final ATermAppl lexicalValue = (ATermAppl) term.getArgument(ATermUtils.LIT_VAL_INDEX); final ATermAppl lang = (ATermAppl) term.getArgument(ATermUtils.LIT_LANG_INDEX); final ATermAppl datatypeURI = (ATermAppl) term.getArgument(ATermUtils.LIT_URI_INDEX); if (datatypeURI.equals(XSDInteger.getInstance().getName()) || datatypeURI.equals(XSDDecimal.getInstance().getName())) _out.print(lexicalValue.getName()); else if (datatypeURI.equals(XSDFloat.getInstance().getName())) { _out.print(lexicalValue.getName()); _out.print("f"); } else if (!datatypeURI.equals(ATermUtils.PLAIN_LITERAL_DATATYPE)) { _out.print(lexicalValue.getName()); _out.print("^^"); _out.print(datatypeURI.getName()); } else { _out.print("\"" + lexicalValue.getName() + "\""); if (!lang.equals(ATermUtils.EMPTY)) _out.print("@" + lang); } }
@Override public Number getValue(final ATermAppl literal) throws InvalidLiteralException { final String lexicalForm = getLexicalForm(literal); try { return OWLRealUtils.getCanonicalObject(DatatypeConverter.parseDecimal(lexicalForm)); } catch (final NumberFormatException e) { throw new InvalidLiteralException(getName(), lexicalForm, e); } }
assertFalse(kb.hasPropertyValue(y, p, ATermUtils.makeTypedLiteral("5", XSDDecimal.getInstance().getName())));