Package java.util

Examples of java.util.ListIterator


     // ****************************************************
     // Disable all foreign key constraint before proceeding

     LinkedList oConstraints = listConstraints(jCon2);

     ListIterator oIter;
     Constraint oCons;
     String sSQL = null;

     try {

       oStmt = oConn.createStatement();

       oIter = oConstraints.listIterator();

       while (oIter.hasNext()) {
         oCons = (Constraint) oIter.next();

         switch (iDbms) {
           case DBMS_MSSQL:
             sSQL = "ALTER TABLE " + oCons.tablename + " NOCHECK CONSTRAINT " + oCons.constraintname;
             break;
           case DBMS_POSTGRESQL:
             sSQL = "UPDATE pg_class SET reltriggers=0 WHERE relname = '" + oCons.tablename + "'";
             break;
           case DBMS_ORACLE:
             sSQL = "ALTER TABLE " + oCons.tablename + " DISABLE CONSTRAINT " + oCons.constraintname;
             break;
         }

         if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");

         oStmt.execute(sSQL);
       } // wend
       oStmt.close();
       sSQL = null;
     }
     catch (SQLException sqle) {
       DebugFile.writeln("SQLException: " + sqle.getMessage() + " " + sSQL + "\n");
       iErrors++;
       if (null!=oStrLog) oStrLog.append("SQLException: " + sqle.getMessage() + " " + sSQL + "\n");
     }

     // ********************************************
     // Copy data from 1.x version datamodel to v2.0

     com.knowgate.datacopy.CopyRegisters oCopy = new com.knowgate.datacopy.CopyRegisters(oProps.getProperty("schema1"), jCon1.getCatalog());

     for (int t=0; t<iTables; t++) {
       try {
         if (DBMS_ORACLE==iDbms) sTables[t] = sTables[t].toUpperCase();

         int iAppended = oCopy.append (jCon1, jCon2, sTables[t], sTables[t], null);

         if (null!=oStrLog) oStrLog.append(String.valueOf(iAppended) + " registers appended or updated at table " + sTables[t] + "\n");
       }
       catch (SQLException sqle) {
         DebugFile.writeln("SQLException: CopyRegisters.append(" + sTables[t] + ") " + sqle.getMessage() + "\n");
         DebugFile.decIdent();
         iErrors++;
         if (null!=oStrLog) oStrLog.append("SQLException: CopyRegisters.append(" + sTables[t] + ") " + sqle.getMessage() + " " + "\n");
       }
     } // next (t)

     // ************************************
     // Additional tables witout primary key

     PreparedStatement oWrtStm;
     Statement oReadStm;
     ResultSet oReadSet;

     oWrtStm = jCon2.prepareStatement("INSERT INTO k_cat_expand (gu_rootcat,gu_category,od_level,od_walk,gu_parent_cat) VALUES (?,?,?,?,?)");

     oReadStm = jCon1.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
     oReadSet = oReadStm.executeQuery("SELECT gu_rootcat,gu_category,od_level,od_walk,gu_parent_cat FROM k_cat_expand");

     while (oReadSet.next()) {
       oWrtStm.setObject(1, oReadSet.getObject(1));
       oWrtStm.setObject(2, oReadSet.getObject(2));
       oWrtStm.setObject(3, oReadSet.getObject(3));
       oWrtStm.setObject(4, oReadSet.getObject(4));
       oWrtStm.setObject(5, oReadSet.getObject(5));
       oWrtStm.executeUpdate();
     } // wend

     oReadSet.close();
     oReadStm.close();
     oWrtStm.close();

     oWrtStm = jCon2.prepareStatement("INSERT INTO k_project_expand (gu_rootprj,gu_project,nm_project,od_level,od_walk,gu_parent) VALUES (?,?,?,?,?,?)");

     oReadStm = jCon1.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
     oReadSet = oReadStm.executeQuery("SELECT gu_rootprj,gu_project,nm_project,od_level,od_walk,gu_parent FROM k_project_expand");

     while (oReadSet.next()) {
       oWrtStm.setObject(1, oReadSet.getObject(1));
       oWrtStm.setObject(2, oReadSet.getObject(2));
       oWrtStm.setObject(3, oReadSet.getObject(3));
       oWrtStm.setObject(4, oReadSet.getObject(4));
       oWrtStm.setObject(5, oReadSet.getObject(5));
       oWrtStm.setObject(6, oReadSet.getObject(6));
       oWrtStm.executeUpdate();
     } // wend

     oReadSet.close();
     oReadStm.close();
     oWrtStm.close();

     oWrtStm = jCon2.prepareStatement("INSERT INTO k_x_list_members (gu_list,tx_email,tx_name,tx_surname,tx_salutation,bo_active,dt_created,tp_member,gu_company,gu_contact,id_format,dt_modified) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)");

     oReadStm = jCon1.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
     oReadSet = oReadStm.executeQuery("SELECT gu_list,tx_email,tx_name,tx_surname,tx_salutation,bo_active,dt_created,tp_member,gu_company,gu_contact,id_format,dt_modified FROM k_x_list_members");

     while (oReadSet.next()) {
       oWrtStm.setObject(1, oReadSet.getObject(1));
       oWrtStm.setObject(2, oReadSet.getObject(2));
       oWrtStm.setObject(3, oReadSet.getObject(3));
       oWrtStm.setObject(4, oReadSet.getObject(4));
       oWrtStm.setObject(5, oReadSet.getObject(5));
       oWrtStm.setObject(6, oReadSet.getObject(6));
       oWrtStm.setObject(7, oReadSet.getObject(7));
       oWrtStm.setObject(8, oReadSet.getObject(8));
       oWrtStm.setObject(9, oReadSet.getObject(9));
       oWrtStm.setObject(10, oReadSet.getObject(10));
       oWrtStm.setObject(11, oReadSet.getObject(11));
       oWrtStm.setObject(12, oReadSet.getObject(12));
       oWrtStm.executeUpdate();
     } // wend

     oReadSet.close();
     oReadStm.close();
     oWrtStm.close();

     // **************************************************
     // Enable all foreign key constraint after processing

     try {

       oStmt = oConn.createStatement();

       oIter = oConstraints.listIterator();

       while (oIter.hasNext()) {
         oCons = (Constraint) oIter.next();

         switch (iDbms) {
           case DBMS_MSSQL:
             sSQL = "ALTER TABLE " + oCons.tablename + " CHECK CONSTRAINT " + oCons.constraintname;
             break;
View Full Code Here


   * @throws SQLException
   */
  public DespatchAdvice createDespatchAdvice(JDCConnection oConn,
                                         boolean bIncludePrices) throws SQLException {
    DespatchAdvice oDispatch = new DespatchAdvice();
    ListIterator oIter = oDispatch.getTable(oConn).getColumns().listIterator();
    if (bIncludePrices) {
      while (oIter.hasNext()) {
        String sKey = ((DBColumn) oIter.next()).getName();
        if (!isNull(sKey)) oDispatch.put(sKey, get(sKey));
      } // wend
    } else {
      while (oIter.hasNext()) {
        String sKey = (String) oIter.next();
        if (!sKey.equalsIgnoreCase(DB.im_subtotal) && !sKey.equalsIgnoreCase(DB.im_taxes) &&
            !sKey.equalsIgnoreCase(DB.im_shipping) && !sKey.equalsIgnoreCase(DB.im_total) &&
            !sKey.equalsIgnoreCase(DB.im_discount)) {
          if (!isNull(sKey)) oDispatch.put(sKey, get(sKey));
        }
View Full Code Here

   */
  public void registerCallback(WorkerThreadCallback oNewCallback)
    throws IllegalArgumentException {

    WorkerThreadCallback oCallback;
    ListIterator oIter = oCallbacks.listIterator();

    while (oIter.hasNext()) {
      oCallback = (WorkerThreadCallback) oIter.next();

      if (oCallback.name().equals(oNewCallback.name())) {
        throw new IllegalArgumentException("Callback " + oNewCallback.name() + " is already registered");
      } // fi
    } // wend
View Full Code Here

   * @return <b>true</b> if a callback with such name was found and unregistered,
   * <b>false</b> otherwise
   */
  public boolean unregisterCallback(String sCallbackName) {
    WorkerThreadCallback oCallback;
    ListIterator oIter = oCallbacks.listIterator();

    while (oIter.hasNext()) {
      oCallback = (WorkerThreadCallback) oIter.next();

      if (oCallback.name().equals(sCallbackName)) {
        oIter.remove();
        iCallbacks--;
        return true;
      } // fi
    } // wend

View Full Code Here

      DebugFile.writeln("Begin Order.createInvoice([Connection])");
      DebugFile.incIdent();
    }
    String sSQL;
    Invoice oInvoice = new Invoice();
    ListIterator oIter = oInvoice.getTable(oConn).getColumns().listIterator();
    while (oIter.hasNext()) {
      String sKey = ((DBColumn) oIter.next()).getName();
      if (!isNull(sKey)) {
        if (DebugFile.trace) DebugFile.writeln("Invoice.put("+sKey+","+get(sKey)+")");
        oInvoice.put(sKey, get(sKey));
      }
    } // wend
View Full Code Here

  // ---------------------------------------------------------------------------

  private void callBack(int iOpCode, String sMessage, Exception oXcpt, Object oParam) {
    WorkerThreadCallback oCallback;
    ListIterator oIter = oCallbacks.listIterator();

    while (oIter.hasNext()) {
      oCallback = (WorkerThreadCallback) oIter.next();
      oCallback.call(getName(), iOpCode, sMessage, oXcpt, oParam);
    } // wend

  }
View Full Code Here

                         new Object[] {after, String.valueOf(untilFocused)});
        }

        int insertionIndex = 0,
            i = typeAheadMarkers.size();
        ListIterator iter = typeAheadMarkers.listIterator(i);

        for (; i > 0; i--) {
            TypeAheadMarker marker = (TypeAheadMarker)iter.previous();
            if (marker.after <= after) {
                insertionIndex = i;
                break;
            }
        }
View Full Code Here

            focusLog.log(Level.FINER, "Dequeue at {0} for {1}",
                         new Object[] {after, String.valueOf(untilFocused)});
        }

        TypeAheadMarker marker;
        ListIterator iter = typeAheadMarkers.listIterator
            ((after >= 0) ? typeAheadMarkers.size() : 0);

        if (after < 0) {
            while (iter.hasNext()) {
                marker = (TypeAheadMarker)iter.next();
                if (marker.untilFocused == untilFocused)
                {
                    iter.remove();
                    return;
                }
            }
        } else {
            while (iter.hasPrevious()) {
                marker = (TypeAheadMarker)iter.previous();
                if (marker.untilFocused == untilFocused &&
                    marker.after == after)
                {
                    iter.remove();
                    return;
                }
            }
        }
    }
View Full Code Here

           break;
         }
         parent=(Element)n;
       }
       //Visit them in reverse order.
       ListIterator it=parents.listIterator(parents.size());
       while (it.hasPrevious()) {
       Element ele=(Element)it.previous();
        if (!ele.hasAttributes()) {
          continue;
        }
    NamedNodeMap attrs = ele.getAttributes();
       int attrsLength = attrs.getLength();
View Full Code Here

      list.addLast(w, 1);
      list.addLast(x, 1);
      list.addLast(y, 0);
      list.addLast(z, 0);
     
      ListIterator iter = list.iterator();
     
      int c = 0;
      while (iter.hasNext())
      {
         Wibble w = (Wibble)iter.next();
         c++;
      }     
      assertEquals(c, 26);
     
      iter = list.iterator();
      assertTrue(iter.hasNext());
      Wibble w = (Wibble)iter.next();
      assertEquals("a", w.s);     
      w = (Wibble)iter.next();
      assertEquals("b", w.s);
      w = (Wibble)iter.next();
      assertEquals("c", w.s);
      w = (Wibble)iter.next();
      assertEquals("d", w.s);
      w = (Wibble)iter.next();
      assertEquals("e", w.s);
      w = (Wibble)iter.next();
      assertEquals("f", w.s);
      w = (Wibble)iter.next();
      assertEquals("g", w.s);
      w = (Wibble)iter.next();
      assertEquals("h", w.s);
      w = (Wibble)iter.next();
      assertEquals("i", w.s);
      w = (Wibble)iter.next();
      assertEquals("j", w.s);
      w = (Wibble)iter.next();
      assertEquals("k", w.s);
      w = (Wibble)iter.next();
      assertEquals("l", w.s);
      w = (Wibble)iter.next();
      assertEquals("m", w.s);
      w = (Wibble)iter.next();
      assertEquals("n", w.s);
      w = (Wibble)iter.next();
      assertEquals("o", w.s);
      w = (Wibble)iter.next();
      assertEquals("p", w.s);
      w = (Wibble)iter.next();
      assertEquals("q", w.s);
      w = (Wibble)iter.next();
      assertEquals("r", w.s);
      w = (Wibble)iter.next();
      assertEquals("s", w.s);
      w = (Wibble)iter.next();
      assertEquals("t", w.s);
      w = (Wibble)iter.next();
      assertEquals("u", w.s);
      w = (Wibble)iter.next();
      assertEquals("v", w.s);
      w = (Wibble)iter.next();
      assertEquals("w", w.s);
      w = (Wibble)iter.next();
      assertEquals("x", w.s);
      w = (Wibble)iter.next();
      assertEquals("y", w.s);
      w = (Wibble)iter.next();
      assertEquals("z", w.s);
      assertFalse(iter.hasNext());
     
      iter = list.iterator();
      assertTrue(iter.hasNext());
      w = (Wibble)iter.next();
      assertEquals("a", w.s);  
     
      iter.remove();
     
      w = (Wibble)iter.next();
      assertEquals("b", w.s);
      w = (Wibble)iter.next();
      assertEquals("c", w.s);
      w = (Wibble)iter.next();
      assertEquals("d", w.s);
     
      iter.remove();
     
      w = (Wibble)iter.next();
      assertEquals("e", w.s);
      w = (Wibble)iter.next();
      assertEquals("f", w.s);
      w = (Wibble)iter.next();
      assertEquals("g", w.s);
      w = (Wibble)iter.next();
      assertEquals("h", w.s);
      w = (Wibble)iter.next();
      assertEquals("i", w.s);
      w = (Wibble)iter.next();
      assertEquals("j", w.s);
     
      iter.remove();
     
      w = (Wibble)iter.next();
      assertEquals("k", w.s);
      w = (Wibble)iter.next();
      assertEquals("l", w.s);
      w = (Wibble)iter.next();
      assertEquals("m", w.s);
      w = (Wibble)iter.next();
      assertEquals("n", w.s);
      w = (Wibble)iter.next();
      assertEquals("o", w.s);
      w = (Wibble)iter.next();
      assertEquals("p", w.s);
      w = (Wibble)iter.next();
      assertEquals("q", w.s);
      w = (Wibble)iter.next();
      assertEquals("r", w.s);
      w = (Wibble)iter.next();
      assertEquals("s", w.s);
      w = (Wibble)iter.next();
      assertEquals("t", w.s);
      w = (Wibble)iter.next();
      assertEquals("u", w.s);
      w = (Wibble)iter.next();
      assertEquals("v", w.s);
      w = (Wibble)iter.next();
      assertEquals("w", w.s);
      w = (Wibble)iter.next();
      assertEquals("x", w.s);
      w = (Wibble)iter.next();
      assertEquals("y", w.s);
      w = (Wibble)iter.next();
      assertEquals("z", w.s);
      iter.remove();
      assertFalse(iter.hasNext());
     
      iter = list.iterator();
      assertTrue(iter.hasNext());
      w = (Wibble)iter.next();
      assertEquals("b", w.s);  
      w = (Wibble)iter.next();
      assertEquals("c", w.s);
      w = (Wibble)iter.next();
      assertEquals("e", w.s);
      w = (Wibble)iter.next();
      assertEquals("f", w.s);
      w = (Wibble)iter.next();
      assertEquals("g", w.s);
      w = (Wibble)iter.next();
      assertEquals("h", w.s);
      w = (Wibble)iter.next();
      assertEquals("i", w.s);
      w = (Wibble)iter.next();
      assertEquals("k", w.s);
      w = (Wibble)iter.next();
      assertEquals("l", w.s);
      w = (Wibble)iter.next();
      assertEquals("m", w.s);
      w = (Wibble)iter.next();
      assertEquals("n", w.s);
      w = (Wibble)iter.next();
      assertEquals("o", w.s);
      w = (Wibble)iter.next();
      assertEquals("p", w.s);
      w = (Wibble)iter.next();
      assertEquals("q", w.s);
      w = (Wibble)iter.next();
      assertEquals("r", w.s);
      w = (Wibble)iter.next();
      assertEquals("s", w.s);
      w = (Wibble)iter.next();
      assertEquals("t", w.s);
      w = (Wibble)iter.next();
      assertEquals("u", w.s);
      w = (Wibble)iter.next();
      assertEquals("v", w.s);
      w = (Wibble)iter.next();
      assertEquals("w", w.s);
      w = (Wibble)iter.next();
      assertEquals("x", w.s);
      w = (Wibble)iter.next();
      assertEquals("y", w.s);    
      assertFalse(iter.hasNext());
     
   }
View Full Code Here

TOP

Related Classes of java.util.ListIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.