@Override public ATermAppl getLiteral(final Object value) { if (value instanceof Rational) return OWLRational.getInstance().getLiteral(value); else if (value instanceof Number) try { return XSDDecimal.getInstance().getLiteral(value); } catch (final IllegalArgumentException e) { throw new IllegalArgumentException(e); } else throw new IllegalArgumentException(); }
@Override public Number getValue(final ATermAppl literal) throws InvalidLiteralException { final String lexicalForm = getLexicalForm(literal); try { return OWLRealUtils.getCanonicalObject(Rational.valueOf(lexicalForm)); } catch (final NumberFormatException e) { throw new InvalidLiteralException(getName(), lexicalForm, e); } }
@Override public ATermAppl getCanonicalRepresentation(final ATermAppl input) throws InvalidLiteralException { final Number n = getValue(input); if (n instanceof Rational) { final String canonicalForm = Rational.simplify((Rational) n).toString(); if (canonicalForm.equals(ATermUtils.getLiteralValue(input))) return input; else return ATermUtils.makeTypedLiteral(canonicalForm, getName()); } else return OWLReal.getInstance().getLiteral(OWLRealUtils.getCanonicalObject(n)); }
@Override public ATermAppl getLiteral(final Object value) { if (value instanceof Rational) { final Rational r = (Rational) value; final String lexicalForm = r.toString(); return ATermUtils.makeTypedLiteral(lexicalForm, getName()); } else throw new IllegalArgumentException(); }
@Override public ATermAppl getCanonicalRepresentation(final ATermAppl input) throws InvalidLiteralException { final Number n = getValue(input); if (n instanceof Rational) { final String canonicalForm = Rational.simplify((Rational) n).toString(); if (canonicalForm.equals(ATermUtils.getLiteralValue(input))) return input; else return ATermUtils.makeTypedLiteral(canonicalForm, getName()); } else return OWLReal.getInstance().getLiteral(OWLRealUtils.getCanonicalObject(n)); }
@Override public ATermAppl getLiteral(final Object value) { if (value instanceof Rational) { final Rational r = (Rational) value; final String lexicalForm = r.toString(); return ATermUtils.makeTypedLiteral(lexicalForm, getName()); } else throw new IllegalArgumentException(); }
@Override public Number getValue(final ATermAppl literal) throws InvalidLiteralException { final String lexicalForm = getLexicalForm(literal); try { return OWLRealUtils.getCanonicalObject(Rational.valueOf(lexicalForm)); } catch (final NumberFormatException e) { throw new InvalidLiteralException(getName(), lexicalForm, e); } }
@Override public ATermAppl getLiteral(final Object value) { if (value instanceof Rational) return OWLRational.getInstance().getLiteral(value); else if (value instanceof Number) try { return XSDDecimal.getInstance().getLiteral(value); } catch (final IllegalArgumentException e) { throw new IllegalArgumentException(e); } else throw new IllegalArgumentException(); }