KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > xml > QText


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.xml;
30
31 import org.w3c.dom.DOMException JavaDoc;
32 import org.w3c.dom.Node JavaDoc;
33 import org.w3c.dom.Text JavaDoc;
34
35 /**
36  * Represents a text node.
37  */

38 public class QText extends QCharacterData implements Text JavaDoc {
39   /**
40    * Creates a new text node.
41    */

42   public QText()
43   {
44     super();
45   }
46
47   /**
48    * Creates a new text node with initial data.
49    */

50   public QText(String JavaDoc data)
51   {
52     super(data);
53   }
54
55   public String JavaDoc getNodeName() { return "#text"; }
56   public short getNodeType() { return TEXT_NODE; }
57
58   Node JavaDoc importNode(QDocument owner, boolean deep)
59   {
60     QText text = new QText(_data);
61     text._owner = owner;
62     text._filename = _filename;
63     text._line = _line;
64     return text;
65   }
66
67   public Text JavaDoc splitText(int offset)
68     throws DOMException JavaDoc
69   {
70     QText text = new QText(_data.substring(offset));
71     text._owner = _owner;
72
73     _data = _data.substring(0, offset);
74
75     text._parent = _parent;
76     if (_next != null)
77       _next._previous = text;
78     else if (_parent != null)
79       _parent._lastChild = text;
80     text._previous = this;
81     text._next = _next;
82     _next = text;
83
84     return text;
85   }
86
87   public Text JavaDoc joinText(Text JavaDoc node1, Text JavaDoc node2)
88     throws DOMException JavaDoc
89   {
90     return new QText(node1.getData() + node2.getData());
91   }
92
93   // DOM level 3
94
public boolean getIsWhitespaceInElementContent()
95   {
96     throw new UnsupportedOperationException JavaDoc();
97   }
98
99   public String JavaDoc getWholeText()
100   {
101     throw new UnsupportedOperationException JavaDoc();
102   }
103
104   public Text JavaDoc replaceWholeText(String JavaDoc content)
105     throws DOMException JavaDoc
106   {
107     throw new UnsupportedOperationException JavaDoc();
108   }
109
110   private Object JavaDoc writeReplace()
111   {
112     return new SerializedXml(this);
113   }
114
115   public String JavaDoc toString()
116   {
117     return "Text[" + getData() + "]";
118   }
119 }
120
Popular Tags