1 6 7 package com.hp.hpl.jena.rdql; 8 9 import java.util.Iterator ; 10 11 12 13 16 17 public class ResultBindingIterator implements Iterator 18 { 19 boolean active ; 20 boolean doneThisOne ; 21 ResultBindingImpl binding ; 22 int i ; 23 24 ResultBindingIterator(ResultBindingImpl _binding) 25 { 26 binding = _binding ; 27 i = -1 ; 29 doneThisOne = true ; 31 active = true ; 32 } 33 34 public boolean hasNext() 35 { 36 if ( doneThisOne ) 37 advance() ; 38 return active ; 39 } 40 41 public Object next() 42 { 43 advance() ; 44 doneThisOne = true ; 45 return binding.varNames.get(i) ; 46 } 47 48 public String varName() 49 { 50 if ( ! active ) 51 return null ; 52 return (String )binding.varNames.get(i) ; 53 } 54 55 62 public void remove() { throw new java.lang.UnsupportedOperationException ("ResultsBindingIterator.remove") ; } 63 64 private boolean advance() 65 { 66 if ( ! active ) 67 return false ; 68 if ( ! doneThisOne ) 70 return true ; 71 i++ ; 72 if ( i >= binding.varNames.size() ) 73 { 74 i = -1 ; 75 binding = binding.parent ; 76 doneThisOne = true ; 77 if ( binding == null ) 78 { 79 active = false ; 80 return active ; 81 } 82 return advance() ; 84 } 85 doneThisOne = false ; 86 return active ; 88 } 89 } 90 | Popular Tags |