com.fasterxml.jackson.databind.jsonFormatVisitors.JsonValueFormat Java Examples

The following examples show how to use com.fasterxml.jackson.databind.jsonFormatVisitors.JsonValueFormat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: YearMonthSerializer.java    From jackson-modules-java8 with Apache License 2.0 5 votes vote down vote up
@Override
protected void _acceptTimestampVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException
{
    SerializerProvider provider = visitor.getProvider();
    boolean useTimestamp = (provider != null) && useTimestamp(provider);
    if (useTimestamp) {
        super._acceptTimestampVisitor(visitor, typeHint);
    } else {
        JsonStringFormatVisitor v2 = visitor.expectStringFormat(typeHint);
        if (v2 != null) {
            v2.format(JsonValueFormat.DATE_TIME);
        }
    }
}
 
Example #2
Source File: DurationSerializer.java    From jackson-modules-java8 with Apache License 2.0 5 votes vote down vote up
@Override
protected void _acceptTimestampVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException
{
    JsonIntegerFormatVisitor v2 = visitor.expectIntegerFormat(typeHint);
    if (v2 != null) {
        v2.numberType(JsonParser.NumberType.LONG);
        SerializerProvider provider = visitor.getProvider();
        if ((provider != null) && useNanoseconds(provider)) {
            // big number, no more specific qualifier to use...
        } else { // otherwise good old Unix timestamp, in milliseconds
            v2.format(JsonValueFormat.UTC_MILLISEC);
        }
    }
}
 
Example #3
Source File: LocalTimeSerializer.java    From jackson-modules-java8 with Apache License 2.0 5 votes vote down vote up
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
    throws JsonMappingException
{
    if (useTimestamp(visitor.getProvider())) {
        _acceptTimestampVisitor(visitor, typeHint);
    } else {
        JsonStringFormatVisitor v2 = visitor.expectStringFormat(typeHint);
        if (v2 != null) {
            v2.format(JsonValueFormat.TIME);
        }
    }
}
 
Example #4
Source File: LocalDateSerializer.java    From jackson-modules-java8 with Apache License 2.0 5 votes vote down vote up
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException
{
    SerializerProvider provider = visitor.getProvider();
    boolean useTimestamp = (provider != null) && useTimestamp(provider);
    if (useTimestamp) {
        _acceptTimestampVisitor(visitor, typeHint);
    } else {
        JsonStringFormatVisitor v2 = visitor.expectStringFormat(typeHint);
        if (v2 != null) {
            v2.format(JsonValueFormat.DATE);
        }
    }
}
 
Example #5
Source File: SqlMetadataRetrieval.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("PMD.CyclomaticComplexity")
static JsonSchema schemaFor(final JDBCType jdbcType) {
    final JsonSchemaFactory factory = new JsonSchemaFactory();
    switch (jdbcType) {
    case ARRAY:
        return factory.arraySchema();
    case BINARY:
    case BLOB:
    case LONGVARBINARY:
    case VARBINARY:
        final ArraySchema binary = factory.arraySchema();
        binary.setItemsSchema(factory.integerSchema());
        return binary;
    case BIT:
    case BOOLEAN:
        return factory.booleanSchema();
    case CHAR:
    case CLOB:
    case DATALINK:
    case LONGNVARCHAR:
    case LONGVARCHAR:
    case NCHAR:
    case NCLOB:
    case NVARCHAR:
    case ROWID:
    case SQLXML:
    case VARCHAR:
        return factory.stringSchema();
    case DATE:
    case TIME:
    case TIMESTAMP:
    case TIMESTAMP_WITH_TIMEZONE:
    case TIME_WITH_TIMEZONE:
        final StringSchema date = factory.stringSchema();
        date.setFormat(JsonValueFormat.DATE_TIME);
        return date;
    case DECIMAL:
    case DOUBLE:
    case FLOAT:
    case NUMERIC:
    case REAL:
        return factory.numberSchema();
    case INTEGER:
    case BIGINT:
    case SMALLINT:
    case TINYINT:
        return factory.integerSchema();
    case NULL:
        return factory.nullSchema();
    case DISTINCT:
    case JAVA_OBJECT:
    case OTHER:
    case REF:
    case REF_CURSOR:
    case STRUCT:
    default:
        return factory.anySchema();
    }
}
 
Example #6
Source File: JsonSchemaHelper.java    From syndesis with Apache License 2.0 4 votes vote down vote up
public static boolean isKnownFormat(String format) {
    return format != null && Stream.of(JsonValueFormat.values())
            .map(Objects::toString)
            .anyMatch(jsonSchemaFormat -> jsonSchemaFormat.equals(format));
}
 
Example #7
Source File: SqlTimeSerializer.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
    throws JsonMappingException
{
    visitStringFormat(visitor, typeHint, JsonValueFormat.DATE_TIME);
}