View Javadoc

1   /*
2    * $Id: AbstractAdapterElement.java 471756 2006-11-06 15:01:43Z husted $
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  package org.apache.struts2.views.xslt;
22  
23  import java.util.HashMap;
24  import java.util.Map;
25  
26  import org.w3c.dom.Attr;
27  import org.w3c.dom.DOMException;
28  import org.w3c.dom.Element;
29  import org.w3c.dom.Node;
30  import org.w3c.dom.TypeInfo;
31  
32  /***
33   * AbstractAdapterElement extends the abstract Node type and implements
34   * the DOM Element interface.
35   */
36  public abstract class AbstractAdapterElement extends AbstractAdapterNode implements Element {
37  
38      private Map attributeAdapters;
39  
40      public AbstractAdapterElement() { }
41  
42      public void setAttribute(String string, String string1) throws DOMException {
43          throw operationNotSupported();
44      }
45  
46      protected Map getAttributeAdapters() {
47          if ( attributeAdapters == null )
48              attributeAdapters = buildAttributeAdapters();
49          return attributeAdapters;
50      }
51  
52      protected Map buildAttributeAdapters() {
53          return new HashMap();
54      }
55  
56      /***
57       * No attributes, return empty attributes if asked.
58       */
59      public String getAttribute(String string) {
60          return "";
61      }
62  
63      public void setAttributeNS(String string, String string1, String string2) throws DOMException {
64          throw operationNotSupported();
65      }
66  
67      public String getAttributeNS(String string, String string1) {
68          return null;
69      }
70  
71      public Attr setAttributeNode(Attr attr) throws DOMException {
72          throw operationNotSupported();
73      }
74  
75      public Attr getAttributeNode( String name ) {
76          return (Attr)getAttributes().getNamedItem( name );
77      }
78  
79      public Attr setAttributeNodeNS(Attr attr) throws DOMException {
80          throw operationNotSupported();
81      }
82  
83      public Attr getAttributeNodeNS(String string, String string1) {
84          throw operationNotSupported();
85      }
86  
87      public String getNodeName() {
88          return getTagName();
89      }
90  
91      public short getNodeType() {
92          return Node.ELEMENT_NODE;
93      }
94  
95      public String getTagName() {
96          return getPropertyName();
97      }
98  
99      public boolean hasAttribute(String string) {
100         return false;
101     }
102 
103     public boolean hasAttributeNS(String string, String string1) {
104         return false;
105     }
106 
107     public boolean hasChildNodes() {
108         return getElementsByTagName("*").getLength() > 0;
109     }
110 
111     public void removeAttribute(String string) throws DOMException {
112         throw operationNotSupported();
113     }
114 
115     public void removeAttributeNS(String string, String string1) throws DOMException {
116         throw operationNotSupported();
117     }
118 
119     public Attr removeAttributeNode(Attr attr) throws DOMException {
120         throw operationNotSupported();
121     }
122 
123     public void setIdAttributeNode(Attr attr, boolean b) throws DOMException {
124         throw operationNotSupported();
125     }
126 
127     public TypeInfo getSchemaTypeInfo() {
128         throw operationNotSupported();
129     }
130 
131     public void setIdAttribute(String string, boolean b) throws DOMException {
132         throw operationNotSupported();
133     }
134 
135     public void setIdAttributeNS(String string, String string1, boolean b) throws DOMException {
136         throw operationNotSupported();
137     }
138 
139 }
140