001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.xml;
018:
019: import org.xml.sax.Attributes;
020:
021: /**
022: * A helper Class creating SAX Attributes
023: *
024: * @author <a href="mailto:volker.schmitt@basf-ag.de">Volker Schmitt</a>
025: * @version CVS $Id: AttributesImpl.java 433543 2006-08-22 06:22:54Z crossley $
026: */
027: public class AttributesImpl extends org.xml.sax.helpers.AttributesImpl {
028:
029: /**
030: * Constructor
031: */
032: public AttributesImpl() {
033: super ();
034: }
035:
036: /**
037: * Constructor
038: */
039: public AttributesImpl(Attributes attr) {
040: super (attr);
041: }
042:
043: /**
044: * Add an attribute of type CDATA with empty Namespace to the end of the list.
045: *
046: * <p>For the sake of speed, this method does no checking
047: * to see if the attribute is already in the list: that is
048: * the responsibility of the application.</p>
049: *
050: * @param localName The local name.
051: * @param value The attribute value.
052: */
053: public void addCDATAAttribute(String localName, String value) {
054: addAttribute("", localName, localName, AttributeTypes.CDATA,
055: value);
056: }
057:
058: /**
059: * Add an attribute of type CDATA with the namespace to the end of the list.
060: *
061: * <p>For the sake of speed, this method does no checking
062: * to see if the attribute is already in the list: that is
063: * the responsibility of the application.</p>
064: *
065: * @param namespace The namespace.
066: * @param localName The local name.
067: * @param value The attribute value.
068: */
069: public void addCDATAAttribute(String namespace, String localName,
070: String value) {
071: addAttribute(namespace, localName, localName,
072: AttributeTypes.CDATA, value);
073: }
074:
075: /**
076: * Add an attribute of type CDATA to the end of the list.
077: *
078: * <p>For the sake of speed, this method does no checking
079: * to see if the attribute is already in the list: that is
080: * the responsibility of the application.</p>
081: *
082: * @param uri The Namespace URI, or the empty string if
083: * none is available or Namespace processing is not
084: * being performed.
085: * @param localName The local name, or the empty string if
086: * Namespace processing is not being performed.
087: * @param qName The qualified (prefixed) name, or the empty string
088: * if qualified names are not available.
089: * @param value The attribute value.
090: */
091: public void addCDATAAttribute(String uri, String localName,
092: String qName, String value) {
093: addAttribute(uri, localName, qName, AttributeTypes.CDATA, value);
094: }
095:
096: /**
097: * Remove an attribute
098: */
099: public void removeAttribute(String localName) {
100: final int index = this .getIndex(localName);
101: if (index != -1) {
102: this .removeAttribute(index);
103: }
104: }
105:
106: /**
107: * Remove an attribute
108: */
109: public void removeAttribute(String uri, String localName) {
110: final int index = this .getIndex(uri, localName);
111: if (index != -1) {
112: this.removeAttribute(index);
113: }
114: }
115: }
|