Skip to content

Commit 7f9cb7d

Browse files
hansonrhansonr
authored andcommitted
adds org.w3c.dom
1 parent 13e1847 commit 7f9cb7d

File tree

78 files changed

+4028
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+4028
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package org.w3c.dom;
2+
3+
/**
4+
* The <code>Attr</code> interface represents an attribute in an
5+
* <code>Element</code> object.Typically the allowable values for the
6+
* attribute are defined in a documenttype definition.
7+
* <p><code>Attr</code> objects inherit the <code>Node</code> interface, but
8+
* since they are not actually child nodes of the element they describe, the
9+
* DOM does not consider them part of the document tree. Thus, the
10+
* <code>Node</code> attributes <code>parentNode</code>,
11+
* <code>previousSibling</code>, and <code>nextSibling</code> have a null
12+
* value for <code>Attr</code> objects. The DOM takes the view that
13+
* attributes are properties of elements rather than having a separate
14+
* identity from the elements they are associated with; this should make it
15+
* more efficient to implement such features as default attributes associated
16+
* with all elements of a given type. Furthermore, <code>Attr</code> nodes
17+
* may not be immediate children of a <code>DocumentFragment</code>. However,
18+
* they can be associated with <code>Element</code> nodes contained within a
19+
* <code>DocumentFragment</code>. In short, users and implementors of the DOM
20+
* need to be aware that <code>Attr</code> nodes have some things in common
21+
* with other objects inheriting the <code>Node</code> interface, but they
22+
* also are quite distinct.
23+
* <p> The attribute's effective value is determined as follows: if this
24+
* attribute has been explicitly assigned any value, that value is the
25+
* attribute's effective value; otherwise, if there is a declaration for
26+
* this attribute, and that declaration includes a default value, then that
27+
* default value is the attribute's effective value; otherwise, the
28+
* attribute does not exist on this element in the structure model until it
29+
* has been explicitly added. Note that the <code>nodeValue</code>
30+
* attribute on the <code>Attr</code> instance can also be used to retrieve
31+
* the string version of the attribute's value(s).
32+
* <p>In XML, where the value of an attribute can contain entity references,
33+
* the child nodes of the <code>Attr</code> node provide a representation in
34+
* which entity references are not expanded. These child nodes may be either
35+
* <code>Text</code> or <code>EntityReference</code> nodes. Because the
36+
* attribute type may be unknown, there are no tokenized attribute values.
37+
*/
38+
public interface Attr extends Node {
39+
/**
40+
* Returns the name of this attribute.
41+
*/
42+
public String getName();
43+
/**
44+
* If this attribute was explicitly given a value in the original document,
45+
* this is <code>true</code>; otherwise, it is <code>false</code>. Note
46+
* that the implementation is in charge of this attribute, not the user. If
47+
* the user changes the value of the attribute (even if it ends up having
48+
* the same value as the default value) then the <code>specified</code>
49+
* flag is automatically flipped to <code>true</code>. To re-specify the
50+
* attribute as the default value from the DTD, the user must delete the
51+
* attribute. The implementation will then make a new attribute available
52+
* with <code>specified</code> set to <code>false</code> and the default
53+
* value (if one exists).
54+
* <br>In summary: If the attribute has an assigned value in the document
55+
* then <code>specified</code> is <code>true</code>, and the value is the
56+
* assigned value. If the attribute has no assigned value in the document
57+
* and has a default value in the DTD, then <code>specified</code> is
58+
* <code>false</code>, and the value is the default value in the DTD. If
59+
* the attribute has no assigned value in the document and has a value of
60+
* #IMPLIED in the DTD, then the attribute does not appear in the
61+
* structure model of the document.
62+
*/
63+
public boolean getSpecified();
64+
/**
65+
* On retrieval, the value of the attribute is returned as a string.
66+
* Character and general entity references are replaced with their values.
67+
* <br>On setting, this creates a <code>Text</code> node with the unparsed
68+
* contents of the string.
69+
*/
70+
public String getValue();
71+
public void setValue(String value);
72+
}
73+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.w3c.dom;
2+
3+
/**
4+
* CDATA sections are used to escape blocks of text containing characters
5+
* that would otherwise be regarded as markup. The only delimiter that is
6+
* recognized in a CDATA section is the "]]&gt;" string that ends the CDATA
7+
* section. CDATA sections can not be nested. The primary purpose is for
8+
* including material such as XML fragments, without needing to escape all
9+
* the delimiters.
10+
* <p>The <code>DOMString</code> attribute of the <code>Text</code> node holds
11+
* the text that is contained by the CDATA section. Note that this may
12+
* contain characters that need to be escaped outside of CDATA sections and
13+
* that, depending on the character encoding ("charset") chosen for
14+
* serialization, it may be impossible to write out some characters as part
15+
* of a CDATA section.
16+
* <p> The <code>CDATASection</code> interface inherits the
17+
* <code>CharacterData</code> interface through the <code>Text</code>
18+
* interface. Adjacent <code>CDATASections</code> nodes are not merged by use
19+
* of the Element.normalize() method.
20+
*/
21+
public interface CDATASection extends Text {
22+
}
23+
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
package org.w3c.dom;
2+
3+
/**
4+
* The <code>CharacterData</code> interface extends Node with a set of
5+
* attributes and methods for accessing character data in the DOM. For
6+
* clarity this set is defined here rather than on each object that uses
7+
* these attributes and methods. No DOM objects correspond directly to
8+
* <code>CharacterData</code>, though <code>Text</code> and others do inherit
9+
* the interface from it. All <code>offset</code>s in this interface start
10+
* from 0.
11+
*/
12+
public interface CharacterData extends Node {
13+
/**
14+
* The character data of the node that implements this interface. The DOM
15+
* implementation may not put arbitrary limits on the amount of data that
16+
* may be stored in a <code>CharacterData</code> node. However,
17+
* implementation limits may mean that the entirety of a node's data may
18+
* not fit into a single <code>DOMString</code>. In such cases, the user
19+
* may call <code>substringData</code> to retrieve the data in
20+
* appropriately sized pieces.
21+
* @exception DOMException
22+
* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
23+
* @exception DOMException
24+
* DOMSTRING_SIZE_ERR: Raised when it would return more characters than
25+
* fit in a <code>DOMString</code> variable on the implementation
26+
* platform.
27+
*/
28+
public String getData()
29+
throws DOMException;
30+
public void setData(String data)
31+
throws DOMException;
32+
/**
33+
* The number of characters that are available through <code>data</code> and
34+
* the <code>substringData</code> method below. This may have the value
35+
* zero, i.e., <code>CharacterData</code> nodes may be empty.
36+
*/
37+
public int getLength();
38+
/**
39+
* Extracts a range of data from the node.
40+
* @param offset Start offset of substring to extract.
41+
* @param count The number of characters to extract.
42+
* @return The specified substring. If the sum of <code>offset</code> and
43+
* <code>count</code> exceeds the <code>length</code>, then all
44+
* characters to the end of the data are returned.
45+
* @exception DOMException
46+
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
47+
* than the number of characters in <code>data</code>, or if the
48+
* specified <code>count</code> is negative.
49+
* <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does not
50+
* fit into a <code>DOMString</code>.
51+
*/
52+
public String substringData(int offset,
53+
int count)
54+
throws DOMException;
55+
/**
56+
* Append the string to the end of the character data of the node. Upon
57+
* success, <code>data</code> provides access to the concatenation of
58+
* <code>data</code> and the <code>DOMString</code> specified.
59+
* @param arg The <code>DOMString</code> to append.
60+
* @exception DOMException
61+
* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
62+
*/
63+
public void appendData(String arg)
64+
throws DOMException;
65+
/**
66+
* Insert a string at the specified character offset.
67+
* @param offset The character offset at which to insert.
68+
* @param arg The <code>DOMString</code> to insert.
69+
* @exception DOMException
70+
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
71+
* than the number of characters in <code>data</code>.
72+
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
73+
*/
74+
public void insertData(int offset,
75+
String arg)
76+
throws DOMException;
77+
/**
78+
* Remove a range of characters from the node. Upon success,
79+
* <code>data</code> and <code>length</code> reflect the change.
80+
* @param offset The offset from which to remove characters.
81+
* @param count The number of characters to delete. If the sum of
82+
* <code>offset</code> and <code>count</code> exceeds <code>length</code>
83+
* then all characters from <code>offset</code> to the end of the data
84+
* are deleted.
85+
* @exception DOMException
86+
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
87+
* than the number of characters in <code>data</code>, or if the
88+
* specified <code>count</code> is negative.
89+
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
90+
*/
91+
public void deleteData(int offset,
92+
int count)
93+
throws DOMException;
94+
/**
95+
* Replace the characters starting at the specified character offset with
96+
* the specified string.
97+
* @param offset The offset from which to start replacing.
98+
* @param count The number of characters to replace. If the sum of
99+
* <code>offset</code> and <code>count</code> exceeds <code>length</code>
100+
* , then all characters to the end of the data are replaced (i.e., the
101+
* effect is the same as a <code>remove</code> method call with the same
102+
* range, followed by an <code>append</code> method invocation).
103+
* @param arg The <code>DOMString</code> with which the range must be
104+
* replaced.
105+
* @exception DOMException
106+
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
107+
* than the number of characters in <code>data</code>, or if the
108+
* specified <code>count</code> is negative.
109+
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
110+
*/
111+
public void replaceData(int offset,
112+
int count,
113+
String arg)
114+
throws DOMException;
115+
}
116+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.w3c.dom;
2+
3+
/**
4+
* This represents the content of a comment, i.e., all the characters between
5+
* the starting '<code>&lt;!--</code>' and ending '<code>--&gt;</code>'. Note
6+
* that this is the definition of a comment in XML, and, in practice, HTML,
7+
* although some HTML tools may implement the full SGML comment structure.
8+
*/
9+
public interface Comment extends CharacterData {
10+
}
11+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.w3c.dom;
2+
3+
/**
4+
* DOM operations only raise exceptions in "exceptional" circumstances, i.e.,
5+
* when an operation is impossible to perform (either for logical reasons,
6+
* because data is lost, or because the implementation has become unstable).
7+
* In general, DOM methods return specific error values in ordinary
8+
* processing situation, such as out-of-bound errors when using
9+
* <code>NodeList</code>.
10+
* <p>Implementations may raise other exceptions under other circumstances.
11+
* For example, implementations may raise an implementation-dependent
12+
* exception if a <code>null</code> argument is passed.
13+
* <p>Some languages and object systems do not support the concept of
14+
* exceptions. For such systems, error conditions may be indicated using
15+
* native error reporting mechanisms. For some bindings, for example, methods
16+
* may return error codes similar to those listed in the corresponding method
17+
* descriptions.
18+
*/
19+
public abstract class DOMException extends RuntimeException {
20+
public DOMException(short code, String message) {
21+
super(message);
22+
this.code = code;
23+
}
24+
public short code;
25+
// ExceptionCode
26+
public static final short INDEX_SIZE_ERR = 1;
27+
public static final short DOMSTRING_SIZE_ERR = 2;
28+
public static final short HIERARCHY_REQUEST_ERR = 3;
29+
public static final short WRONG_DOCUMENT_ERR = 4;
30+
public static final short INVALID_CHARACTER_ERR = 5;
31+
public static final short NO_DATA_ALLOWED_ERR = 6;
32+
public static final short NO_MODIFICATION_ALLOWED_ERR = 7;
33+
public static final short NOT_FOUND_ERR = 8;
34+
public static final short NOT_SUPPORTED_ERR = 9;
35+
public static final short INUSE_ATTRIBUTE_ERR = 10;
36+
37+
}
38+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.w3c.dom;
2+
3+
/**
4+
* The <code>DOMImplementation</code> interface provides a number of methods
5+
* for performing operations that are independent of any particular instance
6+
* of the document object model.
7+
* <p>The DOM Level 1 does not specify a way of creating a document instance,
8+
* and hence document creation is an operation specific to an implementation.
9+
* Future Levels of the DOM specification are expected to provide methods for
10+
* creating documents directly.
11+
*/
12+
public interface DOMImplementation {
13+
/**
14+
* Test if the DOM implementation implements a specific feature.
15+
* @param feature The package name of the feature to test. In Level 1, the
16+
* legal values are "HTML" and "XML" (case-insensitive).
17+
* @param version This is the version number of the package name to test.
18+
* In Level 1, this is the string "1.0". If the version is not specified,
19+
* supporting any version of the feature will cause the method to return
20+
* <code>true</code>.
21+
* @return <code>true</code> if the feature is implemented in the specified
22+
* version, <code>false</code> otherwise.
23+
*/
24+
public boolean hasFeature(String feature,
25+
String version);
26+
}
27+

0 commit comments

Comments
 (0)