Package java.lang

Examples of java.lang.StringBuffer


   replaceCharData(String fileName)
   throws IOException, Exception
   {
      text = br.readLine();
     
      sb = new StringBuffer();
      int iRow = 0;
      String strBefore,
      strAfter;
      int ind;
     
    //pattern = Pattern.compile(searchPossibleMissedChars);
      ConvertedRow convertedRow = null;
      boolean bErrorFounded = false;
      StringBuffer sbErrorRow = new StringBuffer();     
      StringBuffer sbErrorRowPosition = new StringBuffer();
      int iRowLen, iRowLenPos;
     
      while(text != null)
      {
        iRow++;
        iRowLen = sbErrorRow.length();
        bErrorFounded = false;
        if (iRowLen > 0)
          iRowLen = iRowLen -1;
        sbErrorRow.delete(0, iRowLen);
        // sbErrorRow = new StringBuffer();
        iRowLenPos = sbErrorRowPosition.length();
        if (iRowLenPos > 0)
          iRowLenPos = iRowLenPos -1;
        sbErrorRowPosition.delete(0, iRowLenPos);
        // sbErrorRowPosition = new StringBuffer();
        if (text.equals("")) // jos alkup. rivi sisältää pelkän CR:n
          text = "\n"; // lisää se
        else
        {
          String tmp = text;
              if (tmp.length() == 0)
                text = "\n"; // poista välilyonnit
              else
              { // testaa onko trimmattu tmp vain white
                char [] chars = tmp.toCharArray();
                int max = chars.length;
                boolean isWhiteSpace = true;
                for(int i = 0; i < max; i++)
                {
                  if (!Character.isWhitespace(chars[i]))
                  {
                    isWhiteSpace = false;
                    break;
                  }                   
                }
                 
                if (isWhiteSpace
                  text = "\n"; // poista välilyonnit
                else
                {
       
              //text = DecoderCharacterSet.changeSpecialChars(text);
              if (m_bMakeCharConverstion)
              {         
                convertedRow = makeCharConvert(text);
                if (convertedRow != null)
                {
                 
                  //String unModInputRow = convertedRow.getInputRow();
                  String strOutputRow = convertedRow.getOutputRow();
                  if (strOutputRow != null)
                  {
                    String strErrorRow = null;
                    byte [] arrByteUnModInputRow = convertedRow.getArrChangedCharFlags();
                    int maxU = strOutputRow.length();
                    char ch;
                    byte modified;
                    int maxE ;
                    CharArea ca;
                    int iCh;
                    boolean bCharError = false;
                   
                    for(int i = 0 ; i < maxU; i++)
                    {
                      ch = strOutputRow.charAt(i);
                      maxE = arrExcludeAreas.length;
                      iCh = ch;
                      bCharError = false;
                     
                      for(int k = 0 ; k < maxE; k++)
                      {
                        ca = arrExcludeAreas[k];
                        if (ca == null)
                          continue;
                       
                        if (iCh >= ca.getChStartChar() && iCh <= ca.getChEndChar())
                        {
                          int indErrorPos = i;
                           bErrorFounded = true;
                           bCharError = true;
                           sbErrorRow.append("[");
                           sbErrorRow.append(ch);
                           sbErrorRow.append("]");
                           String strCh = "" +ch;
                           sbErrorRowPosition.append(
                                                      "\nrow:          " + iRow +"\n");
                           sbErrorRowPosition.append("column:       " + (i+1) +"\n");
                           sbErrorRowPosition.append("position:     " + (i+1) +"\n");
                           sbErrorRowPosition.append("position end: " + (i+1) +"\n");
                           sbErrorRowPosition.append("'" + ch +"' => utf-8 char: " +iCh +" "
                                    +"utf-8 in hex: "
                                    +byteArrayToHexString(strCh.getBytes()) +"\n");
                           // strErrorRow = sbErrorRow.toString();
                           // int iChError = ch;
                           // giveErrorMessage(fileName,                                   
                            /// strErrorRow, iRow, indErrorPos);
                           break;
                        }                       
                      }   
                     
                      if (!bCharError)
                        sbErrorRow.append(ch);
                    }
                  }
                                   
                   }           
                }
              }
        }
        if (bErrorFounded)
        {                          
         giveErrorMessage(fileName,
            sbErrorRow.toString() +"\n"
            + sbErrorRowPosition.toString() +"\n", iRow, -1);

        }

        sb.append(text +"\n");       
        text = br.readLine();
View Full Code Here


       return value;
     int ind = text.indexOf(chSeach);
     if (ind == -1)
       return value;
    
     StringBuffer ret = new StringBuffer (value.length());
     int max = value.length();
     char ch;
    
     for(int i = 0; i < max; i++)
     {
       ch = value.charAt(i);
       if (ch == chSeach)
         ret.append(strReplace);
       else
         ret.append(ch);
     }
     return ret.toString();
   }
View Full Code Here

   * This method returns a string of random 36-based numbers thats exacly <code>length</code> long.
   * @param length Required length of the string
   * @return A string of random 36-base based numbers with a length of <code>length</code>.
   */
  public static String getRandomValue(int length) {
    StringBuffer result = new StringBuffer();
    for (int i = 0; i < length; i++) {
      int v = Math.abs(RandomGUID.myRand.nextInt()) % 36;
      result.append(Long.toString(v, 36));
    }
    return result.toString();
  }
View Full Code Here

   * for randomness. It is about 3.5-times slower, so use it only when you need really strong
   * randomness!
   * @see #getRandomValue
   */
  public static String getStrongRandomValue(int length) {
    StringBuffer result = new StringBuffer();
    for (int i = 0; i < length; i++) {
      int v = Math.abs(RandomGUID.mySecureRand.nextInt()) % 36;
      result.append(Long.toString(v, 36));
    }
    return result.toString();
  }
View Full Code Here

    String id;                                                // generated id

    while (D.length() < 4) {                                  // The stamp will not be longer than 12 characters
      D = '0' + D;
    }                                                         // start with the current time stamp
    StringBuffer sb = new StringBuffer();

      int i = Math.abs(RandomGUID.myRand.nextInt());
    sb.append(Integer.toString(i, 16));
    sb.append(getRandomValue(sb.length()-8));
      sb.append('-').append(D.substring(D.length() - 4));

    id = sb.toString();

    return id;
  }
View Full Code Here

    String id;                                                // generated id

    while (D.length() < 4) {                                  // The stamp will not be longer than 12 characters
      D = '0' + D;
    }                                                         // start with the current time stamp
    StringBuffer sb = new StringBuffer();

      int i = Math.abs(RandomGUID.mySecureRand.nextInt());
    sb.append(Integer.toString(i, 16));
    sb.append(getRandomValue(sb.length()-8));
      sb.append('-').append(D.substring(D.length() - 4));

    id = sb.toString();

    return id;
  }
View Full Code Here

    lastUserUniqueIDTime = d;
    String D = Long.toString(d, 36);
    while (D.length() < 8) {
      D = '0' + D;
    }
    StringBuffer sb = new StringBuffer(RandomGUID.myShortCode);
    sb.append(D);
    sb.append(getRandomValue(2));
    sb.append(twoLetterChecksum(sb.toString()));
    return sb.toString().toLowerCase();

  }
