Java JsonFormat.merge方法代码示例

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


Java JsonFormat.merge方法代码示例

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

示例1: buildOafObject

import com.googlecode.protobuf.format.JsonFormat; //导入方法依赖的package包/类
/**
 * Builds {@link Oaf} object from JSON body represetation and updates.
 * 
 * @param bodyRecords body records with optional updates
 * @return {@link Oaf} object built from JSON representation or null when body was undefined
 * @throws UnsupportedEncodingException
 * @throws ParseException 
 */
private Oaf buildOafObject(List<QualifiedOafJsonRecord> bodyRecords) throws UnsupportedEncodingException, ParseException {
    if (bodyRecords !=null) {
        OafBodyWithOrderedUpdates bodyWithUpdates = new OafBodyWithOrderedUpdates(bodyRecords);
        if (bodyWithUpdates.getBody() != null) {
            Oaf.Builder oafBuilder = Oaf.newBuilder();
            JsonFormat.merge(bodyWithUpdates.getBody(), oafBuilder);
            if (this.mergeBodyWithUpdates) {
                for (String oafUpdate : bodyWithUpdates.getOrderedUpdates()) {
                    JsonFormat.merge(oafUpdate, oafBuilder);
                }
            }
            return oafBuilder.build();
        }    
    }
    return null;
} 
开发者ID:openaire,项目名称:iis,代码行数:25,代码来源:ImportInformationSpaceReducer.java

示例2: readInternal

import com.googlecode.protobuf.format.JsonFormat; //导入方法依赖的package包/类
@Override
protected Message readInternal(Class<? extends Message> clazz, HttpInputMessage inputMessage)
		throws IOException, HttpMessageNotReadableException {

	MediaType contentType = inputMessage.getHeaders().getContentType();
	contentType = (contentType != null ? contentType : PROTOBUF);

	Charset charset = getCharset(inputMessage.getHeaders());
	InputStreamReader reader = new InputStreamReader(inputMessage.getBody(), charset);

	try {
		Message.Builder builder = getMessageBuilder(clazz);

		if (MediaType.APPLICATION_JSON.isCompatibleWith(contentType)) {
			JsonFormat.merge(reader, this.extensionRegistry, builder);
		}
		else if (MediaType.TEXT_PLAIN.isCompatibleWith(contentType)) {
			TextFormat.merge(reader, this.extensionRegistry, builder);
		}
		else if (MediaType.APPLICATION_XML.isCompatibleWith(contentType)) {
			XmlFormat.merge(reader, this.extensionRegistry, builder);
		}
		else {
			builder.mergeFrom(inputMessage.getBody(), this.extensionRegistry);
		}
		return builder.build();
	}
	catch (Exception e) {
		throw new HttpMessageNotReadableException("Could not read Protobuf message: " + e.getMessage(), e);
	}
} 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:32,代码来源:ProtobufHttpMessageConverter.java

示例3: readList

import com.googlecode.protobuf.format.JsonFormat; //导入方法依赖的package包/类
/**
 * Reads a collection of FileTrackingStatus.<br/>
 * If plain text is a list of line separated plain text.<br/>
 * If json this should be a json array.<br/>
 * 
 * @param format
 * @param reader
 * @return
 * @throws JsonParseException
 * @throws JsonMappingException
 * @throws IOException
 */
@SuppressWarnings("unchecked")
public Collection<FileStatus.FileTrackingStatus> readList(FORMAT format,
		Reader reader) throws JsonParseException, JsonMappingException,
		IOException {

	Collection<FileStatus.FileTrackingStatus> coll = null;

	if (format.equals(FORMAT.JSON)) {
		Collection<String> strcoll = (Collection<String>) mapper.readValue(
				reader, new TypeReference<Collection<String>>() {
				});
		coll = new ArrayList<FileStatus.FileTrackingStatus>();


		
		for (String str : strcoll) {
			Builder builder = FileStatus.FileTrackingStatus.newBuilder();
			JsonFormat.merge(str, builder);
			coll.add(builder.build());
		}

	} else {
		BufferedReader buff = new BufferedReader(reader);
		coll = new ArrayList<FileStatus.FileTrackingStatus>();

		String line = null;
		while ((line = buff.readLine()) != null) {
			coll.add(read(FORMAT.TXT, line));
		}

	}

	return coll;
} 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:47,代码来源:FileTrackingStatusFormatter.java

示例4: decode

import com.googlecode.protobuf.format.JsonFormat; //导入方法依赖的package包/类
@Override
public Message decode(byte[] buffer, Message.Builder builder) throws InvalidProtocolBufferException, ParseException {
	if (builder == null)
		throw new IllegalArgumentException("Message builder not specified");
	if (buffer == null)
		return null;
	
	String json = new String(buffer, charset);
	JsonFormat.merge(json, builder);
	return builder.build();
} 
开发者ID:ugcs,项目名称:ugcs-java-sdk,代码行数:12,代码来源:ProtoJsonDecoder.java

