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


Java Buffer.length方法代码示例

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


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

示例1: decodeHeader

import org.vertx.java.core.buffer.Buffer; //导入方法依赖的package包/类
public static String decodeHeader(Buffer value) {
    if (value == null)
        return null;

    Buffer rc = new Buffer(value.length());
    int pos = 0;
    int max = value.length();
    while (pos < max) {
        if (startsWith(value, pos, ESCAPE_ESCAPE_SEQ.toBuffer())) {
            rc.appendByte(ESCAPE_BYTE);
            pos += 2;
        } else if (startsWith(value, pos, COLON_ESCAPE_SEQ.toBuffer())) {
            rc.appendByte(COLON_BYTE);
            pos += 2;
        } else if (startsWith(value, pos, NEWLINE_ESCAPE_SEQ.toBuffer())) {
            rc.appendByte(NEWLINE_BYTE);
            pos += 2;
        } else {
            rc.appendByte(value.getByte(pos));
            pos += 1;
        }
    }
    return rc.toString();
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:25,代码来源:StompFrame.java

示例2: matches

import org.vertx.java.core.buffer.Buffer; //导入方法依赖的package包/类
@Override
public boolean matches(Buffer buffer) {
    if( buffer.length() >= 6 ) {
      if( buffer.getByte(0) == 0x16 ) { // content type
        return (buffer.getByte(5) == 1) && // Client Hello
        ( (buffer.getByte(1) == 2) // SSLv2
          || (
            buffer.getByte(1)== 3 &&
            isSSLVerions(buffer.getByte(2))
          )
        );
      } else {
        // We have variable header offset..
        return ((buffer.getByte(0) & 0xC0) == 0x80) && // The rest of byte 0 and 1 are holds the record length.
          (buffer.getByte(2) == 1) && // Client Hello
          ( (buffer.getByte(3) == 2) // SSLv2
            || (
              (buffer.getByte(3) == 3) && // SSLv3 or TLS
              isSSLVerions(buffer.getByte(4))
            )
          );
      }
    } else {
      return false;
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:27,代码来源:SslProtocol.java

示例3: split

import org.vertx.java.core.buffer.Buffer; //导入方法依赖的package包/类
static final public Buffer[] split(Buffer self, byte separator) {
    ArrayList<Buffer> rc = new ArrayList<Buffer>();
    int pos = 0;
    int nextStart = pos;
    int end = self.length();
    while( pos < end ) {
        if( self.getByte(pos)==separator ) {
            if( nextStart < pos ) {
                rc.add(self.getBuffer(nextStart, pos));
            }
            nextStart = pos+1;
        }
        pos++;
    }
    if( nextStart < pos ) {
        rc.add(self.getBuffer(nextStart, pos));
    }
    return rc.toArray(new Buffer[rc.size()]);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:20,代码来源:BufferSupport.java

示例4: flushBuffer

import org.vertx.java.core.buffer.Buffer; //导入方法依赖的package包/类
private int flushBuffer(final Buffer buffer, final NetSocket socket) {
    // Write the serialized data
    try {
        final int bufferLength = buffer.length();
        // TODO(vkoskela): Add conditional logging [AINT-552]
        //LOGGER.trace(String.format("Writing buffer to socket; length=%s buffer=%s", bufferLength, buffer.toString("utf-8")));
        LOGGER.debug()
                .setMessage("Writing buffer to socket")
                .addData("sink", getName())
                .addData("length", bufferLength)
                .log();
        socket.write(buffer);
        return bufferLength;
    // CHECKSTYLE.OFF: IllegalCatch - Vertx might not log
    } catch (final Exception e) {
    // CHECKSTYLE.ON: IllegalCatch
        LOGGER.error()
                .setMessage("Error writing AggregatedData data to socket")
                .addData("sink", getName())
                .addData("buffer", buffer)
                .setThrowable(e)
                .log();
        throw e;
    }
}
 
开发者ID:ArpNetworking,项目名称:metrics-aggregator-daemon,代码行数:26,代码来源:VertxSink.java

示例5: PersistantBuffer

import org.vertx.java.core.buffer.Buffer; //导入方法依赖的package包/类
public PersistantBuffer(Vertx vertx, Buffer buffer, String id, String destination) {
	this.buffer = buffer;
	this.vertx = vertx;
	this.filePath = destination + File.separator + PersistantBuffer.class.getSimpleName() + "-" + id;
	this.length = buffer.length();
	if (buffer.length() > persistanceThreshold) {
		persist(new Handler<AsyncResult<Void>>() {
			@Override
			public void handle(AsyncResult<Void> ar) {
				if (ar.failed()) {
					log.error("Error persisting buffer", ar.cause());
				}
			}
		});
	}
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:17,代码来源:PersistantBuffer.java

示例6: debugMessage

import org.vertx.java.core.buffer.Buffer; //导入方法依赖的package包/类
private String debugMessage(Buffer buffer) {
	StringBuilder sb = new StringBuilder();
	sb.append("(" + (char) buffer.getByte(0) + ") ");
	sb.append("#" + buffer.getInt(1) + ' ');
	for (int i = 5, len = buffer.length(); i < len; i++) {
		byte b = buffer.getByte(i);
		if (b < 32) {
			sb.append(Byte.toString(b) + " ");
		} else if (b > 128) {
			sb.append('?');
		} else {
			sb.append((char) b);
		}
	}
	sb.append("\n Len:" + buffer.length() + "\n");
	return sb.toString();
}
 
开发者ID:monoid-us,项目名称:vertx-postgresql,代码行数:18,代码来源:Transaction.java

示例7: test

import org.vertx.java.core.buffer.Buffer; //导入方法依赖的package包/类
@Test
public void test() {
	Buffer buffer = new Buffer();
	buffer.appendByte((byte)'E');
	int start = buffer.length();
	buffer.appendInt(-1);
	buffer.appendByte((byte)'S'); // Severity field type
	buffer.appendString("ERROR").appendByte(EOS);
	buffer.appendByte((byte)'M'); // human message
	buffer.appendString("Unit testing is good for you").appendByte(EOS);
	buffer.appendByte(EOS); // last field
	buffer.setInt(start, buffer.length() - start); // set size
	
	ErrorResponse err = new ErrorResponse();
	err.setBuffer(buffer);
	System.out.println(err.toString());
	assertTrue(err.toString().contains("good"));
}
 
开发者ID:monoid-us,项目名称:vertx-postgresql,代码行数:19,代码来源:ErrorResponseTest.java

示例8: apply

import org.vertx.java.core.buffer.Buffer; //导入方法依赖的package包/类
public StompFrame apply() throws IOException {
    Buffer line = readUntil((byte) '\n', StompProtocol.maxCommandLength, "The maximum command length was exceeded");
    if (line != null) {
        Buffer action = chomp(line);
        if (trim) {
            action = trim(action);
        }
        if (action.length() > 0) {
            StompFrame frame = new StompFrame(Ascii.ascii(action));
            nextDecodeAction = read_headers(frame);
            return nextDecodeAction.apply();
        }
    }
    return null;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:16,代码来源:StompProtocolDecoder.java

示例9: decode

import org.vertx.java.core.buffer.Buffer; //导入方法依赖的package包/类
static public String decode(Buffer value) {
    int size = value.length();
    char rc[] = new char[size];
    for (int i = 0; i < size; i++) {
        rc[i] = (char) (value.getByte(i) & 0xFF);
    }
    return new String(rc);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:9,代码来源:Ascii.java

示例10: matches

import org.vertx.java.core.buffer.Buffer; //导入方法依赖的package包/类
@Override
public boolean matches(Buffer header) {
  if (header.length() < PROTOCOL_MAGIC.length()) {
    return false;
  } else {
    return startsWith(header ,PROTOCOL_MAGIC);
  }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:9,代码来源:AmqpProtocol.java

示例11: trimFront

import org.vertx.java.core.buffer.Buffer; //导入方法依赖的package包/类
static public Buffer trimFront(Buffer self) {
    int length = self.length();
    int pos = 0;
    while ((pos < length) && (self.getByte(pos) <= ' ')) {
        pos++;
    }
    return (pos == 0) ? self : self.getBuffer(pos, length);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:9,代码来源:BufferSupport.java

示例12: trimEnd

import org.vertx.java.core.buffer.Buffer; //导入方法依赖的package包/类
static public Buffer trimEnd(Buffer self) {
    int length = self.length();
    int pos = length;
    while ( pos > 0 && (self.getByte(pos-1) <= ' ')) {
        pos--;
    }
    return (pos == length-1) ? self : self.getBuffer(0, pos);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:9,代码来源:BufferSupport.java

示例13: matches

import org.vertx.java.core.buffer.Buffer; //导入方法依赖的package包/类
static public boolean matches(Buffer self, int pos, Buffer needle) {
    int needleLength = needle.length();
    for (int i = 0; i < needleLength; i++) {
        if( self.getByte(pos+i) != needle.getByte(i) ) {
            return false;
        }
    }
    return true;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:10,代码来源:BufferSupport.java

示例14: matches

import org.vertx.java.core.buffer.Buffer; //导入方法依赖的package包/类
@Override
public boolean matches(Buffer header) {
    if (header.length() < 10) {
      return false;
    } else {
      return BufferSupport.startsWith(header, HEAD_MAGIC) && (
          BufferSupport.indexOf(header, 2, MQTT31_TAIL_MAGIC)< 6
          ||
          BufferSupport.indexOf(header, 2, MQTT311_TAIL_MAGIC) < 6
      );
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:13,代码来源:MqttProtocol.java

示例15: handle

import org.vertx.java.core.buffer.Buffer; //导入方法依赖的package包/类
@Override
public void handle(Buffer buffer) {
  writeStream.write(env, env.wrapJava(buffer.toString()), null);
  pumped += buffer.length();
  if (writeStream.writeQueueFull(env).toBoolean()) {
    readStream.pause(env);
    writeStream.drainHandler(env, drainHandlerValue);
  }
}
 
开发者ID:vert-x,项目名称:mod-lang-php,代码行数:10,代码来源:Pump.java


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