RangeIndexSpec qnIdx = idxSpec.getIndexByQName(node.getQName()); if (qnIdx != null && qnameValueIndexation) { indexType |= RangeIndexSpec.QNAME_INDEX; }
	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 = idxSpec == null ? defaultIndexDepth : idxSpec.getIndexDepth();		final int level = doc.getTreeLevel(gid);		int indexType = RangeIndexSpec.NO_INDEX;		NodeProxy tempProxy;		QName qname;		switch (nodeType) {			case Node.ELEMENT_NODE :				if (idxSpec != null) {				    GeneralRangeIndexSpec spec = idxSpec.getIndexByPath(currentPath);				    if(spec != null)				        indexType = spec.getIndexType();				}				if(ftIdx == null || currentPath == null || ftIdx.match(currentPath))				    indexType |= RangeIndexSpec.TEXT;				if(node.getChildCount() - node.getAttributesCount() > 1) {				    indexType |= RangeIndexSpec.MIXED_CONTENT;				}				((ElementImpl) node).setIndexType(indexType);								break;			case Node.ATTRIBUTE_NODE :				elementIndex.setDocument(doc);				qname = node.getQName();				qname.setNameType(ElementValue.ATTRIBUTE);				tempProxy = new NodeProxy(doc, gid, address);				QName idxQName = new QName('@' + node.getLocalName(), node.getNamespaceURI());				currentPath.addComponent(idxQName);				GeneralRangeIndexSpec valSpec = null;				if (idxSpec != null) {				    valSpec = idxSpec.getIndexByPath(currentPath);				    if(valSpec != null)				        indexType = valSpec.getIndexType();				}				boolean indexAttribs = false;				if(ftIdx == null || currentPath == null || ftIdx.matchAttribute(currentPath)) {				    indexType |= RangeIndexSpec.TEXT;					indexAttribs = true;				}				tempProxy.setIndexType(indexType);								elementIndex.addRow(qname, tempProxy);				if (valSpec != null) {			        valueIndex.setDocument(doc);			        valueIndex.storeAttribute(valSpec, (AttrImpl) node);				}								if (idxSpec != null && qnameValueIndexation) {					RangeIndexSpec qnIdx = idxSpec.getIndexByQName(idxQName);					if (qnIdx != null) {						qnameValueIndex.setDocument(doc);						qnameValueIndex.storeAttribute(qnIdx, (AttrImpl) node);					}				}								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 :				// 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();		}	}