當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。