本文整理了Java中org.vertx.java.core.buffer.Buffer.length()
方法的一些代码示例,展示了Buffer.length()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.length()
方法的具体详情如下:
包路径:org.vertx.java.core.buffer.Buffer
类名称:Buffer
方法名:length
[英]Returns the length of the buffer, measured in bytes. All positions are indexed from zero.
[中]
代码示例来源:origin: io.fabric8/gateway-core
@Override
public boolean matches(Buffer header) {
if (header.length() < PROTOCOL_MAGIC.length()) {
return false;
} else {
return startsWith(header ,PROTOCOL_MAGIC);
}
}
代码示例来源:origin: io.fabric8.jube.images.fabric8/fabric8-mq
static public int indexOf(Buffer self, int start, int end, Buffer needle) {
int max = Math.min(end, self.length() - needle.length());
for (int i = start; i <= max; i++) {
if (matches(self, i, needle)) {
return i;
}
}
return -1;
}
代码示例来源:origin: io.fabric8/gateway-core
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);
}
代码示例来源:origin: io.fabric8.jube.images.fabric8/fabric8-mq
static public int indexOf(Buffer self, int start, int end, byte value) {
int max = Math.min(end, self.length());
for (; start < end; start++) {
if (self.getByte(start) == value) {
return start;
}
}
return -1;
}
代码示例来源:origin: io.fabric8.jube.images.fabric8/fabric8-mq
protected Buffer peekBytes(int length) {
readEnd = readStart + length;
if (buff.length() < readEnd) {
return null;
} else {
return buff.getBuffer(readStart, readEnd);
}
}
代码示例来源:origin: io.fabric8.ipaas.apps/fabric8mq
protected Buffer readBytes(int length) {
readEnd = readStart + length;
if (buff.length() < readEnd) {
return null;
} else {
bytesDecoded += readEnd - readStart;
int offset = readStart;
readStart = readEnd;
return buff.getBuffer(offset, readEnd);
}
}
代码示例来源:origin: io.fabric8/gateway-core
protected Buffer readBytes(int length) {
readEnd = readStart + length;
if (buff.length() < readEnd) {
return null;
} else {
bytesDecoded += readEnd-readStart;
int offset = readStart;
readStart = readEnd;
return buff.getBuffer(offset, readEnd);
}
}
代码示例来源:origin: io.fabric8.jube.images.fabric8/fabric8-mq
protected Buffer readBytes(int length) {
readEnd = readStart + length;
if (buff.length() < readEnd) {
return null;
} else {
bytesDecoded += readEnd - readStart;
int offset = readStart;
readStart = readEnd;
return buff.getBuffer(offset, readEnd);
}
}
代码示例来源:origin: io.fabric8.ipaas.apps/fabric8mq
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;
}
代码示例来源:origin: io.fabric8.jube.images.fabric8/fabric8-mq
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);
}
代码示例来源:origin: io.fabric8.jube.images.fabric8/fabric8-mq
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);
}
代码示例来源:origin: io.fabric8.jube.images.fabric8/fabric8-mq
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);
}
代码示例来源:origin: io.fabric8.jube.images.fabric8/fabric8-mq
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;
}
代码示例来源:origin: io.fabric8/gateway-core
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;
}
代码示例来源:origin: org.vert-x/vertx-core
public void end(Buffer chunk) {
if (!chunked && !contentLengthSet()) {
headers().put(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(chunk.length()));
}
write(chunk);
end();
}
代码示例来源:origin: org.vert-x/vertx-core
/**
* Sets the bytes at position {@code pos} in the Buffer to the bytes represented by the {@code Buffer b}.<p>
* The buffer will expand as necessary to accomodate any value written.
*/
public Buffer setBuffer(int pos, Buffer b) {
ensureWritable(pos, b.length());
buffer.setBytes(pos, b.getChannelBuffer());
return this;
}
代码示例来源:origin: org.vert-x/vertx-core
protected void writeBody(Buffer buff) {
if (body == null) {
buff.appendByte((byte)0);
} else {
buff.appendByte((byte)1);
buff.appendInt(body.length());
buff.appendBuffer(body);
}
}
代码示例来源:origin: org.vert-x/vertx-core
public void handle(Buffer buffer) {
writeStream.writeBuffer(buffer);
pumped += buffer.length();
if (writeStream.writeQueueFull()) {
readStream.pause();
writeStream.drainHandler(drainHandler);
}
}
};
代码示例来源:origin: com.englishtown/vertx-mod-jersey
/**
* {@inheritDoc}
*/
@Override
public void flush() throws IOException {
checkState();
// Only flush to underlying very.x response if the content-length has been set
if (buffer.length() > 0 && response.headers().contains(HttpHeaders.CONTENT_LENGTH)) {
response.write(buffer);
buffer = new Buffer();
}
}
代码示例来源:origin: io.fabric8.jube.images.fabric8/fabric8-mq
private void process(Buffer event) {
if (!isStopped() && !isStopping()) {
try {
int length = event.length();
org.fusesource.hawtbuf.DataByteArrayInputStream dataIn = new org.fusesource.hawtbuf.DataByteArrayInputStream(event.getBytes());
codec.parse(dataIn, length);
} catch (Throwable e) {
transport.handleException(e);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!