protected StringBuffer parseString(StringBuffer sbuf) throws IOException {
  int ch=read();
  for (; ch >= 0 && ch != '<'; ch=read()) {
    if (ch == '&') {
      ch=read();
      if (ch == '#') {
        ch=read();
        if (ch >= '0' && ch <= '9') {
          int v=0;
          for (; ch >= '0' && ch <= '9'; ch=read()) {
            v=10 * v + ch - '0';
          }
          sbuf.append((char)v);
        }
      }
 else {
        StringBuffer entityBuffer=new StringBuffer();
        for (; ch >= 'a' && ch <= 'z'; ch=read())         entityBuffer.append((char)ch);
        String entity=entityBuffer.toString();
        if (entity.equals("amp"))         sbuf.append('&');
 else         if (entity.equals("apos"))         sbuf.append('\'');
 else         if (entity.equals("quot"))         sbuf.append('"');
 else         if (entity.equals("lt"))         sbuf.append('<');
 else         if (entity.equals("gt"))         sbuf.append('>');
 else         throw new BurlapProtocolException("unknown XML entity &" + entity + "; at `"+ (char)ch+ "'");
      }
      if (ch != ';')       throw expectedChar("';'",ch);
    }
 else     if (ch < 0x80)     sbuf.append((char)ch);
 else     if ((ch & 0xe0) == 0xc0) {
      int ch1=read();
      int v=((ch & 0x1f) << 6) + (ch1 & 0x3f);
      sbuf.append((char)v);
    }
 else     if ((ch & 0xf0) == 0xe0) {
      int ch1=read();
      int ch2=read();
      int v=((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f);
      sbuf.append((char)v);
    }
 else     throw new BurlapProtocolException("bad utf-8 encoding");
  }
  peek=ch;
  return sbuf;
}

protected StringBuffer parseString ( StringBuffer sbuf ) throws IOException { int ch = read ( ) ; for ( ; ch >= 0 && ch != '<' ; ch = read ( ) ) { if ( ch == '&' ) { ch = read ( ) ; if ( ch == '#' ) { ch = read ( ) ; if ( ch >= '0' && ch <= '9' ) { int v = 0 ; for ( ; ch >= '0' && ch <= '9' ; ch = read ( ) ) { v = 10 * v + ch - '0' ; } sbuf . append ( ( char ) v ) ; } } else { StringBuffer entityBuffer = new StringBuffer ( ) ; for ( ; ch >= 'a' && ch <= 'z' ; ch = read ( ) ) entityBuffer . append ( ( char ) ch ) ; String entity = entityBuffer . toString ( ) ; if ( entity . equals ( "amp" ) ) sbuf . append ( '&' ) ; else if ( entity . equals ( "apos" ) ) sbuf . append ( '\'' ) ; else if ( entity . equals ( "quot" ) ) sbuf . append ( '"' ) ; else if ( entity . equals ( "lt" ) ) sbuf . append ( '<' ) ; else if ( entity . equals ( "gt" ) ) sbuf . append ( '>' ) ; else throw new BurlapProtocolException ( "unknown XML entity &" + entity + "; at `" + ( char ) ch + "'" ) ; } if ( ch != ';' ) throw expectedChar ( "';'" , ch ) ; } else if ( ch < 0x80 ) sbuf . append ( ( char ) ch ) ; else if ( ( ch & 0xe0 ) == 0xc0 ) { int ch1 = read ( ) ; int v = ( ( ch & 0x1f ) << 6 ) + ( ch1 & 0x3f ) ; sbuf . append ( ( char ) v ) ; } else if ( ( ch & 0xf0 ) == 0xe0 ) { int ch1 = read ( ) ; int ch2 = read ( ) ; int v = ( ( ch & 0x0f ) << 12 ) + ( ( ch1 & 0x3f ) << 6 ) + ( ch2 & 0x3f ) ; sbuf . append ( ( char ) v ) ; } else throw new BurlapProtocolException ( "bad utf-8 encoding" ) ; } peek = ch ; return sbuf ; }
parses a string value from the stream . the burlap object ' s string buffer is used for the result .
