Returns an iterator over the chained SQLExceptions.  The iterator will
be used to iterate over each SQLException and its underlying cause
(if any).

@return an iterator over the chained SQLExceptions and causes in the proper
order

@since 1.6
328253
public Iterator<Throwable> iterator() {

       return new Iterator<Throwable>() {

           SQLException firstException = SQLException.this;
           SQLException nextException = firstException.getNextException();
           Throwable cause = firstException.getCause();

           public boolean hasNext() {
               if(firstException != null || nextException != null || cause != null)
                   return true;
               return false;
           }

           public Throwable next() {
               Throwable throwable = null;
               if(firstException != null){
                   throwable = firstException;
                   firstException = null;
               }
               else if(cause != null){
                   throwable = cause;
                   cause = cause.getCause();
               }
               else if(nextException != null){
                   throwable = nextException;
                   cause = nextException.getCause();
                   nextException = nextException.getNextException();
               }
               else
                   throw new NoSuchElementException();
               return throwable;
           }

           public void remove() {
               throw new UnsupportedOperationException();
           }

       };

    }
941466
public static Throwable getNextThrowable(Throwable t) {

        Throwable nextThrowable = null;
        if (t != null) {

            // try getCause first.
            nextThrowable = t.getCause();

            if (nextThrowable == null) {
                // if getCause returns null, look for the JDBC and JCA specific chained exceptions
                // in case the resource adapter or database has not implemented getCause and initCause yet.
                if (t instanceof SQLException) {
                    nextThrowable = ((SQLException) t).getNextException();
                }

                else if (t instanceof ResourceException) {
                    nextThrowable = ((ResourceException) t).getCause(); 
                }
            }
        }
        return nextThrowable;
    }
206622
public TypeDesc[] getExceptions() {
        if (mExceptions == null) {
            return new TypeDesc[0];
        }

        ConstantClassInfo[] classes = mExceptions.getExceptions();
        TypeDesc[] types = new TypeDesc[classes.length];
        for (int i=0; i<types.length; i++) {
            types[i] = classes[i].getType();
        }

        return types;
    }
355520
public Class getExceptionClass()
    {
    	Class exceptionClass = null;
        Throwable rootCause = this;
        
        do{
            Throwable temp = ((ServletException)rootCause).getRootCause();
            if(temp != null) {
                rootCause = temp;
            }
            else{
                break;
            }
        }while (rootCause instanceof ServletException);

        // rootCause must be non-null (it started as "this" and was then NEVER set to null by the loop above
        exceptionClass = rootCause.getClass();

        return exceptionClass;
    }
643598
public Iterator<Stream> iterator() throws SIResourceException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(this, tc, "iterator");
      
    List<Stream> streams = new ArrayList<Stream>();
    for (int j = 0; j < maxReliabilityIndex + 1; j++)
    {
      ReliabilitySubset subset = getSubset(getReliability(j));
      if(subset != null)
      {
        for (int i = 0; i < SIMPConstants.MSG_HIGH_PRIORITY + 1; i++)
        {      
          Stream stream = subset.getStream(i);
          if (stream != null)
            streams.add(stream);
        }
      }
    }
    
    Iterator<Stream> itr = streams.iterator();
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "iterator", itr);
    
    return itr;
  }
