FileDocCategorySizeDatePackage
Text.javaAPI DocApache Axis 1.45859Sat Apr 22 18:57:28 BST 2006org.apache.axis.message

Text

public class Text extends NodeImpl implements Text
A representation of a node whose value is text. A Text object may represent text that is content or text that is a comment.
author
Davanum Srinivas (dims@yahoo.com)
author
Heejune Ahn (cityboy@tmax.co.kr)

Fields Summary
Constructors Summary
public Text(CharacterData data)

        if ( data == null )
        {
           throw new IllegalArgumentException( "Text value may not be null." );
        }
        textRep = data;
    
public Text(String s)

        try {
            org.w3c.dom.Document doc = org.apache.axis.utils.XMLUtils.newDocument();
            textRep = doc.createTextNode(s);
        } catch (javax.xml.parsers.ParserConfigurationException e) {
            throw new InternalException(e);
        }
    
public Text()

        this((String)null);
    
Methods Summary
public voidappendData(java.lang.String arg)

since
SAAJ 1.2
param
arg
throws
DOMException

        textRep.appendData(arg);
    
public voiddeleteData(int offset, int count)

since
SAAJ 1.2
param
offset
param
count
throws
DOMException

        textRep.deleteData(offset, count);
    
public booleanequals(java.lang.Object obj)

        if ( !( obj instanceof Text ) )
        {
            return false;
        }
        return this == obj || hashCode() == obj.hashCode();
    
public java.lang.StringgetData()

since
SAAJ 1.2

        return textRep.getData();
    
public intgetLength()

since
SAAJ 1.2
return

        return textRep.getLength();
    
public java.lang.StringgetNodeValue()
Implementation of DOM TEXT Interface *************************************************************

        return textRep.getNodeValue();
    
public inthashCode()

        if ( textRep == null )
        {
           return -1;
        }
        return ( textRep.getData() != null ? textRep.getData().hashCode() : 0 );
    
public voidinsertData(int offset, java.lang.String arg)

since
SAAJ 1.2
param
offset
param
arg
throws
DOMException

        textRep.insertData(offset, arg);
    
public booleanisComment()
Retrieves whether this Text object represents a comment.

return
true if this Text object is a comment; false otherwise

        String temp = textRep.getNodeValue().trim();
        if(temp.startsWith("<!--") && temp.endsWith("-->"))
            return true;
        return false;
    
public voidreplaceData(int offset, int count, java.lang.String arg)

since
SAAJ 1.2
param
offset
param
count
param
arg
throws
DOMException

        textRep.replaceData(offset, count, arg);
    
public voidsetData(java.lang.String data)

since
SAAJ 1.2

        textRep.setData(data);
    
public voidsetNodeValue(java.lang.String nodeValue)

        setDirty();
        textRep.setNodeValue(nodeValue);
    
public org.w3c.dom.TextsplitText(int offset)
Use the textRep, and convert it to org.apache.axis.Text in order to keep the Axis SOAP strcture after operation This work would be easier if constructor, Text(org.w3c.dom.Text) is defined

since
SAAJ 1.2
param
offset
return
throws
DOMException

        int length = textRep.getLength();
        // take the first part, and save the second part for new Text
        // length check and exception will be thrown here, no need to duplicated check
        String tailData = textRep.substringData(offset,length);
        textRep.deleteData(offset,length);

        // insert the first part again as a new node
        Text tailText = new Text(tailData);
        org.w3c.dom.Node myParent = getParentNode();
        if(myParent != null){
            org.w3c.dom.NodeList brothers = myParent.getChildNodes();
            for(int i = 0;i  < brothers.getLength(); i++){
                if(brothers.item(i).equals(this)){
                    myParent.insertBefore(tailText, this);
                    return tailText;
                }
            }
        }
        return tailText;
    
public java.lang.StringsubstringData(int offset, int count)

since
SAAJ 1.2
param
offset
param
count
return
throws
DOMException

        return textRep.substringData(offset,count);
    
public java.lang.StringtoString()

        return textRep.getNodeValue();