KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > cyberneko > html > HTMLAugmentations


1 /*
2  * (C) Copyright 2004-2005, Andy Clark. All rights reserved.
3  *
4  * This file is distributed under an Apache style license. Please
5  * refer to the LICENSE file for specific details.
6  */

7
8 package org.cyberneko.html;
9
10 import org.apache.xerces.xni.Augmentations;
11
12 import java.util.Enumeration JavaDoc;
13 import java.util.Hashtable JavaDoc;
14
15 /**
16  * This class is here to overcome the XNI changes to the
17  * <code>Augmentations</code> interface. In early versions of XNI, the
18  * augmentations interface contained a <code>clear()</code> method to
19  * remove all of the items from the augmentations instance. A later
20  * version of XNI changed this method to <code>removeAllItems()</code>.
21  * Therefore, this class extends the augmentations interface and
22  * explicitly implements both of these methods.
23  * <p>
24  * <strong>Note:</strong>
25  * This code is inspired by performance enhancements submitted by
26  * Marc-André Morissette.
27  *
28  * @author Andy Clark
29  */

30 public class HTMLAugmentations
31     implements Augmentations {
32
33     //
34
// Data
35
//
36

37     /** Augmentation items. */
38     protected Hashtable JavaDoc fItems = new Hashtable JavaDoc();
39
40     //
41
// Public methods
42
//
43

44     // since Xerces 2.3.0
45

46     /** Removes all of the elements in this augmentations object. */
47     public void removeAllItems() {
48         fItems.clear();
49     } // removeAllItems()
50

51     // from Xerces 2.0.0 (beta4) until 2.3.0
52

53     /** Removes all of the elements in this augmentations object. */
54     public void clear() {
55         fItems.clear();
56     } // clear()
57

58     //
59
// Augmentations methods
60
//
61

62     /**
63      * Add additional information identified by a key to the Augmentations
64      * structure.
65      *
66      * @param key Identifier, can't be <code>null</code>
67      * @param item Additional information
68      *
69      * @return The previous value of the specified key in the Augmentations
70      * structure, or <code>null</code> if it did not have one.
71      */

72     public Object JavaDoc putItem(String JavaDoc key, Object JavaDoc item) {
73         return fItems.put(key, item);
74     } // putItem(String, Object):Object
75

76
77     /**
78      * Get information identified by a key from the Augmentations structure.
79      *
80      * @param key Identifier, can't be <code>null</code>
81      *
82      * @return The value to which the key is mapped in the Augmentations
83      * structure; <code>null</code> if the key is not mapped to any
84      * value.
85      */

86     public Object JavaDoc getItem(String JavaDoc key) {
87         return fItems.get(key);
88     } // getItem(String):Object
89

90     /**
91      * Remove additional info from the Augmentations structure
92      *
93      * @param key Identifier, can't be <code>null</code>
94      * @return The previous value of the specified key in the Augmentations
95      * structure, or <code>null</code> if it did not have one.
96      */

97     public Object JavaDoc removeItem(String JavaDoc key) {
98         return fItems.remove(key);
99     } // removeItem(String):Object
100

101     /**
102      * Returns an enumeration of the keys in the Augmentations structure.
103      */

104     public Enumeration JavaDoc keys() {
105         return fItems.keys();
106     } // keys():Enumeration
107

108 } // class HTMLAugmentations
109
Popular Tags