Package java.util

Examples of java.util.ListIterator


    oThreadPool = new WorkerThreadPool(oCsr, oEnvProps);

    // Register callbacks on each worker thread

    ListIterator oIter = oCallbacks.listIterator();
    while (oIter.hasNext())
      oThreadPool.registerCallback((WorkerThreadCallback) oIter.next());

    dtStartDate = new Date();

    do {
      try {

        while (bContinue) {

          oJcn = oDbb.getConnection("SchedulerDaemon");
          oJcn.setAutoCommit(true);
         
          // Count how many atoms are pending of processing at the database
          oStmt = oJcn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);

          // ***************************************************
          // Finish all the jobs that have no more pending atoms
          sSQL = "SELECT j.gu_job FROM k_jobs j WHERE ("+
                 "j.id_status="+String.valueOf(Job.STATUS_PENDING)+" OR "+
                 "j.id_status="+String.valueOf(Job.STATUS_RUNNING)+") AND "+
                 "NOT EXISTS (SELECT a.pg_atom FROM k_job_atoms a WHERE "+
                 "j.gu_job=a.gu_job AND a.id_status IN ("+
                 String.valueOf(Atom.STATUS_PENDING)+","+
                 String.valueOf(Atom.STATUS_RUNNING)+","+
                 String.valueOf(Atom.STATUS_SUSPENDED)+"))";

          if (DebugFile.trace) DebugFile.writeln("Statement.executeQuery("+sSQL+") on connection with process id. "+oJcn.pid());

          oRSet = oStmt.executeQuery(sSQL);
          LinkedList<String> oFinished = new LinkedList<String>();
          while (oRSet.next()) {
            oFinished.add(oRSet.getString(1));
          } // wend
          oRSet.close();
      oStmt.close();

          if (DebugFile.trace) DebugFile.writeln("Already finished jobs "+String.valueOf(oFinished.size()));

          if (oFinished.size()>0) {
            sSQL = "UPDATE k_jobs SET id_status="+String.valueOf(Job.STATUS_FINISHED)+",dt_finished="+DBBind.Functions.GETDATE+" WHERE gu_job=?";
            if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement("+sSQL+") on connection with process id. "+oJcn.pid());
            PreparedStatement oUpdt = oJcn.prepareStatement(sSQL);
            oIter = oFinished.listIterator();
            while (oIter.hasNext()) {
              oUpdt.setObject(1, oIter.next(), java.sql.Types.CHAR);
              oUpdt.executeUpdate();
            } // wend
            oUpdt.close();
          } // fi

View Full Code Here


      sJob = aAtoms[a].getString(DB.gu_job);
      if (oJobs.contains(sJob)) oJobs.add(sJob);
    }
    if (oJobs.size()==0) return null;
    String[] aJobs = new String[oJobs.size()];
    ListIterator oIter = oJobs.listIterator();
    int j = 0;
    while (oIter.hasNext()) {
      aJobs[j] = (String) oIter.next();
    } // wend
    return aJobs;
  } // runningJobs
