当前位置: 首页>>代码示例>>Java>>正文


Java SmileFactory类代码示例

本文整理汇总了Java中com.fasterxml.jackson.dataformat.smile.SmileFactory的典型用法代码示例。如果您正苦于以下问题:Java SmileFactory类的具体用法?Java SmileFactory怎么用?Java SmileFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SmileFactory类属于com.fasterxml.jackson.dataformat.smile包,在下文中一共展示了SmileFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: WampClient

import com.fasterxml.jackson.dataformat.smile.SmileFactory; //导入依赖的package包/类
public WampClient(DataFormat dataFormat) {
	this.isBinary = dataFormat != DataFormat.JSON;
	this.result = new CompletableFutureWebSocketHandler();
	this.headers = new WebSocketHttpHeaders();

	switch (dataFormat) {
	case CBOR:
		this.jsonFactory = new ObjectMapper(new CBORFactory()).getFactory();
		this.headers.setSecWebSocketProtocol(WampSubProtocolHandler.CBOR_PROTOCOL);
		break;
	case MSGPACK:
		this.jsonFactory = new ObjectMapper(new MessagePackFactory()).getFactory();
		this.headers.setSecWebSocketProtocol(WampSubProtocolHandler.MSGPACK_PROTOCOL);
		break;
	case JSON:
		this.jsonFactory = new MappingJsonFactory(new ObjectMapper());
		this.headers.setSecWebSocketProtocol(WampSubProtocolHandler.JSON_PROTOCOL);
		break;
	case SMILE:
		this.jsonFactory = new ObjectMapper(new SmileFactory()).getFactory();
		this.headers.setSecWebSocketProtocol(WampSubProtocolHandler.SMILE_PROTOCOL);
		break;
	default:
		this.jsonFactory = null;
	}

}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:28,代码来源:WampClient.java

示例2: SmileJackson

import com.fasterxml.jackson.dataformat.smile.SmileFactory; //导入依赖的package包/类
public SmileJackson() {
	super(new ObjectMapper(new SmileFactory()));

	// Install MongoDB / BSON serializers
	// (Using JSON serializers)
	tryToAddSerializers("io.datatree.dom.adapters.JsonJacksonBsonSerializers", mapper);
}
 
开发者ID:berkesa,项目名称:datatree-adapters,代码行数:8,代码来源:SmileJackson.java

示例3: smile

import com.fasterxml.jackson.dataformat.smile.SmileFactory; //导入依赖的package包/类
/**
 * smile 序列化
 * 
 * object -> byte[]
 * 
 * @param value
 * @param outputStream
 * @return
 */
