Package rocket.serialization.client

Examples of rocket.serialization.client.SerializationException


  protected void prepare0(final String stream) {
    final int comma = stream.indexOf(',');
    final String countString = stream.substring(0, comma);
    int count = Integer.parseInt(countString);
    if (count < 0) {
      throw new SerializationException("String table count is invalid, count: " + count);
    }

    // extract strings and add them to the string table...
    final Map<Integer, String> strings = this.createStrings();
    int j = comma + 1;
    for (int i = 0; i < count; i++) {
      final StringBuffer buf = new StringBuffer();

      // consume leading double quote...
      final char first = stream.charAt(j);
      j++;
      Checker.equals("must be start of quoted string", '\"', first);

      while (true) {
        // consume a char within the quoted string...
        final char c = stream.charAt(j);
        j++;

        // check if closing quote...
        if (c == '"') {
          break;
        }

        // not a backslash add literally...
        if (c != '\'') {
          buf.append(c);
          continue;
        }

        // handle escaped char...
        final char d = stream.charAt(j);
        j++;

        if (d == '\0') {
          buf.append('\0');
          continue;
        }
        if (d == '\t') {
          buf.append('\t');
          continue;
        }
        if (d == '\n') {
          buf.append('\n');
          continue;
        }
        if (d == '\r') {
          buf.append('\r');
          continue;
        }
        if (d == '\\') {
          buf.append('\\');
          continue;
        }
        if (d == '"') {
          buf.append('"');
          continue;
        }
        if (d == 'u') {
          final String codeString = stream.substring(j, j + 4);
          final int code = Integer.parseInt(codeString);
          buf.append((char) code);

          // consume trailing semi colon
          final char semiColon = stream.charAt(j);
          if (semiColon != ';') {
            throw new SerializationException("Stream is corrupted, expected semiColon got \"" + semiColon + "\".");
          }
          j++;
          continue;
        }
        throw new SerializationException("Unknown escaped char '" + d + "'.");
      }

      // add string to table...
      final Integer reference = new Integer(i + Constants.STRING_BIAS);
      strings.put(reference, buf.toString());
View Full Code Here


  protected Class getType(final String typeName) {
    try {
      return Class.forName(typeName);
    } catch (final ClassNotFoundException classNotFound) {
      throw new SerializationException("Unable to instantiate " + typeName, classNotFound);
    }
  }
View Full Code Here

      }

      final String name = field.getName();
      // complain if final
      if (Modifier.isFinal(modifiers)) {
        throw new SerializationException("Unable to serialize type because of final field \"" + name + "\" belonging to type: "
            + classs.getName());
      }

      serializableFields.add(field);
    } // for
View Full Code Here

      throwUnableToSerialize(object);
    }
  }

  protected void throwUnableToSerialize(final Object object) {
    throw new SerializationException("Unable to serialize " + object.getClass().getName());
  }
View Full Code Here

TOP

Related Classes of rocket.serialization.client.SerializationException

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.