本文整理汇总了Java中org.fusesource.hawtbuf.UTF8Buffer类的典型用法代码示例。如果您正苦于以下问题:Java UTF8Buffer类的具体用法?Java UTF8Buffer怎么用?Java UTF8Buffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UTF8Buffer类属于org.fusesource.hawtbuf包,在下文中一共展示了UTF8Buffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tightMarshalThrowable1
import org.fusesource.hawtbuf.UTF8Buffer; //导入依赖的package包/类
protected int tightMarshalThrowable1(OpenWireFormat wireFormat, Throwable o, BooleanStream bs)
throws IOException {
if (o == null) {
bs.writeBoolean(false);
return 0;
} else {
int rc = 0;
bs.writeBoolean(true);
String className = o instanceof OpenwireException ? ((OpenwireException)o).getClassName() : o.getClass().getName();
rc += tightMarshalString1(new UTF8Buffer(className), bs);
rc += tightMarshalString1(new UTF8Buffer(o.getMessage()), bs);
if (wireFormat.isStackTraceEnabled()) {
rc += 2;
StackTraceElement[] stackTrace = o.getStackTrace();
for (int i = 0; i < stackTrace.length; i++) {
StackTraceElement element = stackTrace[i];
rc += tightMarshalString1(new UTF8Buffer(element.getClassName()), bs);
rc += tightMarshalString1(new UTF8Buffer(element.getMethodName()), bs);
rc += tightMarshalString1(new UTF8Buffer(element.getFileName()), bs);
rc += 4;
}
rc += tightMarshalThrowable1(wireFormat, o.getCause(), bs);
}
return rc;
}
}
示例2: tightMarshalThrowable2
import org.fusesource.hawtbuf.UTF8Buffer; //导入依赖的package包/类
protected void tightMarshalThrowable2(OpenWireFormat wireFormat, Throwable o, DataByteArrayOutputStream dataOut,
BooleanStream bs) throws IOException {
if (bs.readBoolean()) {
String className = o instanceof OpenwireException ? ((OpenwireException)o).getClassName() : o.getClass().getName();
tightMarshalString2(new UTF8Buffer(className), dataOut, bs);
tightMarshalString2(new UTF8Buffer(o.getMessage()), dataOut, bs);
if (wireFormat.isStackTraceEnabled()) {
StackTraceElement[] stackTrace = o.getStackTrace();
dataOut.writeShort(stackTrace.length);
for (int i = 0; i < stackTrace.length; i++) {
StackTraceElement element = stackTrace[i];
tightMarshalString2(new UTF8Buffer(element.getClassName()), dataOut, bs);
tightMarshalString2(new UTF8Buffer(element.getMethodName()), dataOut, bs);
tightMarshalString2(new UTF8Buffer(element.getFileName()), dataOut, bs);
dataOut.writeInt(element.getLineNumber());
}
tightMarshalThrowable2(wireFormat, o.getCause(), dataOut, bs);
}
}
}
示例3: tightMarshalString1
import org.fusesource.hawtbuf.UTF8Buffer; //导入依赖的package包/类
protected int tightMarshalString1(UTF8Buffer value, BooleanStream bs) throws IOException {
bs.writeBoolean(value != null);
if (value != null) {
boolean ascii = false;
// we could check to see if its' really ascii.. for now punt.
// boolean ascii = true;
// int last = value.offset+value.length;
// for (int i = value.offset; i < last; i++) {
// if( (value.data[i] & 0x80) !=0 ) {
// ascii = false;
// }
// }
bs.writeBoolean(ascii);
return value.length() + 2;
} else {
return 0;
}
}
示例4: looseMarshalThrowable
import org.fusesource.hawtbuf.UTF8Buffer; //导入依赖的package包/类
protected void looseMarshalThrowable(OpenWireFormat wireFormat, Throwable o, DataByteArrayOutputStream dataOut)
throws IOException {
dataOut.writeBoolean(o != null);
if (o != null) {
String className = o instanceof OpenwireException ? ((OpenwireException)o).getClassName() : o.getClass().getName();
looseMarshalString(new UTF8Buffer(className), dataOut);
looseMarshalString(new UTF8Buffer(o.getMessage()), dataOut);
if (wireFormat.isStackTraceEnabled()) {
StackTraceElement[] stackTrace = o.getStackTrace();
dataOut.writeShort(stackTrace.length);
for (int i = 0; i < stackTrace.length; i++) {
StackTraceElement element = stackTrace[i];
looseMarshalString(new UTF8Buffer(element.getClassName()), dataOut);
looseMarshalString(new UTF8Buffer(element.getMethodName()), dataOut);
looseMarshalString(new UTF8Buffer(element.getFileName()), dataOut);
dataOut.writeInt(element.getLineNumber());
}
looseMarshalThrowable(wireFormat, o.getCause(), dataOut);
}
}
}
示例5: connectionListener
import org.fusesource.hawtbuf.UTF8Buffer; //导入依赖的package包/类
private Listener connectionListener() {
return new Listener() {
@Override
public void onPublish(UTF8Buffer topic, Buffer body, Runnable ack) {
// nothing to do
}
@Override
public void onFailure(Throwable value) {
// nothing to do
}
@Override
public void onDisconnected() {
fireConnectionLost();
}
@Override
public void onConnected() {
fireReconnected();
}
};
}
示例6: unsubscribe
import org.fusesource.hawtbuf.UTF8Buffer; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void unsubscribe(final String channel) {
if (this.connection != null) {
this.channels.remove(channel);
final UTF8Buffer[] topic = { UTF8Buffer.utf8(channel) };
this.connection.unsubscribe(topic, new Callback<Void>() {
@Override
public void onFailure(final Throwable throwable) {
System.out.println("Exception occurred while unsubscribing: " + throwable.getMessage());
logTracker.log("Exception occurred while unsubscribing");
}
@Override
public void onSuccess(final Void aVoid) {
System.out.println("Successfully unsubscribed");
logTracker.log("Successfully unsubscribed");
}
});
}
}
示例7: getBoolean
import org.fusesource.hawtbuf.UTF8Buffer; //导入依赖的package包/类
/**
* Returns the <CODE>boolean</CODE> value with the specified name.
*
* @param name the name of the <CODE>boolean</CODE>
* @return the <CODE>boolean</CODE> value with the specified name
* @throws JMSException if the JMS provider fails to read the message due to
* some internal error.
* @throws MessageFormatException if this type conversion is invalid.
*/
@Override
public boolean getBoolean(String name) throws JMSException {
initializeReading();
Object value = map.get(name);
if (value == null) {
return false;
}
if (value instanceof Boolean) {
return ((Boolean)value).booleanValue();
}
if (value instanceof UTF8Buffer) {
return Boolean.valueOf(value.toString()).booleanValue();
}
if (value instanceof String) {
return Boolean.valueOf(value.toString()).booleanValue();
} else {
throw new MessageFormatException(" cannot read a boolean from " + value.getClass().getName());
}
}
示例8: getByte
import org.fusesource.hawtbuf.UTF8Buffer; //导入依赖的package包/类
/**
* Returns the <CODE>byte</CODE> value with the specified name.
*
* @param name the name of the <CODE>byte</CODE>
* @return the <CODE>byte</CODE> value with the specified name
* @throws JMSException if the JMS provider fails to read the message due to
* some internal error.
* @throws MessageFormatException if this type conversion is invalid.
*/
@Override
public byte getByte(String name) throws JMSException {
initializeReading();
Object value = map.get(name);
if (value == null) {
return 0;
}
if (value instanceof Byte) {
return ((Byte)value).byteValue();
}
if (value instanceof UTF8Buffer) {
return Byte.valueOf(value.toString()).byteValue();
}
if (value instanceof String) {
return Byte.valueOf(value.toString()).byteValue();
} else {
throw new MessageFormatException(" cannot read a byte from " + value.getClass().getName());
}
}
示例9: getShort
import org.fusesource.hawtbuf.UTF8Buffer; //导入依赖的package包/类
/**
* Returns the <CODE>short</CODE> value with the specified name.
*
* @param name the name of the <CODE>short</CODE>
* @return the <CODE>short</CODE> value with the specified name
* @throws JMSException if the JMS provider fails to read the message due to
* some internal error.
* @throws MessageFormatException if this type conversion is invalid.
*/
@Override
public short getShort(String name) throws JMSException {
initializeReading();
Object value = map.get(name);
if (value == null) {
return 0;
}
if (value instanceof Short) {
return ((Short)value).shortValue();
}
if (value instanceof Byte) {
return ((Byte)value).shortValue();
}
if (value instanceof UTF8Buffer) {
return Short.valueOf(value.toString()).shortValue();
}
if (value instanceof String) {
return Short.valueOf(value.toString()).shortValue();
} else {
throw new MessageFormatException(" cannot read a short from " + value.getClass().getName());
}
}
示例10: getInt
import org.fusesource.hawtbuf.UTF8Buffer; //导入依赖的package包/类
/**
* Returns the <CODE>int</CODE> value with the specified name.
*
* @param name the name of the <CODE>int</CODE>
* @return the <CODE>int</CODE> value with the specified name
* @throws JMSException if the JMS provider fails to read the message due to
* some internal error.
* @throws MessageFormatException if this type conversion is invalid.
*/
@Override
public int getInt(String name) throws JMSException {
initializeReading();
Object value = map.get(name);
if (value == null) {
return 0;
}
if (value instanceof Integer) {
return ((Integer)value).intValue();
}
if (value instanceof Short) {
return ((Short)value).intValue();
}
if (value instanceof Byte) {
return ((Byte)value).intValue();
}
if (value instanceof UTF8Buffer) {
return Integer.valueOf(value.toString()).intValue();
}
if (value instanceof String) {
return Integer.valueOf(value.toString()).intValue();
} else {
throw new MessageFormatException(" cannot read an int from " + value.getClass().getName());
}
}
示例11: getFloat
import org.fusesource.hawtbuf.UTF8Buffer; //导入依赖的package包/类
/**
* Returns the <CODE>float</CODE> value with the specified name.
*
* @param name the name of the <CODE>float</CODE>
* @return the <CODE>float</CODE> value with the specified name
* @throws JMSException if the JMS provider fails to read the message due to
* some internal error.
* @throws MessageFormatException if this type conversion is invalid.
*/
@Override
public float getFloat(String name) throws JMSException {
initializeReading();
Object value = map.get(name);
if (value == null) {
return 0;
}
if (value instanceof Float) {
return ((Float)value).floatValue();
}
if (value instanceof UTF8Buffer) {
return Float.valueOf(value.toString()).floatValue();
}
if (value instanceof String) {
return Float.valueOf(value.toString()).floatValue();
} else {
throw new MessageFormatException(" cannot read a float from " + value.getClass().getName());
}
}
示例12: getDouble
import org.fusesource.hawtbuf.UTF8Buffer; //导入依赖的package包/类
/**
* Returns the <CODE>double</CODE> value with the specified name.
*
* @param name the name of the <CODE>double</CODE>
* @return the <CODE>double</CODE> value with the specified name
* @throws JMSException if the JMS provider fails to read the message due to
* some internal error.
* @throws MessageFormatException if this type conversion is invalid.
*/
@Override
public double getDouble(String name) throws JMSException {
initializeReading();
Object value = map.get(name);
if (value == null) {
return 0;
}
if (value instanceof Double) {
return ((Double)value).doubleValue();
}
if (value instanceof Float) {
return ((Float)value).floatValue();
}
if (value instanceof UTF8Buffer) {
return Float.valueOf(value.toString()).floatValue();
}
if (value instanceof String) {
return Float.valueOf(value.toString()).floatValue();
} else {
throw new MessageFormatException(" cannot read a double from " + value.getClass().getName());
}
}
示例13: onPublish
import org.fusesource.hawtbuf.UTF8Buffer; //导入依赖的package包/类
@Override
public void onPublish(UTF8Buffer topic, Buffer body, Runnable ack) {
String message = body.utf8().toString();
this.onMsg.send(message);
ack.run();
Message msg = new Message();
msg.topic = topic.toString();
msg.message = message;
try {
Gson gson = new Gson();
String jsonMsg = gson.toJson(msg);
this.onTopicAndMsg.send(jsonMsg);
} catch (Exception e) {
Log.error("{} unable to serialize topic and message to JSON, onTopicAndMsg port will not be used");
// e.printStackTrace();
}
}
示例14: createThrowable
import org.fusesource.hawtbuf.UTF8Buffer; //导入依赖的package包/类
private Throwable createThrowable(UTF8Buffer className, UTF8Buffer message) {
try {
Class clazz = Class.forName(className.toString(), false, BaseDataStreamMarshaller.class.getClassLoader());
Constructor constructor = clazz.getConstructor(new Class[] {UTF8Buffer.class});
return (Throwable)constructor.newInstance(new Object[] {message.toString()});
} catch (Throwable e) {
return new OpenwireException(message.toString(), className.toString());
}
}
示例15: tightUnmarshalString
import org.fusesource.hawtbuf.UTF8Buffer; //导入依赖的package包/类
@SuppressWarnings("deprecation")
protected UTF8Buffer tightUnmarshalString(DataByteArrayInputStream dataIn, BooleanStream bs) throws IOException {
if (bs.readBoolean()) {
boolean ascii = bs.readBoolean(); // ignored for now.
int size = dataIn.readShort();
if( size== 0 ) {
return new UTF8Buffer("");
} else {
Buffer buffer = dataIn.readBuffer(size);
return buffer.utf8();
}
} else {
return null;
}
}