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.model.NodePointer;
21
22
23
24
25
26
27
28
29 public class BeanAttributeIterator extends PropertyIterator {
30 private NodePointer parent;
31 private int position = 0;
32 private boolean includeXmlLang;
33
34
35
36
37
38
39 public BeanAttributeIterator(PropertyOwnerPointer parent, QName name) {
40 super(
41 parent,
42 (name.getPrefix() == null
43 && (name.getName() == null || name.getName().equals("*")))
44 ? null
45 : name.toString(),
46 false,
47 null);
48 this.parent = parent;
49 includeXmlLang =
50 (name.getPrefix() != null && name.getPrefix().equals("xml"))
51 && (name.getName().equals("lang")
52 || name.getName().equals("*"));
53 }
54
55 public NodePointer getNodePointer() {
56 return includeXmlLang && position == 1 ? new LangAttributePointer(parent) : super.getNodePointer();
57 }
58
59 public int getPosition() {
60 return position;
61 }
62
63 public boolean setPosition(int position) {
64 this.position = position;
65 if (includeXmlLang) {
66 return position == 1 || super.setPosition(position - 1);
67 }
68 return super.setPosition(position);
69 }
70 }