1 16 package org.apache.commons.jxpath.ri.model.beans; 17 18 import org.apache.commons.jxpath.ri.QName; 19 import org.apache.commons.jxpath.ri.model.NodePointer; 20 21 28 public class BeanAttributeIterator extends PropertyIterator { 29 private NodePointer parent; 30 private int position = 0; 31 private boolean includeXmlLang; 32 33 public BeanAttributeIterator(PropertyOwnerPointer parent, QName name) { 34 super( 35 parent, 36 (name.getPrefix() == null 37 && (name.getName() == null || name.getName().equals("*"))) 38 ? null 39 : name.toString(), 40 false, 41 null); 42 this.parent = parent; 43 includeXmlLang = 44 (name.getPrefix() != null && name.getPrefix().equals("xml")) 45 && (name.getName().equals("lang") 46 || name.getName().equals("*")); 47 } 48 49 public NodePointer getNodePointer() { 50 if (includeXmlLang && position == 1) { 51 return new LangAttributePointer(parent); 52 } 53 else { 54 return super.getNodePointer(); 55 } 56 } 57 58 public int getPosition() { 59 return position; 60 } 61 62 public boolean setPosition(int position) { 63 this.position = position; 64 if (includeXmlLang) { 65 if (position == 1) { 66 return true; 67 } 68 else { 69 return super.setPosition(position - 1); 70 } 71 } 72 else { 73 this.position = position; 74 return super.setPosition(position); 75 } 76 } 77 } | Popular Tags |