本文整理汇总了Java中de.undercouch.bson4jackson.BsonFactory类的典型用法代码示例。如果您正苦于以下问题:Java BsonFactory类的具体用法?Java BsonFactory怎么用?Java BsonFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BsonFactory类属于de.undercouch.bson4jackson包,在下文中一共展示了BsonFactory类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: readFileHeader
import de.undercouch.bson4jackson.BsonFactory; //导入依赖的package包/类
/**
* @param dis
* @throws IOException
* @throws JsonParseException
* @throws JsonMappingException
*/
private void readFileHeader(DataInputStream dis) throws IOException, JsonParseException, JsonMappingException {
BsonFactory factory = new BsonFactory();
ObjectMapper mapper = new ObjectMapper(factory);
JsonNode rootNode = mapper.readValue(RogReaderUtils.readBytesArray(dis), JsonNode.class);
JsonNode version = rootNode.findValue(RogReaderUtils.VERSION_KEY);
int rogversion =version.asInt();
if(rogversion > RogReaderUtils.RENDER_GEOMETRY_FILE_VERSION){
throw new RuntimeException(RogReaderUtils.RENDER_GEOMETRY_FILE_EXT + " cannot be read as it is made for a newer version of ODL Studio.");
}
JsonNode isNOLP = rootNode.findValue(RogReaderUtils.IS_NOPL_KEY);
if(isNOLP!=null){
this.isNOLP = isNOLP.asBoolean();
}else{
this.isNOLP = false;
}
}
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:24,代码来源:QuadLoader.java
示例2: writeBJSONFileHeader
import de.undercouch.bson4jackson.BsonFactory; //导入依赖的package包/类
private void writeBJSONFileHeader(boolean isNOLPL,DataOutputStream dos){
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BsonFactory factory = new BsonFactory();
JsonGenerator gen = factory.createJsonGenerator(baos);
gen.writeStartObject();
gen.writeFieldName(RogReaderUtils.VERSION_KEY);
gen.writeNumber(RogReaderUtils.RENDER_GEOMETRY_FILE_VERSION);
gen.writeFieldName(RogReaderUtils.IS_NOPL_KEY);
gen.writeBoolean(isNOLPL);
gen.writeEndObject();
gen.close();
ROGWriterUtils.writeByteArray(baos.toByteArray(), dos);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:23,代码来源:QuadWriter.java
示例3: testBson4Jackson
import de.undercouch.bson4jackson.BsonFactory; //导入依赖的package包/类
@Benchmark
public void testBson4Jackson () throws IOException
{
BsonFactory bsonFactory = new BsonFactory();
de.undercouch.bson4jackson.BsonParser p = bsonFactory.createParser (getInputStream ());
perfTest2 (p);
p.close ();
}
开发者ID:coconut2015,项目名称:cookjson,代码行数:9,代码来源:BsonParserBenchmark.java
示例4: init
import de.undercouch.bson4jackson.BsonFactory; //导入依赖的package包/类
/**
* Initialize the servlet
*
* @param config
* @throws ServletException
*/
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
mJsonMapper = new ObjectMapper(new JsonFactory());
mBsonMapper = new ObjectMapper(new BsonFactory());
}
开发者ID:promovicz,项目名称:better-jsonrpc,代码行数:13,代码来源:JsonRpcHttpServlet.java
示例5: BsonJackson
import de.undercouch.bson4jackson.BsonFactory; //导入依赖的package包/类
public BsonJackson() {
super(new ObjectMapper(new BsonFactory()));
// Install MongoDB / BSON serializers
tryToAddSerializers("io.datatree.dom.adapters.BsonJacksonBsonSerializers", mapper);
}
开发者ID:berkesa,项目名称:datatree-adapters,代码行数:7,代码来源:BsonJackson.java
示例6: testWffBinaryMessageBytesLengthIsLowerThanBson
import de.undercouch.bson4jackson.BsonFactory; //导入依赖的package包/类
@Test
public void testWffBinaryMessageBytesLengthIsLowerThanBson() throws Exception {
List<NameValue> nameValues = getProducedNameValues();
byte[] message = WffBinaryMessageUtil.VERSION_1.getWffBinaryMessageBytes(nameValues);
Map<String, List<String>> jsonObject = getProducedJsonObject();
ObjectMapper bsonMapper = new ObjectMapper(
new BsonFactory());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bsonMapper.writeValue(baos, jsonObject);
byte[] bsonBytes = baos.toByteArray();
assertTrue(message.length < bsonBytes.length);
if (message.length < bsonBytes.length) {
System.out.println("the length of wff binary message is lower than bson bytes, the ratio wff binary message:bson = " + (message.length + ":" + bsonBytes.length)+ ", gain is " + (bsonBytes.length - message.length) + " bytes");
}
}
开发者ID:webfirmframework,项目名称:wff,代码行数:23,代码来源:WffBinaryMessageUtilTest.java
示例7: createObjectMapper
import de.undercouch.bson4jackson.BsonFactory; //导入依赖的package包/类
public static ObjectMapper createObjectMapper() {
BsonFactory bsonFactory = new BsonFactory();
bsonFactory.enable(BsonParser.Feature.HONOR_DOCUMENT_LENGTH);
return new ObjectMapper(bsonFactory);
}
开发者ID:ylemoigne,项目名称:mongo-jackson-codec,代码行数:7,代码来源:ObjectMapperFactory.java
示例8: init
import de.undercouch.bson4jackson.BsonFactory; //导入依赖的package包/类
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
mJsonMapper = new ObjectMapper(new JsonFactory());
mBsonMapper = new ObjectMapper(new BsonFactory());
}
开发者ID:promovicz,项目名称:better-jsonrpc,代码行数:7,代码来源:JsonRpcWsServlet.java
注:本文中的de.undercouch.bson4jackson.BsonFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论