KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > xml > AttributesImpl


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.xml;
17
18 import org.xml.sax.Attributes JavaDoc;
19
20 /**
21  * A helper Class creating SAX Attributes
22  *
23  * @author <a HREF="mailto:volker.schmitt@basf-ag.de">Volker Schmitt</a>
24  * @version CVS $Id: AttributesImpl.java 307064 2005-10-07 09:55:02Z vgritsenko $
25  */

26 public class AttributesImpl extends org.xml.sax.helpers.AttributesImpl JavaDoc {
27
28     /**
29      * Constructor
30      */

31     public AttributesImpl() {
32         super();
33     }
34
35     /**
36      * Constructor
37      */

38     public AttributesImpl(Attributes JavaDoc attr) {
39         super(attr);
40     }
41
42     /**
43      * Add an attribute of type CDATA with empty Namespace to the end of the list.
44      *
45      * <p>For the sake of speed, this method does no checking
46      * to see if the attribute is already in the list: that is
47      * the responsibility of the application.</p>
48      *
49      * @param localName The local name.
50      * @param value The attribute value.
51      */

52     public void addCDATAAttribute(String JavaDoc localName, String JavaDoc value) {
53         addAttribute("", localName, localName, AttributeTypes.CDATA, value);
54     }
55
56     /**
57      * Add an attribute of type CDATA with the namespace to the end of the list.
58      *
59      * <p>For the sake of speed, this method does no checking
60      * to see if the attribute is already in the list: that is
61      * the responsibility of the application.</p>
62      *
63      * @param namespace The namespace.
64      * @param localName The local name.
65      * @param value The attribute value.
66      */

67     public void addCDATAAttribute(String JavaDoc namespace, String JavaDoc localName, String JavaDoc value) {
68         addAttribute(namespace, localName, localName, AttributeTypes.CDATA, value);
69     }
70
71     /**
72      * Add an attribute of type CDATA to the end of the list.
73      *
74      * <p>For the sake of speed, this method does no checking
75      * to see if the attribute is already in the list: that is
76      * the responsibility of the application.</p>
77      *
78      * @param uri The Namespace URI, or the empty string if
79      * none is available or Namespace processing is not
80      * being performed.
81      * @param localName The local name, or the empty string if
82      * Namespace processing is not being performed.
83      * @param qName The qualified (prefixed) name, or the empty string
84      * if qualified names are not available.
85      * @param value The attribute value.
86      */

87     public void addCDATAAttribute(String JavaDoc uri,
88                                     String JavaDoc localName,
89                                     String JavaDoc qName,
90                                     String JavaDoc value) {
91         addAttribute(uri, localName, qName, AttributeTypes.CDATA, value);
92     }
93
94     /**
95      * Remove an attribute
96      */

97     public void removeAttribute(String JavaDoc localName) {
98         final int index = this.getIndex(localName);
99         if ( index != -1 ) {
100             this.removeAttribute(index);
101         }
102     }
103
104     /**
105      * Remove an attribute
106      */

107     public void removeAttribute(String JavaDoc uri, String JavaDoc localName) {
108         final int index = this.getIndex(uri, localName);
109         if ( index != -1 ) {
110             this.removeAttribute(index);
111         }
112     }
113 }
114
Popular Tags