tempProxy = new NodeProxy(doc, gid, node.getInternalAddress());
	public void store(final NodeImpl node, NodePath currentPath, boolean index) {		// 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 boolean isTemp = TEMP_COLLECTION.equals(doc.getCollection().getName());		final IndexSpec idxSpec = 		    doc.getCollection().getIdxConf(this);		final FulltextIndexSpec ftIdx = idxSpec != null ? idxSpec.getFulltextIndexSpec() : null;		final long gid = node.getGID();		if (gid < 0) {			LOG.debug("illegal node: " + gid + "; " + node.getNodeName());			Thread.dumpStack();			return;		}		final short nodeType = node.getNodeType();		final String nodeName = node.getNodeName();		final int depth = ftIdx == null ? defaultIndexDepth : ftIdx.getIndexDepth();		new DOMTransaction(this, domDb, Lock.WRITE_LOCK, doc) {			public Object start() throws ReadOnlyException {				long address = -1;				final byte data[] = node.serialize();				if (nodeType == Node.TEXT_NODE					|| nodeType == Node.ATTRIBUTE_NODE					|| doc.getTreeLevel(gid) > depth)					address = domDb.add(data);				else {					address = domDb.put(new NodeRef(doc.getDocId(), gid), data);				}				if (address < 0)					LOG.warn("address is missing");				node.setInternalAddress(address);				ByteArrayPool.releaseByteArray(data);				return null;			}		}		.run();		++nodesCount;		NodeProxy tempProxy = null;		QName qname;		int indexType = ValueIndexSpec.NO_INDEX;		switch (nodeType) {			case Node.ELEMENT_NODE :				tempProxy = new NodeProxy(doc, gid, node.getInternalAddress());				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);								// save element by calling ElementIndex				elementIndex.setDocument(doc);				elementIndex.addRow(node.getQName(), tempProxy);				break;			case Node.ATTRIBUTE_NODE :				tempProxy = new NodeProxy(doc, gid, node.getInternalAddress());				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);								qname =					new QName(						node.getLocalName(),						node.getNamespaceURI(),						node.getPrefix());				qname.setNameType(ElementValue.ATTRIBUTE);				elementIndex.setDocument(doc);				elementIndex.addRow(qname, tempProxy);				// check if attribute value should be fulltext-indexed				// by calling IndexPaths.match(path) 				boolean indexAttribs = index;				if(index && ftIdx != null) {				    if(ftIdx.getIncludeAttributes()) {				        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 && !isTemp)					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);					//LOG.debug("found ID: " + qname.getLocalName());					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)				if (!isTemp && index) {					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);					    }					}					if (ftIdx == null || ftIdx.match(currentPath)) {     		                boolean valore = (ftIdx == null ? false : ftIdx.preserveContent(currentPath));						textEngine.storeText(ftIdx, (TextImpl) node, valore);					}				}				break;		}	}