Package java.lang

Examples of java.lang.StringBuffer


     * @return The last server response.
     ***/
    public String getReplyString()
    {
        Enumeration en;
        StringBuffer buffer = new StringBuffer(256);

        en = _replyLines.elements();
        while (en.hasMoreElements())
        {
            buffer.append((String)en.nextElement());
            buffer.append(SocketClient.NETASCII_EOL);
        }

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


        m_setterString = "addLiteralResultAttribute";

        return m_setterString;
      }

      StringBuffer outBuf = new StringBuffer();

      outBuf.append("set");

      if ((m_namespace != null)
              && m_namespace.equals(Constants.S_XMLNAMESPACEURI))
      {
        outBuf.append("Xml");
      }

      int n = m_name.length();

      for (int i = 0; i < n; i++)
      {
        char c = m_name.charAt(i);

        if ('-' == c)
        {
          i++;

          c = m_name.charAt(i);
          c = Character.toUpperCase(c);
        }
        else if (0 == i)
        {
          c = Character.toUpperCase(c);
        }

        outBuf.append(c);
      }

      m_setterString = outBuf.toString();
    }

    return m_setterString;
  }
View Full Code Here

     throws Exception
  {
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br =
      new BufferedReader(isr);
    StringBuffer sb = new StringBuffer();
    String l;
    while((l = br.readLine()) != null) {
      sb.append(l);
      sb.append("<CR>");
    }
    is.close();
    return sb.toString();
  }
View Full Code Here

  private void handlePartialScanCommand(TableScanOperator tableScan, ParseContext parseContext,
      QBParseInfo parseInfo, StatsWork statsWork, GenTezProcContext context,
      Task<StatsWork> statsTask) throws SemanticException {

    String aggregationKey = tableScan.getConf().getStatsAggPrefix();
    StringBuffer aggregationKeyBuffer = new StringBuffer(aggregationKey);
    List<Path> inputPaths = GenMapRedUtils.getInputPathsForPartialScan(parseInfo, aggregationKeyBuffer);
    aggregationKey = aggregationKeyBuffer.toString();
   
    // scan work
    PartialScanWork scanWork = new PartialScanWork(inputPaths);
    scanWork.setMapperCannotSpanPartns(true);
    scanWork.setAggKey(aggregationKey);
View Full Code Here

            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

        }
     
    if (curChar != '"')
      throw (new InvalidCharException("stringLiteral() was called when the next character was not a double quote.  Position: " + _pos));
   
    StringBuffer sb = new StringBuffer("\"");
    _pos++;
    try {
      curChar = _queryString.charAt(_pos);
      while (curChar != '"') {
        sb.append(curChar);
        //if the current char is backslash, don't check append the next char
        //without checking whether it's a quote.
        if (curChar == '\\') {
          _pos++;
          curChar = _queryString.charAt(_pos);
          sb.append(curChar);
        }
        _pos++;
        curChar = _queryString.charAt(_pos);
      }
      //append and consume the closing quote
      sb.append(curChar);
      _pos++;
    }
    catch (IndexOutOfBoundsException e) {
      throw ( new InvalidCharException( "End of query string reached, but \" expected." ) );
        }
   
    return ( new Token( STRING_LITERAL, sb.toString() ) );
  }
View Full Code Here

        }
     
    if (curChar != '\'')
      throw (new InvalidCharException("charLiteral() was called when the next character was not a double quote.  Position: " + _pos));
   
    StringBuffer sb = new StringBuffer("'");
    _pos++;
    try {
      curChar = _queryString.charAt(_pos);
      //append the first char after the '
      sb.append(curChar);
      _pos++;
     
      //if the current char is backslash, consume escaped char
      if (curChar == '\\') {
        curChar = _queryString.charAt(_pos);
        sb.append(curChar);
        _pos++;
      }
      curChar = _queryString.charAt(_pos);
      if (curChar == '\'') {
        sb.append(curChar);
        _pos++;
      }
      else
        throw ( new InvalidCharException( "Character literals may only contain a single character or escape sequence.  Position: " + _pos ) );
    }
    catch (IndexOutOfBoundsException e) {
      throw ( new InvalidCharException( "End of query string reached, but \' expected." ) );
    }

    return ( new Token( CHAR_LITERAL, sb.toString() ) );
  }
