本文整理汇总了Java中org.codehaus.jackson.JsonGenerator.writeStringField方法的典型用法代码示例。如果您正苦于以下问题:Java JsonGenerator.writeStringField方法的具体用法?Java JsonGenerator.writeStringField怎么用?Java JsonGenerator.writeStringField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.jackson.JsonGenerator
的用法示例。
在下文中一共展示了JsonGenerator.writeStringField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setBeforeInfo
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
/**
* Populate transaction meta data into the record if requested.
*
* @param jg the handle to the JsonGenerator
* @param op the database operation we are processing.
* @throws IOException if a JSON encoding error occurs
*/
private void setBeforeInfo(JsonGenerator jg, DownstreamOperation op) throws IOException {
LOG.debug("setBeforeInfo()");
jg.writeFieldName("priorValues");
jg.writeStartObject();
// loop through operatons with calls to appropriate jg.write() methods
for (DownstreamColumnData col : op.getBefores()) {
if (textOnly == true) {
jg.writeStringField(col.getBDName(), col.asString());
} else {
// Encode the data appropriately: handle numbers as numbers, etc.
int jdbcType;
jdbcType = op.getTableMeta().getColumn(col.getOrigName()).getJdbcType();
encodeColumn(col, jdbcType, jg);
}
}
jg.writeEndObject();
}
示例2: serialize
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(VirtualNetwork vNet, JsonGenerator jGen,
SerializerProvider serializer) throws IOException,
JsonProcessingException {
jGen.writeStartObject();
jGen.writeStringField("name", vNet.name);
jGen.writeStringField("guid", vNet.guid);
jGen.writeStringField("gateway", vNet.gateway);
jGen.writeArrayFieldStart("mac");
Iterator<MACAddress> hit = vNet.hosts.iterator();
while (hit.hasNext())
jGen.writeString(hit.next().toString());
jGen.writeEndArray();
jGen.writeEndObject();
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:19,代码来源:VirtualNetworkSerializer.java
示例3: serialize
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
/**
* Performs the serialization of a OneComponentTime object
*/
@Override
public void serialize(CumulativeTimeBucket ctb,
JsonGenerator jGen,
SerializerProvider serializer)
throws IOException, JsonProcessingException {
jGen.writeStartObject();
Timestamp ts = new Timestamp(ctb.getStartTimeNs()/1000000);
jGen.writeStringField("start-time", ts.toString());
jGen.writeStringField("current-time",
new Timestamp(System.currentTimeMillis()).toString());
jGen.writeNumberField("total-packets", ctb.getTotalPktCnt());
jGen.writeNumberField("average", ctb.getAverageProcTimeNs());
jGen.writeNumberField("min", ctb.getMinTotalProcTimeNs());
jGen.writeNumberField("max", ctb.getMaxTotalProcTimeNs());
jGen.writeNumberField("std-dev", ctb.getTotalSigmaProcTimeNs());
jGen.writeArrayFieldStart("modules");
for (OneComponentTime oct : ctb.getModules()) {
serializer.defaultSerializeValue(oct, jGen);
}
jGen.writeEndArray();
jGen.writeEndObject();
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:26,代码来源:CumulativeTimeBucketJSONSerializer.java
示例4: serialize
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
/**
* Performs the serialization of a OFFeaturesReply object
*/
@Override
public void serialize(OFFeaturesReply reply, JsonGenerator jGen, SerializerProvider serializer) throws IOException, JsonProcessingException {
jGen.writeStartObject();
jGen.writeNumberField("actions", reply.getActions());
jGen.writeNumberField("buffers", reply.getBuffers());
jGen.writeNumberField("capabilities", reply.getCapabilities());
jGen.writeStringField("datapathId", HexString.toHexString(reply.getDatapathId()));
jGen.writeNumberField("length", reply.getLength());
serializer.defaultSerializeField("ports", reply.getPorts(), jGen);
jGen.writeNumberField("tables", reply.getTables());
jGen.writeStringField("type", reply.getType().toString());
jGen.writeNumberField("version", reply.getVersion());
jGen.writeNumberField("xid", reply.getXid());
jGen.writeEndObject();
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:19,代码来源:OFFeaturesReplyJSONSerializer.java
示例5: toJson
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
/**
* Build a JSON entry from the parameters. This is public for testing.
*
* @param writer destination
* @param loggerName logger name
* @param timeStamp time_t value
* @param level level string
* @param threadName name of the thread
* @param message rendered message
* @param ti nullable thrown information
* @return the writer
* @throws IOException on any problem
*/
public Writer toJson(final Writer writer,
final String loggerName,
final long timeStamp,
final String level,
final String threadName,
final String message,
final ThrowableInformation ti) throws IOException {
JsonGenerator json = factory.createJsonGenerator(writer);
json.writeStartObject();
json.writeStringField(NAME, loggerName);
json.writeNumberField(TIME, timeStamp);
Date date = new Date(timeStamp);
json.writeStringField(DATE, dateFormat.format(date));
json.writeStringField(LEVEL, level);
json.writeStringField(THREAD, threadName);
json.writeStringField(MESSAGE, message);
if (ti != null) {
//there is some throwable info, but if the log event has been sent over the wire,
//there may not be a throwable inside it, just a summary.
Throwable thrown = ti.getThrowable();
String eclass = (thrown != null) ?
thrown.getClass().getName()
: "";
json.writeStringField(EXCEPTION_CLASS, eclass);
String[] stackTrace = ti.getThrowableStrRep();
json.writeArrayFieldStart(STACK);
for (String row : stackTrace) {
json.writeString(row);
}
json.writeEndArray();
}
json.writeEndObject();
json.flush();
json.close();
return writer;
}
示例6: dumpConfiguration
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
/**
* Writes out all the parameters and their properties (final and resource) to
* the given {@link Writer}
* The format of the output would be
* { "properties" : [ {key1,value1,key1.isFinal,key1.resource}, {key2,value2,
* key2.isFinal,key2.resource}... ] }
* It does not output the parameters of the configuration object which is
* loaded from an input stream.
* @param out the Writer to write to
* @throws IOException
*/
public static void dumpConfiguration(Configuration config,
Writer out) throws IOException {
JsonFactory dumpFactory = new JsonFactory();
JsonGenerator dumpGenerator = dumpFactory.createJsonGenerator(out);
dumpGenerator.writeStartObject();
dumpGenerator.writeFieldName("properties");
dumpGenerator.writeStartArray();
dumpGenerator.flush();
synchronized (config) {
for (Map.Entry<Object,Object> item: config.getProps().entrySet()) {
dumpGenerator.writeStartObject();
dumpGenerator.writeStringField("key", (String) item.getKey());
dumpGenerator.writeStringField("value",
config.get((String) item.getKey()));
dumpGenerator.writeBooleanField("isFinal",
config.finalParameters.contains(item.getKey()));
String[] resources = config.updatingResource.get(item.getKey());
String resource = UNKNOWN_RESOURCE;
if(resources != null && resources.length > 0) {
resource = resources[0];
}
dumpGenerator.writeStringField("resource", resource);
dumpGenerator.writeEndObject();
}
}
dumpGenerator.writeEndArray();
dumpGenerator.writeEndObject();
dumpGenerator.flush();
}
示例7: open
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
public Writer open(final PrintWriter writer) throws IOException {
final JsonGenerator jg = jsonFactory.createJsonGenerator(writer);
jg.disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
jg.useDefaultPrettyPrinter();
jg.writeStartObject();
return new Writer() {
@Override
public void flush() throws IOException {
jg.flush();
}
@Override
public void close() throws IOException {
jg.close();
}
@Override
public void write(String key, String value) throws JsonGenerationException, IOException {
jg.writeStringField(key, value);
}
@Override
public int write(MBeanServer mBeanServer, ObjectName qry, String attribute,
boolean description)
throws IOException {
return JSONBean.write(jg, mBeanServer, qry, attribute, description);
}
};
}
示例8: encodeDatabaseOperation
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
/**
* Encode the DownstreamOperation as a JSON record.
*
* @param op the operatoin we are encoding
* @return an instance of EventData
* @throws IOException if an encoding error occurs
*/
public EventData encodeDatabaseOperation(DownstreamOperation op) throws IOException {
JsonGenerator jg;
eventHeader.setHeaderInfo(op);
/*
* need a new one of these with each call because we pass the byte array
* from baos along with the event as it is passed to the publisher.
*/
baos = new ByteArrayOutputStream();
jg = factory.createJsonGenerator(baos);
jg.writeStartObject();
setTxInfo(jg, op);
// loop through operatons with calls to appropriate jg.write() methods
for (DownstreamColumnData col : op.getColumns()) {
if (textOnly == true) {
jg.writeStringField(col.getBDName(), col.asString());
} else {
// Encode the data appropriately: handle numbers as numbers, etc.
int jdbcType;
jdbcType = op.getTableMeta().getColumn(col.getOrigName()).getJdbcType();
encodeColumn(col, jdbcType, jg);
}
}
if (includeBefores) {
setBeforeInfo(jg, op);
}
jg.writeEndObject();
jg.flush();
jg.close();
return new EventData(encoderType, eventHeader.getEventHeader(), baos.toByteArray());
}
示例9: serialize
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(
PropertyInfo propertyInfo, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonProcessingException
{
if (provideDescription) {
jgen.writeStartObject();
jgen.writeStringField("value", propertyInfo.value);
jgen.writeStringField("description", propertyInfo.description);
jgen.writeEndObject();
} else {
jgen.writeString(propertyInfo.value);
}
}
示例10: serialize
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
/**
* Performs the serialization of a OFMatch object
*/
@Override
public void serialize(OFMatch match, JsonGenerator jGen,
SerializerProvider serializer)
throws IOException, JsonProcessingException {
jGen.writeStartObject();
jGen.writeStringField("dataLayerDestination",
HexString.toHexString(match.getDataLayerDestination()));
jGen.writeStringField("dataLayerSource",
HexString.toHexString(match.getDataLayerSource()));
String dataType = Integer.toHexString(match.getDataLayerType());
while (dataType.length() < 4) {
dataType = "0".concat(dataType);
}
jGen.writeStringField("dataLayerType", "0x" + dataType);
jGen.writeNumberField("dataLayerVirtualLan",
match.getDataLayerVirtualLan());
jGen.writeNumberField("dataLayerVirtualLanPriorityCodePoint",
match.getDataLayerVirtualLanPriorityCodePoint());
jGen.writeNumberField("inputPort", match.getInputPort());
jGen.writeStringField("networkDestination",
intToIp(match.getNetworkDestination()));
jGen.writeNumberField("networkDestinationMaskLen",
match.getNetworkDestinationMaskLen());
jGen.writeNumberField("networkProtocol", match.getNetworkProtocol());
jGen.writeStringField("networkSource",
intToIp(match.getNetworkSource()));
jGen.writeNumberField("networkSourceMaskLen",
match.getNetworkSourceMaskLen());
jGen.writeNumberField("networkTypeOfService",
match.getNetworkTypeOfService());
jGen.writeNumberField("transportDestination",
match.getTransportDestination());
jGen.writeNumberField("transportSource",
match.getTransportSource());
jGen.writeNumberField("wildcards", match.getWildcards());
jGen.writeEndObject();
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:41,代码来源:OFMatchJSONSerializer.java
示例11: write
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
/**
* Used to write the state of the ClusterNode instance to disk, when we are
* persisting the state of the NodeManager
* @param jsonGenerator The JsonGenerator instance being used to write JSON
* to disk
* @throws IOException
*/
public void write(JsonGenerator jsonGenerator) throws IOException {
jsonGenerator.writeStartObject();
// clusterNodeInfo begins
jsonGenerator.writeFieldName("clusterNodeInfo");
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField("name", clusterNodeInfo.name);
jsonGenerator.writeObjectField("address", clusterNodeInfo.address);
jsonGenerator.writeObjectField("total", clusterNodeInfo.total);
jsonGenerator.writeObjectField("free", clusterNodeInfo.free);
jsonGenerator.writeObjectField("resourceInfos",
clusterNodeInfo.resourceInfos);
jsonGenerator.writeEndObject();
// clusterNodeInfo ends
// grants begins
jsonGenerator.writeFieldName("grants");
jsonGenerator.writeStartObject();
for (Map.Entry<GrantId, ResourceRequestInfo> entry : grants.entrySet()) {
jsonGenerator.writeFieldName(entry.getKey().unique);
jsonGenerator.writeStartObject();
jsonGenerator.writeFieldName("grantId");
entry.getKey().write(jsonGenerator);
jsonGenerator.writeFieldName("grant");
entry.getValue().write(jsonGenerator);
jsonGenerator.writeEndObject();
}
jsonGenerator.writeEndObject();
// grants ends
jsonGenerator.writeEndObject();
// We skip the hostNode and lastHeartbeatTime as they need not be persisted.
// resourceTypeToMaxCpu and resourceTypeToStatsMap can be rebuilt using the
// conf and the grants respectively.
}
示例12: write
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
/**
* Used to write the state of the SessionNotificationCtx instance to disk,
* when we are persisting the state of the ClusterManager
* @param jsonGenerator The JsonGenerator instance being used to write JSON
* to disk
* @throws IOException
*/
public void write(JsonGenerator jsonGenerator) throws IOException {
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField("handle", handle);
jsonGenerator.writeStringField("host", host);
jsonGenerator.writeNumberField("port", port);
jsonGenerator.writeNumberField("numPendingCalls", pendingCalls.size());
jsonGenerator.writeFieldName("pendingCalls");
jsonGenerator.writeStartArray();
for (TBase call : pendingCalls) {
jsonGenerator.writeStartObject();
// TBase is an abstract class. While reading back, we want to know
// what kind of object we actually wrote. Jackson does provide two methods
// to do it automatically, but one of them adds types at a lot of places
// where we don't need it, and hence our parsing would be required to be
// changed. The other required adding an annotation to the TBase class,
// which we can't do, since it is auto-generated by Thrift.
String callType = call.getClass().getName();
jsonGenerator.writeStringField("callType", callType);
jsonGenerator.writeObjectField("call", call);
jsonGenerator.writeEndObject();
}
jsonGenerator.writeEndArray();
jsonGenerator.writeEndObject();
}
示例13: serialize
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(LangString value, JsonGenerator jgen,
SerializerProvider provider) throws IOException, JsonProcessingException {
jgen.writeStartObject();
jgen.writeStringField(value.getLang(), value.toString());
jgen.writeEndObject();
}
示例14: serialize
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(Device device, JsonGenerator jGen,
SerializerProvider serializer) throws IOException,
JsonProcessingException {
jGen.writeStartObject();
jGen.writeStringField("entityClass", device.getEntityClass().getName());
jGen.writeArrayFieldStart("mac");
jGen.writeString(HexString.toHexString(device.getMACAddress(), 6));
jGen.writeEndArray();
jGen.writeArrayFieldStart("ipv4");
for (Integer ip : device.getIPv4Addresses())
jGen.writeString(IPv4.fromIPv4Address(ip));
jGen.writeEndArray();
jGen.writeArrayFieldStart("vlan");
for (Short vlan : device.getVlanId())
if (vlan >= 0)
jGen.writeNumber(vlan);
jGen.writeEndArray();
jGen.writeArrayFieldStart("attachmentPoint");
for (SwitchPort ap : device.getAttachmentPoints(true)) {
serializer.defaultSerializeValue(ap, jGen);
}
jGen.writeEndArray();
jGen.writeNumberField("lastSeen", device.getLastSeen().getTime());
jGen.writeEndObject();
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:33,代码来源:DeviceSerializer.java
示例15: serialize
import org.codehaus.jackson.JsonGenerator; //导入方法依赖的package包/类
@Override
public void serialize(LinkWithType lwt, JsonGenerator jgen, SerializerProvider arg2)
throws IOException, JsonProcessingException {
// You ****MUST*** use lwt for the fields as it's actually a different object.
jgen.writeStartObject();
jgen.writeStringField("src-switch", HexString.toHexString(lwt.srcSwDpid));
jgen.writeNumberField("src-port", lwt.srcPort);
jgen.writeNumberField("src-port-state", lwt.srcPortState);
jgen.writeStringField("dst-switch", HexString.toHexString(lwt.dstSwDpid));
jgen.writeNumberField("dst-port", lwt.dstPort);
jgen.writeNumberField("dst-port-state", lwt.dstPortState);
jgen.writeStringField("type", lwt.type.toString());
jgen.writeEndObject();
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:15,代码来源:LinkWithType.java