Skip to Content
Java in a Nutshell, 5th Edition
book

Java in a Nutshell, 5th Edition

by David Flanagan
March 2005
Intermediate to advanced
1254 pages
104h 21m
English
O'Reilly Media, Inc.
Content preview from Java in a Nutshell, 5th Edition

Name

Text

Synopsis

A Text node represents a run of plain text that does not contain any XML markup. Plain text appears within XML elements and attributes, and Text nodes typically appear as children of Element and Attr nodes. Text nodes inherit from CharacterData, and the textual content of a Text node is available through the getData( ) method inherited from CharacterData or through the getNodeValue( ) method inherited from Node.

Text nodes may be manipulated using any of the methods inherited from CharacterData. The Text interface defines one method of its own: splitText( ) splits a Text node at the specified character position. The method changes the original node so that it contains only the text up to the specified position. Then it creates a new Text node that contains the text from the specified position on and inserts that new node into the document tree immediately after the original one. The Node.normalize( ) method reverses this process by deleting emty Text nodes and merging adjacent Text nodes into a single node.

Text nodes never have children.

org.w3c.dom.Text

Figure 21-14. org.w3c.dom.Text

public interface Text extends CharacterData {
// Public Instance Methods
                  5.0  String getWholeText( );  
5.0  boolean isElementContentWhitespace( );  
5.0  Text replaceWholeText(String content) throws DOMException;  
     Text splitText(int offset) throws DOMException;  
}

Implementations

CDATASection

Returned By

Document.createTextNode( ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java in a Nutshell, 8th Edition

Java in a Nutshell, 8th Edition

Benjamin J. Evans, Jason Clark, David Flanagan
Java in a Nutshell, 7th Edition

Java in a Nutshell, 7th Edition

Benjamin J. Evans, David Flanagan
Learning Java, 5th Edition

Learning Java, 5th Edition

Marc Loy, Patrick Niemeyer, Daniel Leuck
Learning Java, 4th Edition

Learning Java, 4th Edition

Patrick Niemeyer, Daniel Leuck

Publisher Resources

ISBN: 0596007736Supplemental ContentErrata Page