當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonGenerator.writeEnd方法代碼示例

本文整理匯總了Java中javax.json.stream.JsonGenerator.writeEnd方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonGenerator.writeEnd方法的具體用法?Java JsonGenerator.writeEnd怎麽用?Java JsonGenerator.writeEnd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.json.stream.JsonGenerator的用法示例。


在下文中一共展示了JsonGenerator.writeEnd方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: build

import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
/**
    * Build a Json with name and values rom the passed map
    * @param namesAndValues	the map of (name, value) to add to the JsonGenerator
    * @return
    */
   public static String build(Map<String, String> namesAndValues) {

if (namesAndValues == null) {
    throw new NullPointerException("namesAndValues is null");
}

JsonGeneratorFactory jf = JsonUtil.getJsonGeneratorFactory(JsonUtil.DEFAULT_PRETTY_PRINTING);

StringWriter sw = new StringWriter();
JsonGenerator gen = jf.createGenerator(sw);

gen.writeStartObject()
.write("status", "OK")	;

for (Map.Entry<String, String> entry : namesAndValues.entrySet()) {

    // trace(entry.getKey() + "/" + entry.getValue());
    gen.write(entry.getKey(), entry.getValue());
}

gen.writeEnd();
gen.close();

return sw.toString();
   }
 
開發者ID:kawansoft,項目名稱:aceql-http,代碼行數:31,代碼來源:JsonOkReturn.java

示例2: statementNotAllowedBuild

import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
/**
    * Builds a security error message in JSON format for Statements
    * @param sqlOrder
    * @param errorMessage
    * @param doPrettyPrinting
    * @return
    */
   public static String statementNotAllowedBuild(String sqlOrder, String errorMessage, boolean doPrettyPrinting) {

try {
    JsonGeneratorFactory jf = JsonUtil
    	.getJsonGeneratorFactory(doPrettyPrinting);

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    
    JsonGenerator gen = jf.createGenerator(out);
    gen.writeStartObject();
    gen.write(Tag.PRODUCT_SECURITY, errorMessage);
    gen.write("SQL order", sqlOrder);
    gen.writeEnd();
    gen.close();
    return out.toString("UTF-8");
} catch (Exception e) {
    String returnString = Tag.PRODUCT_SECURITY + " " + errorMessage
	    + " " + sqlOrder;
    return returnString;
}

   }
 
開發者ID:kawansoft,項目名稱:aceql-http,代碼行數:30,代碼來源:JsonSecurityMessage.java

示例3: writeBuilding

import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
void writeBuilding(JsonGenerator gen, Building b) {
	gen.writeStartObject();
	gen.write("id", b.getId());
	gen.write("type", b.getType().toString());
	gen.write("height", b.getFinalHeight());
	gen.write("line", b.getLine().toString());
	gen.write("setback", b.getSetback().toString());
	gen.write("use", b.getUse().toString());
	writeVectorList(gen, "lot", b.getLot().asList());
	gen.writeStartArray("plan");
	for (Polygon p : b.getPlan()) {
		gen.writeStartObject();
		writeVectorList(gen, "polygon", p.asList());
		gen.writeEnd();
	}
	gen.writeEnd();
	gen.writeEnd();
}
 
開發者ID:arisona,項目名稱:ether,代碼行數:19,代碼來源:ScenarioWriter.java

示例4: toJson

import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
@Override
public void toJson(JsonGenerator generator) {
    generator.write("workflowId", workflowId);
    generator.writeStartArray("ruleIds");
    for (RuleId ruleId : ruleIds) {
        generator.writeStartObject();
        generator.write("attributeSet", ruleId.getAttributeSet().toString());
        generator.writeStartObject("securityIndexId");
        generator.write("contingencyId", ruleId.getSecurityIndexId().getContingencyId());
        generator.writeStartObject("securityIndexType");
        generator.write("name", ruleId.getSecurityIndexId().getSecurityIndexType().name());
        generator.write("label", ruleId.getSecurityIndexId().getSecurityIndexType().getLabel());
        generator.write("dynamic", ruleId.getSecurityIndexId().getSecurityIndexType().isDynamic());
        generator.writeEnd();
        generator.writeEnd();
        generator.writeEnd();
    }
    generator.writeEnd();
}
 
