本文整理汇总了Java中io.datatree.dom.BASE64类的典型用法代码示例。如果您正苦于以下问题:Java BASE64类的具体用法?Java BASE64怎么用?Java BASE64使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BASE64类属于io.datatree.dom包,在下文中一共展示了BASE64类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDefaultSerializers
import io.datatree.dom.BASE64; //导入依赖的package包/类
public void addDefaultSerializers() {
// InetAddress
addSerializer(mapper, InetAddress.class, (packer, value) -> {
packer.write(value.getCanonicalHostName());
});
// UUID
addSerializer(mapper, UUID.class, (packer, value) -> {
packer.write(value.toString());
});
// Byte array
addSerializer(mapper, byte[].class, (packer, value) -> {
packer.write(BASE64.encode(value));
});
}
示例2: addDefaultSerializers
import io.datatree.dom.BASE64; //导入依赖的package包/类
public void addDefaultSerializers() {
// InetAddress
addSerializer(mapper, InetAddress.class, (value, ctx) -> {
ctx.writeString(value.getCanonicalHostName());
});
addSerializer(mapper, Inet4Address.class, (value, ctx) -> {
ctx.writeString(value.getCanonicalHostName());
});
addSerializer(mapper, Inet6Address.class, (value, ctx) -> {
ctx.writeString(value.getCanonicalHostName());
});
// UUID
addSerializer(mapper, UUID.class, (value, ctx) -> {
ctx.write(StringPool.QUOTE);
ctx.write(value.toString());
ctx.write(StringPool.QUOTE);
});
// Date
if (Config.USE_TIMESTAMPS) {
addSerializer(mapper, Date.class, (value, ctx) -> {
ctx.write(StringPool.QUOTE);
ctx.write(DataConverterRegistry.convert(String.class, value));
ctx.write(StringPool.QUOTE);
});
} else {
addSerializer(mapper, Date.class, (value, ctx) -> {
ctx.writeNumber(value.getTime());
});
}
// Byte array
addSerializer(mapper, byte[].class, (value, ctx) -> {
ctx.write(StringPool.QUOTE);
ctx.write(BASE64.encode(value));
ctx.write(StringPool.QUOTE);
});
}
示例3: addDefaultSerializers
import io.datatree.dom.BASE64; //导入依赖的package包/类
public void addDefaultSerializers(TypeTransformerMap map) {
// InetAddress
addSerializer(map, InetAddress.class, (value, ctx) -> {
ctx.writeQuoted(value.getCanonicalHostName());
});
addSerializer(map, Inet4Address.class, (value, ctx) -> {
ctx.writeQuoted(value.getCanonicalHostName());
});
addSerializer(map, Inet6Address.class, (value, ctx) -> {
ctx.writeQuoted(value.getCanonicalHostName());
});
// UUID
addSerializer(map, UUID.class, (value, ctx) -> {
ctx.write("\"");
ctx.write(value.toString());
ctx.write("\"");
});
// BASE64
addSerializer(map, byte[].class, (value, ctx) -> {
ctx.write("\"");
ctx.write(BASE64.encode(value));
ctx.write("\"");
});
// Date
addSerializer(map, Date.class, (value, ctx) -> {
if (Config.USE_TIMESTAMPS) {
ctx.writeQuoted(DataConverterRegistry.convert(String.class, value));
} else {
ctx.write(Long.toString(value.getTime()));
}
});
}
示例4: addDefaultSerializers
import io.datatree.dom.BASE64; //导入依赖的package包/类
public void addDefaultSerializers(ExtensibleRepresenter representer) {
// InetAddress
addSerializer(representer, InetAddress.class, (value) -> {
return value.getCanonicalHostName();
});
addSerializer(representer, Inet4Address.class, (value) -> {
return value.getCanonicalHostName();
});
addSerializer(representer, Inet6Address.class, (value) -> {
return value.getCanonicalHostName();
});
// UUID
addSerializer(representer, UUID.class, (value) -> {
return value.toString();
});
// UUID
addSerializer(representer, byte[].class, (value) -> {
return BASE64.encode(value);
});
// Date
addSerializer(representer, Date.class, (value) -> {
if (Config.USE_TIMESTAMPS) {
return DataConverterRegistry.convert(String.class, value);
}
return Long.toString(value.getTime());
});
}
示例5: addDefaultSerializers
import io.datatree.dom.BASE64; //导入依赖的package包/类
public void addDefaultSerializers() {
// InetAddress
addSerializer(mapper, InetAddress.class, (value) -> {
return value.getCanonicalHostName();
});
addSerializer(mapper, Inet4Address.class, (value) -> {
return value.getCanonicalHostName();
});
addSerializer(mapper, Inet6Address.class, (value) -> {
return value.getCanonicalHostName();
});
// UUID
addSerializer(mapper, UUID.class, (value) -> {
return value.toString();
});
// BASE64
addSerializer(mapper, byte[].class, (value) -> {
return BASE64.encode(value);
});
// Date
addSerializer(mapper, Date.class, (value) -> {
if (Config.USE_TIMESTAMPS) {
return DataConverterRegistry.convert(String.class, value);
}
return Long.toString(value.getTime());
});
}
示例6: accept
import io.datatree.dom.BASE64; //导入依赖的package包/类
@Override
public void accept(ObjectMapper mapper) {
SimpleModule module = new SimpleModule();
addSerializer(module, BsonBoolean.class, (value, gen) -> {
gen.writeBoolean(value.getValue());
});
addSerializer(module, BsonDateTime.class, (value, gen) -> {
if (Config.USE_TIMESTAMPS) {
gen.writeString(DataConverterRegistry.convert(String.class, new Date(value.getValue())));
} else {
gen.writeNumber(value.getValue());
}
});
addSerializer(module, BsonDouble.class, (value, gen) -> {
gen.writeNumber(value.getValue());
});
addSerializer(module, BsonInt32.class, (value, gen) -> {
gen.writeNumber(value.getValue());
});
addSerializer(module, BsonInt64.class, (value, gen) -> {
gen.writeNumber(value.getValue());
});
addSerializer(module, BsonNull.class, (value, gen) -> {
gen.writeNull();
});
addSerializer(module, BsonRegularExpression.class, (value, gen) -> {
gen.writeString(value.getPattern());
});
addSerializer(module, BsonString.class, (value, gen) -> {
gen.writeString(value.getValue());
});
addSerializer(module, BsonTimestamp.class, (value, gen) -> {
if (Config.USE_TIMESTAMPS) {
gen.writeString(DataConverterRegistry.convert(String.class, new Date(value.getTime() * 1000L)));
} else {
gen.writeNumber(value.getTime());
}
});
addSerializer(module, BsonUndefined.class, (value, gen) -> {
gen.writeNull();
});
addSerializer(module, Binary.class, (value, gen) -> {
gen.writeString(BASE64.encode(value.getData()));
});
addSerializer(module, Code.class, (value, gen) -> {
gen.writeString(value.getCode());
});
addSerializer(module, Decimal128.class, (value, gen) -> {
gen.writeNumber(value.bigDecimalValue());
});
addSerializer(module, ObjectId.class, (value, gen) -> {
gen.writeString(value.toHexString());
});
addSerializer(module, Symbol.class, (value, gen) -> {
gen.writeString(value.getSymbol());
});
mapper.registerModule(module);
}
示例7: accept
import io.datatree.dom.BASE64; //导入依赖的package包/类
@Override
public void accept(ExtensibleRepresenter representer) {
addSerializer(representer, BsonBoolean.class, (value) -> {
return Boolean.toString(value.getValue());
});
addSerializer(representer, BsonDateTime.class, (value) -> {
if (Config.USE_TIMESTAMPS) {
return DataConverterRegistry.convert(String.class, new Date(value.getValue()));
}
return Long.toString(value.getValue());
});
addSerializer(representer, BsonDouble.class, (value) -> {
return Double.toString(value.getValue());
});
addSerializer(representer, BsonInt32.class, (value) -> {
return Integer.toString(value.getValue());
});
addSerializer(representer, BsonInt64.class, (value) -> {
return Long.toString(value.getValue());
});
addSerializer(representer, BsonNull.class, (value) -> {
return null;
});
addSerializer(representer, BsonRegularExpression.class, (value) -> {
return value.getPattern();
});
addSerializer(representer, BsonString.class, (value) -> {
return value.getValue();
});
addSerializer(representer, BsonTimestamp.class, (value) -> {
if (Config.USE_TIMESTAMPS) {
return DataConverterRegistry.convert(String.class, new Date(value.getTime() * 1000L));
}
return Integer.toString(value.getTime());
});
addSerializer(representer, BsonUndefined.class, (value) -> {
return null;
});
addSerializer(representer, Binary.class, (value) -> {
return BASE64.encode(value.getData());
});
addSerializer(representer, Code.class, (value) -> {
return value.getCode();
});
addSerializer(representer, Decimal128.class, (value) -> {
return value.bigDecimalValue().toPlainString();
});
addSerializer(representer, ObjectId.class, (value) -> {
return value.toHexString();
});
addSerializer(representer, Symbol.class, (value) -> {
return value.getSymbol();
});
}
示例8: accept
import io.datatree.dom.BASE64; //导入依赖的package包/类
@Override
public void accept(MapperBuilder builder) {
addSerializer(builder, BsonBoolean.class, Boolean.class, (value) -> {
return value.getValue();
});
if (Config.USE_TIMESTAMPS) {
addSerializer(builder, BsonDateTime.class, String.class, (value) -> {
return DataConverterRegistry.convert(String.class, new Date(value.getValue()));
});
} else {
addSerializer(builder, BsonDateTime.class, Long.class, (value) -> {
return value.getValue();
});
}
addSerializer(builder, BsonDouble.class, Double.class, (value) -> {
return value.getValue();
});
addSerializer(builder, BsonInt32.class, Integer.class, (value) -> {
return value.getValue();
});
addSerializer(builder, BsonInt64.class, Long.class, (value) -> {
return value.getValue();
});
addSerializer(builder, BsonNull.class, Object.class, (value) -> {
// Johnzon fails from null values
return "null";
});
addSerializer(builder, BsonRegularExpression.class, String.class, (value) -> {
return value.getPattern();
});
addSerializer(builder, BsonString.class, String.class, (value) -> {
return value.getValue();
});
if (Config.USE_TIMESTAMPS) {
addSerializer(builder, BsonTimestamp.class, String.class, (value) -> {
return DataConverterRegistry.convert(String.class, new Date(value.getTime() * 1000L));
});
} else {
addSerializer(builder, BsonTimestamp.class, Integer.class, (value) -> {
return value.getTime();
});
}
addSerializer(builder, BsonUndefined.class, String.class, (value) -> {
// Johnzon fails from null values
return "null";
});
addSerializer(builder, Binary.class, String.class, (value) -> {
return BASE64.encode(value.getData());
});
addSerializer(builder, Code.class, String.class, (value) -> {
return value.getCode();
});
addSerializer(builder, Decimal128.class, BigDecimal.class, (value) -> {
return value.bigDecimalValue();
});
addSerializer(builder, ObjectId.class, String.class, (value) -> {
return value.toHexString();
});
addSerializer(builder, Symbol.class, String.class, (value) -> {
return value.getSymbol();
});
}
示例9: accept
import io.datatree.dom.BASE64; //导入依赖的package包/类
@Override
public void accept(GensonBuilder builder) {
addSerializer(builder, BsonBoolean.class, (value, writer, ctx) -> {
writer.writeBoolean(value.getValue());
});
addSerializer(builder, BsonDateTime.class, (value, writer, ctx) -> {
if (Config.USE_TIMESTAMPS) {
writer.writeString(DataConverterRegistry.convert(String.class, new Date(value.getValue())));
} else {
writer.writeNumber(value.getValue());
}
});
addSerializer(builder, BsonDouble.class, (value, writer, ctx) -> {
writer.writeNumber(value.getValue());
});
addSerializer(builder, BsonInt32.class, (value, writer, ctx) -> {
writer.writeNumber(value.getValue());
});
addSerializer(builder, BsonInt64.class, (value, writer, ctx) -> {
writer.writeNumber(value.getValue());
});
addSerializer(builder, BsonNull.class, (value, writer, ctx) -> {
writer.writeNull();
});
addSerializer(builder, BsonRegularExpression.class, (value, writer, ctx) -> {
writer.writeString(value.getPattern());
});
addSerializer(builder, BsonString.class, (value, writer, ctx) -> {
writer.writeString(value.getValue());
});
addSerializer(builder, BsonTimestamp.class, (value, writer, ctx) -> {
if (Config.USE_TIMESTAMPS) {
writer.writeString(DataConverterRegistry.convert(String.class, new Date(value.getTime() * 1000L)));
} else {
writer.writeNumber(value.getTime());
}
});
addSerializer(builder, BsonUndefined.class, (value, writer, ctx) -> {
writer.writeNull();
});
addSerializer(builder, Binary.class, (value, writer, ctx) -> {
writer.writeString(BASE64.encode(value.getData()));
});
addSerializer(builder, Code.class, (value, writer, ctx) -> {
writer.writeString(value.getCode());
});
addSerializer(builder, Decimal128.class, (value, writer, ctx) -> {
writer.writeNumber(value.bigDecimalValue());
});
addSerializer(builder, ObjectId.class, (value, writer, ctx) -> {
writer.writeString(value.toHexString());
});
addSerializer(builder, Symbol.class, (value, writer, ctx) -> {
writer.writeString(value.getSymbol());
});
}
示例10: accept
import io.datatree.dom.BASE64; //导入依赖的package包/类
@Override
public void accept(DslJson<Object> dslJson) {
dslJson.registerWriter(BsonBoolean.class, (writer, value) -> {
BoolConverter.serialize(value.getValue(), writer);
});
dslJson.registerWriter(BsonDateTime.class, (writer, value) -> {
if (Config.USE_TIMESTAMPS) {
StringConverter.serialize(DataConverterRegistry.convert(String.class, new Date(value.getValue())),
writer);
} else {
NumberConverter.serialize(value.getValue(), writer);
}
});
dslJson.registerWriter(BsonDouble.class, (writer, value) -> {
NumberConverter.serialize(value.getValue(), writer);
});
dslJson.registerWriter(BsonInt32.class, (writer, value) -> {
NumberConverter.serialize(value.getValue(), writer);
});
dslJson.registerWriter(BsonInt64.class, (writer, value) -> {
NumberConverter.serialize(value.getValue(), writer);
});
dslJson.registerWriter(BsonNull.class, (writer, value) -> {
writer.writeNull();
});
dslJson.registerWriter(BsonRegularExpression.class, (writer, value) -> {
StringConverter.serializeNullable(value.getPattern(), writer);
});
dslJson.registerWriter(BsonString.class, (writer, value) -> {
StringConverter.serializeNullable(value.getValue(), writer);
});
dslJson.registerWriter(BsonTimestamp.class, (writer, value) -> {
if (Config.USE_TIMESTAMPS) {
StringConverter.serialize(
DataConverterRegistry.convert(String.class, new Date(value.getTime() * 1000L)), writer);
} else {
NumberConverter.serialize(value.getTime(), writer);
}
});
dslJson.registerWriter(BsonUndefined.class, (writer, value) -> {
writer.writeNull();
});
dslJson.registerWriter(Binary.class, (writer, value) -> {
StringConverter.serialize(BASE64.encode(value.getData()), writer);
});
dslJson.registerWriter(Code.class, (writer, value) -> {
StringConverter.serializeNullable(value.getCode(), writer);
});
dslJson.registerWriter(Decimal128.class, (writer, value) -> {
NumberConverter.serialize(value.bigDecimalValue(), writer);
});
dslJson.registerWriter(ObjectId.class, (writer, value) -> {
StringConverter.serialize(value.toHexString(), writer);
});
dslJson.registerWriter(Symbol.class, (writer, value) -> {
StringConverter.serializeNullable(value.getSymbol(), writer);
});
}
示例11: toString
import io.datatree.dom.BASE64; //导入依赖的package包/类
@Override
public String toString(Object value, Object meta, boolean pretty, boolean insertMeta) {
return BASE64.encode(toBinary(value, meta, insertMeta));
}
示例12: parse
import io.datatree.dom.BASE64; //导入依赖的package包/类
@Override
public Object parse(String source) throws Exception {
return parse(BASE64.decode(source));
}
示例13: accept
import io.datatree.dom.BASE64; //导入依赖的package包/类
@Override
public void accept(MessagePack mapper) {
addSerializer(mapper, BsonBoolean.class, (packer, value) -> {
packer.write(value.getValue());
});
addSerializer(mapper, BsonDateTime.class, (packer, value) -> {
packer.write(value.getValue());
});
addSerializer(mapper, BsonDouble.class, (packer, value) -> {
packer.write(value.getValue());
});
addSerializer(mapper, BsonInt32.class, (packer, value) -> {
packer.write(value.getValue());
});
addSerializer(mapper, BsonInt64.class, (packer, value) -> {
packer.write(value.getValue());
});
addSerializer(mapper, BsonNull.class, (packer, value) -> {
packer.writeNil();
});
addSerializer(mapper, BsonRegularExpression.class, (packer, value) -> {
packer.write(value.getPattern());
});
addSerializer(mapper, BsonString.class, (packer, value) -> {
packer.write(value.getValue());
});
addSerializer(mapper, BsonTimestamp.class, (packer, value) -> {
packer.write(value.getTime() * 1000L);
});
addSerializer(mapper, BsonUndefined.class, (packer, value) -> {
packer.writeNil();
});
addSerializer(mapper, Binary.class, (packer, value) -> {
packer.write(BASE64.encode(value.getData()));
});
addSerializer(mapper, Code.class, (packer, value) -> {
packer.write(value.getCode());
});
addSerializer(mapper, Decimal128.class, (packer, value) -> {
packer.write(value.bigDecimalValue());
});
addSerializer(mapper, ObjectId.class, (packer, value) -> {
packer.write(value.toHexString());
});
addSerializer(mapper, Symbol.class, (packer, value) -> {
packer.write(value.getSymbol());
});
}
示例14: accept
import io.datatree.dom.BASE64; //导入依赖的package包/类
@Override
public void accept(SerializeConfig config) {
addSerializer(config, BsonBoolean.class, (value, serializer) -> {
serializer.write(value.getValue());
});
addSerializer(config, BsonDateTime.class, (value, serializer) -> {
if (Config.USE_TIMESTAMPS) {
serializer.write(DataConverterRegistry.convert(String.class, new Date(value.getValue())));
} else {
serializer.write(value.getValue());
}
});
addSerializer(config, BsonDouble.class, (value, serializer) -> {
serializer.write(value.getValue());
});
addSerializer(config, BsonInt32.class, (value, serializer) -> {
serializer.write(value.getValue());
});
addSerializer(config, BsonInt64.class, (value, serializer) -> {
serializer.write(value.getValue());
});
addSerializer(config, BsonNull.class, (value, serializer) -> {
serializer.writeNull();
});
addSerializer(config, BsonRegularExpression.class, (value, serializer) -> {
serializer.write(value.getPattern());
});
addSerializer(config, BsonString.class, (value, serializer) -> {
serializer.write(value.getValue());
});
addSerializer(config, BsonTimestamp.class, (value, serializer) -> {
if (Config.USE_TIMESTAMPS) {
serializer.write(DataConverterRegistry.convert(String.class, new Date(value.getTime() * 1000L)));
} else {
serializer.write(value.getTime());
}
});
addSerializer(config, BsonUndefined.class, (value, serializer) -> {
serializer.writeNull();
});
addSerializer(config, Binary.class, (value, serializer) -> {
serializer.write(BASE64.encode(value.getData()));
});
addSerializer(config, Code.class, (value, serializer) -> {
serializer.write(value.getCode());
});
addSerializer(config, Decimal128.class, (value, serializer) -> {
serializer.write(value.bigDecimalValue());
});
addSerializer(config, ObjectId.class, (value, serializer) -> {
serializer.write(value.toHexString());
});
addSerializer(config, Symbol.class, (value, serializer) -> {
serializer.write(value.getSymbol());
});
}
示例15: accept
import io.datatree.dom.BASE64; //导入依赖的package包/类
@Override
public void accept(JsonSerializer serializer) {
addSerializer(serializer, BsonBoolean.class, (value, ctx) -> {
ctx.write(Boolean.toString(value.getValue()));
});
addSerializer(serializer, BsonDateTime.class, (value, ctx) -> {
if (Config.USE_TIMESTAMPS) {
ctx.writeString(DataConverterRegistry.convert(String.class, new Date(value.getValue())));
} else {
ctx.writeNumber(value.getValue());
}
});
addSerializer(serializer, BsonDouble.class, (value, ctx) -> {
ctx.writeNumber(value.getValue());
});
addSerializer(serializer, BsonInt32.class, (value, ctx) -> {
ctx.writeNumber(value.getValue());
});
addSerializer(serializer, BsonInt64.class, (value, ctx) -> {
ctx.writeNumber(value.getValue());
});
addSerializer(serializer, BsonNull.class, (value, ctx) -> {
ctx.write("null");
});
addSerializer(serializer, BsonRegularExpression.class, (value, ctx) -> {
ctx.writeString(value.getPattern());
});
addSerializer(serializer, BsonString.class, (value, ctx) -> {
ctx.writeString(value.getValue());
});
addSerializer(serializer, BsonTimestamp.class, (value, ctx) -> {
if (Config.USE_TIMESTAMPS) {
ctx.writeString(
DataConverterRegistry.convert(String.class, new Date(value.getTime() * 1000L)));
} else {
ctx.writeNumber(value.getTime());
}
});
addSerializer(serializer, BsonUndefined.class, (value, ctx) -> {
ctx.write("null");
});
addSerializer(serializer, Binary.class, (value, ctx) -> {
ctx.writeString(BASE64.encode(value.getData()));
});
addSerializer(serializer, Code.class, (value, ctx) -> {
ctx.writeString(value.getCode());
});
addSerializer(serializer, Decimal128.class, (value, ctx) -> {
ctx.writeNumber(value.bigDecimalValue());
});
addSerializer(serializer, ObjectId.class, (value, ctx) -> {
ctx.writeString(value.toHexString());
});
addSerializer(serializer, Symbol.class, (value, ctx) -> {
ctx.writeString(value.getSymbol());
});
}