Examples of ByteArrayBuilder


Examples of com.fasterxml.jackson.core.util.ByteArrayBuilder

    }

    @SuppressWarnings("resource")
    public byte[] asBytes(Object value) throws IOException, JSONObjectException
    {
        ByteArrayBuilder bb = new ByteArrayBuilder(_jsonFactory._getBufferRecycler());
        try {
            _writeAndClose(value, _jsonFactory.createGenerator(bb, JsonEncoding.UTF8));
        } catch (JsonProcessingException e) { // to support [JACKSON-758]
            throw e;
        } catch (IOException e) { // shouldn't really happen, but is declared as possibility so:
            throw JSONObjectException.fromUnexpectedIOE(e);
        }
        byte[] result = bb.toByteArray();
        bb.release();
        return result;
    }
View Full Code Here

Examples of com.fasterxml.jackson.core.util.ByteArrayBuilder

        return JSONComposer.stringComposer(_features, _jsonFactory.createGenerator(out), out);
    }

    @SuppressWarnings("resource")
    public JSONComposer<byte[]> composeBytes() throws IOException, JSONObjectException {
        ByteArrayBuilder out = new ByteArrayBuilder(_jsonFactory._getBufferRecycler());
        return JSONComposer.bytesComposer(_features, _jsonFactory.createGenerator(out), out);
    }
View Full Code Here

Examples of com.fasterxml.jackson.core.util.ByteArrayBuilder

     */
   
    public ByteArrayBuilder _getByteArrayBuilder()
    {
        if (_byteArrayBuilder == null) {
            _byteArrayBuilder = new ByteArrayBuilder();
        } else {
            _byteArrayBuilder.reset();
        }
        return _byteArrayBuilder;
    }
View Full Code Here

Examples of com.fasterxml.jackson.core.util.ByteArrayBuilder

            }
            final String str = getText();
            if (str == null) {
                return null;
            }
            ByteArrayBuilder builder = _byteBuilder;
            if (builder == null) {
                _byteBuilder = builder = new ByteArrayBuilder(100);
            } else {
                _byteBuilder.reset();
            }
            _decodeBase64(str, builder, b64variant);
            return builder.toByteArray();
        }
View Full Code Here

Examples of com.fasterxml.jackson.core.util.ByteArrayBuilder

            }
            final String str = getText();
            if (str == null) {
                return null;
            }
            ByteArrayBuilder builder = _byteBuilder;
            if (builder == null) {
                _byteBuilder = builder = new ByteArrayBuilder(100);
            } else {
                _byteBuilder.reset();
            }
            _decodeBase64(str, builder, b64variant);
            return builder.toByteArray();
        }
View Full Code Here

Examples of com.fasterxml.jackson.core.util.ByteArrayBuilder

    }

    @SuppressWarnings("resource")
    public byte[] asBytes(Object value) throws IOException, JSONObjectException
    {
        ByteArrayBuilder bb = new ByteArrayBuilder(_jsonFactory._getBufferRecycler());
        try {
            _writeAndClose(value, _jsonFactory.createGenerator(bb, JsonEncoding.UTF8));
        } catch (JsonProcessingException e) { // to support [JACKSON-758]
            throw e;
        } catch (IOException e) { // shouldn't really happen, but is declared as possibility so:
            throw JSONObjectException.fromUnexpectedIOE(e);
        }
        byte[] result = bb.toByteArray();
        bb.release();
        return result;
    }
View Full Code Here

Examples of com.fasterxml.jackson.core.util.ByteArrayBuilder

        return JSONComposer.stringComposer(_features, _jsonFactory.createGenerator(out), out);
    }

    @SuppressWarnings("resource")
    public JSONComposer<byte[]> composeBytes() throws IOException, JSONObjectException {
        ByteArrayBuilder out = new ByteArrayBuilder(_jsonFactory._getBufferRecycler());
        return JSONComposer.bytesComposer(_features, _jsonFactory.createGenerator(out), out);
    }
View Full Code Here

Examples of com.serotonin.m2m2.db.dao.nosql.ByteArrayBuilder

   */
  @Override
  public ITime getObject(byte[] bytes, int readOffset, long ts) {
   
    //Get the data type
    ByteArrayBuilder b = new ByteArrayBuilder(bytes, readOffset, bytes.length);

    //Get the data type
    int dataType = b.getShort();
    DataValue dataValue = null;
   
    //Second put in the data value
    switch(dataType){
      case DataTypes.ALPHANUMERIC:
        String s = b.getString();
        dataValue = new AlphanumericValue(s);
        break;
      case DataTypes.BINARY:
        boolean bool  = b.getBoolean();
        dataValue = new BinaryValue(bool);
        break;
      case DataTypes.IMAGE:
        throw new ShouldNeverHappenException("Images are not supported");
      case DataTypes.MULTISTATE:
        int i  = b.getInt();
        dataValue = new MultistateValue(i);
        break;
      case DataTypes.NUMERIC:
        double d  = b.getDouble();
        dataValue = new NumericValue(d);
        break;
      default:
        throw new ShouldNeverHappenException("Data type of " + dataType + " is not supported");
    }
   
    //Get the annotation
    String annotation = b.getString();
   
 
    if(annotation != null){
      try{
        return new AnnotatedPointValueTime(dataValue, ts, TranslatableMessage.deserialize(annotation));
View Full Code Here

Examples of com.serotonin.m2m2.db.dao.nosql.ByteArrayBuilder

   * @see com.serotonin.m2m2.db.dao.nosql.NoSQLDataSerializer#getBytes(com.serotonin.m2m2.db.dao.nosql.NoSQLDataEntry)
   */
  @Override
  public byte[] getBytes(ITime obj) {
    PointValueTime value = (PointValueTime)obj;
    ByteArrayBuilder b = new ByteArrayBuilder();
    //First put in the data type
    b.putShort((short) value.getValue().getDataType());
   
    //Second put in the data value
    switch(value.getValue().getDataType()){
      case DataTypes.ALPHANUMERIC:
        b.putString(value.getStringValue());
        break;
      case DataTypes.BINARY:
        b.putBoolean(value.getBooleanValue());
        break;
      case DataTypes.IMAGE:
        throw new ShouldNeverHappenException("Images are not supported");
      case DataTypes.MULTISTATE:
        b.putInt(value.getIntegerValue());
        break;
      case DataTypes.NUMERIC:
        b.putDouble(value.getDoubleValue());
        break;
      default:
        throw new ShouldNeverHappenException("Data type of " + value.getValue().getDataType() + " is not supported");

    }
   
    //Put in annotation
    if(value.isAnnotated()){
      AnnotatedPointValueTime apv = (AnnotatedPointValueTime)value;
      b.putString(apv.getSourceMessage().serialize());
    }else
      b.putString(null);
   
    byte[] buffer = b.getBuffer();
    byte[] bytes = new byte[b.getWriteOffset()];
    System.arraycopy(buffer, 0, bytes, 0, b.getWriteOffset());
   
    return bytes;
  }
View Full Code Here

Examples of one.nio.util.ByteArrayBuilder

        }
        if (includeBody && body != null) {
            estimatedSize += body.length;
        }

        ByteArrayBuilder builder = new ByteArrayBuilder(estimatedSize);
        builder.append(PROTOCOL_HEADER);
        for (int i = 0; i < headerCount; i++) {
            builder.append(headers[i]).append('\r').append('\n');
        }
        builder.append('\r').append('\n');
        if (includeBody && body != null) {
            builder.append(body);
        }
        return builder.buffer();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.