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


Java IParser.setPrettyPrint方法代码示例

本文整理汇总了Java中ca.uhn.fhir.parser.IParser.setPrettyPrint方法的典型用法代码示例。如果您正苦于以下问题:Java IParser.setPrettyPrint方法的具体用法?Java IParser.setPrettyPrint怎么用?Java IParser.setPrettyPrint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ca.uhn.fhir.parser.IParser的用法示例。


在下文中一共展示了IParser.setPrettyPrint方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import ca.uhn.fhir.parser.IParser; //导入方法依赖的package包/类
public static void main(String[] theArgs) {

		// Create a Patient
		Patient pat = new Patient();
		pat.addName().setFamily("Simpson").addGiven("Homer").addGiven("J");
		pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("7000135");
		pat.addTelecom().setUse(ContactPointUse.HOME).setSystem(ContactPointSystem.PHONE).setValue("1 (416) 340-4800");
		pat.setGender(AdministrativeGender.MALE);

		// Create a context
		FhirContext ctx = FhirContext.forDstu3();

		// Create a JSON parser
		IParser parser = ctx.newJsonParser();
		parser.setPrettyPrint(true);

		String encode = parser.encodeResourceToString(pat);
		System.out.println(encode);

	}
 
开发者ID:furore-fhir,项目名称:fhirstarters,代码行数:21,代码来源:Example04_EncodeResource.java

示例2: main

