Package net.buffalo.protocal

Examples of net.buffalo.protocal.ProtocolException


    if (value.equals("1")) {
      return Boolean.TRUE;
    } else if (value.equals("0")) {
      return Boolean.FALSE;
    } else {
      throw new ProtocolException("<"+ProtocalTag.TAG_BOOLEAN+"> contains only 1 or 0: "+ value);
    }
  }
View Full Code Here


      currentTag = new Tag(tag, parseString());
      stack.push(currentTag);
      depth++;
      break;
     
    default: throw new ProtocolException("unexpected tag: " + tagName(tag));
    }
  }
View Full Code Here

  }

  public Converter lookupConverterForTagName(String tagName) {
    Object converter = tagNameConverterCache.get(tagName);
    if (converter == null) {
      throw new ProtocolException("unrecoganized tag: " + tagName);
    }
   
    return (Converter) converter;
  }
View Full Code Here

    currentTag = (Tag) stack.pop();
    if (currentTag.tag+100 == tag) {
      depth--;
      currentTag = (Tag) stack.get(depth-1);
    } else {
      throw new ProtocolException("tag not match: " + tagName(currentTag.tag));
    }
  }
View Full Code Here

          for (; ch >= '0' && ch <= '9'; ch = read()) {
            v = 10 * v + ch - '0';
          }

          if (ch != ';')
            throw new ProtocolException("expected ';' at " + (char) ch);

          return (char) v;
        } else
          throw new ProtocolException("expected digit at " + (char) ch);
      } else {
        entityBuffer.setLength(0);
        for (; ch >= 'a' && ch <= 'z'; ch = read())
          entityBuffer.append((char) ch);

        String entity = entityBuffer.toString();

        if (ch != ';')
          throw expectedChar("';'", ch);

        if (entity.equals("amp"))
          return '&';
        else if (entity.equals("apos"))
          return '\'';
        else if (entity.equals("quot"))
          return '"';
        else if (entity.equals("lt"))
          return '<';
        else if (entity.equals("gt"))
          return '>';
        else
          throw new ProtocolException("unknown XML entity &"
              + entity + "; at `" + (char) ch + "'");
      }
    } else if (ch < 0x80)
      return (char) ch;
    else if ((ch & 0xe0) == 0xc0) {
      int ch1 = read();
      int v = ((ch & 0x1f) << 6) + (ch1 & 0x3f);

      return (char) v;
    } else if ((ch & 0xf0) == 0xe0) {
      int ch1 = read();
      int ch2 = read();
      int v = ((ch & 0x0f) << 12) + ((ch1 & 0x3f) << 6) + (ch2 & 0x3f);
      return (char) v;
    } else
      throw new ProtocolException("bad utf-8 encoding");
  }
View Full Code Here

    if (!isTagChar(ch)) throw expectedChar("tag", ch);
    sbuf.setLength(0);
    for (; isTagChar(ch); ch = read()) sbuf.append((char) ch);
    if (ch != '>') throw expectedChar("'>'", ch);
    Integer value = (Integer) tagCache.get(sbuf.toString());
    if (value == null) throw new ProtocolException("Unknown tag <" + sbuf + ">");

    return value.intValue() + endTagDelta;
  }
View Full Code Here

    }
  }

  private ProtocolException expectedChar(String expect, int ch) {
    if (ch < 0)
      return new ProtocolException("expected " + expect + " at end of file");
    else
      return new ProtocolException("expected " + expect + " at " + (char) ch);
  }
View Full Code Here

    return num < 10 ? "0" + num : String.valueOf(num);
  }

  public static java.util.Date fromUTCString(String string) {
    if (string == null || !Pattern.matches("^\\d{8}T\\d{6}Z$", string)) {
      throw new ProtocolException("date format error: " + string);
    }
    Calendar cal = Calendar.getInstance();
        cal.clear();
    cal.set(Calendar.YEAR, Integer.valueOf(string.substring(0,4)).intValue());
    cal.set(Calendar.MONTH, Integer.valueOf(string.substring(4,6)).intValue() - 1);
View Full Code Here

TOP

Related Classes of net.buffalo.protocal.ProtocolException

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.