@Override public boolean containsKey(Object nextKey) { if (nextKey instanceof String) { for (Namespace nextNamespace : namespaces) { if (nextNamespace.getPrefix().equals(nextKey)) { return true; } } } return false; }
@Override public String getNamespace(String prefix) throws SailException { Namespace namespace = namespaces.get(prefix); return (namespace == null) ? null : namespace.getName(); }
@Override public boolean containsKey(Object nextKey) { if (nextKey instanceof String) { for (Namespace nextNamespace : namespaces) { if (nextNamespace.getPrefix().equals(nextKey)) { return true; } } } return false; }
@Override public boolean containsValue(Object nextValue) { if (nextValue instanceof String) { for (Namespace nextNamespace : namespaces) { if (nextNamespace.getName().equals(nextValue)) { return true; } } } return false; }
@Override public Set<String> keySet() { Set<String> result = new LinkedHashSet<String>(); for (Namespace nextNamespace : namespaces) { result.add(nextNamespace.getPrefix()); } return result; }
@Override public boolean containsValue(Object nextValue) { if (nextValue instanceof String) { for (Namespace nextNamespace : namespaces) { if (nextNamespace.getName().equals(nextValue)) { return true; } } } return false; }
@Override public Set<String> keySet() { Set<String> result = new LinkedHashSet<>(); for (Namespace nextNamespace : namespaces) { result.add(nextNamespace.getPrefix()); } return result; }
@Override public Collection<String> values() { List<String> result = new ArrayList<String>(); for (Namespace nextNamespace : namespaces) { result.add(nextNamespace.getName()); } return result; } };
@Override public Collection<String> values() { List<String> result = new ArrayList<>(); for (Namespace nextNamespace : namespaces) { result.add(nextNamespace.getName()); } return result; } };
@Override public Optional<Namespace> getNamespace(String prefix) { for (Namespace nextNamespace : namespaces) { if (prefix.equals(nextNamespace.getPrefix())) { return Optional.of(nextNamespace); } } return Optional.empty(); }
@Override public String getNamespace(String prefix) throws RepositoryException { Optional<Namespace> ns = committed.getNamespace(prefix); if (ns.isPresent()) { return ns.get().getName(); } else { return null; } }
@Override public Optional<Namespace> getNamespace(String prefix) { for (Namespace nextNamespace : namespaces) { if (prefix.equals(nextNamespace.getPrefix())) { return Optional.of(nextNamespace); } } return Optional.empty(); }
/** * Sets the prefix for a namespace. This will replace any existing namespace associated to the prefix. * * @param prefix * The new prefix. * @param name * The namespace name that the prefix maps to. * @return The {@link Namespace} object for the given namespace. */ public default Namespace setNamespace(String prefix, String name) { Optional<? extends Namespace> result = getNamespace(prefix); if (!result.isPresent() || !result.get().getName().equals(name)) { result = Optional.of(new SimpleNamespace(prefix, name)); setNamespace(result.get()); } return result.get(); }