1 28 29 package com.idaremedia.antx.condition; 30 31 import java.util.Iterator ; 32 import java.util.List ; 33 import java.util.Map ; 34 import java.util.NoSuchElementException ; 35 36 import com.idaremedia.antx.AntX; 37 import com.idaremedia.antx.ownhelpers.InnerProperties; 38 import com.idaremedia.antx.ownhelpers.ProjectDependentSkeleton; 39 import com.idaremedia.antx.ownhelpers.PropertiesIterator; 40 import com.idaremedia.antx.ownhelpers.UnresolvedProperty; 41 42 56 57 public final class FlexIncludesIterator extends ProjectDependentSkeleton 58 implements Iterator 59 { 60 private static final String IAM_ = AntX.conditions+"FlexIncludesIterator:"; 61 62 63 68 public FlexIncludesIterator(FlexOuterCondition owner) 69 { 70 AntX.require_(owner!=null,IAM_,"ctor- nonzro owning set"); 71 m_owner = owner; 72 m_scratchFV = new ExternalPropertyDef(); 73 } 74 75 76 81 private boolean prepareToIterate() 82 { 83 List l= m_owner.getIncludes(); 84 if (l.isEmpty()) { 85 return false; } 87 88 setProject(m_owner.getProject()); 89 m_scratchFV.setProject(getProjectNoNull()); 90 m_scratchFV.setTrim(m_owner.willTrim()); 91 m_includesItr = l.iterator(); 92 return true; 93 } 94 95 96 100 public boolean hasNext() 101 { 102 if (m_includesItr==null) { 103 if (!prepareToIterate()) { 104 return false; 105 } 106 } 107 108 boolean gotOne = (m_nextItem!=null); 109 110 if (!gotOne) { 111 if (m_innerItr!=null) { 112 if (m_innerItr.hasNext()) { 113 Map.Entry entry= (Map.Entry )m_innerItr.next(); 114 m_scratchFV.set(entry); 115 m_nextItem = m_scratchFV; 116 return true; 117 } 118 m_innerItr.dispose(); 119 m_innerItr = null; 120 if (m_privateCall) { 121 return false; 122 } 123 } 124 while (m_includesItr.hasNext()) { 125 Object candidate = m_includesItr.next(); 126 127 if (candidate instanceof InnerProperties) { 128 m_innerItr = new PropertiesIterator((InnerProperties)candidate); 129 m_innerItr.setCheckBrokenSubstitution(); 130 m_innerItr.setBrokenSubstitutionProxy(UnresolvedProperty.VALUE); 131 m_privateCall=true; 132 gotOne = hasNext(); m_privateCall=false; 134 if (gotOne) { 135 return true; 136 } 137 candidate = null; 138 } 139 140 if (candidate!=null) { 141 m_nextItem = candidate; 142 gotOne = true; 143 break; 144 } 145 } 146 } 147 148 return gotOne; 149 } 150 151 152 158 public Object next() 159 { 160 if (m_nextItem==null) { 161 throw new NoSuchElementException (); 162 } 163 Object result = m_nextItem; 164 m_nextItem = null; 165 return result; 166 } 167 168 169 174 public void remove() 175 { 176 throw new UnsupportedOperationException (); 177 } 178 179 180 181 private final FlexOuterCondition m_owner; 182 private Iterator m_includesItr; 183 private PropertiesIterator m_innerItr; 184 private Object m_nextItem; 185 private final ExternalPropertyDef m_scratchFV; 186 private boolean m_privateCall; 187 } 188 189 190 | Popular Tags |