本文整理汇总了Java中com.fasterxml.jackson.core.io.SegmentedStringWriter类的典型用法代码示例。如果您正苦于以下问题:Java SegmentedStringWriter类的具体用法?Java SegmentedStringWriter怎么用?Java SegmentedStringWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SegmentedStringWriter类属于com.fasterxml.jackson.core.io包,在下文中一共展示了SegmentedStringWriter类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeValueAsString
import com.fasterxml.jackson.core.io.SegmentedStringWriter; //导入依赖的package包/类
public String writeValueAsString(Object paramObject)
{
SegmentedStringWriter localSegmentedStringWriter = new SegmentedStringWriter(this._jsonFactory._getBufferRecycler());
try
{
_configAndWriteValue(this._jsonFactory.createGenerator(localSegmentedStringWriter), paramObject);
}
catch (JsonProcessingException localJsonProcessingException)
{
throw localJsonProcessingException;
}
catch (IOException localIOException)
{
throw JsonMappingException.fromUnexpectedIOE(localIOException);
}
return localSegmentedStringWriter.getAndClear();
}
示例2: testSimple
import com.fasterxml.jackson.core.io.SegmentedStringWriter; //导入依赖的package包/类
public void testSimple() throws Exception
{
BufferRecycler br = new BufferRecycler();
SegmentedStringWriter w = new SegmentedStringWriter(br);
StringBuilder exp = new StringBuilder();
for (int i = 0; exp.length() < 100; ++i) {
String nr = String.valueOf(i);
exp.append(' ').append(nr);
w.append(' ');
switch (i % 4) {
case 0:
w.append(nr);
break;
case 1:
{
String str = " "+nr;
w.append(str, 2, str.length());
}
break;
case 2:
w.write(nr.toCharArray());
break;
default:
{
char[] ch = (" "+nr+" ").toCharArray();
w.write(ch, 1, nr.length());
}
break;
}
}
// flush, close are nops but trigger just for fun
w.flush();
w.close();
String act = w.getAndClear();
assertEquals(exp.toString(), act);
}
示例3: writeValueAsString
import com.fasterxml.jackson.core.io.SegmentedStringWriter; //导入依赖的package包/类
/**
* Converts a {@link Message} into a JSON {@link String}.
*
* @throws InvalidProtocolBufferException if there are unknown Any types in the message.
*/
public <T extends Message> String writeValueAsString(T message) throws IOException {
checkNotNull(message, "message");
SegmentedStringWriter sw = new SegmentedStringWriter(jsonFactory._getBufferRecycler());
JsonGenerator gen = jsonFactory.createGenerator(sw);
writeValue(message, gen);
return sw.getAndClear();
}
示例4: JSONComposer
import com.fasterxml.jackson.core.io.SegmentedStringWriter; //导入依赖的package包/类
protected JSONComposer(int features, JsonGenerator gen, SegmentedStringWriter w)
{
super(gen);
_features = features;
_stringWriter = w;
_byteWriter = null;
_closeGenerator = true;
}
示例5: writeBackListToRowTable
import com.fasterxml.jackson.core.io.SegmentedStringWriter; //导入依赖的package包/类
/**
* 回写List对象到行编辑模式的表格
* @param namespace
* @param lvo
* @param ignoreName
* @param om
* @return
* @throws JsonProcessingException
*/
public static String writeBackListToRowTable(String namespace, List lvo, final String[] ignoreName, ObjectMapper objectMapper) {
if(lvo == null || lvo.size() == 0) {
return "";
}
StringBuilder result = new StringBuilder();
result.append("jQuery(function(){\n");
result.append("writeBackListToRowTable(");
result.append("'");
result.append(namespace);
result.append("'");
result.append(", ");
try {
if(objectMapper == null) {
objectMapper = RmObjectMapper.getInstance();
}
// 排除
if(ignoreName != null) {
SimpleFilterProvider fileter = new SimpleFilterProvider();
fileter.addFilter("executeFilter", SimpleBeanPropertyFilter.serializeAllExcept(ignoreName));
objectMapper.setFilters(fileter);
}
// 设置日期格式化
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
SegmentedStringWriter sw = new SegmentedStringWriter(objectMapper.getFactory()._getBufferRecycler());
JsonGenerator generator = objectMapper.getFactory().createGenerator(sw);
RmBeanSerializerFactory rmBeanFactory = RmBeanSerializerFactory.instance;
if(ignoreName != null) {
rmBeanFactory.setFilterId("executeFilter");
}
objectMapper.setSerializerFactory(rmBeanFactory);
objectMapper.writeValue(generator, lvo);
result.append( sw.getAndClear());
} catch (Exception e) {
throw new RuntimeException(e);
}
result.append(");");
result.append("\n});");
return result.toString();
}
示例6: writeBackListToRowTable
import com.fasterxml.jackson.core.io.SegmentedStringWriter; //导入依赖的package包/类
public static String writeBackListToRowTable(String namespace, List lvo, final String[] ignoreName, ObjectMapper objectMapper) {
if(lvo == null || lvo.size() == 0) {
return "";
}
//TODO ignoreName
if(objectMapper == null) {
objectMapper = RmObjectMapper.getInstance();
}
JsonEncoding encoding = JsonEncoding.UTF8;
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd"));
StringBuilder result = new StringBuilder();
result.append("jQuery(function(){\n");
result.append("writeBackListToRowTable(");
result.append("'");
result.append(namespace);
result.append("'");
result.append(", \n");
try {
// 排除
SimpleFilterProvider fileter = new SimpleFilterProvider();
fileter.addFilter("executeFilter", SimpleBeanPropertyFilter.serializeAllExcept(ignoreName));
objectMapper.setFilters(fileter);
// // 仅包含
// SimpleFilterProvider fileter2 = new SimpleFilterProvider();
// fileter2.addFilter("includeFilter", SimpleBeanPropertyFilter.filterOutAllExcept(new String[] { "id", "quality" }));
// objectMapper.setFilters(fileter2);
// 设置日期格式化
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
SegmentedStringWriter sw = new SegmentedStringWriter(objectMapper.getFactory()._getBufferRecycler());
JsonGenerator generator = objectMapper.getFactory().createJsonGenerator(sw);
RmBeanSerializerFactory bidBeanFactory = RmBeanSerializerFactory.instance;
bidBeanFactory.setFilterId("executeFilter"); // 如果是仅包含这里填写 includeFilter
objectMapper.setSerializerFactory(bidBeanFactory);
objectMapper.writeValue(generator, lvo);
result.append( sw.getAndClear());
} catch (Exception e) {
throw new RuntimeException(e);
}
result.append("\n);");
result.append("\n});");
return result.toString();
}
示例7: stringComposer
import com.fasterxml.jackson.core.io.SegmentedStringWriter; //导入依赖的package包/类
public static JSONComposer<String> stringComposer(int features,
JsonGenerator gen, SegmentedStringWriter w) {
return new JSONComposer<String>(features, gen, w);
}
示例8: composeString
import com.fasterxml.jackson.core.io.SegmentedStringWriter; //导入依赖的package包/类
public JSONComposer<String> composeString() throws IOException, JSONObjectException {
SegmentedStringWriter out = new SegmentedStringWriter(_streamFactory._getBufferRecycler());
JsonGenerator gen = _config(_streamFactory.createGenerator(this, out));
return JSONComposer.stringComposer(_features, gen, out);
}