KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > gargoylesoftware > htmlunit > javascript > host > CharacterDataImpl


1 /*
2  * Copyright (c) 2002, 2005 Gargoyle Software Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12  * 3. The end-user documentation included with the redistribution, if any, must
13  * include the following acknowledgment:
14  *
15  * "This product includes software developed by Gargoyle Software Inc.
16  * (http://www.GargoyleSoftware.com/)."
17  *
18  * Alternately, this acknowledgment may appear in the software itself, if
19  * and wherever such third-party acknowledgments normally appear.
20  * 4. The name "Gargoyle Software" must not be used to endorse or promote
21  * products derived from this software without prior written permission.
22  * For written permission, please contact info@GargoyleSoftware.com.
23  * 5. Products derived from this software may not be called "HtmlUnit", nor may
24  * "HtmlUnit" appear in their name, without prior written permission of
25  * Gargoyle Software Inc.
26  *
27  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
28  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
29  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARGOYLE
30  * SOFTWARE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
31  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
33  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
36  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  */

38 package com.gargoylesoftware.htmlunit.javascript.host;
39
40 import com.gargoylesoftware.htmlunit.html.DomCharacterData;
41
42 /**
43  * A javascript object for CharacterData.
44  *
45  * @version $Revision: 100 $
46  * @author David K. Taylor
47  * @author Chris Erskine
48  */

49 public abstract class CharacterDataImpl extends NodeImpl {
50
51     /**
52      * Create an instance. Javascript objects must have a default constructor.
53      */

54     public CharacterDataImpl() {
55     }
56
57
58     /**
59      * Get the JavaScript property "data" for this character data.
60      * @return The String of data.
61      */

62     public Object JavaDoc jsxGet_data() {
63         final DomCharacterData domCharacterData =
64             (DomCharacterData) getDomNodeOrDie();
65         return domCharacterData.getData();
66     }
67
68
69     /**
70      * Set the JavaScript property "data" for this character data.
71      * @param newValue The new String of data.
72      */

73     public void jsxSet_data( final String JavaDoc newValue ) {
74         final DomCharacterData domCharacterData =
75             (DomCharacterData) getDomNodeOrDie();
76         domCharacterData.setData(newValue);
77     }
78
79
80     /**
81      * Get the number of character in the character data.
82      * @return The number of characters.
83      */

84     public int jsxGet_length() {
85         final DomCharacterData domCharacterData =
86             (DomCharacterData) getDomNodeOrDie();
87         return domCharacterData.getLength();
88     }
89
90
91     /**
92      * Append a string to character data.
93      * @param arg The string to be appended to the character data.
94      */

95     public void jsxFunction_appendData(final String JavaDoc arg) {
96         final DomCharacterData domCharacterData =
97             (DomCharacterData) getDomNodeOrDie();
98         domCharacterData.appendData(arg);
99     }
100
101
102     /**
103      * Delete characters from character data.
104      * @param offset The position of the first character to be deleted.
105      * @param count The number of characters to be deleted.
106      */

107     public void jsxFunction_deleteData(final int offset, final int count) {
108         final DomCharacterData domCharacterData =
109             (DomCharacterData) getDomNodeOrDie();
110         domCharacterData.deleteData(offset, count);
111     }
112
113
114     /**
115      * Insert a string into character data.
116      * @param offset The position within the first character at which
117      * the string is to be inserted.
118      * @param arg The string to insert.
119      */

120     public void jsxFunction_insertData(final int offset, final String JavaDoc arg) {
121         final DomCharacterData domCharacterData =
122             (DomCharacterData) getDomNodeOrDie();
123         domCharacterData.insertData(offset, arg);
124     }
125
126
127     /**
128      * Replace characters of character data with a string.
129      * @param offset The position within the first character at which
130      * the string is to be replaced.
131      * @param count The number of characters to be replaced.
132      * @param arg The string that replaces the count characters beginning at
133      * the character at offset.
134      */

135     public void jsxFunction_replaceData(final int offset, final int count,
136         final String JavaDoc arg) {
137         final DomCharacterData domCharacterData =
138             (DomCharacterData) getDomNodeOrDie();
139         domCharacterData.replaceData(offset, count, arg);
140     }
141
142
143     /**
144      * Extract a substring from character data.
145      * @param offset The position of the first character to be extracted.
146      * @param count The number of characters to be extracted.
147      * @return A string that consists of the count characters of the
148      * character data starting from the character at position offset.
149      */

150     public String JavaDoc jsxFunction_substringData(final int offset,
151         final int count) {
152         final DomCharacterData domCharacterData =
153             (DomCharacterData) getDomNodeOrDie();
154         return domCharacterData.substringData(offset, count);
155     }
156 }
157
Popular Tags