View Javadoc

1   /*
2    * $Id: AbstractAdapterElement.java 651946 2008-04-27 13:41:38Z apetrelli $
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  
22  package org.apache.struts2.views.xslt;
23  
24  import java.util.HashMap;
25  import java.util.Map;
26  
27  import org.w3c.dom.Attr;
28  import org.w3c.dom.DOMException;
29  import org.w3c.dom.Element;
30  import org.w3c.dom.Node;
31  import org.w3c.dom.TypeInfo;
32  
33  /***
34   * AbstractAdapterElement extends the abstract Node type and implements
35   * the DOM Element interface.
36   */
37  public abstract class AbstractAdapterElement extends AbstractAdapterNode implements Element {
38  
39      private Map attributeAdapters;
40  
41      public AbstractAdapterElement() { }
42  
43      public void setAttribute(String string, String string1) throws DOMException {
44          throw operationNotSupported();
45      }
46  
47      protected Map getAttributeAdapters() {
48          if ( attributeAdapters == null )
49              attributeAdapters = buildAttributeAdapters();
50          return attributeAdapters;
51      }
52  
53      protected Map buildAttributeAdapters() {
54          return new HashMap();
55      }
56  
57      /***
58       * No attributes, return empty attributes if asked.
59       */
60      public String getAttribute(String string) {
61          return "";
62      }
63  
64      public void setAttributeNS(String string, String string1, String string2) throws DOMException {
65          throw operationNotSupported();
66      }
67  
68      public String getAttributeNS(String string, String string1) {
69          return null;
70      }
71  
72      public Attr setAttributeNode(Attr attr) throws DOMException {
73          throw operationNotSupported();
74      }
75  
76      public Attr getAttributeNode( String name ) {
77          return (Attr)getAttributes().getNamedItem( name );
78      }
79  
80      public Attr setAttributeNodeNS(Attr attr) throws DOMException {
81          throw operationNotSupported();
82      }
83  
84      public Attr getAttributeNodeNS(String string, String string1) {
85          throw operationNotSupported();
86      }
87  
88      public String getNodeName() {
89          return getTagName();
90      }
91  
92      public short getNodeType() {
93          return Node.ELEMENT_NODE;
94      }
95  
96      public String getTagName() {
97          return getPropertyName();
98      }
99  
100     public boolean hasAttribute(String string) {
101         return false;
102     }
103 
104     public boolean hasAttributeNS(String string, String string1) {
105         return false;
106     }
107 
108     public boolean hasChildNodes() {
109         return getElementsByTagName("*").getLength() > 0;
110     }
111 
112     public void removeAttribute(String string) throws DOMException {
113         throw operationNotSupported();
114     }
115 
116     public void removeAttributeNS(String string, String string1) throws DOMException {
117         throw operationNotSupported();
118     }
119 
120     public Attr removeAttributeNode(Attr attr) throws DOMException {
121         throw operationNotSupported();
122     }
123 
124     public void setIdAttributeNode(Attr attr, boolean b) throws DOMException {
125         throw operationNotSupported();
126     }
127 
128     public TypeInfo getSchemaTypeInfo() {
129         throw operationNotSupported();
130     }
131 
132     public void setIdAttribute(String string, boolean b) throws DOMException {
133         throw operationNotSupported();
134     }
135 
136     public void setIdAttributeNS(String string, String string1, boolean b) throws DOMException {
137         throw operationNotSupported();
138     }
139 
140 }
141