tempProxy = new NodeProxy(doc, gid, node.getInternalAddress());
	public void index(final NodeImpl node, NodePath currentPath) {	    // first, check available memory		if (++nodesCount > MEM_LIMIT_CHECK) {			final int percent = (int) (run.freeMemory() / (run.totalMemory() / 100));			if (percent < memMinFree) {				//LOG.info(				//	"total memory: " + run.totalMemory() + "; free: " + run.freeMemory());				flush();				System.gc();				LOG.info(					"total memory: " + run.totalMemory() + "; free: " + run.freeMemory());			}		}		final DocumentImpl doc = (DocumentImpl) node.getOwnerDocument();		final long gid = node.getGID();		final short nodeType = node.getNodeType();		final String nodeName = node.getNodeName();		final long address = node.getInternalAddress();		final IndexSpec idxSpec = 		    doc.getCollection().getIdxConf(this);		final FulltextIndexSpec ftIdx = idxSpec != null ? idxSpec.getFulltextIndexSpec() : null; 		if (address < 0)			LOG.debug("node " + gid + ": internal address missing");		final int depth = ftIdx == null ? defaultIndexDepth : ftIdx.getIndexDepth();		final int level = doc.getTreeLevel(gid);		int indexType = ValueIndexSpec.NO_INDEX;		NodeProxy tempProxy;		QName qname;		switch (nodeType) {			case Node.ELEMENT_NODE :				// save element by calling ElementIndex				qname = node.getQName();				qname.setNameType(ElementValue.ELEMENT);				tempProxy = new NodeProxy(doc, gid, address);				if (idxSpec != null) {				    ValueIndexSpec spec = idxSpec.getIndexByPath(currentPath);				    if(spec != null) {				        indexType = spec.getIndexType();				    }				}				if(ftIdx == null || currentPath == null || ftIdx.match(currentPath))				    indexType |= ValueIndexSpec.TEXT;				tempProxy.setIndexType(indexType);				elementIndex.setDocument(doc);				elementIndex.addRow(qname, tempProxy);				break;			case Node.ATTRIBUTE_NODE :				elementIndex.setDocument(doc);				qname =					new QName(						node.getLocalName(),						node.getNamespaceURI(),						node.getPrefix());				qname.setNameType(ElementValue.ATTRIBUTE);				tempProxy = new NodeProxy(doc, gid, address);				currentPath.addComponent(new QName('@' + node.getLocalName(), node.getNamespaceURI()));				if (idxSpec != null) {				    ValueIndexSpec spec = idxSpec.getIndexByPath(currentPath);				    if(spec != null)				        indexType = spec.getIndexType();				}				if(ftIdx == null || currentPath == null || ftIdx.match(currentPath))				    indexType |= ValueIndexSpec.TEXT;				tempProxy.setIndexType(indexType);								elementIndex.addRow(qname, tempProxy);				// check if attribute value should be fulltext-indexed				// by calling IndexPaths.match(path)				boolean indexAttribs = true;				if(ftIdx != null) {				    if(ftIdx.getIncludeAttributes()) {				        if(currentPath != null) {						    indexAttribs = ftIdx.match(currentPath);				        }				    } else				        indexAttribs = false;				}				if (idxSpec != null) {				    ValueIndexSpec spec = idxSpec.getIndexByPath(currentPath);				    if(spec != null) {				        tempProxy = new NodeProxy(doc, gid, node.getInternalAddress());				        valueIndex.setDocument(doc);				        valueIndex.storeAttribute(spec, (AttrImpl) node, tempProxy);				    }				}				if(indexAttribs)					textEngine.storeAttribute(ftIdx, (AttrImpl) node);				// if the attribute has type ID, store the ID-value				// to the element index as well				if (((AttrImpl) node).getType() == AttrImpl.ID) {					qname = new QName(((AttrImpl) node).getValue(), "", null);					qname.setNameType(ElementValue.ATTRIBUTE_ID);					elementIndex.addRow(qname, tempProxy);				}			    currentPath.removeLastComponent();				break;			case Node.TEXT_NODE :				if (idxSpec != null) {				    ValueIndexSpec spec = idxSpec.getIndexByPath(currentPath);				    if(spec != null) {				        tempProxy = new NodeProxy(doc, gid, node.getInternalAddress());				        valueIndex.setDocument(doc);				        valueIndex.storeText(spec, (TextImpl) node, tempProxy);				    }				}				// check if this textual content should be fulltext-indexed				// by calling IndexPaths.match(path)			    boolean indexText = true;				if(ftIdx != null && currentPath != null)				    indexText = ftIdx.match(currentPath);	                	                                boolean valore = (ftIdx == null || currentPath == null ? false : ftIdx.preserveContent(currentPath));                if(indexText)                    textEngine.storeText(ftIdx, (TextImpl) node, valore);				break;		}		if (nodeType == Node.ELEMENT_NODE && level <= depth) {			new DOMTransaction(this, domDb, Lock.WRITE_LOCK) {				public Object start() throws ReadOnlyException {					try {						domDb.addValue(							new NodeRef(doc.getDocId(), gid),							node.getInternalAddress());					} catch (BTreeException e) {						LOG.warn(EXCEPTION_DURING_REINDEX, e);					} catch (IOException e) {						LOG.warn(EXCEPTION_DURING_REINDEX, e);					}					return null;				}			}			.run();		}	}