static public ATermList toSet(final ATerm[] a, final int size) { Arrays.sort(a, 0, size, Comparators.termComparator); ATermList set = makeList(a[size - 1]); for (int i = size - 2; i >= 0; i--) { final ATerm s = set.getFirst(); if (!s.equals(a[i])) set = set.insert(a[i]); } return set; }
static public ATermList toSet(final ATerm[] a, final int size) { Arrays.sort(a, 0, size, Comparators.termComparator); ATermList set = makeList(a[size - 1]); for (int i = size - 2; i >= 0; i--) { final ATerm s = set.getFirst(); if (!s.equals(a[i])) set = set.insert(a[i]); } return set; }
public ATerm normalize(ATerm t_) { ATerm s = t_; ATerm t = t_; do { t = s; s = oneStep(t); } while (!s.equals(fail)); return t; }
@Override public Double getValue(final ATermAppl literal) throws InvalidLiteralException { if (!ATermUtils.isLiteral(literal)) throw new IllegalArgumentException(); if (!literal.getArgument(ATermUtils.LIT_URI_INDEX).equals(name)) throw new IllegalArgumentException(); final String lexicalForm = ATermUtils.getLiteralValue(literal); try { return DatatypeConverter.parseDouble(lexicalForm); } catch (final NumberFormatException e) { throw new InvalidLiteralException(name, lexicalForm, e); } }
@Override public Float getValue(final ATermAppl literal) throws InvalidLiteralException { if (!ATermUtils.isLiteral(literal)) throw new IllegalArgumentException(); if (!literal.getArgument(ATermUtils.LIT_URI_INDEX).equals(name)) throw new IllegalArgumentException(); final String lexicalForm = ATermUtils.getLiteralValue(literal); try { return DatatypeConverter.parseFloat(lexicalForm); } catch (final NumberFormatException e) { throw new InvalidLiteralException(name, lexicalForm, e); } }
public default boolean isClass(final ATerm c) { if (getTBox().getClasses().contains(c) || c.equals(ATermUtils.TOP)) return true; else if (ATermUtils.isComplexClass(c)) return getFullyDefinedVisitor().isFullyDefined((ATermAppl) c); else return false; }
@Override public Double getValue(final ATermAppl literal) throws InvalidLiteralException { if (!ATermUtils.isLiteral(literal)) throw new IllegalArgumentException(); if (!literal.getArgument(ATermUtils.LIT_URI_INDEX).equals(name)) throw new IllegalArgumentException(); final String lexicalForm = ATermUtils.getLiteralValue(literal); try { return DatatypeConverter.parseDouble(lexicalForm); } catch (final NumberFormatException e) { throw new InvalidLiteralException(name, lexicalForm, e); } }
public default boolean isClass(final ATerm c) { if (getTBox().getClasses().contains(c) || c.equals(ATermUtils.TOP)) return true; else if (ATermUtils.isComplexClass(c)) return getFullyDefinedVisitor().isFullyDefined((ATermAppl) c); else return false; }
@Override public Float getValue(final ATermAppl literal) throws InvalidLiteralException { if (!ATermUtils.isLiteral(literal)) throw new IllegalArgumentException(); if (!literal.getArgument(ATermUtils.LIT_URI_INDEX).equals(name)) throw new IllegalArgumentException(); final String lexicalForm = ATermUtils.getLiteralValue(literal); try { return DatatypeConverter.parseFloat(lexicalForm); } catch (final NumberFormatException e) { throw new InvalidLiteralException(name, lexicalForm, e); } }
@Override public ATermList dictRemove(final ATerm key) { if (isEmpty()) return this; final ATermList pair = (ATermList) _first; if (key.equals(pair.getFirst())) return _next; return _next.dictRemove(key).insert(_first); }
@Override public Number getValue(final ATermAppl literal) throws InvalidLiteralException { if (!ATermUtils.isLiteral(literal)) throw new IllegalArgumentException(); if (!literal.getArgument(ATermUtils.LIT_URI_INDEX).equals(name)) throw new IllegalArgumentException(); final String lexicalForm = ATermUtils.getLiteralValue(literal); try { return OWLRealUtils.getCanonicalObject(DatatypeConverter.parseLong(lexicalForm)); } catch (final NumberFormatException e) { throw new InvalidLiteralException(name, lexicalForm, e); } }
@Override public Number getValue(final ATermAppl literal) throws InvalidLiteralException { if (!ATermUtils.isLiteral(literal)) throw new IllegalArgumentException(); if (!literal.getArgument(ATermUtils.LIT_URI_INDEX).equals(name)) throw new IllegalArgumentException(); final String lexicalForm = ATermUtils.getLiteralValue(literal); try { return OWLRealUtils.getCanonicalObject(DatatypeConverter.parseLong(lexicalForm)); } catch (final NumberFormatException e) { throw new InvalidLiteralException(name, lexicalForm, e); } }
@Override public Number getValue(final ATermAppl literal) throws InvalidLiteralException { if (!ATermUtils.isLiteral(literal)) throw new IllegalArgumentException(); if (!literal.getArgument(ATermUtils.LIT_URI_INDEX).equals(name)) throw new IllegalArgumentException(); final String lexicalForm = ATermUtils.getLiteralValue(literal); try { return OWLRealUtils.getCanonicalObject(DatatypeConverter.parseDecimal(lexicalForm)); } catch (final NumberFormatException e) { throw new InvalidLiteralException(name, lexicalForm, e); } }
@Override public Number getValue(final ATermAppl literal) throws InvalidLiteralException { if (!ATermUtils.isLiteral(literal)) throw new IllegalArgumentException(); if (!literal.getArgument(ATermUtils.LIT_URI_INDEX).equals(name)) throw new IllegalArgumentException(); final String lexicalForm = ATermUtils.getLiteralValue(literal); try { return OWLRealUtils.getCanonicalObject(DatatypeConverter.parseInteger(lexicalForm)); } catch (final NumberFormatException e) { throw new InvalidLiteralException(name, lexicalForm, e); } }
@Override public Number getValue(final ATermAppl literal) throws InvalidLiteralException { if (!ATermUtils.isLiteral(literal)) throw new IllegalArgumentException(); if (!literal.getArgument(ATermUtils.LIT_URI_INDEX).equals(name)) throw new IllegalArgumentException(); final String lexicalForm = ATermUtils.getLiteralValue(literal); try { return OWLRealUtils.getCanonicalObject(DatatypeConverter.parseDecimal(lexicalForm)); } catch (final NumberFormatException e) { throw new InvalidLiteralException(name, lexicalForm, e); } }
@Override public ATerm dictGet(final ATerm key) { if (isEmpty()) return null; final ATermList pair = (ATermList) _first; if (key.equals(pair.getFirst())) return pair.getNext().getFirst(); return _next.dictGet(key); }
@Override public ATermList dictPut(final ATerm key, final ATerm value) { if (isEmpty()) { final ATermList pair = getEmpty().insert(value).insert(key); return getEmpty().insert(pair); } ATermList pair = (ATermList) _first; if (key.equals(pair.getFirst())) { pair = getEmpty().insert(value).insert(pair); return _next.insert(pair); } return _next.dictPut(key, value).insert(_first); }
public void testDict() { ATermList dict = _factory.makeList(); ATerm key, value; for (int i = 0; i < 5; i++) { key = _factory.parse("key" + i); value = _factory.parse("value" + i); dict = dict.dictPut(key, value); } key = _factory.parse("key3"); value = _factory.parse("value3"); test_assert(dict.dictGet(key).equals(value)); }