本文整理了Java中org.fusesource.hawtbuf.Buffer
类的一些代码示例,展示了Buffer
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer
类的具体详情如下:
包路径:org.fusesource.hawtbuf.Buffer
类名称:Buffer
暂无
代码示例来源:origin: fusesource/mqtt-client
static private String hex(SocketAddress address) {
if( address instanceof InetSocketAddress ) {
InetSocketAddress isa = (InetSocketAddress)address;
return HexSupport.toHexFromBuffer(new Buffer(isa.getAddress().getAddress()))+Integer.toHexString(isa.getPort());
}
return "";
}
代码示例来源:origin: fusesource/mqtt-client
public byte[] getPayload() {
return payload.toByteArray();
}
代码示例来源:origin: fusesource/mqtt-client
public void onPublish(UTF8Buffer topic, final Buffer payload, final Callback<Callback<Void>> onComplete) {
getDispatchQueue().assertExecuting();
receiveBufferRemaining -= payload.length();
if( !receiveBufferFull && receiveBufferRemaining <=0 ) {
receiveBufferFull = true;
suspend();
}
deliverMessage(new Message(getDispatchQueue(), topic, payload, new Callback<Callback<Void>>() {
public void onSuccess(Callback<Void> value) {
processed();
onComplete.onSuccess(value);
}
public void onFailure(Throwable value) {
processed();
onComplete.onFailure(value);
}
private void processed() {
getDispatchQueue().assertExecuting();
receiveBufferRemaining += payload.length();
if( receiveBufferFull && receiveBufferRemaining >0 ) {
receiveBufferFull = false;
resume();
}
}
}));
}
代码示例来源:origin: fusesource/mqtt-client
public void publish(final String topic, final byte[] payload, final QoS qos, final boolean retain) throws Exception {
publish(utf8(topic), new Buffer(payload), qos, retain);
}
代码示例来源:origin: org.apache.activemq/activemq-all
public Buffer decode(DataInput dataIn) throws IOException {
byte[] data = new byte[size];
dataIn.readFully(data);
return new Buffer(data);
}
代码示例来源:origin: org.fusesource.hawtbuf/hawtbuf
/**
* reset the <code>StoreByteArrayInputStream</code> to use an new
* Buffer
*
* @param buffer
*/
public void restart(Buffer buffer) {
this.buf = buffer.getData();
this.offset = buffer.getOffset();
this.pos = this.offset;
this.length = buffer.getLength();
}
代码示例来源:origin: org.apache.activemq/activemq-all
final public Buffer compact() {
if (length != data.length) {
return new Buffer(toByteArray());
}
return this;
}
代码示例来源:origin: org.apache.activemq/activemq-console
public void writeExternal(java.io.DataOutput out) throws java.io.IOException {
out.writeLong(bean.f_key);
if( bean.f_bindingKind!=null ) {
out.writeInt(bean.f_bindingKind.getLength());
out.write(bean.f_bindingKind.getData(), bean.f_bindingKind.getOffset(), bean.f_bindingKind.getLength());
} else {
out.writeInt(-1);
}
if( bean.f_bindingData!=null ) {
out.writeInt(bean.f_bindingData.getLength());
out.write(bean.f_bindingData.getData(), bean.f_bindingData.getOffset(), bean.f_bindingData.getLength());
} else {
out.writeInt(-1);
}
}
代码示例来源:origin: org.fusesource.hawtdb/hawtdb
public void readHeader() {
buffer = paged.slice(SliceType.READ, page, 1);
Buffer m = new Buffer(magic.length);
buffer.get(m.data);
if( !magic.equals(m) ) {
throw new IOPagingException("Invalid extent read request. The requested page was not an extent: "+page);
}
IntBuffer ib = buffer.asIntBuffer();
length = ib.get();
next = ib.get();
}
代码示例来源:origin: org.apache.activemq/activemq-all
public void setBuffer(Buffer value, boolean validate) {
if (validate && !value.startsWith(PREFIX) || value.length() != 8) {
throw new IllegalArgumentException("Not an AMQP header buffer");
}
buffer = value.buffer();
}
代码示例来源:origin: org.apache.activemq/activemq-osgi
@Override
public boolean equals(Object obj) {
if (obj == this)
return true;
if (obj == null || obj.getClass() != Buffer.class)
return false;
return equals((Buffer) obj);
}
代码示例来源:origin: org.apache.activemq/activemq-all
@Override
public int hashCode() {
if( hashCode==0 ) {
hashCode = super.hashCode();;
}
return hashCode;
}
代码示例来源:origin: org.fusesource.stompjms/stompjms-client
private void initializeReading() throws JMSException {
checkWriteOnlyBody();
if (dataIn == null) {
Buffer buffer = getContent();
if (buffer==null) {
buffer = new Buffer(0);
}
dataIn = new DataInputStream(new ByteArrayInputStream(buffer));
this.length = buffer.getLength();
}
}
代码示例来源:origin: apache/activemq-artemis
/**
* Converts a Binary value to a long assuming that the contained value is
* stored in Big Endian encoding.
*
* @param value the Binary object whose payload is converted to a long.
* @return a long value constructed from the bytes of the Binary instance.
*/
public static long toLong(Binary value) {
Buffer buffer = new Buffer(value.getArray(), value.getArrayOffset(), value.getLength());
return buffer.bigEndianEditor().readLong();
}
代码示例来源:origin: org.apache.activemq/activemq-all
public int hashCode() {
int rc=2066384;
if (hasKey()) {
rc ^= ( 75327^(new Long(getKey())).hashCode() );
}
if (hasBindingKind()) {
rc ^= ( 1382366105^getBindingKind().hashCode() );
}
if (hasBindingData()) {
rc ^= ( 1382150063^getBindingData().hashCode() );
}
return rc;
}
代码示例来源:origin: org.apache.activemq/activemq-all
private void store(String ext, Buffer value) throws IOException {
TarEntry entry = new TarEntry(seq + "." + ext);
seq += 1;
entry.setSize(value.length());
stream.putNextEntry(entry);
value.writeTo(stream);
stream.closeEntry();
}
代码示例来源:origin: org.fusesource.stompjms/stompjms-client
public void addContentLengthHeader() {
addHeader(CONTENT_LENGTH, new AsciiBuffer(Integer.toString(content.length())));
}
代码示例来源:origin: org.apache.activemq/activemq-all
public boolean equals(Bean obj) {
if (hasKey() ^ obj.hasKey() )
return false;
if (hasKey() && ( getKey()!=obj.getKey() ))
return false;
if (hasBindingKind() ^ obj.hasBindingKind() )
return false;
if (hasBindingKind() && ( !getBindingKind().equals(obj.getBindingKind()) ))
return false;
if (hasBindingData() ^ obj.hasBindingData() )
return false;
if (hasBindingData() && ( !getBindingData().equals(obj.getBindingData()) ))
return false;
return true;
}
代码示例来源:origin: fusesource/stompjms
public StompFrame createCreditFrame(StompJmsMessageConsumer consumer, StompFrame messageFrame) {
final Buffer content = messageFrame.content();
String credit = "1";
if( content!=null ) {
credit += ","+content.length();
}
StompFrame frame = new StompFrame();
frame.action(ACK);
frame.headerMap().put(SUBSCRIPTION, consumer.id);
frame.headerMap().put(CREDIT, AsciiBuffer.ascii(credit));
return frame;
}
代码示例来源:origin: org.fusesource.stompjms/stompjms-client
public int size() {
int rc = action.length() + 1;
if( headerList!=null ) {
for (HeaderEntry entry : headerList) {
rc += entry.getKey().length() + entry.getValue().length() + 2;
}
} else {
for (Map.Entry<AsciiBuffer,AsciiBuffer> entry : headerMap.entrySet()) {
rc += entry.getKey().length() + entry.getValue().length() + 2;
}
}
rc += content.length() + 3;
return rc;
}
内容来源于网络,如有侵权,请联系作者删除!