org.fusesource.hawtbuf.Buffer.startsWith()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中org.fusesource.hawtbuf.Buffer.startsWith()方法的一些代码示例,展示了Buffer.startsWith()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.startsWith()方法的具体详情如下:
包路径:org.fusesource.hawtbuf.Buffer
类名称:Buffer
方法名:startsWith

Buffer.startsWith介绍

暂无

代码示例

代码示例来源:origin: org.apache.activemq/activemq-all

public boolean hasValidPrefix() {
  return buffer.startsWith(PREFIX);
}

代码示例来源:origin: org.apache.activemq/activemq-osgi

public boolean hasValidPrefix() {
  return buffer.startsWith(PREFIX);
}

代码示例来源:origin: apache/activemq-artemis

public boolean hasValidPrefix() {
  return buffer.startsWith(PREFIX);
}

代码示例来源: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.qpid/proton-hawtdispatch

public void setBuffer(Buffer value) {
  if( !value.startsWith(PREFIX) || value.length()!=8 ) {
    throw new IllegalArgumentException("Not an AMQP header buffer");
  }
  buffer = value.buffer();
}

代码示例来源:origin: org.apache.activemq/activemq-osgi

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/apollo-mqtt

@Override
public boolean matchesIdentification(Buffer header) {
  if (header.length < 10) {
   return false;
  } else {
   return header.startsWith(HEAD_MAGIC) && (
     header.indexOf(MQTT31_TAIL_MAGIC, 2) < 6 ||
     header.indexOf(MQTT311_TAIL_MAGIC, 2) < 6
   );
  }
}

代码示例来源:origin: apache/activemq-artemis

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.fusesource.stompjms/stompjms-client

public static String decodeHeader(Buffer value) {
  if (value == null)
    return null;
  ByteArrayOutputStream rc = new ByteArrayOutputStream(value.length);
  Buffer pos = new Buffer(value);
  int max = value.offset + value.length;
  while (pos.offset < max) {
    if (pos.startsWith(ESCAPE_ESCAPE_SEQ)) {
      rc.write(ESCAPE_BYTE);
      pos.moveHead(2);
    } else if (pos.startsWith(COLON_ESCAPE_SEQ)) {
      rc.write(COLON_BYTE);
      pos.moveHead(2);
    } else if (pos.startsWith(NEWLINE_ESCAPE_SEQ)) {
      rc.write(NEWLINE_BYTE);
      pos.moveHead(2);
    } else {
      rc.write(pos.data[pos.offset]);
      pos.moveHead(1);
    }
  }
  try {
    return new String(rc.toByteArray(), "UTF-8");
  } catch (UnsupportedEncodingException e) {
    throw new RuntimeException(e); // not expected.
  }
}

代码示例来源:origin: fusesource/stompjms

public static String decodeHeader(Buffer value) {
  if (value == null)
    return null;
  ByteArrayOutputStream rc = new ByteArrayOutputStream(value.length);
  Buffer pos = new Buffer(value);
  int max = value.offset + value.length;
  while (pos.offset < max) {
    if (pos.startsWith(ESCAPE_ESCAPE_SEQ)) {
      rc.write(ESCAPE_BYTE);
      pos.moveHead(2);
    } else if (pos.startsWith(COLON_ESCAPE_SEQ)) {
      rc.write(COLON_BYTE);
      pos.moveHead(2);
    } else if (pos.startsWith(NEWLINE_ESCAPE_SEQ)) {
      rc.write(NEWLINE_BYTE);
      pos.moveHead(2);
    } else {
      rc.write(pos.data[pos.offset]);
      pos.moveHead(1);
    }
  }
  try {
    return new String(rc.toByteArray(), "UTF-8");
  } catch (UnsupportedEncodingException e) {
    throw new RuntimeException(e); // not expected.
  }
}

代码示例来源:origin: chirino/hawtdb

BTreeNode<Key, Value> loadNode(BTreeNode<Key, Value> parent, int page) {
  BTreeNode<Key, Value> node = new BTreeNode<Key, Value>(parent, page);
  if( deferredEncoding ) {
    node.data = paged.get(DATA_ENCODER_DECODER, page);
    node.storedInExtent=true;
  } else {
    Buffer buffer = new Buffer(paged.getPageSize());
    paged.read(page, buffer);
    if ( buffer.startsWith(Extent.DEFAULT_MAGIC) ) {
      // Page data was stored in an extent..
      node.data = DATA_ENCODER_DECODER.load(paged, page);
      node.storedInExtent=true;
    } else {
      // It was just in a plain page..
      DataByteArrayInputStream is = new DataByteArrayInputStream(buffer);
      try {
        node.data = BTreeNode.read(is, this);
        node.storedInExtent=false;
      } catch (IOException e) {
        throw new IndexException("Could not read btree node");
      }
    }
  }
  return node;
}

代码示例来源:origin: org.fusesource.hawtdb/hawtdb

BTreeNode<Key, Value> loadNode(BTreeNode<Key, Value> parent, int page) {
  BTreeNode<Key, Value> node = new BTreeNode<Key, Value>(parent, page);
  if( deferredEncoding ) {
    node.data = paged.get(DATA_ENCODER_DECODER, page);
    node.storedInExtent=true;
  } else {
    Buffer buffer = new Buffer(paged.getPageSize());
    paged.read(page, buffer);
    if ( buffer.startsWith(Extent.DEFAULT_MAGIC) ) {
      // Page data was stored in an extent..
      node.data = DATA_ENCODER_DECODER.load(paged, page);
      node.storedInExtent=true;
    } else {
      // It was just in a plain page..
      DataByteArrayInputStream is = new DataByteArrayInputStream(buffer);
      try {
        node.data = BTreeNode.read(is, this);
        node.storedInExtent=false;
      } catch (IOException e) {
        throw new IndexException("Could not read btree node");
      }
    }
  }
  return node;
}

相关文章