2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / org / xml / sax / Attributes.java
blob251fe206a00d175ffd97de9c4d381cda861e9e71
1 // Attributes.java - attribute list with Namespace support
2 // http://www.saxproject.org
3 // Written by David Megginson
4 // NO WARRANTY! This class is in the public domain.
6 // $Id: Attributes.java,v 1.5.2.4 2002/01/29 21:34:14 dbrownell Exp $
9 package org.xml.sax;
12 /**
13 * Interface for a list of XML attributes.
15 * <blockquote>
16 * <em>This module, both source code and documentation, is in the
17 * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
18 * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
19 * for further information.
20 * </blockquote>
22 * <p>This interface allows access to a list of attributes in
23 * three different ways:</p>
25 * <ol>
26 * <li>by attribute index;</li>
27 * <li>by Namespace-qualified name; or</li>
28 * <li>by qualified (prefixed) name.</li>
29 * </ol>
31 * <p>The list will not contain attributes that were declared
32 * #IMPLIED but not specified in the start tag. It will also not
33 * contain attributes used as Namespace declarations (xmlns*) unless
34 * the <code>http://xml.org/sax/features/namespace-prefixes</code>
35 * feature is set to <var>true</var> (it is <var>false</var> by
36 * default).
37 * Because SAX2 conforms to the "Namespaces in XML" specification,
38 * it does not give namespace declaration attributes a namespace URI.
39 * Some other W3C specifications are in conflict with that, expecting
40 * these declarations to be in a namespace.
41 * Handler code may need to resolve that conflict.
42 * </p>
44 * <p>If the namespace-prefixes feature (see above) is <var>false</var>,
45 * access by qualified name may not be available; if the
46 * <code>http://xml.org/sax/features/namespaces</code>
47 * feature is <var>false</var>, access by Namespace-qualified names
48 * may not be available.</p>
50 * <p>This interface replaces the now-deprecated SAX1 {@link
51 * org.xml.sax.AttributeList AttributeList} interface, which does not
52 * contain Namespace support. In addition to Namespace support, it
53 * adds the <var>getIndex</var> methods (below).</p>
55 * <p>The order of attributes in the list is unspecified, and will
56 * vary from implementation to implementation.</p>
58 * @since SAX 2.0
59 * @author David Megginson
60 * @version 2.0.1 (sax2r2)
61 * @see org.xml.sax.helpers.AttributesImpl
62 * @see org.xml.sax.ext.DeclHandler#attributeDecl
64 public interface Attributes
68 ////////////////////////////////////////////////////////////////////
69 // Indexed access.
70 ////////////////////////////////////////////////////////////////////
73 /**
74 * Return the number of attributes in the list.
76 * <p>Once you know the number of attributes, you can iterate
77 * through the list.</p>
79 * @return The number of attributes in the list.
80 * @see #getURI(int)
81 * @see #getLocalName(int)
82 * @see #getQName(int)
83 * @see #getType(int)
84 * @see #getValue(int)
86 public abstract int getLength ();
89 /**
90 * Look up an attribute's Namespace URI by index.
92 * @param index The attribute index (zero-based).
93 * @return The Namespace URI, or the empty string if none
94 * is available, or null if the index is out of
95 * range.
96 * @see #getLength
98 public abstract String getURI (int index);
102 * Look up an attribute's local name by index.
104 * @param index The attribute index (zero-based).
105 * @return The local name, or the empty string if Namespace
106 * processing is not being performed, or null
107 * if the index is out of range.
108 * @see #getLength
110 public abstract String getLocalName (int index);
114 * Look up an attribute's XML 1.0 qualified name by index.
116 * @param index The attribute index (zero-based).
117 * @return The XML 1.0 qualified name, or the empty string
118 * if none is available, or null if the index
119 * is out of range.
120 * @see #getLength
122 public abstract String getQName (int index);
126 * Look up an attribute's type by index.
128 * <p>The attribute type is one of the strings "CDATA", "ID",
129 * "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES",
130 * or "NOTATION" (always in upper case).</p>
132 * <p>If the parser has not read a declaration for the attribute,
133 * or if the parser does not report attribute types, then it must
134 * return the value "CDATA" as stated in the XML 1.0 Recommentation
135 * (clause 3.3.3, "Attribute-Value Normalization").</p>
137 * <p>For an enumerated attribute that is not a notation, the
138 * parser will report the type as "NMTOKEN".</p>
140 * @param index The attribute index (zero-based).
141 * @return The attribute's type as a string, or null if the
142 * index is out of range.
143 * @see #getLength
145 public abstract String getType (int index);
149 * Look up an attribute's value by index.
151 * <p>If the attribute value is a list of tokens (IDREFS,
152 * ENTITIES, or NMTOKENS), the tokens will be concatenated
153 * into a single string with each token separated by a
154 * single space.</p>
156 * @param index The attribute index (zero-based).
157 * @return The attribute's value as a string, or null if the
158 * index is out of range.
159 * @see #getLength
161 public abstract String getValue (int index);
165 ////////////////////////////////////////////////////////////////////
166 // Name-based query.
167 ////////////////////////////////////////////////////////////////////
171 * Look up the index of an attribute by Namespace name.
173 * @param uri The Namespace URI, or the empty string if
174 * the name has no Namespace URI.
175 * @param localName The attribute's local name.
176 * @return The index of the attribute, or -1 if it does not
177 * appear in the list.
179 public int getIndex (String uri, String localName);
183 * Look up the index of an attribute by XML 1.0 qualified name.
185 * @param qName The qualified (prefixed) name.
186 * @return The index of the attribute, or -1 if it does not
187 * appear in the list.
189 public int getIndex (String qName);
193 * Look up an attribute's type by Namespace name.
195 * <p>See {@link #getType(int) getType(int)} for a description
196 * of the possible types.</p>
198 * @param uri The Namespace URI, or the empty String if the
199 * name has no Namespace URI.
200 * @param localName The local name of the attribute.
201 * @return The attribute type as a string, or null if the
202 * attribute is not in the list or if Namespace
203 * processing is not being performed.
205 public abstract String getType (String uri, String localName);
209 * Look up an attribute's type by XML 1.0 qualified name.
211 * <p>See {@link #getType(int) getType(int)} for a description
212 * of the possible types.</p>
214 * @param qName The XML 1.0 qualified name.
215 * @return The attribute type as a string, or null if the
216 * attribute is not in the list or if qualified names
217 * are not available.
219 public abstract String getType (String qName);
223 * Look up an attribute's value by Namespace name.
225 * <p>See {@link #getValue(int) getValue(int)} for a description
226 * of the possible values.</p>
228 * @param uri The Namespace URI, or the empty String if the
229 * name has no Namespace URI.
230 * @param localName The local name of the attribute.
231 * @return The attribute value as a string, or null if the
232 * attribute is not in the list.
234 public abstract String getValue (String uri, String localName);
238 * Look up an attribute's value by XML 1.0 qualified name.
240 * <p>See {@link #getValue(int) getValue(int)} for a description
241 * of the possible values.</p>
243 * @param qName The XML 1.0 qualified name.
244 * @return The attribute value as a string, or null if the
245 * attribute is not in the list or if qualified names
246 * are not available.
248 public abstract String getValue (String qName);
252 // end of Attributes.java