Package co.nstant.in.cbor

Examples of co.nstant.in.cbor.CborException


            return eightByteValue;
        case INDEFINITE:
            return INFINITY;
        case RESERVED:
        default:
            throw new CborException("Reserved additional information");
        }
    }
View Full Code Here


            return eightByteValue;
        case INDEFINITE:
            return BigInteger.valueOf(INFINITY);
        case RESERVED:
        default:
            throw new CborException("Reserved additional information");
        }
    }
View Full Code Here

    int symbol = majorType.getValue() << 5;
    symbol |= AdditionalInformation.INDEFINITE.getValue();
    try {
      outputStream.write(symbol);
    } catch (IOException ioException) {
      throw new CborException(ioException);
    }
  }
View Full Code Here

  protected void write(int b) throws CborException {
    try {
      outputStream.write(b);
    } catch (IOException ioException) {
      throw new CborException(ioException);
    }
  }
View Full Code Here

  protected void write(byte[] bytes) throws CborException {
    try {
      outputStream.write(bytes);
    } catch (IOException ioException) {
      throw new CborException(ioException);
    }
  }
View Full Code Here

  private final Number numerator;
  private final Number denominator;

  protected RationalNumber(Number numerator, Number denomiator) throws CborException {
    if (numerator == null) {
      throw new CborException("Numerator is null");
    }
    if (denomiator == null) {
      throw new CborException("Denomiator is null");
    }
    if (denomiator.getValue().equals(BigInteger.ZERO)) {
      throw new CborException("Denomiator is zero");
    }
    this.numerator = numerator;
    this.denominator = denomiator;
  }
View Full Code Here

      } 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

      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

                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

            if (symbol == -1) {
                throw new IOException("Unexpected end of stream");
            }
            return symbol;
        } catch (IOException ioException) {
            throw new CborException(ioException);
        }
    }
View Full Code Here

TOP

Related Classes of co.nstant.in.cbor.CborException

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.