1 package org.apache.maven.project.harness;
2
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 import java.util.Map;
23
24 import org.apache.commons.jxpath.ri.QName;
25 import org.apache.commons.jxpath.ri.model.NodePointer;
26
27 /**
28 * An attribute pointer for JXPath to support <code>Xpp3Dom</code>.
29 *
30 * @author Benjamin Bentmann
31 */
32 class Xpp3DomAttributePointer
33 extends NodePointer
34 {
35
36 private Map.Entry<String, String> attrib;
37
38 public Xpp3DomAttributePointer( NodePointer parent, Map.Entry<String, String> attrib )
39 {
40 super( parent );
41 this.attrib = attrib;
42 }
43
44 @Override
45 public int compareChildNodePointers( NodePointer pointer1, NodePointer pointer2 )
46 {
47 // should never happen because attributes have no children
48 return 0;
49 }
50
51 @Override
52 public Object getValue()
53 {
54 return attrib.getValue();
55 }
56
57 @Override
58 public Object getBaseValue()
59 {
60 return attrib;
61 }
62
63 @Override
64 public Object getImmediateNode()
65 {
66 return attrib;
67 }
68
69 @Override
70 public int getLength()
71 {
72 return 1;
73 }
74
75 @Override
76 public QName getName()
77 {
78 return new QName( null, attrib.getKey() );
79 }
80
81 @Override
82 public boolean isActual()
83 {
84 return true;
85 }
86
87 @Override
88 public boolean isCollection()
89 {
90 return false;
91 }
92
93 @Override
94 public boolean isLeaf()
95 {
96 return true;
97 }
98
99 @Override
100 public void setValue( Object value )
101 {
102 throw new UnsupportedOperationException();
103 }
104
105 }