示例5: parse

import com.googlecode.protobuf.format.JsonFormat; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <T extends Message> T parse(T template) throws Exception {
    Builder builder = template.newBuilderForType();
    JsonFormat.merge(json, builder);
    return (T) builder.build();
} 
开发者ID:rhlabs,项目名称:louie,代码行数:8,代码来源:Data.java

示例6: readStudy

import com.googlecode.protobuf.format.JsonFormat; //导入方法依赖的package包/类
private Pair<BaseStudy, List<Attachment>> readStudy(InputStream inputStream) throws IOException {
  Mica.StudyDto.Builder builder = Mica.StudyDto.newBuilder();
  Readable input = new InputStreamReader(inputStream, Charsets.UTF_8);
  ExtensionRegistry extensionRegistry = ExtensionRegistry.newInstance();
  extensionRegistry .add(Mica.CollectionStudyDto.type);
  extensionRegistry .add(Mica.HarmonizationStudyDto.type);
  JsonFormat.merge(input, extensionRegistry, builder);
  List<Attachment> atts = extractAttachments(builder);
  BaseStudy study = dtos.fromDto( builder);
  return Pair.create(study, atts);
} 
开发者ID:obiba,项目名称:mica2,代码行数:12,代码来源:StudyPackageImportServiceImpl.java

示例7: fromJson

import com.googlecode.protobuf.format.JsonFormat; //导入方法依赖的package包/类
public static Optional<Message> fromJson(final Message prototype, final String json) {
	final Message.Builder builder = prototype.newBuilderForType();
	try {
		JsonFormat.merge(json, builder);
		return Optional.of(builder.build());
	} catch (final JsonFormat.ParseException e) {
		LOGGER.error("Could not create protobuf message from json structure.", e);
	}
	return Optional.absent();
} 
开发者ID:ngerakines,项目名称:elasticservices,代码行数:11,代码来源:MessageUtils.java

示例8: decodeTargetValue

import com.googlecode.protobuf.format.JsonFormat; //导入方法依赖的package包/类
private byte[] decodeTargetValue(final String json) throws Exception {
	OafProtos.Oaf.Builder oaf = OafProtos.Oaf.newBuilder();
	JsonFormat.merge(json, oaf);
	return oaf.build().toByteArray();
} 
开发者ID:openaire,项目名称:iis,代码行数:6,代码来源:FieldAccessorTest.java

示例9: merge

import com.googlecode.protobuf.format.JsonFormat; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <T extends Builder> T merge(T builder) throws Exception {
    JsonFormat.merge(json, builder);
    return builder;
} 
开发者ID:rhlabs,项目名称:louie,代码行数:7,代码来源:Data.java

示例10: readNetwork

import com.googlecode.protobuf.format.JsonFormat; //导入方法依赖的package包/类
private Network readNetwork(InputStream inputStream) throws IOException {
  Mica.NetworkDto.Builder builder = Mica.NetworkDto.newBuilder();
  Readable input = new InputStreamReader(inputStream, Charsets.UTF_8);
  JsonFormat.merge(input, builder);
  return dtos.fromDto(builder);
} 
开发者ID:obiba,项目名称:mica2,代码行数:7,代码来源:StudyPackageImportServiceImpl.java

示例11: readDataset

import com.googlecode.protobuf.format.JsonFormat; //导入方法依赖的package包/类
private Dataset readDataset(InputStream inputStream) throws IOException {
  Mica.DatasetDto.Builder builder = Mica.DatasetDto.newBuilder();
  Readable input = new InputStreamReader(inputStream, Charsets.UTF_8);
  JsonFormat.merge(input, builder);
  return dtos.fromDto(builder);
} 
开发者ID:obiba,项目名称:mica2,代码行数:7,代码来源:StudyPackageImportServiceImpl.java

示例12: buildOaf

import com.googlecode.protobuf.format.JsonFormat; //导入方法依赖的package包/类
/**
 * Builds {@link Oaf} object from JSON representation.
 * 
 * @param input JSON representation of {@link Oaf} object
 * @throws ParseException
 */
public static Oaf buildOaf(String input) throws ParseException {
    Oaf.Builder oafBuilder = Oaf.newBuilder();
    JsonFormat.merge(input, oafBuilder);
    return oafBuilder.build();
} 
开发者ID:openaire,项目名称:iis,代码行数:12,代码来源:OafHelper.java

本文标签属性:

示例:示例是什么意思

代码:代码生成器

java:java游戏

上一篇:C++ HID_USB_DEVICE函数代码示例
下一篇:C++ range::TopLeft方法代码示例

为您推荐