Package java.util

Examples of java.util.ListIterator


      ArrayList ret = null;
      ArrayList entriesToRemove = new ArrayList();
      try {
         synchronized(this) {
            LinkedList list = new LinkedList(this.storage);
            ListIterator iter = list.listIterator(list.size());
            int count = 0;
            long currentSizeInBytes = 0L;
            long totalSizeInBytes = 0L;
            ret = new ArrayList();

            // it leaves at least one entry in the list
            while (iter.hasPrevious()) {
               I_QueueEntry entry = (I_QueueEntry)iter.previous();
               currentSizeInBytes = entry.getSizeInBytes();
               if (!isInsideRange(count, numOfEntries, totalSizeInBytes, numOfBytes)) break;
               totalSizeInBytes += currentSizeInBytes;

               if (limitEntry != null && this.comparator.compare(limitEntry, entry) >= 0) break;
View Full Code Here


              Value lock2 = lock2EqVal.getValue();
              Integer lock2Num = lockToLockNum.get(lock2);

                List afterTn2 = new ArrayList();
              afterTn2.addAll( lockOrder.getSuccsOf(lock2Num) ); // filter here!
              ListIterator lit = afterTn2.listIterator();
              while(lit.hasNext())
              {
                Integer to = (Integer) lit.next(); // node the edges go to
                List labels = lockOrder.getLabelsForEdges(lock2Num, to);
                boolean keep = false;
                if(labels != null) // this shouldn't really happen... is something wrong with the edge-labelled graph?
                {
                  for(Object l : labels)
                  {
                    CriticalSection labelTn = (CriticalSection) l;
                   
                    // Check if labelTn and tn1 share a static lock
                    boolean tnsShareAStaticLock = false;
                    for( EquivalentValue tn1LockEqVal : tn1.lockset )
                    {
                      Integer tn1LockNum = lockToLockNum.get(tn1LockEqVal.getValue());
                      if(tn1LockNum < 0)
                      {
                        // this is a static lock... see if some lock in labelTn has the same #
                        for( EquivalentValue labelTnLockEqVal : labelTn.lockset )
                        {
                          if(lockToLockNum.get(labelTnLockEqVal.getValue()) == tn1LockNum)
                          {
                            tnsShareAStaticLock = true;
                          }
                        }
                      }
                    }
                   
                    if(!tnsShareAStaticLock) // !hasStaticLockInCommon(tn1, labelTn))
                    {
                      keep = true;
                      break;
                    }
                  }
                }
                if(!keep)
                  lit.remove();
              }

/*                  for( int i = 0; i < afterTn2.size(); i++ )
                {
                  List succs = lockOrder.getSuccsOf(afterTn2.get(i)); // but not here
View Full Code Here

    List imports = _unit.imports();
    if (imports.size() == 0) {
      return null;
    }
    ArrayList importDecl = new ArrayList();
    ListIterator iter = imports.listIterator();
    while (iter.hasNext()) {
      ImportDeclaration decl = (ImportDeclaration) iter.next();
      importDecl.add(decl.getName().toString());
    }
    return importDecl;
  }
View Full Code Here

    List comments = _unit.getCommentList();
    if (comments.size() == 0) {
      return null;
    }
    ArrayList javaDocComments = new ArrayList();
    ListIterator iterator = comments.listIterator();
    while (iterator.hasNext()) {
      Object object = iterator.next();
      if (object instanceof Javadoc) {
        String comment = ((Javadoc) object).getComment();
        // ((Javadoc)object).isDocComment();
        // if (object instanceof Comment){
        // comment = ((Comment)object).toString();
View Full Code Here

    return javaDocComments;
  }

  public JClass getDeclaredClass() {
    List types = _unit.types();
    ListIterator typeIter = types.listIterator(0);
    if (typeIter.hasNext()) {
      TypeDeclaration object = (TypeDeclaration) typeIter.next();
      _class = new JClass();
      setClassInformation(_class, object);
      return _class;
    }
    return null;
View Full Code Here

      cls.setSuperClass(_superClass.getName().getFullyQualifiedName());
    }

    List interfaceLst = object.superInterfaceTypes();

    ListIterator interfaces = interfaceLst.listIterator();
    while (interfaces.hasNext()) {
      {
        SimpleType sin = (SimpleType) interfaces.next();
        cls.getInterfaces().add(sin.toString());
      }

    }
    addMethods(cls, object);
View Full Code Here

      if (d == null) {
        continue;
      }
      method.setCodeBlock(d.toString());
      List param = dec.parameters();
      ListIterator paramList = param.listIterator();
      while (paramList.hasNext()) {
        SingleVariableDeclaration sin = (SingleVariableDeclaration) paramList.next();
        method.getParameters().add(sin.getType().toString());
      }

      cls.getMethodDeclarations().add(method);
    }
View Full Code Here

      oStmt.close();
    } // fi (k_x_contact_prods)

    // Saca la lista de categorías hijas de primer nivel y repite el proceso de borrado
    LinkedList oChilds = oCat.browse(oConn, BROWSE_DOWN, BROWSE_BOTTOMUP);
    ListIterator oIter = oChilds.listIterator();

    while (oIter.hasNext()) {
      oCat = (Category) oIter.next();
      oCat.delete(oConn);
    } // wend

    if (oConn.getDataBaseProduct()==JDCConnection.DBMS_POSTGRESQL) {
      if (DebugFile.trace) DebugFile.writeln("Connection.executeQuery(SELECT k_sp_del_category_r ('" + sCategoryGUID + "'))");
View Full Code Here

   */
  public void cloneContacts(String sContactsFilter, String sTargetWorkArea, String sNewOwnerId)
    throws SQLException,IOException,InstantiationException,IllegalAccessException,
           IOException, ClassNotFoundException, org.xml.sax.SAXException {

  ListIterator oIter;
    Statement oStmt= null;
    ResultSet oRSet= null;
    Object[] oPKOr = new Object[1];
  Object[] oPKTr = new Object[1];

    if (DebugFile.trace) {
      DebugFile.writeln("Begin ModelManager.cloneContacts(" + sContactsFilter + "," + sTargetWorkArea + "," + sNewOwnerId + ")");
      DebugFile.incIdent();
    }

    if (null==oConn)
      throw new IllegalStateException("Not connected to database");

  JDCConnection oJDC;
    // Get a JDC Connection Wrapper
    if (oConn instanceof JDCConnection)
      oJDC = (JDCConnection) oConn;
    else
      oJDC = new JDCConnection(oConn, null);

  String sContactXml = null;
  String sCompanyXml = null;
 
  if (oJDC.getPool()==null) {
      switch (oJDC.getDataBaseProduct()) {
        case JDCConnection.DBMS_MSSQL:
          sContactXml = getResourceAsString("scripts/mssql/contact_clon.xml", sEncoding);
          sCompanyXml = getResourceAsString("scripts/mssql/company_clon.xml", sEncoding);
          break;
        case JDCConnection.DBMS_MYSQL:
          sContactXml = getResourceAsString("scripts/mysql/contact_clon.xml", sEncoding);
          sCompanyXml = getResourceAsString("scripts/mysql/company_clon.xml", sEncoding);
          break;
      case JDCConnection.DBMS_ORACLE:
        sContactXml = getResourceAsString("scripts/oracle/contact_clon.xml", sEncoding);
        sCompanyXml = getResourceAsString("scripts/oracle/company_clon.xml", sEncoding);
        break;
      case JDCConnection.DBMS_POSTGRESQL:
        sContactXml = getResourceAsString("scripts/postgresql/contact_clon.xml", sEncoding);
        sCompanyXml = getResourceAsString("scripts/postgresql/company_clon.xml", sEncoding);
        break;
      default:
        if (DebugFile.trace) {
          DebugFile.writeln("Unsupported database");
          DebugFile.decIdent();
        }
        throw new SQLException ("Unsupported database");
      }
  }
  else {
    FileSystemWorkArea oFsw = new FileSystemWorkArea(((DBBind)oJDC.getPool().getDatabaseBinding()).getProperties());
      try {
        switch (oJDC.getDataBaseProduct()) {
          case JDCConnection.DBMS_MSSQL:
            sContactXml = oFsw.readstorfilestr("datacopy/mssql/contact_clon.xml", sEncoding);
            sCompanyXml = oFsw.readstorfilestr("datacopy/mssql/company_clon.xml", sEncoding);
            break;
          case JDCConnection.DBMS_MYSQL:
            sContactXml = oFsw.readstorfilestr("datacopy/mysql/contact_clon.xml", sEncoding);
            sCompanyXml = oFsw.readstorfilestr("datacopy/mysql/company_clon.xml", sEncoding);
            break;
          case JDCConnection.DBMS_ORACLE:
            sContactXml = oFsw.readstorfilestr("datacopy/oracle/contact_clon.xml", sEncoding);
            sCompanyXml = oFsw.readstorfilestr("datacopy/oracle/company_clon.xml", sEncoding);
            break;
          case JDCConnection.DBMS_POSTGRESQL:
            sContactXml = oFsw.readstorfilestr("datacopy/postgresql/contact_clon.xml", sEncoding);
            sCompanyXml = oFsw.readstorfilestr("datacopy/postgresql/company_clon.xml", sEncoding);
            break;
          default:
            if (DebugFile.trace) {
              DebugFile.writeln("Unsupported database "+oJDC.getMetaData().getDatabaseProductName());
              DebugFile.decIdent();
            }
            throw new SQLException ("Unsupported database "+oJDC.getMetaData().getDatabaseProductName());
        }
      } catch (com.enterprisedt.net.ftp.FTPException neverthrown) { }
  } // fi
 
    Properties oParams = new Properties();
    oParams.put("IdWorkArea", sTargetWorkArea);
    oParams.put("IdOwner", sNewOwnerId==null ? "null" : sNewOwnerId);

    DataStruct oCS = new DataStruct();
    DataStruct oDS = new DataStruct();

    oCS.setOriginConnection(oConn);
    oCS.setTargetConnection(oConn);
    oCS.setAutoCommit(false);

    oDS.setOriginConnection(oConn);
    oDS.setTargetConnection(oConn);
    oDS.setAutoCommit(false);

    oCS.parse (sCompanyXml, oParams);
    oDS.parse (sContactXml, oParams);

  try {

    LinkedList<String> oContacts = new LinkedList<String>();
    LinkedList<String> oCompanies = new LinkedList<String>();

    oStmt = oConn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
    oRSet = oStmt.executeQuery("SELECT gu_contact,gu_company,gu_workarea FROM k_contacts WHERE "+sContactsFilter);
    while (oRSet.next()) {
      oContacts.add(oRSet.getString(1));
      String sCompany = oRSet.getString(2);
      if (!oRSet.wasNull()) {
        if (!sTargetWorkArea.equals(oRSet.getString(3))) {
          oCompanies.add(sCompany);
        }
      }
    } // wend
    oRSet.close();
    oRSet=null;
    oStmt.close();
    oStmt=null;

    if (oCompanies.size()>0) {
      oIter = oCompanies.listIterator();
      while (oIter.hasNext()) {
        oPKOr[0] = oIter.next();
        oPKTr[0] = Gadgets.generateUUID();
          oCS.insert(oPKOr, oPKTr, 1);
        oCS.commit();
          if (null!=oStrLog) oStrLog.append("New Company "+oPKTr[0]+" created successfully\n");
      } // wend
    } // fi

    oIter = oContacts.listIterator();
    while (oIter.hasNext()) {
      oPKOr[0] = oIter.next();
      oPKTr[0] = Gadgets.generateUUID();
        oDS.insert(oPKOr, oPKTr, 1);
      oDS.commit();
        if (null!=oStrLog) oStrLog.append("New Contact "+oPKTr[0]+" created successfully\n");
    } // wend
View Full Code Here

    oRSet = oStmt.executeQuery(sSQL);
    while (oRSet.next()) oApps.add(oRSet.getObject(1));
    oRSet.close();
    oStmt.close();

    ListIterator oIter = oApps.listIterator();
    oPrep = oConn.prepareStatement("DELETE FROM k_x_app_workarea WHERE gu_workarea='" + sTargetWorkAreaId + "' AND id_app=?");
    while (oIter.hasNext()) {
      oPrep.setObject(1, oIter.next());
      oPrep.executeUpdate();
    }
    oPrep.close();
    oIter = null;
    oApps = null;
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.