if (doc.getNodeType(lastNode) == Node.TEXT_NODE && level == doc.getTreeLevel(lastNode)) {   doc.appendChars(lastNode, ch, start, len); return lastNode; } else { int nodeNr = doc.addNode(Node.TEXT_NODE, level, null); doc.addChars(nodeNr, ch, start, len); linkNode(nodeNr); return nodeNr;
if (0 < lastNode && level == doc.getTreeLevel(lastNode)) { if (doc.getNodeType(lastNode) == Node.TEXT_NODE) {   doc.appendChars(lastNode, ch, start, len); return lastNode; } if (doc.getNodeType(lastNode) == NodeImpl.REFERENCE_NODE) {  int p = doc.alpha[lastNode]; if (doc.references[p].getNodeType() == Node.TEXT_NODE) {   StringBuffer s = new StringBuffer(doc.references[p].getStringValue()); s.append(ch, start, len); doc.replaceReferenceNode(lastNode, s); return lastNode; }  }
	public int characters(char[] ch, int start, int len) {        int lastNode = doc.getLastNode();        if (doc.getNodeType(lastNode) == Node.TEXT_NODE && level == doc.getTreeLevel(lastNode)) {            // if the last node is a text node, we have to append the            // characters to this node. XML does not allow adjacent text nodes.            doc.appendChars(lastNode, ch, start, len);            return lastNode;        } else {    		int nodeNr = doc.addNode(Node.TEXT_NODE, level, null);    		doc.addChars(nodeNr, ch, start, len);    		linkNode(nodeNr);    		return nodeNr;        }	}