本文整理汇总了Java中org.vertx.java.core.buffer.Buffer.getByte方法的典型用法代码示例。如果您正苦于以下问题:Java Buffer.getByte方法的具体用法?Java Buffer.getByte怎么用?Java Buffer.getByte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.vertx.java.core.buffer.Buffer
的用法示例。
在下文中一共展示了Buffer.getByte方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read_binary_body
import org.vertx.java.core.buffer.Buffer; //导入方法依赖的package包/类
private Action<StompFrame> read_binary_body(final StompFrame frame, final int contentLength) {
return new Action<StompFrame>() {
public StompFrame apply() throws IOException {
Buffer content = readBytes(contentLength + 1);
if (content != null) {
if (content.getByte(contentLength) != 0) {
throw new IOException("Expected null terminator after " + contentLength + " content bytes");
}
frame.content(chomp(content));
nextDecodeAction = read_action;
return frame;
} else {
return null;
}
}
};
}
示例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;
}
}
示例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()]);
}
示例4: 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();
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}
示例8: indexOf
import org.vertx.java.core.buffer.Buffer; //导入方法依赖的package包/类
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;
}
示例9: 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;
}
示例10: dispatch
import org.vertx.java.core.buffer.Buffer; //导入方法依赖的package包/类
/** Called from the Transaction to parse messages from the back-end */
void dispatch(Buffer buffer, Transaction trx) {
switch (buffer.getByte(0)) {
case 'E':
errorResponse.setBuffer(buffer);
trx.on(errorResponse);
break;
case 'R':
authenticationRequest.setBuffer(buffer);
trx.on(authenticationRequest);
break;
case 'S':
parameterStatus.setBuffer(buffer);
trx.on(parameterStatus);
break;
case 'K':
backendKeyData.setBuffer(buffer);
trx.on(backendKeyData);
break;
case 'Z':
readyForQuery.setBuffer(buffer);
trx.on(readyForQuery);
break;
case 'C':
commandComplete.setBuffer(buffer);
trx.on(commandComplete);
break;
case 'T':
rowDescription.setBuffer(buffer);
trx.on(rowDescription);
break;
case 'D':
dataRow.setBuffer(buffer);
trx.on(dataRow);
break;
case '1':
parseComplete.setBuffer(buffer);
trx.on(parseComplete);
break;
case'I':
emptyQueryResponse.setBuffer(buffer);
trx.on(emptyQueryResponse);
break;
default:
log.warning("Unknown message" + (char) buffer.getByte(0));
}
}