Package co.nstant.in.cbor.model

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


        switch (dataItem.getSpecialType()) {
        case BREAK:
            write((7 << 5) | 31);
            break;
        case SIMPLE_VALUE:
            SimpleValue simpleValue = (SimpleValue) dataItem;
            switch (simpleValue.getSimpleValueType()) {
            case FALSE:
            case NULL:
            case TRUE:
            case UNDEFINED:
                SimpleValueType type = simpleValue.getSimpleValueType();
                write((7 << 5) | type.getValue());
                break;
            case UNALLOCATED:
                write((7 << 5) | simpleValue.getValue());
                break;
            case RESERVED:
            default:
                throw new CborException("Not implemented");
            }
            break;
        case UNALLOCATED:
            throw new CborException("Unallocated special type");
        case IEEE_754_HALF_PRECISION_FLOAT:
            if (!(dataItem instanceof HalfPrecisionFloat)) {
                throw new CborException("Wrong data item type");
            }
            halfPrecisionFloatEncoder.encode((HalfPrecisionFloat) dataItem);
            break;
        case IEEE_754_SINGLE_PRECISION_FLOAT:
            if (!(dataItem instanceof SinglePrecisionFloat)) {
                throw new CborException("Wrong data item type");
            }
            singlePrecisionFloatEncoder.encode((SinglePrecisionFloat) dataItem);
            break;
        case IEEE_754_DOUBLE_PRECISION_FLOAT:
            if (!(dataItem instanceof DoublePrecisionFloat)) {
                throw new CborException("Wrong data item type");
            }
            doublePrecisionFloatEncoder.encode((DoublePrecisionFloat) dataItem);
            break;
        case SIMPLE_VALUE_NEXT_BYTE:
            if (!(dataItem instanceof SimpleValue)) {
                throw new CborException("Wrong data item type");
            }
            SimpleValue simpleValueNextByte = (SimpleValue) dataItem;
            write((7 << 5) | 24);
            write(simpleValueNextByte.getValue());
            break;
        default:
            throw new CborException("Not implemented");
        }
    }
View Full Code Here


            case NULL:
                return SimpleValue.NULL;
            case UNDEFINED:
                return SimpleValue.UNDEFINED;
            case UNALLOCATED:
                return new SimpleValue(initialByte & 0b11111);
            case RESERVED:
            default:
                throw new CborException("Not implemented");
            }
        case IEEE_754_HALF_PRECISION_FLOAT:
            return halfPrecisionFloatDecoder.decode(initialByte);
        case IEEE_754_SINGLE_PRECISION_FLOAT:
            return singlePrecisionFloatDecoder.decode(initialByte);
        case IEEE_754_DOUBLE_PRECISION_FLOAT:
            return doublePrecisionFloatDecoder.decode(initialByte);
        case SIMPLE_VALUE_NEXT_BYTE:
            return new SimpleValue(nextSymbol());
        case UNALLOCATED:
        default:
            throw new CborException("Not implemented");
        }
    }
View Full Code Here

    switch (dataItem.getSpecialType()) {
    case BREAK:
      write((7 << 5) | 31);
      break;
    case SIMPLE_VALUE:
      SimpleValue simpleValue = (SimpleValue) dataItem;
      switch (simpleValue.getSimpleValueType()) {
      case FALSE:
      case NULL:
      case TRUE:
      case UNDEFINED:
        SimpleValueType type = simpleValue.getSimpleValueType();
        write((7 << 5) | type.getValue());
        break;
      case UNALLOCATED:
        write((7 << 5) | simpleValue.getValue());
        break;
      case RESERVED:
      default:
        throw new CborException("Not implemented");
      }
      break;
    case UNALLOCATED:
      throw new CborException("Unallocated special type");
    case IEEE_754_HALF_PRECISION_FLOAT:
      if (!(dataItem instanceof HalfPrecisionFloat)) {
        throw new CborException("Wrong data item type");
      }
      halfPrecisionFloatEncoder.encode((HalfPrecisionFloat) dataItem);
      break;
    case IEEE_754_SINGLE_PRECISION_FLOAT:
      if (!(dataItem instanceof SinglePrecisionFloat)) {
        throw new CborException("Wrong data item type");
      }
      singlePrecisionFloatEncoder.encode((SinglePrecisionFloat) dataItem);
      break;
    case IEEE_754_DOUBLE_PRECISION_FLOAT:
      if (!(dataItem instanceof DoublePrecisionFloat)) {
        throw new CborException("Wrong data item type");
      }
      doublePrecisionFloatEncoder.encode((DoublePrecisionFloat) dataItem);
      break;
    case SIMPLE_VALUE_NEXT_BYTE:
      if (!(dataItem instanceof SimpleValue)) {
        throw new CborException("Wrong data item type");
      }
      SimpleValue simpleValueNextByte = (SimpleValue) dataItem;
      write((7 << 5) | 24);
      write(simpleValueNextByte.getValue());
      break;
    default:
      throw new CborException("Not implemented");
    }
  }
View Full Code Here

            case NULL:
                return SimpleValue.NULL;
            case UNDEFINED:
                return SimpleValue.UNDEFINED;
            case UNALLOCATED:
                return new SimpleValue(initialByte & 31);
            case RESERVED:
            default:
                throw new CborException("Not implemented");
            }
        case IEEE_754_HALF_PRECISION_FLOAT:
            return halfPrecisionFloatDecoder.decode(initialByte);
        case IEEE_754_SINGLE_PRECISION_FLOAT:
            return singlePrecisionFloatDecoder.decode(initialByte);
        case IEEE_754_DOUBLE_PRECISION_FLOAT:
            return doublePrecisionFloatDecoder.decode(initialByte);
        case SIMPLE_VALUE_NEXT_BYTE:
            return new SimpleValue(nextSymbol());
        case UNALLOCATED:
        default:
            throw new CborException("Not implemented");
        }
    }
View Full Code Here

TOP

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

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.