/** * Clone this SAXText object. * @return A cloned copy of this SAXText object. */ protected Object clone() { SAXText clone = new SAXText(); clone.characters = new char[length]; System.arraycopy(characters, offset, clone.characters, 0, length); clone.offset = 0; clone.length = length; clone.type = type; return clone; } }
public boolean add(SAXText saxText) { if(textAccumulator != null) { // Clear the accumulatedText object so as any subsequent calls to the // getTextAsString method will recreate the buffer from scratch... accumulatedText = null; } return super.add((SAXText) saxText.clone()); } };
public static void writeText(SAXText text, Writer writer) throws IOException { if(writer != null) { switch (text.getType()) { case TEXT: writer.write(text.getCharacters(), text.getOffset(), text.getLength()); break; case CDATA: writer.write("<![CDATA["); writer.write(text.getCharacters(), text.getOffset(), text.getLength()); writer.write("]]>"); break; case COMMENT: writer.write("<!--"); writer.write(text.getCharacters(), text.getOffset(), text.getLength()); writer.write("-->"); break; case ENTITY: writer.write("&"); writer.write(HTMLEntityLookup.getEntityRef(text.getCharacters()[text.getOffset()])); writer.write(';'); break; } } }
/** * Write the text to the supplied writer. * <p/> * It wraps the text based on its {@link #getType() type}. * * @param writer The writer. * @throws IOException Write exception. */ public void toWriter(Writer writer) throws IOException { toWriter(writer, true); }
@SuppressWarnings("RedundantThrows") public void onChildText(SAXElement element, SAXText childText, ExecutionContext executionContext) throws SmooksException, IOException { if(currentNode == document) { // Just ignore for now... return; } if(childText.getText().trim().length() == 0) { // Ignore pure whitespace... return; } switch (childText.getType()) { case TEXT: currentNode.appendChild(document.createTextNode(childText.getText())); break; case CDATA: currentNode.appendChild(document.createCDATASection(childText.getText())); break; case COMMENT: currentNode.appendChild(document.createComment(childText.getText())); break; case ENTITY: currentNode.appendChild(document.createTextNode(childText.getText())); break; } }
public SAXText(char[] characters, int offset, int length, TextType type) { setText(characters, offset, length, type); }
/** * Write the text to the supplied writer. * <p/> * It wraps the text based on its {@link #getType() type}. * * @param writer The writer. * @throws IOException Write exception. */ public void toWriter(Writer writer) throws IOException { toWriter(writer, true); }
@SuppressWarnings("RedundantThrows") public void onChildText(SAXElement element, SAXText childText, ExecutionContext executionContext) throws SmooksException, IOException { if(currentNode == document) { // Just ignore for now... return; } if(childText.getText().trim().length() == 0) { // Ignore pure whitespace... return; } switch (childText.getType()) { case TEXT: currentNode.appendChild(document.createTextNode(childText.getText())); break; case CDATA: currentNode.appendChild(document.createCDATASection(childText.getText())); break; case COMMENT: currentNode.appendChild(document.createComment(childText.getText())); break; case ENTITY: currentNode.appendChild(document.createTextNode(childText.getText())); break; } }
public SAXText(char[] characters, int offset, int length, TextType type) { setText(characters, offset, length, type); }
public static void writeText(SAXText text, Writer writer) throws IOException { if(writer != null) { switch (text.getType()) { case TEXT: writer.write(text.getCharacters(), text.getOffset(), text.getLength()); break; case CDATA: writer.write("<![CDATA["); writer.write(text.getCharacters(), text.getOffset(), text.getLength()); writer.write("]]>"); break; case COMMENT: writer.write("<!--"); writer.write(text.getCharacters(), text.getOffset(), text.getLength()); writer.write("-->"); break; case ENTITY: writer.write("&"); writer.write(HTMLEntityLookup.getEntityRef(text.getCharacters()[text.getOffset()])); writer.write(';'); break; } } }
/** * Write the text to the supplied writer. * * It wraps the text based on its {@link #getType() type}. * * @param writer The writer. * @throws IOException Write exception. */ public void toWriter(Writer writer) throws IOException { toWriter(writer, true); }
@SuppressWarnings("RedundantThrows") public void onChildText(SAXElement element, SAXText childText, ExecutionContext executionContext) throws SmooksException, IOException { if(currentNode == document) { // Just ignore for now... return; } if(childText.getText().trim().length() == 0) { // Ignore pure whitespace... return; } switch (childText.getType()) { case TEXT: currentNode.appendChild(document.createTextNode(childText.getText())); break; case CDATA: currentNode.appendChild(document.createCDATASection(childText.getText())); break; case COMMENT: currentNode.appendChild(document.createComment(childText.getText())); break; case ENTITY: currentNode.appendChild(document.createTextNode(childText.getText())); break; } }
public SAXText(char[] characters, int offset, int length, TextType type) { setText(characters, offset, length, type); }
/** * Clone this SAXText object. * @return A cloned copy of this SAXText object. */ protected Object clone() { SAXText clone = new SAXText(); clone.characters = new char[length]; System.arraycopy(characters, offset, clone.characters, 0, length); clone.offset = 0; clone.length = length; clone.type = type; return clone; } }
public boolean add(SAXText saxText) { if(textAccumulator != null) { // Clear the accumulatedText object so as any subsequent calls to the // getTextAsString method will recreate the buffer from scratch... accumulatedText = null; } return super.add((SAXText) saxText.clone()); } };
public static void writeText(SAXText text, Writer writer) throws IOException { if(writer != null) { switch (text.getType()) { case TEXT: writer.write(text.getCharacters(), text.getOffset(), text.getLength()); break; case CDATA: writer.write("<![CDATA["); writer.write(text.getCharacters(), text.getOffset(), text.getLength()); writer.write("]]>"); break; case COMMENT: writer.write("<!--"); writer.write(text.getCharacters(), text.getOffset(), text.getLength()); writer.write("-->"); break; case ENTITY: writer.write("&"); writer.write(HTMLEntityLookup.getEntityRef(text.getCharacters()[text.getOffset()])); writer.write(';'); break; } } }
/** * Write the text to the supplied writer. * <p/> * It wraps the text based on its {@link #getType() type}. * * @param writer The writer. * @throws IOException Write exception. */ public void toWriter(Writer writer) throws IOException { toWriter(writer, true); }
public void onChildText(SAXElement element, SAXText childText, ExecutionContext executionContext) throws SmooksException, IOException { if(currentNode == document) { // Just ignore for now... return; } if(childText.getText().trim().length() == 0) { // Ignore pure whitespace... return; } switch (childText.getType()) { case TEXT: currentNode.appendChild(document.createTextNode(childText.getText())); break; case CDATA: currentNode.appendChild(document.createCDATASection(childText.getText())); break; case COMMENT: currentNode.appendChild(document.createComment(childText.getText())); break; case ENTITY: currentNode.appendChild(document.createTextNode(childText.getText())); break; } }
public SAXText(char[] characters, int offset, int length, TextType type) { setText(characters, offset, length, type); }
/** * Clone this SAXText object. * @return A cloned copy of this SAXText object. */ protected Object clone() { SAXText clone = new SAXText(); clone.characters = new char[length]; System.arraycopy(characters, offset, clone.characters, 0, length); clone.offset = 0; clone.length = length; clone.type = type; return clone; } }