View Full Code Here

      D = '0' + D;
    }                                                         // start with the current time stamp

    D = D.substring(D.length() - 6);

    StringBuffer sb = new StringBuffer(RandomGUID.machineID);

    if (RandomGUID.myRand != null) {                                        // and a few random bytes
      long l = Math.abs(RandomGUID.myRand.nextLong());

      sb.append(Long.toString(l, 32));

      sb.append('-');
    }

    id = sb.append(D).toString();

    return id;
  }
View Full Code Here

      D = '0' + D;
    }                                                         // start with the current time stamp

    D = D.substring(D.length() - 6);

    StringBuffer sb = new StringBuffer(RandomGUID.machineID);

    if (RandomGUID.mySecureRand != null) {                                        // and a few random bytes
      long l = Math.abs(RandomGUID.mySecureRand.nextLong());

      sb.append(Long.toString(l, 32));

      sb.append('-');
    }

    id = sb.append(D).toString();

    return id;
  }
View Full Code Here

     * to <code>DISCONNECTED_STATE</code>.
     ***/
    public POP3()
    {
        setDefaultPort(DEFAULT_PORT);
        __commandBuffer = new StringBuffer();
        __popState = DISCONNECTED_STATE;
        _reader = null;
        __writer = null;
        _replyLines = new Vector();
        _commandSupport_ = new ProtocolCommandSupport(this);
View Full Code Here

TOP

Related Classes of java.lang.StringBuffer

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.