Package co.nstant.in.cbor.model

Examples of co.nstant.in.cbor.model.ByteString


        add(convert(bytes));
        return this;
    }

    public ByteStringBuilder<CborBuilder> startByteString() {
        ByteString byteString = new ByteString(null);
        byteString.setChunked(true);
        add(byteString);
        return new ByteStringBuilder<CborBuilder>(this);
    }
View Full Code Here


    public void encode(ByteString byteString) throws CborException {
        byte[] bytes = byteString.getBytes();
        if (byteString.isChunked()) {
            encodeTypeChunked(MajorType.BYTE_STRING);
            if (bytes != null) {
                encode(new ByteString(bytes));
            }
        } else if (bytes == null) {
            encoder.encode(SimpleValue.NULL);
        } else {
            encodeTypeAndLength(MajorType.BYTE_STRING, bytes.length);
View Full Code Here

            if (negative) {
                encoder.encode(new Tag(3));
            } else {
                encoder.encode(new Tag(2));
            }
            encoder.encode(new ByteString(length.toByteArray()));
        }
    }
View Full Code Here

        long length = getLength(initialByte);
        if (length == INFINITY) {
            if (decoder.isAutoDecodeInfinitiveByteStrings()) {
                return decodeInfinitiveLength();
            } else {
                ByteString byteString = new ByteString(null);
                byteString.setChunked(true);
                return byteString;
            }
        } else {
            return decodeFixedLength(length);
        }
View Full Code Here

            dataItem = decoder.decodeNext();
            MajorType majorType = dataItem.getMajorType();
            if (Special.BREAK.equals(dataItem)) {
                break;
            } else if (majorType == MajorType.BYTE_STRING) {
                ByteString byteString = (ByteString) dataItem;
                try {
                    bytes.write(byteString.getBytes());
                } catch (IOException ioException) {
                    throw new CborException(ioException);
                }
            } else {
                throw new CborException("Unexpected major type "
                                + majorType);
            }
        }
        return new ByteString(bytes.toByteArray());
    }
View Full Code Here

    private ByteString decodeFixedLength(long length) throws CborException {
        ByteArrayOutputStream bytes = new ByteArrayOutputStream((int) length);
        for (long i = 0; i < length; i++) {
            bytes.write(nextSymbol());
        }
        return new ByteString(bytes.toByteArray());
    }
View Full Code Here

      return SimpleValue.FALSE;
    }
  }

  protected DataItem convert(byte[] bytes) {
    return new ByteString(bytes);
  }
View Full Code Here

      if (negative) {
        encoder.encode(new Tag(3));
      } else {
        encoder.encode(new Tag(2));
      }
      encoder.encode(new ByteString(length.toByteArray()));
    }
  }
View Full Code Here

TOP

Related Classes of co.nstant.in.cbor.model.ByteString

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.