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


Java TextFormat.merge方法代码示例

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


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

示例1: get

import com.google.protobuf.TextFormat; //导入方法依赖的package包/类
synchronized long get() throws IOException {
  try {
    currentStat = zkc.exists(path, false);
    if (currentStat == null) {
      return 0;
    } else {

      byte[] bytes = zkc.getData(path, false, currentStat);

      MaxTxIdProto.Builder builder = MaxTxIdProto.newBuilder();
      TextFormat.merge(new String(bytes, UTF_8), builder);
      if (!builder.isInitialized()) {
        throw new IOException("Invalid/Incomplete data in znode");
      }

      return builder.build().getTxId();
    }
  } catch (KeeperException e) {
    throw new IOException("Error reading the max tx id from zk", e);
  } catch (InterruptedException ie) {
    throw new IOException("Interrupted while reading thr max tx id", ie);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:MaxTxId.java

示例2: parseMessage

import com.google.protobuf.TextFormat; //导入方法依赖的package包/类
public ApplicationLog parseMessage(String messageString) throws InvalidProtocolBufferException, TextFormat
        .ParseException {
    LogMessages.Message.Builder builder = LogMessages.Message.newBuilder();
    TextFormat.merge(messageString, builder);
    LogMessages.Message message = builder.build();

    return createApplicationLog(message);
}
 
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:9,代码来源:LoggregatorMessageParser.java

示例3: read

import com.google.protobuf.TextFormat; //导入方法依赖的package包/类
static EditLogLedgerMetadata read(ZooKeeper zkc, String path)
    throws IOException, KeeperException.NoNodeException  {
  try {
    byte[] data = zkc.getData(path, false, null);

    EditLogLedgerProto.Builder builder = EditLogLedgerProto.newBuilder();
    if (LOG.isDebugEnabled()) {
      LOG.debug("Reading " + path + " data: " + new String(data, UTF_8));
    }
    TextFormat.merge(new String(data, UTF_8), builder);
    if (!builder.isInitialized()) {
      throw new IOException("Invalid/Incomplete data in znode");
    }
    EditLogLedgerProto ledger = builder.build();

    int dataLayoutVersion = ledger.getDataLayoutVersion();
    long ledgerId = ledger.getLedgerId();
    long firstTxId = ledger.getFirstTxId();
    if (ledger.hasLastTxId()) {
      long lastTxId = ledger.getLastTxId();
      return new EditLogLedgerMetadata(path, dataLayoutVersion,
                                       ledgerId, firstTxId, lastTxId);
    } else {
      return new EditLogLedgerMetadata(path, dataLayoutVersion,
                                       ledgerId, firstTxId);
    }
  } catch(KeeperException.NoNodeException nne) {
    throw nne;
  } catch(KeeperException ke) {
    throw new IOException("Error reading from zookeeper", ke);
  } catch (InterruptedException ie) {
    throw new IOException("Interrupted reading from zookeeper", ie);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:EditLogLedgerMetadata.java

示例4: toBuildFarmServerConfig

import com.google.protobuf.TextFormat; //导入方法依赖的package包/类
private static BuildFarmServerConfig toBuildFarmServerConfig(InputStream inputStream, BuildFarmServerOptions options) throws IOException {
  BuildFarmServerConfig.Builder builder = BuildFarmServerConfig.newBuilder();
  String data = new String(Encoding.convertFromLatin1(ByteStreams.toByteArray(inputStream)));
  TextFormat.merge(data, builder);
  if (options.port > 0) {
      builder.setPort(options.port);
  }
  return builder.build();
}
 
开发者ID:bazelbuild,项目名称:bazel-buildfarm,代码行数:10,代码来源:BuildFarmServer.java

示例5: toWorkerConfig

import com.google.protobuf.TextFormat; //导入方法依赖的package包/类
private static WorkerConfig toWorkerConfig(InputStream inputStream, WorkerOptions options) throws IOException {
  WorkerConfig.Builder builder = WorkerConfig.newBuilder();
  String data = new String(Encoding.convertFromLatin1(ByteStreams.toByteArray(inputStream)));
  TextFormat.merge(data, builder);
  if (!Strings.isNullOrEmpty(options.root)) {
    builder.setRoot(options.root);
  }

  if (!Strings.isNullOrEmpty(options.casCacheDirectory)) {
    builder.setCasCacheDirectory(options.casCacheDirectory);
  }
  return builder.build();
}
 
开发者ID:bazelbuild,项目名称:bazel-buildfarm,代码行数:14,代码来源:Worker.java

示例6: run

import com.google.protobuf.TextFormat; //导入方法依赖的package包/类
@Override
public void run()
{
  try
  {
    URL url = new URL(urlStr);
    HttpURLConnection myURLConnection = (HttpURLConnection)url.openConnection();
    if (headers != null && headers.length > 0) 
    {
      for (int i = 0; i < headers.length; i++)
      {
        String[] nameValue = headers[i].split(":");
        myURLConnection.setRequestProperty (nameValue[0], nameValue[1]);
      }
    }
    
    //myURLConnection.setRequestProperty ("Authorization", basicAuth);
    //String userCredentials = "username:password";
    //String basicAuth = "Basic " + new String(new Base64().encode(userCredentials.getBytes()));
    //myURLConnection.setRequestProperty ("Authorization", basicAuth);
    //myURLConnection.setRequestMethod("POST");
    //myURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    //myURLConnection.setRequestProperty("Content-Length", "" + postData.getBytes().length);
    //myURLConnection.setRequestProperty("Content-Language", "en-US");
    //myURLConnection.setUseCaches(false);
    //myURLConnection.setDoInput(true);
    //myURLConnection.setDoOutput(true);  
    
    FeedMessage feed;
    if (isTextFormat == true)
    {
      InputStream inputStream = myURLConnection.getInputStream();
      InputStreamReader reader = new InputStreamReader(inputStream);
      FeedMessage.Builder myProtoBuilder = FeedMessage.newBuilder();
      TextFormat.merge(reader,  myProtoBuilder);
      feed = myProtoBuilder.build();
    }
    else {
      feed = FeedMessage.parseFrom(myURLConnection.getInputStream());          
      //feed = FeedMessage.parseFrom(url.openStream());
    }
    long headerTimestamp = feed.getHeader().getTimestamp();
    for (FeedEntity entity : feed.getEntityList())
    {
      if (entity.hasVehicle())
      {
        getVehiclesAndSendGeoEvents(entity, headerTimestamp);
      }

      if (entity.hasAlert())
      {
        getAlertsAndSendGeoEvents(entity, headerTimestamp);
      }

      if (entity.hasTripUpdate())
      {
        getTripUpdatesAndSendGeoEvents(entity, headerTimestamp);
      }
    } // for
  }
  catch (IOException e)
  {
    LOGGER.error(e.getMessage());
  }
}
 
开发者ID:Esri,项目名称:gtfsrealtime-for-geoevent,代码行数:66,代码来源:GtfsRealtimeInboundAdapter.java


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