1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.jxpath.ri.model.beans;
19
20 import org.apache.commons.jxpath.ri.QName;
21 import org.apache.commons.jxpath.ri.model.NodePointer;
22
23
24
25
26 public class BeanAttributeIterator extends PropertyIterator {
27
28 private final NodePointer parent;
29 private int position;
30 private final boolean includeXmlLang;
31
32
33
34
35
36
37
38 public BeanAttributeIterator(final PropertyOwnerPointer parent, final QName qName) {
39 super(parent, qName.getPrefix() == null && (qName.getName() == null || qName.getName().equals("*")) ? null : qName.toString(), false, null);
40 this.parent = parent;
41 includeXmlLang = qName.getPrefix() != null && qName.getPrefix().equals("xml") && (qName.getName().equals("lang") || qName.getName().equals("*"));
42 }
43
44 @Override
45 public NodePointer getNodePointer() {
46 return includeXmlLang && position == 1 ? new LangAttributePointer(parent) : super.getNodePointer();
47 }
48
49 @Override
50 public int getPosition() {
51 return position;
52 }
53
54 @Override
55 public boolean setPosition(final int position) {
56 this.position = position;
57 if (includeXmlLang) {
58 return position == 1 || super.setPosition(position - 1);
59 }
60 return super.setPosition(position);
61 }
62 }