本文整理汇总了Java中org.apache.qpid.proton.amqp.Binary.getLength方法的典型用法代码示例。如果您正苦于以下问题:Java Binary.getLength方法的具体用法?Java Binary.getLength怎么用?Java Binary.getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.qpid.proton.amqp.Binary
的用法示例。
在下文中一共展示了Binary.getLength方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUserId
import org.apache.qpid.proton.amqp.Binary; //导入方法依赖的package包/类
@Override
public byte[] getUserId()
{
if(_properties == null || _properties.getUserId() == null)
{
return null;
}
else
{
final Binary userId = _properties.getUserId();
byte[] id = new byte[userId.getLength()];
System.arraycopy(userId.getArray(),userId.getArrayOffset(),id,0,userId.getLength());
return id;
}
}
示例2: fastWrite
import org.apache.qpid.proton.amqp.Binary; //导入方法依赖的package包/类
public void fastWrite(EncoderImpl encoder, Binary binary)
{
if (binary.getLength() <= 255)
{
encoder.writeRaw(EncodingCodes.VBIN8);
encoder.writeRaw((byte) binary.getLength());
encoder.writeRaw(binary.getArray(), binary.getArrayOffset(), binary.getLength());
}
else
{
encoder.writeRaw(EncodingCodes.VBIN32);
encoder.writeRaw(binary.getLength());
encoder.writeRaw(binary.getArray(), binary.getArrayOffset(), binary.getLength());
}
}
示例3: BinaryElement
import org.apache.qpid.proton.amqp.Binary; //导入方法依赖的package包/类
BinaryElement(Element parent, Element prev, Binary b)
{
super(parent, prev);
byte[] data = new byte[b.getLength()];
System.arraycopy(b.getArray(),b.getArrayOffset(),data,0,b.getLength());
_value = new Binary(data);
}
示例4: toQuotedString
import org.apache.qpid.proton.amqp.Binary; //导入方法依赖的package包/类
/**
* Converts the Binary to a quoted string.
*
* @param bin the Binary to convert
* @param stringLength the maximum length of stringified content (excluding the quotes, and truncated indicator)
* @param appendIfTruncated appends "...(truncated)" if not all of the payload is present in the string
* @return the converted string
*/
public static String toQuotedString(final Binary bin,final int stringLength,final boolean appendIfTruncated)
{
if(bin == null)
{
return "\"\"";
}
final byte[] binData = bin.getArray();
final int binLength = bin.getLength();
final int offset = bin.getArrayOffset();
StringBuilder str = new StringBuilder();
str.append("\"");
int size = 0;
boolean truncated = false;
for (int i = 0; i < binLength; i++)
{
byte c = binData[offset + i];
if (c > 31 && c < 127 && c != '\\')
{
if (size + 1 <= stringLength)
{
size += 1;
str.append((char) c);
}
else
{
truncated = true;
break;
}
}
else
{
if (size + 4 <= stringLength)
{
size += 4;
str.append(String.format("\\x%02x", c));
}
else
{
truncated = true;
break;
}
}
}
str.append("\"");
if (truncated && appendIfTruncated)
{
str.append("...(truncated)");
}
return str.toString();
}
示例5: getEncoding
import org.apache.qpid.proton.amqp.Binary; //导入方法依赖的package包/类
public BinaryEncoding getEncoding(final Binary val)
{
return val.getLength() <= 255 ? _shortBinaryEncoding : _binaryEncoding;
}
示例6: getEncodedValueSize
import org.apache.qpid.proton.amqp.Binary; //导入方法依赖的package包/类
@Override
protected int getEncodedValueSize(final Binary val)
{
return val.getLength();
}