/** * Creates a new prefix map which is intended for use in output * <p> * Will use whatever the version of ARQ you are using considers the best * implementation for output, this may change from release to release. * </p> * * @return Prefix Map */ public static PrefixMap createForOutput() { return new FastAbbreviatingPrefixMap(); }
@Override public Pair<String, String> abbrev(String uriStr) { return abbrev(this.prefixes, uriStr, true); }
@Override public boolean contains(String prefix) { prefix = canonicalPrefix(prefix); return this.prefixes.containsKey(prefix); }
/** * Create a new fast abbreviating prefix map which copies mappings from an existing map * * @param pmap * Prefix Map */ public FastAbbreviatingPrefixMap(PrefixMap pmap) { this.putAll(pmap); }
@Override public String expand(String prefixedName) { int i = prefixedName.indexOf(':'); if (i < 0) return null; return expand(prefixedName.substring(0, i), prefixedName.substring(i + 1)); }
@Override protected Pair<String, String> abbrev(Map<String, IRI> prefixes, String uriStr, boolean checkLocalPart) { //Use longest match to find the longest possible match String prefix = this.abbrevs.longestMatch(uriStr); if (prefix == null) return null; String ln = uriStr.substring(this.prefixes.get(prefix).toString().length()); if (!checkLocalPart || isSafeLocalPart(ln)) return Pair.create(prefix, ln); return null; }
/** * Create a new fast abbreviating prefix map which copies mappings from an existing map * * @param pmap * Prefix Map */ public FastAbbreviatingPrefixMap(PrefixMap pmap) { this.putAll(pmap); }
@Override public String expand(String prefixedName) { int i = prefixedName.indexOf(':'); if (i < 0) return null; return expand(prefixedName.substring(0, i), prefixedName.substring(i + 1)); }
@Override protected Pair<String, String> abbrev(Map<String, IRI> prefixes, String uriStr, boolean checkLocalPart) { //Use longest match to find the longest possible match String prefix = this.abbrevs.longestMatch(uriStr); if (prefix == null) return null; String ln = uriStr.substring(this.prefixes.get(prefix).toString().length()); if (!checkLocalPart || isSafeLocalPart(ln)) return Pair.create(prefix, ln); return null; }
/** * Creates a new prefix map which is intended for use in output * <p> * Will use whatever the version of ARQ you are using considers the best * implementation for output, this may change from release to release. * </p> * * @return Prefix Map */ public static PrefixMap createForOutput() { return new FastAbbreviatingPrefixMap(); }
@Override public boolean contains(String prefix) { prefix = canonicalPrefix(prefix); return this.prefixes.containsKey(prefix); }
@Override public Pair<String, String> abbrev(String uriStr) { return abbrev(this.prefixes, uriStr, true); }
/** * Creates a new prefix map which is intended for use in output which starts * with a copy of an existing map * <p> * Will use whatever the version of ARQ you are using considers the best * implementation for output, this may change from release to release. * </p> * * @param pmap * Prefix Map to copy * * @return Prefix Map */ public static PrefixMap createForOutput(PrefixMap pmap) { return new FastAbbreviatingPrefixMap(pmap); }
@Override public String expand(String prefix, String localName) { prefix = canonicalPrefix(prefix); IRI x = prefixes.get(prefix); if (x == null) return null; return x.toString() + localName; }
@Override public String abbreviate(String uriStr) { Pair<String, String> p = abbrev(this.prefixes, uriStr, true); if (p == null) return null; return p.getLeft() + ":" + p.getRight(); }
/** * Creates a new prefix map which is intended for use in output which starts * with a copy of an existing map * <p> * Will use whatever the version of ARQ you are using considers the best * implementation for output, this may change from release to release. * </p> * * @param pmap * Prefix Map to copy * * @return Prefix Map */ public static PrefixMap createForOutput(PrefixMap pmap) { return new FastAbbreviatingPrefixMap(pmap); }
@Override public String expand(String prefix, String localName) { prefix = canonicalPrefix(prefix); IRI x = prefixes.get(prefix); if (x == null) return null; return x.toString() + localName; }
@Override public String abbreviate(String uriStr) { Pair<String, String> p = abbrev(this.prefixes, uriStr, true); if (p == null) return null; return p.getLeft() + ":" + p.getRight(); }
@Override protected PrefixMap getPrefixMap() { return new FastAbbreviatingPrefixMap(); }
@Override public void delete(String prefix) { prefix = canonicalPrefix(prefix); IRI iri = this.prefixes.get(prefix); if (iri == null) return; // Delete the abbreviation mapping this.abbrevs.remove(iri.toString()); // Delete the mapping this.prefixes.remove(prefix); }