View Javadoc

1   /*
2    * $Id: ProxyAttrAdapter.java 440597 2006-09-06 03:34:39Z wsmoak $
3    *
4    * Copyright 2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.struts2.views.xslt;
19  
20  import org.w3c.dom.Attr;
21  import org.w3c.dom.DOMException;
22  import org.w3c.dom.Element;
23  import org.w3c.dom.TypeInfo;
24  
25  /***
26   * ProxyAttrAdapter is a pass-through adapter for objects which already
27   * implement the Attr interface.  All methods are proxied to the underlying
28   * Node except node traversal (e.g. getParent()) related methods which
29   * are implemented by the abstract adapter node to work with the parent adapter.
30   */
31  public class ProxyAttrAdapter extends ProxyNodeAdapter implements Attr {
32  
33      public ProxyAttrAdapter(AdapterFactory factory, AdapterNode parent, Attr value) {
34          super(factory, parent, value);
35      }
36  
37      // convenience
38      protected Attr attr() {
39          return (Attr) getPropertyValue();
40      }
41  
42      // Proxied Attr methods
43  
44      public String getName() {
45          return attr().getName();
46      }
47  
48      public boolean getSpecified() {
49          return attr().getSpecified();
50      }
51  
52      public String getValue() {
53          return attr().getValue();
54      }
55  
56      public void setValue(String string) throws DOMException {
57          throw new UnsupportedOperationException();
58      }
59  
60      public Element getOwnerElement() {
61          return (Element) getParent();
62      }
63  
64      // DOM level 3
65  
66      public TypeInfo getSchemaTypeInfo() {
67          throw operationNotSupported();
68      }
69  
70      public boolean isId() {
71          throw operationNotSupported();
72      }
73  
74      // end DOM level 3
75  
76      // End Proxied Attr methods
77  
78      public String toString() {
79          return "ProxyAttribute for: " + attr();
80      }
81  }
82