1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.jxpath.ri.model.beans;
18
19 import org.apache.commons.jxpath.ri.QName;
20 import org.apache.commons.jxpath.ri.compiler.NodeTest;
21 import org.apache.commons.jxpath.ri.model.NodePointer;
22
23
24
25
26
27
28
29
30 public class LangAttributePointer extends NodePointer {
31
32 private static final long serialVersionUID = -8665319197100034134L;
33
34
35
36
37
38 public LangAttributePointer(NodePointer parent) {
39 super(parent);
40 }
41
42 public QName getName() {
43 return new QName("xml", "lang");
44 }
45
46 public String getNamespaceURI() {
47 return null;
48 }
49
50 public boolean isCollection() {
51 return false;
52 }
53
54 public int getLength() {
55 return 1;
56 }
57
58 public Object getBaseValue() {
59 return parent.getLocale().toString().replace('_', '-');
60 }
61
62 public Object getImmediateNode() {
63 return getBaseValue();
64 }
65
66 public boolean isLeaf() {
67 return true;
68 }
69
70
71
72
73
74
75
76 public void setValue(Object value) {
77 throw new UnsupportedOperationException(
78 "Cannot change locale using the 'lang' attribute");
79 }
80
81 public String asPath() {
82 StringBuffer buffer = new StringBuffer();
83 if (parent != null) {
84 buffer.append(parent.asPath());
85 if (buffer.length() == 0
86 || buffer.charAt(buffer.length() - 1) != '/') {
87 buffer.append('/');
88 }
89 }
90 buffer.append("@xml:lang");
91 return buffer.toString();
92 }
93
94 public int hashCode() {
95 return 0;
96 }
97
98 public boolean equals(Object object) {
99 return object instanceof LangAttributePointer;
100 }
101
102 public boolean testNode(NodeTest test) {
103 return false;
104 }
105
106 public int compareChildNodePointers(
107 NodePointer pointer1,
108 NodePointer pointer2) {
109
110 return 0;
111 }
112 }