Package java.lang

Examples of java.lang.StringBuffer


            while (!self.getQuorumVerifier().containsQuorum(newLeaderProposal.ackSet)){
            //while (newLeaderProposal.ackCount <= self.quorumPeers.size() / 2) {
                if (self.tick > self.initLimit) {
                    // Followers aren't syncing fast enough,
                    // renounce leadership!
                    StringBuffer ackToString = new StringBuffer();
                    for(Long id : newLeaderProposal.ackSet)
                        ackToString.append(id + ": ");
                   
                    shutdown("Waiting for a quorum of followers, only synced with: " + ackToString);
                    HashSet<Long> followerSet = new HashSet<Long>();
                    for(FollowerHandler f : followers)
                        followerSet.add(f.getSid());
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

      // (see HTTP specification section 3.4.1)
      logger.info("changing to default encoding");
      request.setCharacterEncoding( encoding );
    }

    StringBuffer correction = new StringBuffer();
 
    String query = request.getParameter("query");
    String lang = request.getParameter("l");

    if (lang == null) {
      lang = "pt_PT";
    } else if ( lang.equals("en") ) {
      lang = "en_US";
    } else {
      lang = "pt_PT";
    }

    if (query != null && lang != null) {
      Matcher matcher = pattern.matcher( query );

      logger.info("checking query: "+ query);

      while ( matcher.find() ) {
        String[] allSuggestions = null;

        String match = matcher.group(1).toLowerCase();
        logger.info("match: "+ match);

        if ( !isOperator( match ) ) {
          try {
            allSuggestions = SpellChecker.suggestSimilarHunspell(match, lang, 1, reader, FIELD, minFreq, timesFreq, dictPath);
   
            if ( allSuggestions.length > 0 ) {
              // only add word to suggestion if it is different
              if ( !match.equals( allSuggestions[0] ) ) {
                logger.info("suggestion: "+ allSuggestions[0]);
                matcher.appendReplacement( correction, "<em>"+ allSuggestions[0] +"</em>");
              }
            }        
          } catch (InterruptedException e) {     
            throw new IOException(e);
          }
        }
      }
      matcher.appendTail(correction);
    }
   
    response.setContentType("text/html; charset=UTF-8");
    response.setCharacterEncoding("UTF-8");
   
    PrintWriter out=response.getWriter();
      out.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
      out.println("<html>");
        out.println("<head>");
          out.println("<title>Query Spellchecker</title>");
        out.println("</head>");
        out.println("<body>");
          out.println("<h3>Query Spellchecker</h3>");
          out.println("<h5>Query:</h5>");
            out.println("<div id=\"query\">");     
            out.println( query );
          out.println("</div>");
          out.println("<h5>Correction:</h5>");
          out.println("<div id=\"correction\">");     
            out.println( correction.toString() );
          out.println("</div>");
        out.println("</body>");
      out.println("</html>");   
      out.close();
  }
View Full Code Here

     * @author Steve Jin <sjin@vmware.com>
     */
  private String readOvfContent(String ovfFilePath)
        throws IOException
  {
    StringBuffer strContent = new StringBuffer();
    BufferedReader in = new BufferedReader
            (new InputStreamReader(new FileInputStream(ovfFilePath)));
    String lineStr;
    while ((lineStr = in.readLine()) != null) {
      strContent.append(lineStr);
    }
    in.close();
    return strContent.toString();
  }