開發者ID:itesla,項目名稱:ipst,代碼行數:20,代碼來源:SecurityRulesChangeMessage.java

示例5: toJson

import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
@Override
public void toJson(JsonGenerator generator) {
    generator.write("workflowId", workflowId);
    generator.writeStartArray("samplesSynthesis");
    for (SampleSynthesis sample : samples) {
        generator.writeStartObject()
                    .write("id", sample.getId())
                    .writeStartObject("lastTaskEvent")
                        .write("type", sample.getLastTaskEvent().getTaskType().name())
                        .write("status", sample.getLastTaskEvent().getTaskStatus().name());
        if (sample.getLastTaskEvent().getFailureReason() != null) {
            generator.write("failureReason", sample.getLastTaskEvent().getFailureReason());
        }
        generator.writeEnd()
                .writeEnd();
    }
    generator.writeEnd();
}
 
開發者ID:itesla,項目名稱:ipst,代碼行數:19,代碼來源:SamplesSynthesisMessage.java

示例6: writeTo

import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
@Override
public void writeTo(VirtualInstanceCollection virtualInstanceCollection, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws UnsupportedEncodingException {
    String charSet = "UTF-8";
    JsonGenerator jg = Json.createGenerator(new OutputStreamWriter(entityStream, charSet));
    jg.writeStartArray();

    Matrix4d gM = new Matrix4d();
    gM.setIdentity();

    PartLink virtualRootPartLink = getVirtualRootPartLink(virtualInstanceCollection);
    List<PartLink> path = new ArrayList<>();
    path.add(virtualRootPartLink);
    InstanceBodyWriterTools.generateInstanceStreamWithGlobalMatrix(productService, path, gM, virtualInstanceCollection, new ArrayList<>(), jg);
    jg.writeEnd();
    jg.flush();
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:17,代碼來源:VirtualInstanceCollectionMessageBodyWriter.java

示例7: writeLeaf

import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
private static void writeLeaf(List<PartLink> currentPath, List<Integer> copyInstanceIds, PartIteration partI, Matrix4d combinedMatrix, JsonGenerator jg) {
    String partIterationId = partI.toString();
    List<InstanceAttributeDTO> attributes = new ArrayList<>();
    for (InstanceAttribute attr : partI.getInstanceAttributes()) {
        attributes.add(mapper.map(attr, InstanceAttributeDTO.class));
    }

    jg.writeStartObject();
    jg.write("id", Tools.getPathInstanceAsString(currentPath, copyInstanceIds));
    jg.write("partIterationId", partIterationId);
    jg.write("path", Tools.getPathAsString(currentPath));

    writeMatrix(combinedMatrix, jg);
    writeGeometries(partI.getSortedGeometries(), jg);
    writeAttributes(attributes, jg);

    jg.writeEnd();
    jg.flush();
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:20,代碼來源:InstanceBodyWriterTools.java

示例8: createString

import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
public static String createString(Collection<License> licenses)
{
    TreeSet<License> licenseSet = new TreeSet<>();
    licenseSet.addAll(licenses);

    StringWriter jsonString = new StringWriter();
    JsonGenerator generator = Json.createGenerator(jsonString);
    generator.writeStartArray();
    for (License license : licenseSet)
    {
        generator.writeStartObject();
        generator.write("name", license.getName());
        generator.write("identifier", license.getIdentifier());
        generator.write("status", license.getStatus());
        generator.writeEnd();
    }
    generator.writeEnd();
    generator.close();

    return jsonString.toString();
}
 
開發者ID:porscheinformatik,項目名稱:sonarqube-licensecheck,代碼行數:22,代碼來源:License.java

示例9: createString

import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
public static String createString(Collection<MavenLicense> mavenLicenses)
{
    TreeSet<MavenLicense> mavenLicenseSet = new TreeSet<>();
    mavenLicenseSet.addAll(mavenLicenses);

    StringWriter jsonString = new StringWriter();
    JsonGenerator generator = Json.createGenerator(jsonString);
    generator.writeStartArray();
    for (MavenLicense mavenLicense : mavenLicenseSet)
    {
        generator.writeStartObject();
        generator.write("regex", mavenLicense.getRegex().pattern());
        generator.write("license", mavenLicense.getLicense());
        generator.writeEnd();
    }
    generator.writeEnd();
    generator.close();

    return jsonString.toString();
}
 
開發者ID:porscheinformatik,項目名稱:sonarqube-licensecheck,代碼行數:21,代碼來源:MavenLicense.java

示例10: serialize

import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(Book book, JsonGenerator generator, SerializationContext ctx) {

    if (book != null) {
        generator.writeStartObject();
        ctx.serialize(book.getClass().getName(), book, generator);
        generator.writeEnd();
    } else {
        ctx.serialize(null, generator);
    }
}
 
開發者ID:readlearncode,項目名稱:Java-EE-8-Sampler,代碼行數:12,代碼來源:BookSerializer.java

示例11: serialize

import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(Magazine magazine, JsonGenerator generator, SerializationContext ctx) {

    if (magazine != null) {
        generator.writeStartObject();
        ctx.serialize("name", magazine.getAuthor(), generator);
        generator.writeEnd();
    } else {
        ctx.serialize(null, generator);
    }

}
 
開發者ID:readlearncode,項目名稱:Java-EE-8-Sampler,代碼行數:13,代碼來源:MagazineSerializer.java

示例12: serialize

import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(Book book, JsonGenerator generator, SerializationContext ctx) {
    generator.writeStartObject();
    generator.write("id", "QWE-123-RTS");
    generator.write("title", book.getTitle());
    generator.write("firstName", book.getAuthor().split(" ")[0]);
    generator.write("lastName", book.getAuthor().split(" ")[1]);
    generator.writeEnd();
}
 
開發者ID:readlearncode,項目名稱:Java-EE-8-Sampler,代碼行數:10,代碼來源:BookSerializer.java

示例13: build

import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
/**
    * Builds the error message
    * @return the error message
    */
   public String build() {

JsonGeneratorFactory jf = JsonUtil.getJsonGeneratorFactory(JsonUtil.DEFAULT_PRETTY_PRINTING);
    
StringWriter sw = new StringWriter();	
JsonGenerator gen = jf.createGenerator(sw);

gen.writeStartObject()
   .write("status", "FAIL")
   .write("error_type", errorType);

if (errorMessage != null) {
    gen.write("error_message", errorMessage);
}
else {
    gen.write("error_message", JsonValue.NULL);
}

if (stackTrace != null) {
    gen.write("stack_trace", stackTrace);
    System.err.println(stackTrace);
}

gen.write("http_status", httpStatus);

gen.writeEnd();
gen.close();

String doc = sw.toString();

if (LOG_JSON_ERROR) {
    System.err.println(doc);
}

return doc;
   }
 
開發者ID:kawansoft,項目名稱:aceql-http,代碼行數:41,代碼來源:JsonErrorReturn.java

示例14: serialize

import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
@Override
public void serialize(final CoffeeEvent event, final JsonGenerator generator, final SerializationContext ctx) {
    generator.write("class", event.getClass().getCanonicalName());
    generator.writeStartObject("data");
    ctx.serialize("data", event, generator);
    generator.writeEnd();
}
 
開發者ID:sdaschner,項目名稱:scalable-coffee-shop,代碼行數:8,代碼來源:EventJsonbSerializer.java

示例15: toJson

import javax.json.stream.JsonGenerator; //導入方法依賴的package包/類
@Override
public void toJson(JsonGenerator generator) {
    generator.writeStartArray("workflowStatuses");
    for (OfflineWorkflowStatus status : offlineWorkflowStatuses) {
        generator.writeStartObject();
        new WorkflowStatusMessage(status).toJson(generator);
        generator.writeEnd();
    }
    generator.writeEnd();
}
 
開發者ID:itesla,項目名稱:ipst,代碼行數:11,代碼來源:WorkflowListMessage.java


注:本文中的javax.json.stream.JsonGenerator.writeEnd方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。