View Full Code Here

    Statement oStmt;
    ResultSet rCount;
    int cAffected;
    String sSQL;
    String sTable;
    ListIterator oIter;

    if (DebugFile.trace) {
      if (iTable!=-1)
        sTable = getRowSet(iTable).OriginTable;
      else
        sTable = "";
      DebugFile.writeln ("Begin DataStruct.execCommands(" +  sTime + ", " + sTable + ", ..., " + String.valueOf(cParams) + ")");
      DebugFile.incIdent();
    }

    // Seleccionar el iterador para la lista adecudada de comandos
    if (-1==iTable) {
      if (sTime.equals("INIT")) {
        if (null==InitStmts)
          throw new NullPointerException("DataStruct.execCommands() InitStmts list not initialized");
        oIter = InitStmts.listIterator();
      } else {
        if (null==TermStmts)
          throw new NullPointerException("DataStruct.execCommands() TermStmts list not initialized");
        oIter = TermStmts.listIterator();
      }
    }
    else {
      if (sTime.equals("BEFORE"))
        oIter = ((LinkedList)Before.get(iTable)).listIterator();
      else
        oIter = ((LinkedList)After.get(iTable)).listIterator();
    }

    while (oIter.hasNext()) {
      sSQL = oIter.next().toString();

      // Si el SQL empieza por "{" entonces se ejecuta como un procedimiento almacenado
      if (sSQL.startsWith("{") || sSQL.startsWith("k_sp")) {
        if (DebugFile.trace) DebugFile.writeln ("Connection.prepareCall(" + sSQL + ")");
        oCall = oTrConn.prepareCall(sSQL);
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

     sDump += "\n";

     if (errorlog.size()>0) {
       sDump += "Fatal error log:\n";
       ListIterator oErrIterator = errorlog.listIterator();
       while (oErrIterator.hasNext()) sDump += oErrIterator.next()+"\n";
     } // fi

     DebugFile.writeln(sDump);

     if (DebugFile.trace) {
View Full Code Here

    int iAttachs = oAttachs.load(oConn, new Object[]{get(DB.gu_contact)});
    if (0==iAttachs) {
      aAttachs = null;
    } else {
      aAttachs = new Attachment[iAttachs];
      ListIterator oCols = oAttach.getTable(oConn).getColumns().listIterator();
      while (oCols.hasNext()) {
        String sKey = (String) oCols.next();
        if (!sKey.equalsIgnoreCase(DB.dt_created)) {
          for (int a=0; a<iAttachs; a++) {
            aAttachs[a].put(sKey, oAttachs.get(sKey,a));
          } // next (a)
        } // fi (sKey!="dt_created")
View Full Code Here

  oSum.setString(7, getString(DB.gu_workarea));
   
    Term oZone = new Term();
    oZone.load(oConn, getString(DB.gu_geozone));
    LinkedList oChlds = oZone.getChilds(oConn, Term.SCOPE_ALL);
    ListIterator oIter = oChlds.listIterator();
    while (oIter.hasNext()) {
      oZone = (Term) oIter.next();
    oSum.setString(6, oZone.getString(DB.gu_term));
    oSum.setString(8, oZone.getString(DB.gu_term));
    oRst = oSum.executeQuery();
      oRst.next();
    if (DebugFile.trace)
View Full Code Here

        SmbFile[] dirents;
        SmbFile f;
        int i, j, len, maxLen, dirCount, fileCount, sort;
        String str, name, path, fmt;
        LinkedList sorted;
        ListIterator iter;
        SimpleDateFormat sdf = new SimpleDateFormat( "MM/d/yy h:mm a" );
        GregorianCalendar cal = new GregorianCalendar();

        sdf.setCalendar( cal );

        dirents = dir.listFiles();
        sorted = new LinkedList();
        if(( fmt = req.getParameter( "fmt" )) == null ) {
            fmt = "col";
        }
        sort = 0;
        if(( str = req.getParameter( "sort" )) == null || str.equals( "name" )) {
            sort = 0;
        } else if( str.equals( "size" )) {
            sort = 1;
        } else if( str.equals( "type" )) {
            sort = 2;
        } else if( str.equals( "date" )) {
            sort = 3;
        }
        dirCount = fileCount = 0;
        maxLen = 28;
        for( i = 0; i < dirents.length; i++ ) {
            try {
                if( dirents[i].getType() == SmbFile.TYPE_NAMED_PIPE ) {
                    continue;
                }
            } catch( SmbAuthException sae ) {
            } catch( SmbException se ) {
                if( se.getNtStatus() != se.NT_STATUS_UNSUCCESSFUL ) {
                    throw se;
                }
            }
            if( dirents[i].isDirectory() ) {
                dirCount++;
            } else {
                fileCount++;
            }

            name = dirents[i].getName();
            len = name.length();
            if( len > maxLen ) {
                maxLen = len;
            }

            iter = sorted.listIterator();
            for( j = 0; iter.hasNext(); j++ ) {
                if( sort == 0 ) {
                    if( compareNames( dirents[i], name, (SmbFile)iter.next() ) < 0 ) {
                        break;
                    }
                } else if( sort == 1 ) {
                    if( compareSizes( dirents[i], name, (SmbFile)iter.next() ) < 0 ) {
                        break;
                    }
                } else if( sort == 2 ) {
                    if( compareTypes( dirents[i], name, (SmbFile)iter.next() ) < 0 ) {
                        break;
                    }
                } else if( sort == 3 ) {
                    if( compareDates( dirents[i], name, (SmbFile)iter.next() ) < 0 ) {
                        break;
                    }
                }
            }
            sorted.add( j, dirents[i] );
        }
        if( maxLen > 50 ) {
            maxLen = 50;
        }
        maxLen *= 9; /* convert to px */

        out = resp.getWriter();

        resp.setContentType( "text/html" );

        out.println( "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">" );
        out.println( "<html><head><title>Network Explorer</title>" );
        out.println( "<meta HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">" );
        out.println( "<style TYPE=\"text/css\">" );

        out.println( style );

        if( dirents.length < 200 ) {
            out.println( "    a:hover {" );
            out.println( "        background: #a2ff01;" );
            out.println( "    }" );
        }

        out.println( "</STYLE>" );
        out.println( "</head><body>" );

        out.print( "<a class=\"sort\" style=\"width: " + maxLen + ";\" href=\"?fmt=detail&sort=name\">Name</a>" );
        out.println( "<a class=\"sort\" href=\"?fmt=detail&sort=size\">Size</a>" );
        out.println( "<a class=\"sort\" href=\"?fmt=detail&sort=type\">Type</a>" );
        out.println( "<a class=\"sort\" style=\"width: 180\" href=\"?fmt=detail&sort=date\">Modified</a><br clear='all'><p>" );

        path = dir.getCanonicalPath();

        if( path.length() < 7 ) {
            out.println( "<b><big>smb://</big></b><br>" );
            path = ".";
        } else {
            out.println( "<b><big>" + path + "</big></b><br>" );
            path = "../";
        }
        out.println( (dirCount + fileCount) + " objects (" + dirCount + " directories, " + fileCount + " files)<br>" );
        out.println( "<b><a class=\"plain\" href=\".\">normal</a> | <a class=\"plain\" href=\"?fmt=detail\">detailed</a></b>" );
        out.println( "<p><table border='0' cellspacing='0' cellpadding='0'><tr><td>" );

        out.print( "<A style=\"width: " + maxLen );
        out.print( "; height: 18;\" HREF=\"" );
        out.print( path );
        out.println( "\"><b>&uarr;</b></a>" );
        if( fmt.equals( "detail" )) {
            out.println( "<br clear='all'>" );
        }

        if( path.length() == 1 || dir.getType() != SmbFile.TYPE_WORKGROUP ) {
            path = "";
        }

        iter = sorted.listIterator();
        while( iter.hasNext() ) {
            f = (SmbFile)iter.next();
            name = f.getName();

            if( fmt.equals( "detail" )) {
                out.print( "<A style=\"width: " + maxLen );
                out.print( "; height: 18;\" HREF=\"" );
View Full Code Here

      } // wend
      oRSet.close();
      oRecp.close();

      PreparedStatement oUpdt = oConn.prepareStatement("UPDATE k_mime_msgs SET bo_indexed=1 WHERE gu_mimemsg=?");
      ListIterator oIter = oIndexedGuids.listIterator();
      while (oIter.hasNext()) {
        oUpdt.setObject(1, oIter.next(), java.sql.Types.CHAR);
        oUpdt.executeUpdate();
      } // wend
      oUpdt.close();
    } // fi
View Full Code Here

  } // wend
    oRSet.close();
    oStmt.close();
    oConn.close();

  ListIterator oIter = oWrkA.listIterator();
  while (oIter.hasNext()) {
    rebuild(oProps, sTableName, (String) oIter.next());
  } // wend

    if (DebugFile.trace) {
      DebugFile.decIdent();
      DebugFile.writeln("End Indexer.rebuild()");
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.