public static boolean smile(final Serializable value, final OutputStream outputStream) {
	boolean result = false;
	//
	AssertHelper.notNull(value, "The Value must not be null");
	AssertHelper.notNull(outputStream, "The OutputStream must not be null");
	//
	ObjectMapper mapper = null;
	try {
		mapper = new ObjectMapper(new SmileFactory());
		byte[] buff = mapper.writeValueAsBytes(value);
		outputStream.write(buff);
		result = true;
	} catch (Exception ex) {
		ex.printStackTrace();
	} finally {
	}
	//
	return result;
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:29,代码来源:SerializeHelperWithoutPool.java

示例4: desmile

import com.fasterxml.jackson.dataformat.smile.SmileFactory; //导入依赖的package包/类
/**
 * smile 反序列化
 * 
 * byte[] -> object
 * 
 * @param inputStream
 * @param clazz
 * @return
 */
public static <T> T desmile(final InputStream inputStream, final Class<T> clazz) {
	T result = null;
	//
	AssertHelper.notNull(inputStream, "The InputStream must not be null");
	AssertHelper.notNull(inputStream, "The Class must not be null");
	//
	ObjectMapper mapper = null;
	try {
		mapper = new ObjectMapper(new SmileFactory());
		result = mapper.readValue(inputStream, clazz);
	} catch (Exception ex) {
		ex.printStackTrace();
	} finally {
	}
	//
	return result;
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:27,代码来源:SerializeHelperWithoutPool.java

示例5: smile

import com.fasterxml.jackson.dataformat.smile.SmileFactory; //导入依赖的package包/类
/**
 * smile 序列化
 * 
 * object -> byte[]
 * 
 * @param value
 * @param outputStream
 * @return
 */
public static boolean smile(Object value, OutputStream outputStream) {
	boolean result = false;
	//
	AssertHelper.notNull(value, "The Value must not be null");
	AssertHelper.notNull(outputStream, "The OutputStream must not be null");
	//
	ObjectMapper mapper = null;
	try {
		mapper = new ObjectMapper(new SmileFactory());
		byte[] buff = mapper.writeValueAsBytes(value);
		outputStream.write(buff);
		result = true;
	} catch (Exception ex) {
		ex.printStackTrace();
	} finally {
	}
	//
	return result;
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:29,代码来源:SerializeHelper.java

示例6: desmile

import com.fasterxml.jackson.dataformat.smile.SmileFactory; //导入依赖的package包/类
/**
 * smile 反序列化
 * 
 * byte[] -> object
 * 
 * @param inputStream
 * @param clazz
 * @return
 */
public static <T> T desmile(InputStream inputStream, Class<T> clazz) {
	T result = null;
	//
	AssertHelper.notNull(inputStream, "The InputStream must not be null");
	AssertHelper.notNull(inputStream, "The Class must not be null");
	//
	ObjectMapper mapper = null;
	try {
		mapper = new ObjectMapper(new SmileFactory());
		result = mapper.readValue(inputStream, clazz);
	} catch (Exception ex) {
		ex.printStackTrace();
	} finally {
	}
	//
	return result;
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:27,代码来源:SerializeHelper.java

示例7: CompletableFutureWebSocketHandler

import com.fasterxml.jackson.dataformat.smile.SmileFactory; //导入依赖的package包/类
public CompletableFutureWebSocketHandler(int expectedNoOfResults) {
	this.jsonFactory = new MappingJsonFactory(new ObjectMapper());
	this.msgpackFactory = new ObjectMapper(new MessagePackFactory()).getFactory();
	this.cborFactory = new ObjectMapper(new CBORFactory()).getFactory();
	this.smileFactory = new ObjectMapper(new SmileFactory()).getFactory();
	this.timeout = getTimeoutValue();
	this.welcomeMessageFuture = new CompletableFuture<>();
	this.reset(expectedNoOfResults);
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:10,代码来源:CompletableFutureWebSocketHandler.java

示例8: configure

import com.fasterxml.jackson.dataformat.smile.SmileFactory; //导入依赖的package包/类
@Override
public void configure(Map<String, ?> map, boolean b) {
    if(mapper == null) {
        if("true".equals(map.get("value.serializer.jackson.smile"))) {
            mapper = new ObjectMapper(new SmileFactory());
        }
        else {
            mapper = new ObjectMapper();
        }
    }
}
 
开发者ID:nielsutrecht,项目名称:kafka-serializer-example,代码行数:12,代码来源:JacksonReadingSerializer.java

示例9: SmileObjectMapperProvider

import com.fasterxml.jackson.dataformat.smile.SmileFactory; //导入依赖的package包/类
public SmileObjectMapperProvider() {
    final SmileFactory smileFactory = new SmileFactory()
            .disable(SmileGenerator.Feature.ENCODE_BINARY_AS_7BIT)
            .enable(SmileGenerator.Feature.WRITE_END_MARKER);

    objectMapper = new ObjectMapper(smileFactory)
            .setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
            .registerModule(new JodaModule())
            .registerModule(new GuavaModule());
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-anonymous-usage-statistics,代码行数:11,代码来源:SmileObjectMapperProvider.java

示例10: convertToDatabaseColumn

import com.fasterxml.jackson.dataformat.smile.SmileFactory; //导入依赖的package包/类
/**
 * Converts a hashmap to a smile json byte array
 *
 * @param attribute the hashmap to be converted
 * @return a byte array json representation of the hashmap
 */
@Override
public byte[] convertToDatabaseColumn(Map<?, ?> attribute) {
	SmileFactory factory = new SmileFactory();
	ObjectMapper mapper = new ObjectMapper(factory);
	try {
		return mapper.writeValueAsBytes(attribute);
	} catch (JsonProcessingException ex) {
		throw new ConversionFailedException(TypeDescriptor.forObject(attribute), TypeDescriptor.valueOf(byte[].class), "Could not convert value to json", ex);
	}
}
 
开发者ID:thunderbird,项目名称:pungwecms,代码行数:17,代码来源:HashMapBinaryJSONConverter.java

示例11: convertToEntityAttribute

import com.fasterxml.jackson.dataformat.smile.SmileFactory; //导入依赖的package包/类
/**
 * Converts a byte array back into a hashmap
 *
 * @param dbData the json byte array
 * @return a HashMap
 */
@Override
public Map<?, ?> convertToEntityAttribute(byte[] dbData) {
	SmileFactory factory = new SmileFactory();
	ObjectMapper mapper = new ObjectMapper(factory);
	try {
		return mapper.readValue(dbData, HashMap.class);
	} catch (IOException ex) {
		throw new ConversionFailedException(TypeDescriptor.forObject(dbData), TypeDescriptor.valueOf(HashMap.class), "Could not convert value to json", ex);
	}
}
 
开发者ID:thunderbird,项目名称:pungwecms,代码行数:17,代码来源:HashMapBinaryJSONConverter.java

示例12: Tool

import com.fasterxml.jackson.dataformat.smile.SmileFactory; //导入依赖的package包/类
public Tool()
{
    jsonFactory = new JsonFactory();
    smileFactory = new SmileFactory();
    // check all shared refs (-> small size); add header, not trailing marker; do not use raw binary
    smileFactory.configure(SmileGenerator.Feature.CHECK_SHARED_NAMES, true);
    smileFactory.configure(SmileGenerator.Feature.CHECK_SHARED_STRING_VALUES, true);
    smileFactory.configure(SmileGenerator.Feature.ENCODE_BINARY_AS_7BIT, true);
    smileFactory.configure(SmileGenerator.Feature.WRITE_HEADER, true);
    smileFactory.configure(SmileGenerator.Feature.WRITE_END_MARKER, false);
    // also: do not require header
    smileFactory.configure(SmileParser.Feature.REQUIRE_HEADER, false);
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:14,代码来源:Tool.java

示例13: AtlasRegistry

import com.fasterxml.jackson.dataformat.smile.SmileFactory; //导入依赖的package包/类
/** Create a new instance. */
public AtlasRegistry(Clock clock, AtlasConfig config) {
  super(new StepClock(clock, config.step().toMillis()), config);
  this.clock = clock;

  this.enabled = config.enabled();
  this.step = config.step();
  this.stepMillis = step.toMillis();
  this.meterTTL = config.meterTTL().toMillis();
  this.uri = URI.create(config.uri());

  this.lwcEnabled = config.lwcEnabled();
  this.configRefreshFrequency = config.configRefreshFrequency();
  this.configTTL = config.configTTL().toMillis();
  this.configUri = URI.create(config.configUri());
  this.evalUri = URI.create(config.evalUri());

  this.connectTimeout = (int) config.connectTimeout().toMillis();
  this.readTimeout = (int) config.readTimeout().toMillis();
  this.batchSize = config.batchSize();
  this.numThreads = config.numThreads();
  this.commonTags = new TreeMap<>(config.commonTags());

  this.charset = AsciiSet.fromPattern(config.validTagCharacters());
  this.overrides = config.validTagValueCharacters()
      .keySet().stream()
      .collect(Collectors.toMap(k -> k, AsciiSet::fromPattern));
  SimpleModule module = new SimpleModule()
      .addSerializer(Measurement.class, new MeasurementSerializer(charset, overrides));
  this.jsonMapper = new ObjectMapper(new JsonFactory()).registerModule(module);
  this.smileMapper = new ObjectMapper(new SmileFactory()).registerModule(module);
}
 
开发者ID:Netflix,项目名称:spectator,代码行数:33,代码来源:AtlasRegistry.java

示例14: makeBinary

import com.fasterxml.jackson.dataformat.smile.SmileFactory; //导入依赖的package包/类
public static <V> Serializer makeBinary(final Class<V> type) {
    return new JsonSerializer<>(
        type,
        HzSerializationConstants.TYPEID_JSON_BINARY,
        new SmileFactory()
    );
}
 
开发者ID:lburgazzoli,项目名称:lb-hazelcast,代码行数:8,代码来源:JsonSerializer.java

示例15: SmileJacksonCodec

import com.fasterxml.jackson.dataformat.smile.SmileFactory; //导入依赖的package包/类
public SmileJacksonCodec() {
    super(new ObjectMapper(new SmileFactory()));
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:4,代码来源:SmileJacksonCodec.java


注:本文中的com.fasterxml.jackson.dataformat.smile.SmileFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。