1 4 package com.tc.config.schema.repository; 5 6 import org.apache.xmlbeans.XmlObject; 7 8 import java.util.ArrayList ; 9 import java.util.List ; 10 11 14 public class MockChildBeanFetcher implements ChildBeanFetcher { 15 16 private int numGetChilds; 17 private XmlObject[] returnedChildren; 18 private int returnedChildrenPos; 19 private List lastParents; 20 21 public MockChildBeanFetcher() { 22 this.returnedChildren = new XmlObject[] { null }; 23 this.lastParents = new ArrayList (); 24 25 reset(); 26 } 27 28 public void reset() { 29 this.numGetChilds = 0; 30 this.returnedChildrenPos = 0; 31 this.lastParents.clear(); 32 } 33 34 public XmlObject getChild(XmlObject parent) { 35 ++this.numGetChilds; 36 this.lastParents.add(parent); 37 XmlObject out = this.returnedChildren[this.returnedChildrenPos++]; 38 if (this.returnedChildrenPos >= this.returnedChildren.length) this.returnedChildrenPos = 0; 39 return out; 40 } 41 42 public XmlObject getLastParent() { 43 return (XmlObject) this.lastParents.get(this.lastParents.size() - 1); 44 } 45 46 public XmlObject[] getLastParents() { 47 return (XmlObject[]) this.lastParents.toArray(new XmlObject[this.lastParents.size()]); 48 } 49 50 public int getNumGetChilds() { 51 return numGetChilds; 52 } 53 54 public void setReturnedChild(XmlObject returnedChild) { 55 setReturnedChildren(new XmlObject[] { returnedChild }); 56 } 57 58 public void setReturnedChildren(XmlObject[] returnedChildren) { 59 this.returnedChildren = returnedChildren; 60 } 61 62 } 63 | Popular Tags |