1 19 20 package org.netbeans.modules.form.codestructure; 21 22 import java.util.Iterator ; 23 24 31 32 abstract class AbstractCodeStatement implements CodeStatement { 33 34 protected CodeExpression parentExpression; 35 36 protected AbstractCodeStatement(CodeExpression parentExpression) { 37 this.parentExpression = parentExpression; 38 } 39 40 public CodeExpression getParentExpression() { 41 return parentExpression; 42 } 43 44 47 public void usageRegistered(UsedCodeObject usedObject) { 49 } 50 51 public boolean usedObjectRemoved(UsedCodeObject usedObject) { 53 return false; 54 } 55 56 public UsedCodeObject getDefiningObject() { 57 return getParentExpression(); 58 } 59 60 public Iterator getUsedObjectsIterator() { 61 return new UsedObjectsIterator(); 62 } 63 64 66 private class UsedObjectsIterator implements Iterator { 67 int index; 68 CodeExpression[] parameters; 69 70 UsedObjectsIterator() { 71 index = getParentExpression() != null ? -1 : 0; 72 parameters = getStatementParameters(); 73 if (parameters == null) 74 parameters = CodeStructure.EMPTY_PARAMS; 75 } 76 77 public boolean hasNext() { 78 return index < parameters.length; 79 } 80 81 public Object next() { 82 if (!hasNext()) 83 throw new java.util.NoSuchElementException (); 84 85 Object obj = index > -1 ? parameters[index] : getParentExpression(); 86 index++; 87 return obj; 88 } 89 90 public void remove() { 91 throw new UnsupportedOperationException (); 92 } 93 } 94 } 95 | Popular Tags |