Package co.nstant.in.cbor.model

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


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

    public UnicodeStringBuilder<CborBuilder> startString() {
        UnicodeString unicodeString = new UnicodeString(null);
        unicodeString.setChunked(true);
        add(unicodeString);
        return new UnicodeStringBuilder<CborBuilder>(this);
    }
View Full Code Here


    public void encode(UnicodeString dataItem) throws CborException {
        String string = dataItem.getString();
        if (dataItem.isChunked()) {
            encodeTypeChunked(MajorType.UNICODE_STRING);
            if (string != null) {
                encode(new UnicodeString(string));
            }
        } else if (string == null) {
            encoder.encode(SimpleValue.NULL);
        } else {
            byte[] bytes = string.getBytes(UTF8);
View Full Code Here

        long length = getLength(initialByte);
        if (length == INFINITY) {
            if (decoder.isAutoDecodeInfinitiveUnicodeStrings()) {
                return decodeInfinitiveLength();
            } else {
                UnicodeString unicodeString = new UnicodeString(null);
                unicodeString.setChunked(true);
                return unicodeString;
            }
        } 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.UNICODE_STRING) {
                UnicodeString unicodeString = (UnicodeString) dataItem;
                try {
                    bytes.write(unicodeString.toString().getBytes(UTF8));
                } catch (IOException ioException) {
                    throw new CborException(ioException);
                }
            } else {
                throw new CborException("Unexpected major type "
                                + majorType);
            }
        }
        return new UnicodeString(new String(bytes.toByteArray(), UTF8));
    }
View Full Code Here

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

  protected DataItem convert(byte[] bytes) {
    return new ByteString(bytes);
  }

  protected DataItem convert(String string) {
    return new UnicodeString(string);
  }
View Full Code Here

    long length = getLength(initialByte);
    if (length == INFINITY) {
      if (decoder.isAutoDecodeInfinitiveUnicodeStrings()) {
        return decodeInfinitiveLength();
      } else {
        UnicodeString unicodeString = new UnicodeString(null);
        unicodeString.setChunked(true);
        return unicodeString;
      }
    } 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.UNICODE_STRING) {
        UnicodeString unicodeString = (UnicodeString) dataItem;
        try {
          bytes.write(unicodeString.toString().getBytes(UTF8));
        } catch (IOException ioException) {
          throw new CborException(ioException);
        }
      } else {
        throw new CborException("Unexpected major type " + majorType);
      }
    }
    return new UnicodeString(new String(bytes.toByteArray(), UTF8));
  }
View Full Code Here

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

TOP

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

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.