Ejemplo n.º 1
0
  public List<ByteArrayOutput> split(final int maxSize) {
    final List<ByteArrayOutput> list = new ArrayList<ByteArrayOutput>();
    int currentSize = 0;
    TBaseStreamNode node = null;
    while ((node = nodes.peek()) != null) {
      if (node.size() > maxSize) {
        if (list.isEmpty()) {
          // first node
          list.add(node);
          nodes.poll();
        }
        break;
      }

      if (currentSize + node.size() > maxSize) {
        break;
      }

      currentSize += node.size();
      list.add(node);
      nodes.poll();
    }

    return list;
  }
Ejemplo n.º 2
0
  public int size() {
    int size = 0;
    for (TBaseStreamNode node : nodes) {
      size += node.size();
    }

    return size;
  }
Ejemplo n.º 3
0
  public void write(final TBase<?, ?> base) throws TException {
    final TBaseStreamNode node = new TBaseStreamNode(transport);
    node.setClassName(base.getClass().getName());
    node.setBeginPosition(transport.getBufferPosition());

    final TProtocol protocol = protocolFactory.getProtocol(transport);
    base.write(protocol);

    node.setEndPosition(transport.getBufferPosition());
    nodes.add(node);
  }