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


Java Buffer.appendString方法代码示例

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


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

示例1: encodeToWire

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
@Override
public void encodeToWire(Buffer buffer, AuthInfo s) {
	// Easiest ways is using JSON object
    JsonObject jsonToEncode = new JsonObject();
    jsonToEncode.put("serverName", s.serverName);
    jsonToEncode.put("sessionToken", s.sessionToken);

    // Encode object to string
    String jsonToStr = jsonToEncode.encode();

    // Length of JSON: is NOT characters count
    int length = jsonToStr.getBytes().length;

    // Write data into given buffer
    buffer.appendInt(length);
    buffer.appendString(jsonToStr);
	
}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:19,代码来源:AuthInfoCodec.java

示例2: setBodyBuffer

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
@Test
public void setBodyBuffer() {
  Buffer bodyBuffer = Buffer.buffer();
  bodyBuffer.appendString("abc");

  requestEx.setBodyBuffer(bodyBuffer);
  Assert.assertSame(bodyBuffer, requestEx.getBodyBuffer());
  Assert.assertArrayEquals("abc".getBytes(), Arrays.copyOf(requestEx.getBodyBytes(), requestEx.getBodyBytesLength()));
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:10,代码来源:TestStandardHttpServletRequestEx.java

示例3: setBodyBuffer

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
@Test
public void setBodyBuffer() {
  Assert.assertNull(responseEx.getBodyBuffer());

  Buffer bodyBuffer = Buffer.buffer();
  bodyBuffer.appendString("abc");
  responseEx.setBodyBuffer(bodyBuffer);
  Assert.assertEquals("abc", responseEx.getBodyBuffer().toString());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:10,代码来源:TestStandardHttpServletResponseEx.java

示例4: getBodyBytes

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
@Test
public void getBodyBytes() {
  Buffer bodyBuffer = Buffer.buffer();
  bodyBuffer.appendString("abc");
  responseEx.setBodyBuffer(bodyBuffer);
  Assert.assertEquals("abc", new String(responseEx.getBodyBytes(), 0, responseEx.getBodyBytesLength()));
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:8,代码来源:TestStandardHttpServletResponseEx.java

示例5: getBodyBytesLength

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
@Test
public void getBodyBytesLength() {
  Buffer bodyBuffer = Buffer.buffer();
  bodyBuffer.appendString("abc");
  responseEx.setBodyBuffer(bodyBuffer);
  Assert.assertEquals(3, responseEx.getBodyBytesLength());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:8,代码来源:TestStandardHttpServletResponseEx.java

示例6: testRegisterSchemaErrorResponse

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
@Test
public void testRegisterSchemaErrorResponse() {
  new MockUp<ServiceRegistryClientImpl>() {
    @Mock
    Handler<RestResponse> syncHandlerEx(CountDownLatch countDownLatch, Holder<ResponseWrapper> holder) {
      return restResponse -> {
        HttpClientResponse response = Mockito.mock(HttpClientResponse.class);
        Mockito.when(response.statusCode()).thenReturn(400);
        Mockito.when(response.statusMessage()).thenReturn("client error");

        Buffer bodyBuffer = Buffer.buffer();
        bodyBuffer.appendString("too big");

        ResponseWrapper responseWrapper = new ResponseWrapper();
        responseWrapper.response = response;
        responseWrapper.bodyBuffer = bodyBuffer;
        holder.value = responseWrapper;
      };
    }
  };
  new MockUp<RestUtils>() {
    @Mock
    void httpDo(RequestContext requestContext, Handler<RestResponse> responseHandler) {
      responseHandler.handle(null);
    }
  };

  new RegisterSchemaTester() {
    void doRun(java.util.List<LoggingEvent> events) {
      oClient.registerSchema("msid", "schemaId", "content");
      Assert.assertEquals(
          "Register schema msid/schemaId failed, statusCode: 400, statusMessage: client error, description: too big.",
          events.get(0).getMessage());
    }
  }.run();
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:37,代码来源:TestServiceRegistryClientImpl.java

示例7: fileBoundaryInfo

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
protected Buffer fileBoundaryInfo(String boundary, String name, Part part) {
  Buffer buffer = Buffer.buffer();
  buffer.appendString("\r\n");
  buffer.appendString("--" + boundary + "\r\n");
  buffer.appendString("Content-Disposition: form-data; name=\"")
      .appendString(name)
      .appendString("\"; filename=\"")
      .appendString(part.getSubmittedFileName() != null ? part.getSubmittedFileName() : "null")
      .appendString("\"\r\n");
  buffer.appendString("Content-Type: ").appendString(part.getContentType()).appendString("\r\n");
  buffer.appendString("Content-Transfer-Encoding: binary\r\n");
  buffer.appendString("\r\n");
  return buffer;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:15,代码来源:RestClientRequestImpl.java

示例8: encodeSyncMessage

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
private Buffer encodeSyncMessage(List<GossipDigest> digests) {
    Buffer buffer = Buffer.buffer();
    JsonArray array = new JsonArray();
    for (GossipDigest e : digests) {
        array.add(Serializer.getInstance().encode(e).toString());
    }
    buffer.appendString(GossipMessageFactory.getInstance().makeMessage(MessageType.SYNC_MESSAGE, array.encode(), getCluster(), getSelf().ipAndPort()).encode());
    return buffer;
}
 
开发者ID:monkeymq,项目名称:jgossip,代码行数:10,代码来源:GossipManager.java

示例9: encode

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
public Buffer encode(Serializable obj) {
    Buffer buffer = Buffer.buffer();
    try {
        buffer.appendString(JsonObject.mapFrom(obj).encode());
    } catch (Exception e) {
        e.printStackTrace();
    }
    return buffer;
}
 
开发者ID:monkeymq,项目名称:jgossip,代码行数:10,代码来源:Serializer.java

示例10: encodeAckMessage

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
public Buffer encodeAckMessage(AckMessage ackMessage) {
    Buffer buffer = Buffer.buffer();
    JsonObject ackJson = JsonObject.mapFrom(ackMessage);
    buffer.appendString(GossipMessageFactory.getInstance().makeMessage(MessageType.ACK_MESSAGE, ackJson.encode(), getCluster(), getSelf().ipAndPort()).encode());
    return buffer;
}
 
开发者ID:monkeymq,项目名称:jgossip,代码行数:7,代码来源:GossipManager.java

示例11: encodeAck2Message

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
public Buffer encodeAck2Message(Ack2Message ack2Message) {
    Buffer buffer = Buffer.buffer();
    JsonObject ack2Json = JsonObject.mapFrom(ack2Message);
    buffer.appendString(GossipMessageFactory.getInstance().makeMessage(MessageType.ACK2_MESSAGE, ack2Json.encode(), getCluster(), getSelf().ipAndPort()).encode());
    return buffer;
}
 
开发者ID:monkeymq,项目名称:jgossip,代码行数:7,代码来源:GossipManager.java

示例12: encodeShutdownMessage

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
private Buffer encodeShutdownMessage() {
    Buffer buffer = Buffer.buffer();
    JsonObject self = JsonObject.mapFrom(getSelf());
    buffer.appendString(GossipMessageFactory.getInstance().makeMessage(MessageType.SHUTDOWN, self.encode(), getCluster(), getSelf().ipAndPort()).encode());
    return buffer;
}
 
开发者ID:monkeymq,项目名称:jgossip,代码行数:7,代码来源:GossipManager.java

示例13: encodeToWire

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
@Override
public void encodeToWire(Buffer buffer, String[] message) {

    String messageString = Json.encode(message);

    int length = messageString.getBytes().length;

    buffer.appendInt(length);
    buffer.appendString(messageString);
}
 
开发者ID:bpark,项目名称:chlorophytum-semantics,代码行数:11,代码来源:StringArrayCodec.java

示例14: encodeToWire

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
@Override
public void encodeToWire(Buffer buffer, PersonName message) {

    String messageString = Json.encode(message);

    int length = messageString.getBytes().length;

    buffer.appendInt(length);
    buffer.appendString(messageString);
}
 
开发者ID:bpark,项目名称:chlorophytum-semantics,代码行数:11,代码来源:PersonNameCodec.java

示例15: encodeToWire

import io.vertx.core.buffer.Buffer; //导入方法依赖的package包/类
@Override
public void encodeToWire(Buffer buffer, ChatMessage chatMessage) {

    String messageString = Json.encode(chatMessage);

    int length = messageString.getBytes().length;

    buffer.appendInt(length);
    buffer.appendString(messageString);
}
 
开发者ID:bpark,项目名称:chlorophytum-semantics,代码行数:11,代码来源:ChatMessageCodec.java


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