protected void writeEntity(Entity entity) throws IOException { if (!resolveEntityRefs()) { writeEntityRef(entity.getName()); } else { writer.write(entity.getText()); } }
public void assertNodesEqual( Node n1, Node n2 ) { int nodeType1 = n1.getNodeType(); int nodeType2 = n2.getNodeType(); assertTrue( "Nodes are of same type: ", nodeType1 == nodeType2 ); switch (nodeType1) { case Node.ELEMENT_NODE: assertNodesEqual((Element) n1, (Element) n2); break; case Node.DOCUMENT_NODE: assertNodesEqual((Document) n1, (Document) n2); break; case Node.ATTRIBUTE_NODE: assertNodesEqual((Attribute) n1, (Attribute) n2); break; case Node.TEXT_NODE: assertNodesEqual((Text) n1, (Text) n2); break; case Node.CDATA_SECTION_NODE: assertNodesEqual((CDATA) n1, (CDATA) n2); break; case Node.ENTITY_REFERENCE_NODE: assertNodesEqual((Entity) n1, (Entity) n2); break; case Node.PROCESSING_INSTRUCTION_NODE: assertNodesEqual((ProcessingInstruction) n1, (ProcessingInstruction) n2); break; case Node.COMMENT_NODE: assertNodesEqual((Comment) n1, (Comment) n2); break; case Node.DOCUMENT_TYPE_NODE: assertNodesEqual((DocumentType) n1, (DocumentType) n2); break; case Node.NAMESPACE_NODE: assertNodesEqual((Namespace) n1, (Namespace) n2); break; default: assertTrue( "Invalid node types. node1: " + n1 + " and node2: " + n2, false ); } }
public void add(Entity entity) { element.add( entity ); }
public boolean remove(Entity entity) { return element.remove( entity ); }
public void assertNodesEqual( Entity o1, Entity o2 ) { assertEquals( "Entity names equal", o1.getName(), o2.getName() ); assertEquals( "Entity values equal", o1.getText(), o2.getText() ); }
public void add(Entity entity) { target().add( entity ); }
public boolean remove(Entity entity) { return target().remove( entity ); }
/** * Writes the given {@link Entity}. * * @param entity * <code>Entity</code> to output. * * @throws IOException * DOCUMENT ME! */ public void write(Entity entity) throws IOException { writeEntity(entity); if (autoFlush) { flush(); } }
protected void writeNode(Node node) throws IOException { int nodeType = node.getNodeType(); switch (nodeType) { case Node.ELEMENT_NODE: writeElement((Element) node); break; case Node.ATTRIBUTE_NODE: writeAttribute((Attribute) node); break; case Node.TEXT_NODE: writeNodeText(node); // write((Text) node); break; case Node.CDATA_SECTION_NODE: writeCDATA(node.getText()); break; case Node.ENTITY_REFERENCE_NODE: writeEntity((Entity) node); break; case Node.PROCESSING_INSTRUCTION_NODE: writeProcessingInstruction((ProcessingInstruction) node); break; case Node.COMMENT_NODE: writeComment(node.getText()); break; case Node.DOCUMENT_NODE: write((Document) node); break; case Node.DOCUMENT_TYPE_NODE: writeDocType((DocumentType) node); break; case Node.NAMESPACE_NODE: // Will be output with attributes // write((Namespace) node); break; default: throw new IOException("Invalid node type: " + node); } }