本文整理了Java中org.littleshoot.mina.common.ByteBuffer.get()
方法的一些代码示例,展示了ByteBuffer.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuffer.get()
方法的具体详情如下:
包路径:org.littleshoot.mina.common.ByteBuffer
类名称:ByteBuffer
方法名:get
暂无
代码示例来源:origin: org.littleshoot/mina-port
/**
* Reads one unsigned byte as a short integer.
*/
public short getUnsigned() {
return (short) (get() & 0xff);
}
代码示例来源:origin: org.littleshoot/mina-port
/**
* Reads one byte as an unsigned short integer.
*/
public short getUnsigned(int index) {
return (short) (get(index) & 0xff);
}
代码示例来源:origin: org.littleshoot/mina-port
/**
* @see java.nio.ByteBuffer#get(byte[])
*/
public ByteBuffer get(byte[] dst) {
return get(dst, 0, dst.length);
}
代码示例来源:origin: org.littleshoot/mina-port
public ByteBuffer get(byte[] dst) {
buf.get(dst);
return this;
}
代码示例来源:origin: org.littleshoot/mina-port
public ByteBuffer get(byte[] dst, int offset, int length) {
buf.get(dst, offset, length);
return this;
}
代码示例来源:origin: org.littleshoot/mina-port
public byte get() {
return buf.get();
}
代码示例来源:origin: org.littleshoot/mina-port
public byte get(int index) {
return buf.get(index);
}
代码示例来源:origin: org.littleshoot/mina-util
public int read() throws IOException
{
synchronized (m_mutex)
{
if (!waitForData())
{
return -1;
}
return m_buf.get() & 0xff;
}
}
代码示例来源:origin: org.littleshoot/mina-port
@Override
public int read() {
if (ByteBuffer.this.hasRemaining()) {
return ByteBuffer.this.get() & 0xff;
} else {
return -1;
}
}
代码示例来源:origin: org.littleshoot/mina-util
/**
* Copies the specified buffer to a byte array.
*
* @param buf The buffer to copy.
* @return The byte array.
*/
public static byte[] toByteArray(final ByteBuffer buf)
{
final byte[] bytes = new byte[buf.remaining()];
buf.get(bytes);
return bytes;
}
代码示例来源:origin: org.littleshoot/mina-port
public int read() throws IOException {
synchronized (mutex) {
if (!waitForData()) {
return -1;
}
return buf.get() & 0xff;
}
}
代码示例来源:origin: org.littleshoot/mina-port
@Override
public int read(byte[] b, int off, int len) {
int remaining = ByteBuffer.this.remaining();
if (remaining > 0) {
int readBytes = Math.min(remaining, len);
ByteBuffer.this.get(b, off, readBytes);
return readBytes;
} else {
return -1;
}
}
代码示例来源:origin: org.littleshoot/mina-port
@Override
public int hashCode() {
int h = 1;
int p = position();
for (int i = limit() - 1; i >= p; i--) {
h = 31 * h + get(i);
}
return h;
}
代码示例来源:origin: org.littleshoot/mina-port
public static String getHexdump(ByteBuffer in) {
int size = in.remaining();
if (size == 0) {
return "empty";
}
StringBuffer out = new StringBuffer((in.remaining() * 3) - 1);
int mark = in.position();
// fill the first
int byteValue = in.get() & 0xFF;
out.append((char) highDigits[byteValue]);
out.append((char) lowDigits[byteValue]);
size--;
// and the others, too
for (; size > 0; size--) {
out.append(' ');
byteValue = in.get() & 0xFF;
out.append((char) highDigits[byteValue]);
out.append((char) lowDigits[byteValue]);
}
in.position(mark);
return out.toString();
}
}
代码示例来源:origin: org.littleshoot/mina-util
private void debugStateTransition2(final DecodingState returningState,
final ByteBuffer in)
{
final String stateString;
if (returningState != null)
{
stateString =
ClassUtils.getShortClassName(returningState.getClass());
}
else
{
stateString = null;
}
LOG.debug(ClassUtils.getShortClassName(getClass()) +
" transitioning to state: {}", stateString);
LOG.debug("Remaining bytes: "+in.remaining());
if (in.remaining() == 1)
{
LOG.debug("Remaining byte: '"+in.get()+"'");
}
}
}
代码示例来源:origin: org.littleshoot/mina-port
@Override
public boolean equals(Object o) {
if (!(o instanceof ByteBuffer)) {
return false;
}
ByteBuffer that = (ByteBuffer) o;
if (this.remaining() != that.remaining()) {
return false;
}
int p = this.position();
for (int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j--) {
byte v1 = this.get(i);
byte v2 = that.get(j);
if (v1 != v2) {
return false;
}
}
return true;
}
代码示例来源:origin: org.littleshoot/mina-port
public int compareTo(ByteBuffer that) {
int n = this.position() + Math.min(this.remaining(), that.remaining());
for (int i = this.position(), j = that.position(); i < n; i++, j++) {
byte v1 = this.get(i);
byte v2 = that.get(j);
if (v1 == v2) {
continue;
}
if (v1 < v2) {
return -1;
}
return +1;
}
return this.remaining() - that.remaining();
}
代码示例来源:origin: org.littleshoot/mina-port
public int read(byte[] b, int off, int len) throws IOException {
synchronized (mutex) {
if (!waitForData()) {
return -1;
}
int readBytes;
if (len > buf.remaining()) {
readBytes = buf.remaining();
} else {
readBytes = len;
}
buf.get(b, off, readBytes);
return readBytes;
}
}
代码示例来源:origin: org.littleshoot/mina-util
/**
* Returns the buffer as a string while preserving the buffer position
* and limit.
*
* @param buffer The buffer to create a string from.
* @return The buffer string.
*/
public static String toString(final ByteBuffer buffer)
{
final int position = buffer.position();
final int limit = buffer.limit();
final byte[] data = new byte[buffer.remaining()];
buffer.get(data);
final String dataString = new String(data);
buffer.position(position);
buffer.limit(limit);
return dataString;
}
}
代码示例来源:origin: org.littleshoot/mina-util
public DecodingState decode(ByteBuffer in, ProtocolDecoderOutput out)
throws Exception
{
final int beginPos = in.position();
final int limit = in.limit();
for (int i = beginPos; i < limit; i++)
{
final byte b = in.get(i);
if (b != m_byteToSkip)
{
in.position(i);
return finishDecode();
}
else
{
}
}
in.position(limit);
return this;
}
内容来源于网络,如有侵权,请联系作者删除!