final SchemaNodeIdentifier key) { final NamespaceStorageNode lookupStartStorage; if (key.isAbsolute() || storage.getStorageNodeType() == StorageNodeType.ROOT_STATEMENT_LOCAL) { lookupStartStorage = NamespaceBehaviour.findClosestTowardsRoot(storage, StorageNodeType.GLOBAL); } else { Mutable<?, ?, EffectiveStatement<?, ?>> current = (Mutable)lookupStartStorage.getFromLocalStorage( ChildSchemaNodeNamespace.class,nextPath); if (current == null && lookupStartStorage instanceof StmtContext<?, ?, ?>) {
protected final V getFromLocalStorage(final NamespaceStorageNode storage, final K key) { return storage.getFromLocalStorage(getIdentifier(), key); }
@Override public <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromLocalStorage(final Class<N> type) { final Map<K, V> potentialLocal = getRoot().getAllFromLocalStorage(type); if (potentialLocal != null) { return potentialLocal; } for (final NamespaceStorageNode importedSource : importedNamespaces) { final Map<K, V> potential = importedSource.getAllFromLocalStorage(type); if (potential != null) { return potential; } } return null; }
protected final void addToStorage(final NamespaceStorageNode storage, final K key, final V value) { storage.putToLocalStorage(getIdentifier(), key, value); }
protected final Map<K, V> getAllFromLocalStorage(final NamespaceStorageNode storage) { return storage.getAllFromLocalStorage(getIdentifier()); }
@Override public StmtContext<?, D, E> getFrom(final NamespaceStorageNode storage, final QName key) { return globalOrStatementSpecific(storage).getFromLocalStorage(getIdentifier(), key); }
@Override public Map<QName, QName> getAllFrom(final NamespaceStorageNode storage) { return getRoot(storage).getAllFromLocalStorage(QNameCacheNamespace.class); }
@Override public Map<K, V> getAllFrom(final NamespaceStorageNode storage) { NamespaceStorageNode current = storage; while (current.getStorageNodeType() != storageType) { current = current.getParentNamespaceStorage(); } return getAllFromLocalStorage(current); }
@SuppressWarnings("unchecked") @Override public void addTo(final NamespaceStorageNode storage, final QName key, final StmtContext<?, D, E> value) { final StmtContext<?, D, E> prev = globalOrStatementSpecific(storage).putToLocalStorageIfAbsent( ChildSchemaNodeNamespace.class, key, value); if (prev != null) { throw new SourceException(value.getStatementSourceReference(), "Error in module '%s': cannot add '%s'. Node name collision: '%s' already declared at %s", value.getRoot().getStatementArgument(), key, prev.getStatementArgument(), prev.getStatementSourceReference()); } }
@Override public Map<K, V> getAllFrom(final NamespaceStorageNode storage) { NamespaceStorageNode current = storage; while (current != null) { final Map<K, V> val = getAllFromLocalStorage(current); if (val != null) { return val; } current = current.getParentNamespaceStorage(); } return null; }
@Override public V getFrom(final NamespaceStorageNode storage, final K key) { NamespaceStorageNode current = storage; while (current != null) { final V val = getFromLocalStorage(current, key); if (val != null) { return val; } current = current.getParentNamespaceStorage(); } return null; }
private static NamespaceStorageNode globalOrStatementSpecific(final NamespaceStorageNode storage) { NamespaceStorageNode current = storage; while (!isLocalOrGlobal(current.getStorageNodeType())) { current = current.getParentNamespaceStorage(); } return current; }
@Override public QName getFrom(final NamespaceStorageNode storage, final QName key) { final NamespaceStorageNode root = getRoot(storage); final QName stored = root.getFromLocalStorage(QNameCacheNamespace.class, key); if (stored != null) { return stored; } root.putToLocalStorage(QNameCacheNamespace.class, key, key); return key; }
@Override public <K, V, N extends IdentifierNamespace<K, V>> V getFromLocalStorage(final Class<N> type, final K key) { final V potentialLocal = getRoot().getFromLocalStorage(type, key); if (potentialLocal != null) { return potentialLocal; } for (final NamespaceStorageNode importedSource : importedNamespaces) { final V potential = importedSource.getFromLocalStorage(type, key); if (potential != null) { return potential; } } return null; }
private static NamespaceStorageNode getRoot(final NamespaceStorageNode storage) { NamespaceStorageNode wlk = storage; while (wlk.getParentNamespaceStorage() != null) { wlk = wlk.getParentNamespaceStorage(); } return wlk; }
protected static NamespaceStorageNode findClosestTowardsRoot(final NamespaceStorageNode storage, final StorageNodeType type) { NamespaceStorageNode current = storage; while (current != null && current.getStorageNodeType() != type) { current = current.getParentNamespaceStorage(); } return current; }