View Full Code Here

        }
     
    if ( ! isDigit(curChar) )
      throw (new InvalidCharException("numericLiteral() was called when the next character was not a digit.  Position: " + _pos));
   
    StringBuffer sb = new StringBuffer().append(curChar);
    _pos++;
    curChar = getChar();
         
    while ( isDigit(curChar) ) {
      sb.append(curChar);
      _pos++;
      curChar = getChar();
    }

    //is this a long or a double
    if (curChar == '.') {
      //it's a double
      sb.append('.');
      _pos++;
      curChar = getChar();
           
      if ( ! isDigit(curChar) )
        throw (new InvalidCharException( "Digit expected after decimal point in double literal. Position: " + _pos));
       
      while ( isDigit(curChar) ) {
        sb.append(curChar);
        _pos++;
        curChar = getChar();
      }
     
      if (curChar == 'E' || curChar == 'e') {
        sb.append(curChar);
        _pos++;
        curChar = getChar();
       
        boolean isExponentSigned = false;
        if (curChar == '+' || curChar == '-') {
          isExponentSigned = true;
          sb.append(curChar);
          _pos++;
          curChar = getChar();
        }
       
        if ( ! isDigit(curChar) )
          if (isExponentSigned)
            throw (new InvalidCharException( "Digit expected after sign in exponent (double literal).  Position: " + _pos ));
          else
            throw (new InvalidCharException( "Digit expected after exponent character (double literal).  Position: " + _pos ));
        else {
          sb.append(curChar);
          _pos++;
          curChar = getChar();
          while ( isDigit(curChar) ) {
            sb.append(curChar);
            _pos++;
            curChar = getChar();
          }
        }
      }
     
      return (new Token( DOUBLE_LITERAL, sb.toString() ) );
    }
    else
      //it's a long
      return (new Token( LONG_LITERAL, sb.toString() ) );
  }
View Full Code Here

        }
     
    if ( ! isLetter(curChar) )
      throw (new InvalidCharException("identifier() was called when the next character was not a letter.  Position: " + _pos));
   
    StringBuffer sb = new StringBuffer().append(curChar);
    _pos++;
    curChar = getChar();
         
    while ( isDigit(curChar) || isLetter(curChar) || curChar == '_' ) {
      sb.append(curChar);
      _pos++;
      curChar = getChar();
    }

    String ident = sb.toString().toLowerCase();

    // If there's a dot before, we'll assume that it's an identifier in any case.
    if( oldChar == '.' )
        return (new Token( IDENTIFIER, sb.toString() ));

    if (ident.equals("date"))
      return dateLiteral(sb.toString());
    if (ident.equals("time"))
      return timeLiteral(sb.toString());
    if (ident.equals("timestamp"))
      return timeStampLiteral(sb.toString());
     
    if (ident.equals("true") || ident.equals("false"))
      return (new Token( BOOLEAN_LITERAL, sb.toString() ));

    if (keywords.containsKey(ident))
      return (new Token( ((Integer)keywords.get(ident)).intValue(),
                         sb.toString() ));

    return (new Token( IDENTIFIER, sb.toString() ));

  }
View Full Code Here

   *    date literal is otherwise not of the proper form:
   *    date 'longLiteral-longLiteral-longLiteral'.
   */
  private Token dateLiteral(String alreadyConsumed) throws InvalidCharException {
 
    StringBuffer sb = new StringBuffer(alreadyConsumed);
   
    char curChar = getChar();
    try {
     
      curChar = _queryString.charAt(_pos);
     
      curChar = consumeWhiteSpace(curChar);
     
      if ( curChar != '\'' )
        throw (new InvalidCharException("The date keyword must be followed by a single quote.  Position: " + _pos));
  
      sb.append(" '");
      _pos++;
      curChar = _queryString.charAt(_pos);
          
      curChar = consumeWhiteSpace(curChar);
     
      if ( ! isDigit(curChar) )
        throw (new InvalidCharException("Digit expected in date literal.  Position: " + _pos));
       
      while ( isDigit(curChar) ) {
        sb.append(curChar);
        _pos++;
        curChar = _queryString.charAt(_pos);
      }

      curChar = consumeWhiteSpace(curChar);
     
      if ( curChar != '-' )
        throw (new InvalidCharException("- expected.  Fields in date literal must be separated by a dash.  Position: " + _pos));
  
      sb.append(curChar);
      _pos++;
      curChar = _queryString.charAt(_pos);
          
      curChar = consumeWhiteSpace(curChar);
     
      if ( ! isDigit(curChar) )
        throw (new InvalidCharException("Digit expected in date literal.  Position: " + _pos));
       
      while ( isDigit(curChar) ) {
        sb.append(curChar);
        _pos++;
        curChar = _queryString.charAt(_pos);
      }

      curChar = consumeWhiteSpace(curChar);
     
      if ( curChar != '-' )
        throw (new InvalidCharException("- expected.  Fields in date literal must be separated by a dash.  Position: " + _pos));
  
      sb.append(curChar);
      _pos++;
      curChar = _queryString.charAt(_pos);
          
      curChar = consumeWhiteSpace(curChar);
     
      if ( ! isDigit(curChar) )
        throw (new InvalidCharException("Digit expected in date literal.  Position: " + _pos));
       
      while ( isDigit(curChar) ) {
        sb.append(curChar);
        _pos++;
        curChar = _queryString.charAt(_pos);
      }

      curChar = consumeWhiteSpace(curChar);
     
      if ( curChar != '\'' )
        throw (new InvalidCharException("' expected.  Date literal must be enclosed by a single quotes.  Position: " + _pos));

      sb.append(curChar);
      _pos++;

      return (new Token( DATE_LITERAL, sb.toString() ));

    }
    catch (IndexOutOfBoundsException e) {
      throw (new InvalidCharException("End of query encountered in the middle of date literal."));
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.