import ca.uhn.fhir.parser.IParser; //导入方法依赖的package包/类
public static void main(String[] theArgs) {
	
	// Create a Patient
	Patient pat = new Patient();
	pat.addName().addFamily("Simpson").addGiven("Homer").addGiven("J");
	pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("7000135");
	pat.addIdentifier().setLabel("Library Card 12345").setValue("12345");
	pat.addTelecom().setUse(ContactUseEnum.HOME).setSystem(ContactSystemEnum.PHONE).setValue("1 (416) 340-4800");
	pat.setGender(AdministrativeGenderCodesEnum.M);
	
	// Create a context
	FhirContext ctx = new FhirContext();
	
	// Create a XML parser
	IParser parser = ctx.newXmlParser();
	parser.setPrettyPrint(true);
	
	String encode = parser.encodeResourceToString(pat);
	System.out.println(encode);
	
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:22,代码来源:Example03_EncodeResource.java

示例3: returnResponse

import ca.uhn.fhir.parser.IParser; //导入方法依赖的package包/类
public Object returnResponse(ServletRequestDetails theRequest, ParseAction<?> outcome, int operationStatus, boolean allowPrefer, MethodOutcome response, String resourceName) throws IOException {
	HttpServletResponse servletResponse = theRequest.getServletResponse();
	servletResponse.setStatus(operationStatus);
	servletResponse.setCharacterEncoding(Constants.CHARSET_NAME_UTF8);
	addHeadersToResponse(servletResponse);
	if (allowPrefer) {
		addContentLocationHeaders(theRequest, servletResponse, response, resourceName);
	}
	Writer writer;
	if (outcome != null) {
		ResponseEncoding encoding = RestfulServerUtils.determineResponseEncodingWithDefault(theRequest);
		servletResponse.setContentType(encoding.getResourceContentType());
		writer = servletResponse.getWriter();
		IParser parser = encoding.getEncoding().newParser(getFhirContext());
		parser.setPrettyPrint(RestfulServerUtils.prettyPrintResponse(this, theRequest));
		outcome.execute(parser, writer);
	} else {
		servletResponse.setContentType(Constants.CT_TEXT_WITH_UTF8);
		writer = servletResponse.getWriter();
	}
	return writer;
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:23,代码来源:RestfulServer.java

示例4: encodeMsg

import ca.uhn.fhir.parser.IParser; //导入方法依赖的package包/类
public void encodeMsg() throws DataFormatException {
FhirContext ctx = new FhirContext(Patient.class, Observation.class);
//START SNIPPET: encodeMsg

/**
 * FHIR model types in HAPI are simple POJOs. To create a new
 * one, invoke the default constructor and then
 * start populating values.
 */
Patient patient = new Patient();

// Add an MRN (a patient identifier)
IdentifierDt id = patient.addIdentifier();
id.setSystem("http://example.com/fictitious-mrns");
id.setValue("MRN001");

// Add a name
HumanNameDt name = patient.addName();
name.setUse(NameUseEnum.OFFICIAL);
name.addFamily("Tester");
name.addGiven("John");
name.addGiven("Q");

// We can now use a parser to encode this resource into a string.
String encoded = ctx.newXmlParser().encodeResourceToString(patient);
System.out.println(encoded);
//END SNIPPET: encodeMsg

//START SNIPPET: encodeMsgJson
IParser jsonParser = ctx.newJsonParser();
jsonParser.setPrettyPrint(true);
encoded = jsonParser.encodeResourceToString(patient);
System.out.println(encoded);
//END SNIPPET: encodeMsgJson

		
	}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:38,代码来源:FhirContextIntro.java

示例5: invokeServer

import ca.uhn.fhir.parser.IParser; //导入方法依赖的package包/类
@Override
public void invokeServer(RestfulServer theServer, Request theRequest) throws BaseServerResponseException, IOException {
	Object[] params = createParametersForServerRequest(theRequest, null);

	if (myIdParamIndex != null) {
		params[myIdParamIndex] = theRequest.getId();
	}
	if (myVersionIdParamIndex != null) {
		params[myVersionIdParamIndex] = theRequest.getId();
	}

	TagList resp = (TagList) invokeServerMethod(params);

	for (int i = theServer.getInterceptors().size() - 1; i >= 0; i--) {
		IServerInterceptor next = theServer.getInterceptors().get(i);
		boolean continueProcessing = next.outgoingResponse(theRequest, resp, theRequest.getServletRequest(), theRequest.getServletResponse());
		if (!continueProcessing) {
			return;
		}
	}
	
	EncodingEnum responseEncoding = RestfulServerUtils.determineResponseEncodingWithDefault(theServer, theRequest.getServletRequest());

	HttpServletResponse response = theRequest.getServletResponse();
	response.setContentType(responseEncoding.getResourceContentType());
	response.setStatus(Constants.STATUS_HTTP_200_OK);
	response.setCharacterEncoding(Constants.CHARSETNAME_UTF_8);

	theServer.addHeadersToResponse(response);

	IParser parser = responseEncoding.newParser(getContext());
	parser.setPrettyPrint(RestfulServerUtils.prettyPrintResponse(theServer, theRequest));
	PrintWriter writer = response.getWriter();
	try {
		parser.encodeTagListToWriter(resp, writer);
	} finally {
		writer.close();
	}
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:40,代码来源:GetTagsMethodBinding.java

示例6: encodeContents

import ca.uhn.fhir.parser.IParser; //导入方法依赖的package包/类
private String encodeContents(Boolean thePrettyPrint, EncodingEnum encoding) {
	IParser parser;

	if (encoding == EncodingEnum.JSON) {
		parser = getContext().newJsonParser();
	} else {
		parser = getContext().newXmlParser();
	}

	if (thePrettyPrint != null) {
		parser.setPrettyPrint(thePrettyPrint);
	}

	if (myForceResourceId != null) {
		parser.setEncodeForceResourceId(myForceResourceId);
	}
	
	parser.setOmitResourceId(myOmitResourceId);
	if (myResources != null) {
		IVersionSpecificBundleFactory bundleFactory = getContext().newBundleFactory();
		bundleFactory.initializeBundleFromResourceList("", myResources, "", "", myResources.size(), myBundleType);
		IBaseResource bundle = bundleFactory.getResourceBundle();
		if (bundle != null) {
			return parser.encodeResourceToString(bundle);
		}
		IBaseResource bundleRes = bundleFactory.getResourceBundle();
		return parser.encodeResourceToString(bundleRes);
	} else if (myContents != null) {
		return myContents;
	} else {
		return parser.encodeResourceToString(myResource);
	}
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:34,代码来源:BaseHttpClientInvocationWithContents.java


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