use of org.exist.storage.dom.INodeIterator in project exist by eXist-db.
the class NativeBroker method dropIndex.
private void dropIndex(final Txn transaction, @EnsureLocked(mode = LockMode.WRITE_LOCK) final DocumentImpl document) {
final StreamListener listener = getIndexController().getStreamListener(document, ReindexMode.REMOVE_ALL_NODES);
listener.startIndexDocument(transaction);
final NodeList nodes = document.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
final IStoredNode<?> node = (IStoredNode<?>) nodes.item(i);
try (final INodeIterator iterator = getNodeIterator(node)) {
iterator.next();
scanNodes(transaction, iterator, node, new NodePath2(), IndexMode.REMOVE, listener);
} catch (final IOException ioe) {
LOG.error("Unable to close node iterator", ioe);
}
}
listener.endIndexDocument(transaction);
notifyDropIndex(document);
getIndexController().flush();
}
use of org.exist.storage.dom.INodeIterator in project exist by eXist-db.
the class ElementImpl method getAttributes.
@Override
public NamedNodeMap getAttributes() {
final org.exist.dom.NamedNodeMapImpl map = new NamedNodeMapImpl(ownerDocument, true);
if (hasAttributes()) {
try (final DBBroker broker = ownerDocument.getBrokerPool().getBroker();
final INodeIterator iterator = broker.getNodeIterator(this)) {
// skip self
iterator.next();
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
final IStoredNode next = iterator.next();
if (next.getNodeType() != Node.ATTRIBUTE_NODE) {
break;
}
map.setNamedItem(next);
}
} catch (final EXistException | IOException e) {
LOG.warn("Exception while retrieving attributes: {}", e.getMessage());
}
}
if (declaresNamespacePrefixes()) {
for (final Map.Entry<String, String> entry : namespaceMappings.entrySet()) {
final String prefix = entry.getKey();
final String ns = entry.getValue();
final QName attrName = new QName(prefix, Namespaces.XMLNS_NS, XMLConstants.XMLNS_ATTRIBUTE);
final AttrImpl attr = new AttrImpl(attrName, ns, null);
attr.setOwnerDocument(ownerDocument);
map.setNamedItem(attr);
}
}
return map;
}
Aggregations