Package org.bson

Examples of org.bson.BSONException


    // also skip the terminator
    buffer.readByte();
    try {
      return new String(bytes, "UTF-8");
    } catch (java.io.UnsupportedEncodingException uee) {
      throw new BSONException("impossible", uee);
    }
  }
View Full Code Here


  static final String readUTF8String(ChannelBuffer buffer, byte[] fourBytes) {
    int size = readInt32(buffer, fourBytes);
    // this is just protection in case it's corrupted, to avoid huge strings
    if (size <= 0 || size > (32 * 1024 * 1024))
      throw new BSONException("bad string size: " + size);

    byte[] b = new byte[size];
    buffer.readBytes(b);

    try {
      return new String(b, 0, size - 1, "UTF-8");
    } catch (java.io.UnsupportedEncodingException uee) {
      throw new BSONException("impossible", uee);
    }
  }
View Full Code Here

        for (int i = 0; i < len;/*i gets incremented*/) {
            final int c = Character.codePointAt(str, i);

            if (checkForNullCharacters && c == 0x0) {
                throw new BSONException(
                        String.format("BSON cstring '%s' is not valid because it contains a null character at index %d", str, i));
            }
            if (c < 0x80) {
                write((byte) c);
                total += 1;
View Full Code Here

    public String getUTF8String(int valueOffset) {
        int size = getInt(valueOffset) - 1;
        try {
            return new String(array(), valueOffset + 4, size, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new BSONException( "Cannot decode string as UTF-8." );
        }
    }
View Full Code Here

     * @throws BSONException if maximum serialization depth exceeded.
     */
    public void writeStartArray() {
        serializationDepth++;
        if (serializationDepth > settings.getMaxSerializationDepth()) {
            throw new BSONException("Maximum serialization depth exceeded (does the object being serialized have a circular reference?).");
        }
    }
View Full Code Here

     * @throws BSONException if maximum serialization depth exceeded.
     */
    public void writeStartDocument() {
        serializationDepth++;
        if (serializationDepth > settings.getMaxSerializationDepth()) {
            throw new BSONException("Maximum serialization depth exceeded (does the object being serialized have a circular reference?).");
        }
    }
View Full Code Here

                                           final BSONContextType... validContextTypes) {
        final String validContextTypesString = StringUtils.join(" or ", Arrays.asList(validContextTypes));
        final String message = format("%s can only be called when ContextType is %s, "
                                      + "not when ContextType is %s.", methodName, validContextTypesString,
                                      actualContextType);
        throw new BSONException(message);
    }
View Full Code Here

                if (Arrays.asList('A', 'E', 'I', 'O', 'U').contains(typeName.charAt(0))) {
                    article = "An";
                }
                message = format("%s %s value cannot be written to the root level of a BSON document.", article,
                                 typeName);
                throw new BSONException(message);
            }
        }

        final String validStatesString = StringUtils.join(" or ", Arrays.asList(validStates));
        message = format("%s can only be called when State is %s, not when State is %s", methodName,
                         validStatesString, state);
        throw new BSONException(message);
    }
View Full Code Here

TOP

Related Classes of org.bson.BSONException

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.