577346
@Nonnull
    public Iterator<Long> iterator() {
        return new Iterator<Long>() {
            private long base2 = base;
            private int remaining = batchSize;

            @Override
            public boolean hasNext() {
                return remaining > 0;
            }

            @Override
            public Long next() {
                if (remaining == 0) {
                    throw new NoSuchElementException();
                }
                remaining--;
                try {
                    return base2;
                } finally {
                    base2 += increment;
                }
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }
826190
protected function get_iterator() {
        global $DB;

        // Build the SQL dynamically here
        $fieldslist = 't.' . implode(', t.', $this->fields);
        $sql = "SELECT t.id, $fieldslist
                  FROM {" . $this->tablename . "} t
                  JOIN {backup_ids_temp} b ON b.newitemid = t.id
                 WHERE b.backupid = ?
                   AND b.itemname = ?
                   AND t.blockname = 'html'";
        $params = array($this->restoreid, $this->mapping);
        return ($DB->get_recordset_sql($sql, $params));
    }
224435
public Iterator iterator() {
        return new Iterator() {
            private LeftTupleSinkNode currentNode = null;
            private LeftTupleSinkNode nextNode    = getFirst();

            public boolean hasNext() {
                return (this.nextNode != null);
            }

            public Object next() {
                this.currentNode = this.nextNode;
                if ( this.currentNode != null ) {
                    this.nextNode = this.currentNode.getNextLeftTupleSinkNode();
                } else {
                    throw new NoSuchElementException( "No more elements to return" );
                }
                return this.currentNode;
            }

            public void remove() {
                if ( this.currentNode != null ) {
                    LeftTupleSinkNodeList.this.remove( this.currentNode );
                    this.currentNode = null;
                } else {
                    throw new IllegalStateException( "No item to remove. Call next() before calling remove()." );
                }
            }
        };
    }
1146826
public DataSetIterator getTrainIterator() {
        return new DataSetIterator() {
            @Override
            public DataSet next(int i) {
                throw new UnsupportedOperationException();
            }

            @Override
            public List<String> getLabels() {
                return backedIterator.getLabels();
            }

            @Override
            public int inputColumns() {
                return backedIterator.inputColumns();
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException();
            }

            @Override
            public int totalOutcomes() {
                return backedIterator.totalOutcomes();
            }

            @Override
            public boolean resetSupported() {
                return backedIterator.resetSupported();
            }

            @Override
            public boolean asyncSupported() {
                return backedIterator.asyncSupported();
            }

            @Override
            public void reset() {
                resetPending.set(true);
            }

            @Override
            public int batch() {
                return backedIterator.batch();
            }

            @Override
            public void setPreProcessor(DataSetPreProcessor dataSetPreProcessor) {
                backedIterator.setPreProcessor(dataSetPreProcessor);
            }

            @Override
            public DataSetPreProcessor getPreProcessor() {
                return backedIterator.getPreProcessor();
            }


            @Override
            public boolean hasNext() {
                if (resetPending.get()) {
                    if (resetSupported()) {
                        backedIterator.reset();
                        counter.set(0);
                        resetPending.set(false);
                    } else
                        throw new UnsupportedOperationException("Reset isn't supported by underlying iterator");
                }

                val state = backedIterator.hasNext();
                if (state && counter.get() < numTrain)
                    return true;
                else
                    return false;
            }

            @Override
            public DataSet next() {
                counter.incrementAndGet();
                val p = backedIterator.next();

                if (counter.get() == 1 && firstTrain == null) {
                    // first epoch ever, we'll save first dataset and will use it to check for equality later
                    firstTrain =  p.copy();
                    firstTrain.detach();
                } else if (counter.get() == 1) {
                    // epoch > 1, comparing first dataset to previously stored dataset. they should be equal
                    int cnt = 0;
                    if (!p.getFeatures().equalsWithEps(firstTrain.getFeatures(), 1e-5))
                        throw new ND4JIllegalStateException("First examples do not match. Randomization was used?");
                }

                return p;
            }
        };
    }
486782
@Override
    public Iterator<String> iterator() {
        this.reset();
        Iterator<String> ret = new Iterator<String>() {
            @Override
            public boolean hasNext() {
                return BasicLineIterator.this.hasNext();
            }

            @Override
            public String next() {
                return BasicLineIterator.this.nextSentence();
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException();
            }
        };

        return ret;
    }
1065810
public java.util.ArrayList getExceptions() {
        if (exceptions != null)
            return (java.util.ArrayList) exceptions.clone();
        else
            return null;
    }
1008027
public Connection getConnection() throws SQLException {
    try {
      if (pool == null) {
        initialize();
      }
      return pool.getConnection();
    } catch (SQLException e) {
      throw ExceptionMapper.getException(e, null, null, false);
    }
  }
850094
public static <E> Iterator<E> get() {
		@SuppressWarnings("unchecked")
		Iterator<E> iter = (Iterator<E>) INSTANCE;
		return iter;
	}
810830
public int[] executeBatch() throws SQLException {
        final boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
        SQLExecuteCallback<int[]> callback = new SQLExecuteCallback<int[]>(getDatabaseType(), isExceptionThrown) {
            
            @Override
            protected int[] executeSQL(final RouteUnit routeUnit, final Statement statement, final ConnectionMode connectionMode) throws SQLException {
                return statement.executeBatch();
            }
        };
        List<int[]> results = executeCallback(callback);
        if (isAccumulate()) {
            return accumulate(results);
        } else {
            return results.get(0);
        }
    }
802244
public Iterator<Example> iterator()
    {
        return new Iterator<Example>()
        {
            private int index = 0;

            public boolean hasNext()
            {
                return at( index ) != null;
            }

            public Example next()
            {
                return at( index++ );
            }

            public void remove()
            {
                throw new UnsupportedOperationException( "Specification not mutable" );
            }
        };
    }
133432
public boolean isAnAuthorizationException(SQLException x) {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(this, tc, "isAnAuthorizationException", x);

        boolean isAuthError = false;
        LinkedList<SQLException> stack = new LinkedList<SQLException>();
        if (x != null) 
            stack.push(x);

        // Limit the chain depth so that poorly written exceptions don't cause an infinite loop.
        for (int depth = 0; depth < 20 && !isAuthError && !stack.isEmpty(); depth++) {
            x = stack.pop();

            isAuthError |= isAuthException(x);

            // Add the chained exceptions to the stack.

            if (x.getNextException() != null)
                stack.push(x.getNextException());
            if (x.getCause() instanceof SQLException && x.getCause() != x.getNextException())
                stack.push((SQLException) x.getCause());
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(this, tc, "isAnAuthorizationException", isAuthError);
        return isAuthError;
    }
412886
public Iterator<A> iterator() {
        return new Iterator<A>() {
            List<A> elems = ListBuffer.this.elems;
            public boolean hasNext() {
                return !elems.isEmpty();
            }
            public A next() {
                if (elems.isEmpty())
                    throw new NoSuchElementException();
                A elem = elems.head;
                elems = elems.tail;
                return elem;
            }
            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }