File: IXMLElement.java

package info (click to toggle)
libnanoxml2-java 2.2.3.dfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 992 kB
  • sloc: java: 5,085; xml: 150; makefile: 91; sh: 59
file content (529 lines) | stat: -rw-r--r-- 13,637 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
/* IXMLElement.java                                                NanoXML/Java
 *
 * $Revision: 1.4 $
 * $Date: 2002/01/04 21:03:28 $
 * $Name: RELEASE_2_2_1 $
 *
 * This file is part of NanoXML 2 for Java.
 * Copyright (C) 2000-2002 Marc De Scheemaecker, All Rights Reserved.
 *
 * This software is provided 'as-is', without any express or implied warranty.
 * In no event will the authors be held liable for any damages arising from the
 * use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 *
 *  1. The origin of this software must not be misrepresented; you must not
 *     claim that you wrote the original software. If you use this software in
 *     a product, an acknowledgment in the product documentation would be
 *     appreciated but is not required.
 *
 *  2. Altered source versions must be plainly marked as such, and must not be
 *     misrepresented as being the original software.
 *
 *  3. This notice may not be removed or altered from any source distribution.
 */

package net.n3.nanoxml;


import java.io.Serializable;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;
import java.util.Vector;


/**
 * IXMLElement is an XML element. It provides an easy to use generic interface
 * on top of an XML like data structure like e.g. a DOM like structure.
 * Elements returned by StdXMLBuilder also implement this interface.
 *
 * @see net.n3.nanoxml.StdXMLBuilder
 *
 * @author Marc De Scheemaecker
 * @version $Name: RELEASE_2_2_1 $, $Revision: 1.4 $
 */
public interface IXMLElement
{

   /**
    * No line number defined.
    */
   public static final int NO_LINE = -1;


   /**
    * Creates an element to be used for #PCDATA content.
    */
   public IXMLElement createPCDataElement();


   /**
    * Creates an empty element.
    *
    * @param fullName the name of the element.
    */
   public IXMLElement createElement(String fullName);


   /**
    * Creates an empty element.
    *
    * @param fullName the name of the element.
    * @param systemID the system ID of the XML data where the element starts.
    * @param lineNr   the line in the XML data where the element starts.
    */
   public IXMLElement createElement(String fullName,
                                    String systemID,
                                    int    lineNr);


   /**
    * Creates an empty element.
    *
    * @param fullName  the full name of the element
    * @param namespace the namespace URI.
    */
   public IXMLElement createElement(String fullName,
                                    String namespace);


   /**
    * Creates an empty element.
    *
    * @param fullName  the full name of the element
    * @param namespace the namespace URI.
    * @param systemID  the system ID of the XML data where the element starts.
    * @param lineNr    the line in the XML data where the element starts.
    */
   public IXMLElement createElement(String fullName,
                                    String namespace,
                                    String systemID,
                                    int    lineNr);


   /**
    * Returns the parent element. This method returns null for the root
    * element.
    */
   public IXMLElement getParent();


   /**
    * Returns the full name (i.e. the name including an eventual namespace
    * prefix) of the element.
    *
    * @return the name, or null if the element only contains #PCDATA.
    */
   public String getFullName();


   /**
    * Returns the name of the element.
    *
    * @return the name, or null if the element only contains #PCDATA.
    */
   public String getName();


   /**
    * Returns the namespace of the element.
    *
    * @return the namespace, or null if no namespace is associated with the
    *         element.
    */
   public String getNamespace();


   /**
    * Sets the full name. This method also sets the short name and clears the
    * namespace URI.
    *
    * @param name the non-null name.
    */
   public void setName(String name);


   /**
    * Sets the name.
    *
    * @param fullName  the non-null full name.
    * @param namespace the namespace URI, which may be null.
    */
   public void setName(String fullName,
                       String namespace);


   /**
    * Adds a child element.
    *
    * @param child the non-null child to add.
    */
   public void addChild(IXMLElement child);


   /**
    * Removes a child element.
    *
    * @param child the non-null child to remove.
    */
   public void removeChild(IXMLElement child);


   /**
    * Removes the child located at a certain index.
    *
    * @param index the index of the child, where the first child has index 0.
    */
   public void removeChildAtIndex(int index);


   /**
    * Returns an enumeration of all child elements.
    *
    * @return the non-null enumeration
    */
   public Enumeration enumerateChildren();


   /**
    * Returns whether the element is a leaf element.
    *
    * @return true if the element has no children.
    */
   public boolean isLeaf();


   /**
    * Returns whether the element has children.
    *
    * @return true if the element has children.
    */
   public boolean hasChildren();


   /**
    * Returns the number of children.
    *
    * @return the count.
    */
   public int getChildrenCount();


   /**
    * Returns a vector containing all the child elements.
    *
    * @return the vector.
    */
   public Vector getChildren();


   /**
    * Returns the child at a specific index.
    *
    * @param index the index of the child
    *
    * @return the non-null child
    *
    * @throws java.lang.ArrayIndexOutOfBoundsException
    *		if the index is out of bounds.
    */
   public IXMLElement getChildAtIndex(int index)
      throws ArrayIndexOutOfBoundsException;


   /**
    * Searches a child element.
    *
    * @param name the full name of the child to search for.
    *
    * @return the child element, or null if no such child was found.
    */
   public IXMLElement getFirstChildNamed(String name);


   /**
    * Searches a child element.
    *
    * @param name      the name of the child to search for.
    * @param namespace the namespace, which may be null.
    *
    * @return the child element, or null if no such child was found.
    */
   public IXMLElement getFirstChildNamed(String name,
                                         String namespace);


   /**
    * Returns a vector of all child elements named <I>name</I>.
    *
    * @param name the full name of the children to search for.
    *
    * @return the non-null vector of child elements.
    */
   public Vector getChildrenNamed(String name);


   /**
    * Returns a vector of all child elements named <I>name</I>.
    *
    * @param name      the name of the children to search for.
    * @param namespace the namespace, which may be null.
    *
    * @return the non-null vector of child elements.
    */
   public Vector getChildrenNamed(String name,
                                  String namespace);



   /**
    * Returns the number of attributes.
    */
   public int getAttributeCount();


   /**
    * @deprecated As of NanoXML/Java 2.0.1, replaced by
    *             {@link #getAttribute(java.lang.String,java.lang.String)}
    * Returns the value of an attribute.
    *
    * @param name the non-null name of the attribute.
    *
    * @return the value, or null if the attribute does not exist.
    */
   public String getAttribute(String name);


   /**
    * Returns the value of an attribute.
    *
    * @param name the non-null full name of the attribute.
    * @param defaultValue the default value of the attribute.
    *
    * @return the value, or defaultValue if the attribute does not exist.
    */
   public String getAttribute(String name,
                              String defaultValue);


   /**
    * Returns the value of an attribute.
    *
    * @param name the non-null name of the attribute.
    * @param namespace the namespace URI, which may be null.
    * @param defaultValue the default value of the attribute.
    *
    * @return the value, or defaultValue if the attribute does not exist.
    */
   public String getAttribute(String name,
                              String namespace,
                              String defaultValue);


   /**
    * Returns the value of an attribute.
    *
    * @param name the non-null full name of the attribute.
    * @param defaultValue the default value of the attribute.
    *
    * @return the value, or defaultValue if the attribute does not exist.
    */
   public int getAttribute(String name,
                           int    defaultValue);


   /**
    * Returns the value of an attribute.
    *
    * @param name the non-null name of the attribute.
    * @param namespace the namespace URI, which may be null.
    * @param defaultValue the default value of the attribute.
    *
    * @return the value, or defaultValue if the attribute does not exist.
    */
   public int getAttribute(String name,
                           String namespace,
                           int    defaultValue);


   /**
    * Returns the type of an attribute.
    *
    * @param name the non-null full name of the attribute.
    *
    * @return the type, or null if the attribute does not exist.
    */
   public String getAttributeType(String name);


   /**
    * Returns the namespace of an attribute.
    *
    * @param name the non-null full name of the attribute.
    *
    * @return the namespace, or null if there is none associated.
    */
   public String getAttributeNamespace(String name);


   /**
    * Returns the type of an attribute.
    *
    * @param name the non-null name of the attribute.
    * @param namespace the namespace URI, which may be null.
    *
    * @return the type, or null if the attribute does not exist.
    */
   public String getAttributeType(String name,
                                  String namespace);


   /**
    * Sets an attribute.
    *
    * @param name the non-null full name of the attribute.
    * @param value the non-null value of the attribute.
    */
   public void setAttribute(String name,
                            String value);


   /**
    * Sets an attribute.
    *
    * @param fullName the non-null full name of the attribute.
    * @param namespace the namespace URI of the attribute, which may be null.
    * @param value the non-null value of the attribute.
    */
   public void setAttribute(String fullName,
                            String namespace,
                            String value);


   /**
    * Removes an attribute.
    *
    * @param name the non-null name of the attribute.
    */
   public void removeAttribute(String name);


   /**
    * Removes an attribute.
    *
    * @param name the non-null name of the attribute.
    * @param namespace the namespace URI of the attribute, which may be null.
    */
   public void removeAttribute(String name,
                               String namespace);


   /**
    * Returns an enumeration of all attribute names.
    *
    * @return the non-null enumeration.
    */
   public Enumeration enumerateAttributeNames();


   /**
    * Returns whether an attribute exists.
    *
    * @param name the non-null name of the attribute.
    *
    * @return true if the attribute exists.
    */
   public boolean hasAttribute(String name);


   /**
    * Returns whether an attribute exists.
    *
    * @param name the non-null name of the attribute.
    * @param namespace the namespace URI of the attribute, which may be null.
    *
    * @return true if the attribute exists.
    */
   public boolean hasAttribute(String name,
                               String namespace);


   /**
    * Returns all attributes as a Properties object.
    *
    * @return the non-null set.
    */
   public Properties getAttributes();


   /**
    * Returns all attributes in a specific namespace as a Properties object.
    *
    * @param namespace the namespace URI of the attributes, which may be null.
    *
    * @return the non-null set.
    */
   public Properties getAttributesInNamespace(String namespace);


   /**
    * Returns the system ID of the data where the element started.
    *
    * @return the system ID, or null if unknown.
    *
    * @see #getLineNr
    */
   public String getSystemID();


   /**
    * Returns the line number in the data where the element started.
    *
    * @return the line number, or NO_LINE if unknown.
    *
    * @see #NO_LINE
    * @see #getSystemID
    */
   public int getLineNr();


   /**
    * Return the #PCDATA content of the element. If the element has a
    * combination of #PCDATA content and child elements, the #PCDATA
    * sections can be retrieved as unnamed child objects. In this case,
    * this method returns null.
    *
    * @return the content.
    */
   public String getContent();


   /**
    * Sets the #PCDATA content. It is an error to call this method with a
    * non-null value if there are child objects.
    *
    * @param content the (possibly null) content.
    */
   public void setContent(String content);


   /**
    * Returns true if the element equals another element.
    *
    * @param rawElement the element to compare to
    */
   public boolean equals(Object rawElement);


   /**
    * Returns true if the element equals another element.
    *
    * @param rawElement the element to compare to
    */
   public boolean equalsXMLElement(IXMLElement elt);

}