Package java.util

Examples of java.util.StringTokenizer


      Remove item
      */
      if(typeOfOperation != null &&  typeOfOperation.equals("REMOVEITEM") )
      {
        String removeIDs = request.getParameter("removeID");
        StringTokenizer st;
        Iterator itr;
        Vector removeKeys = new Vector();

        itemLines = expenseForm.getItemLines();
        if (itemLines != null)
        {
          st = new StringTokenizer(removeIDs, ",");
          while (st.hasMoreTokens())
          {
            String str = st.nextToken();
            int removeToken = Integer.parseInt(str);

            itr = itemLines.keySet().iterator();
            while (itr.hasNext())
            {
              Object obj = itr.next();
              ItemElement ILE = (ItemElement)itemLines.get(obj);
              IntMember ItemId = (IntMember)ILE.get("ItemId");
              Integer currItemId = (Integer)ItemId.getMemberValue();
              if ( currItemId.intValue() == removeToken)
              {
                String status = ILE.getLineStatus();
                if (status.equals("Active"))
                {
                  ILE.setLineStatus("Deleted");
                }//end of if (status.equals("Active"))
                else  if (status.equals("New"))
                {
                  removeKeys.add(obj);
                }//end of else  if (status.equals("New"))
              }//end of if ( currItemId.intValue() == removeToken)
            }//end of while (itr.hasNext())
          }//end of while (st.hasMoreTokens())

          for(int i=0; i<removeKeys.size(); i++)
          {
            itemLines.remove(removeKeys.get(i));
          }// end of for(int i=0; i<removeKeys.size(); i++)
        }//end of if (itemLines != null)

        expenseForm.setItemLines(itemLines);
        request.setAttribute("expenseform",expenseForm);
      }// end of if(typeOfOperation != null &&  typeOfOperation.equals("REMOVEITEM") )
      /*  ADD item  */
      else if(typeOfOperation != null && typeOfOperation.equals("ADDITEM") )
      {
        String newItemID = request.getParameter("theitemid");
        ItemList IL = null ;
        ListGenerator lg = ListGenerator.getListGenerator(dataSource);//get the List Generator object for Listing
        IL = (ItemList )lg.getItemList( individualID , 1, 10 , "" , "ItemID");//called when the request for the list is for first time

        StringTokenizer st;
        String token, nextItr;
        if (newItemID != null)
        {
          st = new StringTokenizer(newItemID, ",");
          itemLines = (expenseForm).getItemLines();

          if(itemLines == null)
            itemLines = new ItemLines();
          int counter = itemLines.size();
          while (st.hasMoreTokens())
          {
            token   = (String)st.nextToken();
            int intToken = Integer.parseInt(token);

            Iterator itr = IL.keySet().iterator();
            while (itr.hasNext())
            {
View Full Code Here


    if (request.getParameter("literatureid") != null)
    {
      if (!request.getParameter("literatureid").equals(""))
      {
        String strValues = request.getParameter("literatureid").toString();
        StringTokenizer st = new StringTokenizer(strValues,",");
        String strId = "";
        while(st.hasMoreTokens())
        {
          strId = st.nextToken();
          literatureIDList.add(strId);
        }
       }
     }
    request.setAttribute("literatureIDList", literatureIDList);
View Full Code Here

     * Setting this value to false is the same as calling the {@link MediaType#MediaType(String)} constructor.
     * @throws ParseException on error parsing mediaType
     */
    public MediaType(String mediaType, boolean ignoreParameters) throws ParseException {
        try {
            StringTokenizer st = new StringTokenizer(mediaType, "/");
            m_primaryType = st.nextToken().trim().toLowerCase();
            m_subtype = st.nextToken(";").trim().toLowerCase().substring(1); // substring to remove the "/" first char
            if (m_primaryType.length() == 0 || m_subtype.length() == 0) {
                throw new ParseException("Type and subtype must contain values in '" + mediaType + "'", -1);
            }
            if (ignoreParameters) {
                m_parameterList = Collections.EMPTY_LIST;
            } else {
                m_parameterList = new ArrayList();
                while (st.hasMoreTokens()) {
                    addParameter(Parameter.parse(st.nextToken().trim()));
                }
            }
        } catch (NoSuchElementException e) {
            throw new ParseException("Unable to parse mediaType '" + mediaType + "'", -1);
        }
View Full Code Here

       
        return null;
    }

    private static MediaType[] parseAcceptString(String acceptString) throws ParseException {
        StringTokenizer toke = new StringTokenizer(acceptString, ",");
        MediaType[] acceptTypes = new MediaType[toke.countTokens()];
        int i = 0;
        while (toke.hasMoreTokens()) {
            acceptTypes[i++] = new MediaType(toke.nextToken(), true);
        }
        return acceptTypes;
    }
View Full Code Here

  {

    int[] fieldIds = null;
    String[] sortOs = null;
    if (contentOrders != null && contentOrders.length() > 0) {
      StringTokenizer tok = new StringTokenizer(contentOrders, ";");
      int fieldLength = tok.countTokens();
      fieldIds = new int[fieldLength];
      sortOs = new String[fieldLength];
      int i = 0;
      while (tok.hasMoreTokens()) {
        String tmp = tok.nextToken();
        String ad = tmp.substring(0, 1);
        String id = tmp.substring(1, tmp.length());
        if (ad.equals("D")) {
          ad = ReportConstants.SORTORDER_DESC;
        } else {
          ad = ReportConstants.SORTORDER_ASC;
        }
        StringTokenizer tok2 = new StringTokenizer(id, ":");
        String tableId = tok2.nextToken();
        String fieldId = tok2.nextToken();
        fieldIds[i] = Integer.parseInt(fieldId);
        sortOs[i++] = ad;
      }
    } // end if (contentOrders != null && contentOrders.length() > 0)

    String sort = null;
    Byte sortSeq = null;
    int fieldId = 0;
    int tableId = 0;
    ArrayList selectedFields = new ArrayList();

    // The contentFields values have a semicolon seperated list
    // of colon separated Ids Where the first ID is the parent or table id
    // and the second is the field id.
    if (contentFields != null && contentFields.length() > 0) {
      int i = 0;
      StringTokenizer tok = new StringTokenizer(contentFields, ";");
      while (tok.hasMoreTokens()) {
        sort = null;
        sortSeq = null;
        StringTokenizer tok2 = new StringTokenizer(tok.nextToken(), ":");
        tableId = Integer.parseInt(tok2.nextToken());
        fieldId = Integer.parseInt(tok2.nextToken());
        // hopefully this sort stuff still works after adding the parent
        // ID in above.
        if (fieldIds != null) {
          for (i = 0; i < fieldIds.length; i++) {
            if (fieldIds[i] == fieldId) {
View Full Code Here

  protected ArrayList getSelectedFieldsWithNames(String contentFields, String contentOrders, String contentFieldNames)
  {
    int[] fieldIds = null;
    String[] sortOs = null;
    if (contentOrders != null && contentOrders.length() > 0) {
      StringTokenizer tok = new StringTokenizer(contentOrders, ";");
      int fieldLength = tok.countTokens();
      fieldIds = new int[fieldLength];
      sortOs = new String[fieldLength];
      int i = 0;
      while (tok.hasMoreTokens()) {
        String tmp = tok.nextToken();
        String ad = tmp.substring(0, 1);
        String id = tmp.substring(1, tmp.length());
        if (ad.equals("D"))
          ad = ReportConstants.SORTORDER_DESC;
        else
          ad = ReportConstants.SORTORDER_ASC;
        StringTokenizer tok2 = new StringTokenizer(id, ":");
        String tableId = tok2.nextToken();
        String fieldId = tok2.nextToken();
        fieldIds[i] = Integer.parseInt(fieldId);
        sortOs[i++] = ad;
      }
    }

    String sort = null;
    Byte sortSeq = null;
    int fieldId = 0;
    int tableId = 0;
    String fieldName = "";
    ArrayList selectedFields = new ArrayList();

    // The contentFields values have a semicolon seperated list
    // of colon separated Ids Where the first ID is the parent or table id
    // and the second is the field id.
    if (contentFields != null && contentFields.length() > 0) {
      int i = 0;
      StringTokenizer tok = new StringTokenizer(contentFields, ";");
      StringTokenizer nameTok = new StringTokenizer(contentFieldNames, ";");
      while (tok.hasMoreTokens()) {
        sort = null;
        sortSeq = null;
        StringTokenizer tok2 = new StringTokenizer(tok.nextToken(), ":");
        tableId = Integer.parseInt(tok2.nextToken());
        fieldId = Integer.parseInt(tok2.nextToken());
        fieldName = nameTok.nextToken();
        // Any way go through the sortIds found and see if the current
        // field is part of the sorting rules.
        if (fieldIds != null) {
          for (i = 0; i < fieldIds.length; i++) {
View Full Code Here

  protected ArrayList getSearchFields(String searchFields)
  {
    ArrayList searches = new ArrayList();
    TheSearchItem searchItem = null;
    if (searchFields != null && searchFields.length() > 0) {
      StringTokenizer tok = new StringTokenizer(searchFields, ";");
      int tokCount = 0;
      int row = 0;
      while (tok.hasMoreTokens()) {
        String tmp = tok.nextToken();
        row = tokCount % 5;
        switch (row) {
          case 0 :
            // allocate new row of search
            if (searchItem != null) {
View Full Code Here

      String strLiteraturename = (String)literatureDetails.getLiteratureName();
      String strnames = "";

      if (strLiteratureid != null && !strLiteratureid.equals(""))
      {
    StringTokenizer stid = new StringTokenizer(strLiteratureid,",");
    StringTokenizer stName = new StringTokenizer(strLiteraturename,",");
    String strId = "";
    String strName = "";
    while(stid.hasMoreTokens())
    {
      strId = stid.nextToken();
      strName = stName.nextToken();
      if (!strId.equals("")){
        int id = Integer.parseInt(strId);
        literaturenamevec.add(new DDNameValue(id,strName));
      }
    }
View Full Code Here

   *         in the future as we add features.
   */
  private String isMessageWebformImport(String headers)
  {
    String webformType = "NONE";
    StringTokenizer tokenizer = new StringTokenizer(headers, System.getProperty("line.separator", "\n"));
    while (tokenizer.hasMoreTokens())
    {
      String currentHeader = (String)tokenizer.nextToken();
      if (currentHeader.matches(".*X-CentraView-Webform: .*"))
      {
        webformType = (currentHeader.substring(21)).trim();
      }
    }
View Full Code Here

                  } //end of if statement (!tables.contains(tableName))
                  // alias determination

                  Collection alias = new ArrayList();

                  StringTokenizer aliasCommaTokens = new StringTokenizer(thisRealTable, ",");

                  while(aliasCommaTokens.hasMoreTokens()){
            String aliasRealTable = aliasCommaTokens.nextToken();
            StringTokenizer aliasTokens = new StringTokenizer(aliasRealTable, " ");
            int tokenLen = aliasTokens.countTokens();
            if(tokenLen > 1){
              if(aliasTokens.hasMoreTokens())
              {
                String tempTableName = aliasTokens.nextToken();
                alias.add(aliasTokens.nextToken());
              }//end of if(aliasTokens.hasMoreTokens())
            }
            else{
              if(aliasTokens.hasMoreTokens())
              {
                alias.add(aliasTokens.nextToken());
              }
            }
          }//end of while(aliasCommaTokens.hasMoreTokens())

                  thisRelationship = (String) fieldHashMap.get("RelationshipQuery");
                  if (thisRelationship != null)
                  {
                    StringTokenizer relationshipTokens = new StringTokenizer(thisRelationship, " ");
                    while (relationshipTokens.hasMoreTokens())
                    {
                      String thisToken = relationshipTokens.nextToken();
                      int index = thisToken.indexOf(".");
                      if (index > -1)
                      {
                        String tableName = null;
                        if (thisToken.indexOf("(") == 0) {  // grrrrrrr
                          tableName = thisToken.substring(1, index);
                        } else {
                          tableName = thisToken.substring(0, index);
                        }
                        //Incase if you added the new line to the Query then before
                        //check for the occurance. We will eliminate the new line return character.
                        tableName = tableName.replaceAll("\n","");
                        if ((!allTables.contains(tableName)) && (!alias.contains(tableName)))
                        {
                          allTables.add(tableName);
                        } //end of if statement (!tables.contains(tableName))
                      } //end of if statement (index > -1)
                    } //end of while loop (relationshipTokens.hasMoreTokens())
                  } //end of if statement (thisRelationship != null)
                } //end of if statement (isOnTable.equalsIgnoreCase("N"))
              } //end of if statement (fieldIterator.hasNext())
            } //end of if statement (fieldResults != null)

            if (thisRealTable.length() < 1)
            {
              thisRealTable = thisTable;
            } //end of if statement (thisRealTable.length() < 1)

            // This is the actual interesting part of the WHERE clause

            String valueCondition = (String) this.getConditionString(
              searchCriteria.getValue(), thisField, thisRealTable,
              Integer.parseInt(searchCriteria.getConditionID()));

            // Build the criterion Query
            selectQuery.append("SELECT ");
            selectQuery.append(thisTable);
            selectQuery.append(".");
            selectQuery.append(thisPrimaryKey);
            selectQuery.append(" FROM ");

            Iterator thisTableIterator = allTables.iterator();
            while (thisTableIterator.hasNext())
            {
              String currentTable = (String) thisTableIterator.next();
              selectQuery.append(currentTable);
              if (thisTableIterator.hasNext())
              {
                selectQuery.append(", ");
              } //end of if statement (thisTableIterator.hasNext())
            } //end of while loop (thisTableIterator.hasNext())

            // The actual Question the user is asking about this field:
            StringBuffer fieldCriterion = new StringBuffer();
            //If there is a relationship, this following piece
            //should be setup in the database.
            if (thisRelationship == null || thisRelationship.length() < 1)
            {
              fieldCriterion.append(thisRealTable);
              fieldCriterion.append(".");
            } //end of if statement (thisRelationship == null ...

            fieldCriterion.append(thisField);
            fieldCriterion.append(" ");
            fieldCriterion.append(valueCondition);

            // the following things don't have "record" rights applied
            // they can be skipped and just do this thing.
            if (thisRealTable.equalsIgnoreCase("methodofcontact")
                || thisRealTable.equalsIgnoreCase("customfield")
                || thisRealTable.equalsIgnoreCase("address")
                || (thisRelationship != null && thisRelationship.length() > 0))
            {
              //This is bad.... bad bad bad, but there isn't an easier way
              //to do this.
              selectQuery.append(" WHERE ");
              if (thisRelationship != null && thisRelationship.length() > 0)
              {
                selectQuery.append(thisRelationship);
                selectQuery.append(" AND ");
              } //end of if statement (thisRelationship != null ...

              selectQuery.append(fieldCriterion);

            } //end of if statement (thisTable.equals("methodofcontact"))...
            else
            {
              // Gotta do some record rights crap.
              selectQuery.append(this.getRecordPermissionQuery(individualID,
                thisRealTable, thisPrimaryKey, selectQuery, fieldCriterion,
                searchVO.getModuleID(),allTables));
            } //end of else statement (thisTable.equals("methodofcontact"))...
          } // end else for if (searchCriteria.getTableID().equals(CUSTOM_FIELD_TABLEID))

          // built the query now get iterum results.
          cvdal.setSqlQuery(selectQuery.toString());
          Collection searchResults = cvdal.executeQuery();
          cvdal.setSqlQueryToNull();
          if (searchResults != null)
          {
            StringBuffer commaDelimitedIDs = new StringBuffer("");
            Iterator resultsIterator = searchResults.iterator();
            while (resultsIterator.hasNext())
            {
              HashMap resultsHashMap = (HashMap) resultsIterator.next();
              Number primaryID = (Number) resultsHashMap.get(thisPrimaryKey);
              commaDelimitedIDs.append(primaryID.toString());
              if (resultsIterator.hasNext())
              {
                commaDelimitedIDs.append(", ");
              } //end of if statement (resultsIterator.hasNext())
            } //end of while loop (resultsIterator.hasNext())

            if (commaDelimitedIDs.length() < 1)
            {
              commaDelimitedIDs.append("0");
            } //end of if statement (commaDelimitedIDs.length() < 1)

            // interumResults are now keyed on a unique counter
            interumResults.put(new Integer(searchCriteriaCounter), commaDelimitedIDs.toString());
          } //end of if statement (searchResults != null)
          // whack the tables from this list
          allTables.clear();
          // The guaranteed unique counter is now stored in the collection of searchCriteria
          // which we are working with.
          searchCriteria.setSearchCriteriaID(String.valueOf(searchCriteriaCounter));
          searchCriteriaCounter++;
        } //end of while loop (criteriaIterator.hasNext())
      } //end of if statement (criteriaCollection != null)
      //End Criteria Searches

      // Build the relationship and get out the primary keys we need.
      if (criteriaCollection != null)
      {
        Iterator criteriaIterator = criteriaCollection.iterator();
        while (criteriaIterator.hasNext())
        {
          SearchCriteriaVO searchCriteria = (SearchCriteriaVO) criteriaIterator.next();
          Integer searchCriteriaId = new Integer(searchCriteria.getSearchCriteriaID());
          // See if its worth finding the relationship, etc.  If there is no
          // interum results then there will most definitely be no final results
          String ids = (String)interumResults.get(searchCriteriaId);
          String relationshipQuery = "";
          if (ids != null && ids.length() > 0 && !ids.equals("0")) // oh yeah, and if it equals 0, we can skip it too.
          {
            // if the table for this criteria is not the primary table, then we need to
            // get the relationship query from searchtablerelate, and run a query to
            // reduce back to the primarykey.
            if ((primaryTableID.intValue() != Integer.parseInt(searchCriteria.getTableID()))
                && !(searchCriteria.getTableID().equals(SearchVO.CUSTOM_FIELD_TABLEID)))
            {
              String tableString = "SELECT RelationshipQuery FROM searchtablerelate " +
                  "WHERE (LeftSearchTableID = ? AND RightSearchTableID = ?) " +
                  "OR (LeftSearchTableID = ? AND RightSearchTableID = ?)";
              cvdal.setSqlQuery(tableString);
              cvdal.setInt(1, primaryTableID.intValue());
              cvdal.setInt(2, Integer.parseInt(searchCriteria.getTableID()));
              cvdal.setInt(3, Integer.parseInt(searchCriteria.getTableID()));
              cvdal.setInt(4, primaryTableID.intValue());

              Collection relationCollection = cvdal.executeQuery();
              cvdal.setSqlQueryToNull();
              if (relationCollection != null)
              {
                Iterator relationIterator = relationCollection.iterator();
                if (relationIterator.hasNext())
                {
                  HashMap relationHashMap = (HashMap)relationIterator.next();
                  relationshipQuery = (String)relationHashMap.get("RelationshipQuery");
                  // build up a collection of all the tables referenced in the relationship
                  // query.
                  StringTokenizer relationshipTokens = new StringTokenizer(relationshipQuery, " ");
                  while (relationshipTokens.hasMoreTokens())
                  {
                    String thisToken = relationshipTokens.nextToken();
                    int index = thisToken.indexOf(".");
                    if (index > -1)
                    {
                      String tableName = thisToken.substring(0, index);
                      if (!allTables.contains(tableName))
View Full Code Here

TOP

Related Classes of java.util.StringTokenizer

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.