001: /*
002: * $Id: AbstractAdapterElement.java 471756 2006-11-06 15:01:43Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts2.views.xslt;
022:
023: import java.util.HashMap;
024: import java.util.Map;
025:
026: import org.w3c.dom.Attr;
027: import org.w3c.dom.DOMException;
028: import org.w3c.dom.Element;
029: import org.w3c.dom.Node;
030: import org.w3c.dom.TypeInfo;
031:
032: /**
033: * AbstractAdapterElement extends the abstract Node type and implements
034: * the DOM Element interface.
035: */
036: public abstract class AbstractAdapterElement extends
037: AbstractAdapterNode implements Element {
038:
039: private Map attributeAdapters;
040:
041: public AbstractAdapterElement() {
042: }
043:
044: public void setAttribute(String string, String string1)
045: throws DOMException {
046: throw operationNotSupported();
047: }
048:
049: protected Map getAttributeAdapters() {
050: if (attributeAdapters == null)
051: attributeAdapters = buildAttributeAdapters();
052: return attributeAdapters;
053: }
054:
055: protected Map buildAttributeAdapters() {
056: return new HashMap();
057: }
058:
059: /**
060: * No attributes, return empty attributes if asked.
061: */
062: public String getAttribute(String string) {
063: return "";
064: }
065:
066: public void setAttributeNS(String string, String string1,
067: String string2) throws DOMException {
068: throw operationNotSupported();
069: }
070:
071: public String getAttributeNS(String string, String string1) {
072: return null;
073: }
074:
075: public Attr setAttributeNode(Attr attr) throws DOMException {
076: throw operationNotSupported();
077: }
078:
079: public Attr getAttributeNode(String name) {
080: return (Attr) getAttributes().getNamedItem(name);
081: }
082:
083: public Attr setAttributeNodeNS(Attr attr) throws DOMException {
084: throw operationNotSupported();
085: }
086:
087: public Attr getAttributeNodeNS(String string, String string1) {
088: throw operationNotSupported();
089: }
090:
091: public String getNodeName() {
092: return getTagName();
093: }
094:
095: public short getNodeType() {
096: return Node.ELEMENT_NODE;
097: }
098:
099: public String getTagName() {
100: return getPropertyName();
101: }
102:
103: public boolean hasAttribute(String string) {
104: return false;
105: }
106:
107: public boolean hasAttributeNS(String string, String string1) {
108: return false;
109: }
110:
111: public boolean hasChildNodes() {
112: return getElementsByTagName("*").getLength() > 0;
113: }
114:
115: public void removeAttribute(String string) throws DOMException {
116: throw operationNotSupported();
117: }
118:
119: public void removeAttributeNS(String string, String string1)
120: throws DOMException {
121: throw operationNotSupported();
122: }
123:
124: public Attr removeAttributeNode(Attr attr) throws DOMException {
125: throw operationNotSupported();
126: }
127:
128: public void setIdAttributeNode(Attr attr, boolean b)
129: throws DOMException {
130: throw operationNotSupported();
131: }
132:
133: public TypeInfo getSchemaTypeInfo() {
134: throw operationNotSupported();
135: }
136:
137: public void setIdAttribute(String string, boolean b)
138: throws DOMException {
139: throw operationNotSupported();
140: }
141:
142: public void setIdAttributeNS(String string, String string1,
143: boolean b) throws DOMException {
144: throw operationNotSupported();
145: }
146:
147: }
|