View Full Code Here

   * Extract title from plain text (first paragrapth until the maximum of tokens with LIMIT_TOKENS length)
   * @param text text
   * @return title from @text
   */
  private String getTitle(String text) {   
    StringBuffer buf=new StringBuffer();
    BufferedReader reader=new BufferedReader(new StringReader(text));
    int i=0;
    boolean hasText=false;
    boolean stop=false;
    int ntokens=0;
    String saux=null;
    String tokens[]=null;
   
    try {
      while (!stop && (saux=reader.readLine())!=null) {
        saux=saux.trim();     
          
        if (saux.equals("")) {
          if (hasText) {
            stop=true;
          }
        }
        else {
          hasText=true;
         
          tokens=saux.split("[^a-zA-Z_0-9����������������������������������]"); // a non-word character
          for (int j=0; ntokens<LIMIT_TOKENS && j<tokens.length; j++) {
            if (!tokens[j].equals("")) {
              if (ntokens!=0) {
                buf.append(' ');
             
              buf.append(tokens[j]);
              ntokens++;             
            }
          }
          if (ntokens==LIMIT_TOKENS) {
            stop=true;
          }       
        }
           
        i++;
      }
    }
    catch (IOException e) {
      e.printStackTrace();
      return "";
    }
   
    return buf.toString();
  }
View Full Code Here

        }
        return (List) hostList.clone();
    }

    public String toString() {
        StringBuffer buf = new StringBuffer();

        buf.append("FileName=" + propertyPath);
        buf.append(", ");
        buf.append(SignOnConstants.CERT_TERM_VALIDITY);
        buf.append("=");
        buf.append(getCertTermOfValidity());
        buf.append(", ");
        buf.append(SignOnConstants.LEGACY_PROXY);
        buf.append("=");
        buf.append(isLegacyProxy());
        buf.append(", ");
        buf.append(SignOnConstants.OPEN_BROWSER);
        buf.append("=");
        buf.append(isOpenBrowser());
        buf.append(SignOnConstants.HOST_LIST);
        buf.append("=");
        if (hostList != null) {
            buf.append(hostList.toString());
        }
        return buf.toString();
    }
View Full Code Here

     * Log a particular message
     *
     * @param mail the mail to process
     */
    public void service(Mail mail) {
        log(new StringBuffer(160).append("Logging mail ").append(mail.getName()).toString());
        if (comment != null) log(comment);
        try {
            if (headers) log(getMessageHeaders(mail.getMessage()));
            if (body) {
                int len = bodyMax > 0 ? bodyMax : mail.getMessage().getSize();
View Full Code Here

            int nColumnCount = mxTable.getAccessibleColumnCount();
            maRowCountLabel.setText (Integer.toString (nRowCount));
            maColumnCountLabel.setText (Integer.toString (nColumnCount));
            maCellCountLabel.setText (Integer.toString (nRowCount*nColumnCount));

            StringBuffer sList = new StringBuffer();
            int[] aSelected = mxTable.getSelectedAccessibleRows();
            boolean bFirst = true;
            for (int i=0; i<aSelected.length; i++)
            {
                if ( ! bFirst)
                {
                    sList.append (", ");
                    bFirst = false;
                }
                sList.append (Integer.toString(aSelected[i]));
            }
            maSelectedRowsLabel.setText (sList.toString());
            sList = new StringBuffer();
            aSelected = mxTable.getSelectedAccessibleColumns();
            bFirst = true;
            for (int i=0; i<aSelected.length; i++)
            {
                if ( ! bFirst)
                {
                    sList.append (", ");
                    bFirst = false;
                }
                sList.append (Integer.toString(aSelected[i]));
            }
            maSelectedColumnsLabel.setText (sList.toString());
        }
    }
View Full Code Here

  /**
   * Print out some information about this HDU.
   */
  public String toString() {
    StringBuffer sb = new StringBuffer();
    if (isHeader(myHeader)) {
      sb.append("  Image\n");
    } else {
      sb.append("  Image (bad header)\n");
    }

    sb.append("      Header Information:\n");
    sb.append("         BITPIX=" + myHeader.getIntValue("BITPIX", -1)
        + "\n");
    int naxis = myHeader.getIntValue(Header.NAXIS, -1);
    sb.append("         NAXIS=" + naxis + "\n");
    for (int i = 1; i <= naxis; i += 1) {
      sb.append("         NAXIS" + i + "="
          + myHeader.getIntValue(Header.NAXIS + i, -1) + "\n");
    }

    sb.append("      Data information:\n");
    try {
      if (myData.getData() == null) {
        sb.append("        No Data\n");
      } else {
        sb.append("         "
            + ArrayFuncs.arrayDescription(myData.getData()) + "\n");
      }
    } catch (Exception e) {
      sb.append("      Unable to get data\n");
    }
    return sb.toString();
  }
View Full Code Here

     *
     * @return a String containing the serialisation of this XPointer
     */
    public String toString() {
        if (shorthandPointer.equals(emptyNCName)) {
            StringBuffer buffer = new StringBuffer();
            Iterator parts = pointerParts.iterator();
            while (parts.hasNext()) {
                buffer.append(parts.next());
            }
            return buffer.toString();
        } else {
            return shorthandPointer.toString();
        }
    }
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.