/** * Jackson doesn't have native support for timestamp. As per the RFC 7049 * (https://tools.ietf.org/html/rfc7049#section-2.4.1) we will need to * write a tag and write the epoch. */ @Override public StructuredJsonGenerator writeValue(Date date, TimestampFormat timestampFormat) { if (!(getGenerator() instanceof CBORGenerator)) { throw new IllegalStateException("SdkCborGenerator is not created with a CBORGenerator."); } CBORGenerator generator = (CBORGenerator) getGenerator(); try { generator.writeTag(CBOR_TAG_TIMESTAP); generator.writeNumber(date.getTime()); } catch (IOException e) { throw new JsonGenerationException(e); } return this; }
/** * Jackson doesn't have native support for timestamp. As per the RFC 7049 * (https://tools.ietf.org/html/rfc7049#section-2.4.1) we will need to * write a tag and write the epoch. */ @Override public StructuredJsonGenerator writeValue(Date date, TimestampFormat timestampFormat) { if (!(getGenerator() instanceof CBORGenerator)) { throw new IllegalStateException("SdkCborGenerator is not created with a CBORGenerator."); } CBORGenerator generator = (CBORGenerator) getGenerator(); try { generator.writeTag(CBOR_TAG_TIMESTAP); generator.writeNumber(date.getTime()); } catch (IOException e) { throw new JsonGenerationException(e); } return this; }
private final CBORGenerator _createCBORGenerator(IOContext ctxt, int stdFeat, int formatFeat, ObjectCodec codec, OutputStream out) throws IOException { // false -> we won't manage the stream unless explicitly directed to CBORGenerator gen = new CBORGenerator(ctxt, stdFeat, formatFeat, _objectCodec, out); if (CBORGenerator.Feature.WRITE_TYPE_HEADER.enabledIn(formatFeat)) { gen.writeTag(CBORConstants.TAG_ID_SELF_DESCRIBE); } return gen; }
private final CBORGenerator _createCBORGenerator(IOContext ctxt, int stdFeat, int formatFeat, ObjectCodec codec, OutputStream out) throws IOException { // false -> we won't manage the stream unless explicitly directed to CBORGenerator gen = new CBORGenerator(ctxt, stdFeat, formatFeat, _objectCodec, out); if (CBORGenerator.Feature.WRITE_TYPE_HEADER.enabledIn(formatFeat)) { gen.writeTag(CBORConstants.TAG_ID_SELF_DESCRIBE); } return gen; }
protected void maybeCopyTag(JsonParser p) throws IOException { if (p instanceof CBORParser) { if (p.hasCurrentToken()) { final int currentTag = ((CBORParser) p).getCurrentTag(); if (currentTag != -1) { writeTag(currentTag); } } } }
private final CBORGenerator _createCBORGenerator(IOContext ctxt, int stdFeat, int formatFeat, ObjectCodec codec, OutputStream out) throws IOException { // false -> we won't manage the stream unless explicitly directed to CBORGenerator gen = new CBORGenerator(ctxt, stdFeat, formatFeat, _objectCodec, out); if (CBORGenerator.Feature.WRITE_TYPE_HEADER.enabledIn(formatFeat)) { gen.writeTag(CBORConstants.TAG_ID_SELF_DESCRIBE); } return gen; }
protected void maybeCopyTag(JsonParser p) throws IOException { if (p instanceof CBORParser) { if (p.hasCurrentToken()) { final int currentTag = ((CBORParser)p).getCurrentTag(); if (currentTag != -1) { writeTag(currentTag); } } } }
/** * Jackson doesn't have native support for timestamp. As per the RFC 7049 * (https://tools.ietf.org/html/rfc7049#section-2.4.1) we will need to * write a tag and write the epoch. */ @Override public StructuredJsonGenerator writeValue(Instant instant) { if (!(getGenerator() instanceof CBORGenerator)) { throw new IllegalStateException("SdkCborGenerator is not created with a CBORGenerator."); } CBORGenerator generator = (CBORGenerator) getGenerator(); try { generator.writeTag(CBOR_TAG_TIMESTAMP); generator.writeNumber(instant.toEpochMilli()); } catch (IOException e) { throw new JsonGenerationException(e); } return this; } }
/** * Jackson doesn't have native support for timestamp. As per the RFC 7049 * (https://tools.ietf.org/html/rfc7049#section-2.4.1) we will need to * write a tag and write the epoch. */ @Override public StructuredJsonGenerator writeValue(Date date) { if (!(getGenerator() instanceof CBORGenerator)) { throw new IllegalStateException("SdkCborGenerator is not created with a CBORGenerator."); } CBORGenerator generator = (CBORGenerator) getGenerator(); try { generator.writeTag(CBOR_TAG_TIMESTAP); generator.writeNumber(date.getTime()); } catch (IOException e) { throw new JsonGenerationException(e); } return this; }
/** * Jackson doesn't have native support for timestamp. As per the RFC 7049 * (https://tools.ietf.org/html/rfc7049#section-2.4.1) we will need to * write a tag and write the epoch. */ @Override public StructuredJsonGenerator writeValue(Instant instant) { if (!(getGenerator() instanceof CBORGenerator)) { throw new IllegalStateException("SdkCborGenerator is not created with a CBORGenerator."); } CBORGenerator generator = (CBORGenerator) getGenerator(); try { generator.writeTag(CBOR_TAG_TIMESTAMP); generator.writeNumber(instant.toEpochMilli()); } catch (IOException e) { throw new JsonGenerationException(e); } return this; } }