Package java.lang

Examples of java.lang.StringBuilder


          int newssize = heraldNews.size();
          if(newssize==0){
            npc.say("My announcements list is empty.");
            return;
          }
          StringBuilder sb=new StringBuilder();
          sb.append("Here " + Grammar.isare(newssize) + " my current " + Grammar.plnoun(newssize,"announcement") + ": ");

         
          for(int i=0; i<newssize;i++){
            // will add 1 to position numbers to show position 0 as 1.
            logger.info("info: index "+Integer.toString(i));
            try {
            final int left = heraldNews.get(i).getLimit()/heraldNews.get(i).getInterval()-
                     heraldNews.get(i).getCounter();
            sb.append(" #"+Integer.toString(i+1)+". (left "+
                  Integer.toString(left)+" times): "+
                "#Every #"+Integer.toString(heraldNews.get(i).getInterval())+
                " #seconds #to #"+Integer.toString(heraldNews.get(i).getLimit())+
                " #seconds: \""+heraldNews.get(i).getNews()+"\"");
            } catch (IndexOutOfBoundsException ioobe) {
              logger.error("ReadNewsAction: size of heraldNews = "+
                  Integer.toString(newssize), ioobe);
            }
            if(i!=(newssize-1)){
              sb.append("; ");
            }
          }
          npc.say(sb.toString());
        }
View Full Code Here


          if(newssize==0){
            npc.say("My announcements list is empty.");
            return;
          }

          StringBuilder sb=new StringBuilder();
          sb.append("Here " + Grammar.isare(newssize) + " my current " + Grammar.plnoun(newssize,"announcement") + ": ");
         
          for(int i=0; i<newssize;i++){
            // will add 1 to position numbers to show position 0 as 1.
            logger.info("info: index "+Integer.toString(i));
            try {
            sb.append("\""+heraldNews.get(i).getNews()+"\"");
            } catch (IndexOutOfBoundsException ioobe) {
              logger.error("ReadNewsAction: size of heraldNews = "+
                  Integer.toString(newssize), ioobe);
            }
            if(i!=(newssize-1)){
              sb.append("; ");
            }
          }
          npc.say(sb.toString());
        }
View Full Code Here

  */

  public InputStream getPayload1()
      throws Exception {

    StringBuilder s = new StringBuilder();

    s.setLength(0);
    s.append("<html>\n");
    s.append("  <head>\n");
    s.append("    <title>This is a web page!</title>\n");
    s.append("  </head>\n");
    s.append("  <body>\n");
    s.append("    <h1>This is some content!</h1>\n");
    s.append("  </body>\n");
    s.append("</html>");

    String content = s.toString();

    s.setLength(0);
    s.append("HTTP/1.1 200 OK\r\n");
    s.append("Date: Fri, 31 Dec 1999 23:59:59 GMT\r\n");
    s.append("Content-Type: text/html; charset=utf-8\r\n");
    s.append("\r\n");
    s.append(content);
    s.insert(0, "http://www.example.com/path/file.php?param=123,456%20789 123.123.123.123 20120235131415 text/html "+(s.length()-3)+"\n");

    return new ByteArrayInputStream(s.toString().getBytes("UTF-8"));
  }   
View Full Code Here

    assertNotNull(r.getHttpResponse().getEntity());

    byte[] buffer = new byte[1000];
    r.getHttpResponse().getEntity().getContent().read(buffer, 0, 1000);

    StringBuilder s = new StringBuilder();
    s.append("<html>\n");
    s.append("  <head>\n");
    s.append("    <title>This is a web page!</title>\n");
    s.append("  </head>\n");
    s.append("  <body>\n");
    s.append("    <h1>This is some content!</h1>\n");
    s.append("  </body>\n");
    s.append("</html>");

    String v1 = s.toString();
    String v2 = new String(buffer, "UTF-8");

    assertEquals(v1.trim(), v2.trim());
  }
View Full Code Here

    public abstract String name();

    @Override
    public String toString() {
        StringBuilder msg = new StringBuilder();

        msg.append("(Name: " + name() + " Operator Key: " + mKey + ")");

        return msg.toString();
    }
View Full Code Here

        this.totalSplits = totalSplits;
    }

    @Override
    public String toString() {
        StringBuilder st = new StringBuilder();
        st.append("Number of splits :" + wrappedSplits.length+"\n");
        try {
            st.append("Total Length = "+ getLength()+"\n");
            for (int i = 0; i < wrappedSplits.length; i++) {
                st.append("Input split["+i+"]:\n   Length = "+ wrappedSplits[i].getLength()+"\n  Locations:\n");
                for (String location :  wrappedSplits[i].getLocations())
                    st.append("    "+location+"\n");
                st.append("\n-----------------------\n");
          }
        } catch (IOException e) {
          return null;
        } catch (InterruptedException e) {
          return null;
        }
        return st.toString();
    }
View Full Code Here

     * @param delim Delimiter to use in the string.
     * @return A string containing the tuple.
     * @throws ExecException if a non-atomic value is found.
     */
    public String toDelimitedString(String delim) throws ExecException {
        StringBuilder buf = new StringBuilder();
        for (Iterator<Object> it = mFields.iterator(); it.hasNext();) {
            Object field = it.next();
            buf.append(field == null ? "" : field.toString());
            if (it.hasNext())
                buf.append(delim);
        }
        return buf.toString();
    }
View Full Code Here

           throw new ParseException(err.getMessage());
          }     
        }
        catch (Exception e) {
          LOG.error("Parsing exception:"+e.toString());
          StringBuilder buffer = new StringBuilder(16000); // TODO MC
          Token t=null
         
          do {
            try {
              t = getNextToken();
              buffer.append(t.image);
            }                       
            catch (Error err) {
              LOG.error("Parsing nested error:"+err.toString());
            }
            catch (Exception enest) {
              LOG.error("Parsing nested exception:"+enest.toString());
            }
          }
          while (t.kind != DOC_END && t.kind != EOF);
          docBody.append(buffer.toString()); // TODO MC
          if (t.kind != EOF) {
            // Eat up DOC_END.
            try {
              t = getNextToken();
            }             
View Full Code Here

    jj_consume_token(0);
  }

  final public String body() throws ParseException {
    Token bd = null;
    StringBuilder buffer = new StringBuilder(16000);
    label_7:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case BODY:
          ;
          break;
        default:
          jj_la1[12] = jj_gen;
        break label_7;
        }
        bd = jj_consume_token(BODY);
        buffer.append(bd.image);
      }
    {if (true) return(buffer.toString());}
    throw new Error("Missing return statement in function");
  }
View Full Code Here

      }
  }

  final public void header(TRECDoc d) throws ParseException {
    Token la = null, ct = null;
    StringBuilder buffer = new StringBuilder();
    try {
      la = jj_consume_token(HEADER_LABEL);
      label_9:
        while (true) {
          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
          case HEADER_CONTENT:
            ;
            break;
          default:
            jj_la1[14] = jj_gen;
          break label_9;
          }
          ct = jj_consume_token(HEADER_CONTENT);
          buffer.append(ct.image);
        }
      jj_consume_token(HEADER_END);
      d.headers.put(la.image.substring(0,la.image.length()-2), buffer.toString());
    } catch (ParseException e) {
      LOG.error(e.toString());
      Token t;
      do {
        t = getNextToken();
View Full Code Here

TOP

Related Classes of java.lang.StringBuilder

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.