View Javadoc

1   /*
2    * $Id: ProxyAttrAdapter.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 org.w3c.dom.Attr;
24  import org.w3c.dom.DOMException;
25  import org.w3c.dom.Element;
26  import org.w3c.dom.TypeInfo;
27  
28  /***
29   * ProxyAttrAdapter is a pass-through adapter for objects which already
30   * implement the Attr interface.  All methods are proxied to the underlying
31   * Node except node traversal (e.g. getParent()) related methods which
32   * are implemented by the abstract adapter node to work with the parent adapter.
33   */
34  public class ProxyAttrAdapter extends ProxyNodeAdapter implements Attr {
35  
36      public ProxyAttrAdapter(AdapterFactory factory, AdapterNode parent, Attr value) {
37          super(factory, parent, value);
38      }
39  
40      // convenience
41      protected Attr attr() {
42          return (Attr) getPropertyValue();
43      }
44  
45      // Proxied Attr methods
46  
47      public String getName() {
48          return attr().getName();
49      }
50  
51      public boolean getSpecified() {
52          return attr().getSpecified();
53      }
54  
55      public String getValue() {
56          return attr().getValue();
57      }
58  
59      public void setValue(String string) throws DOMException {
60          throw new UnsupportedOperationException();
61      }
62  
63      public Element getOwnerElement() {
64          return (Element) getParent();
65      }
66  
67      // DOM level 3
68  
69      public TypeInfo getSchemaTypeInfo() {
70          throw operationNotSupported();
71      }
72  
73      public boolean isId() {
74          throw operationNotSupported();
75      }
76  
77      // end DOM level 3
78  
79      // End Proxied Attr methods
80  
81      public String toString() {
82          return "ProxyAttribute for: " + attr();
83      }
84  }
85