Package org.entityfs.util.io

Examples of org.entityfs.util.io.RandomAccessToInputStreamAdapter


  public void replaceContentsWith(RandomAccess ra, long dataSize)
  {
    assert dataSize > 0;
    assertNotClosed();
    assertNotReadOnly();
    m_tree.replaceContentsWith(new RandomAccessToInputStreamAdapter(ra), dataSize);
    updateContentsVersion();
  }
View Full Code Here


  }

  public long writeContentsTo(OutputStream os)
  {
    m_file.seek(m_startPosOfData);
    return StreamUtil.copyStreams(new RandomAccessToInputStreamAdapter(m_file), os, m_bufSize);
  }
View Full Code Here

  public long writeContentsTo(RandomAccess ra)
  {
    assertNotClosed();
    m_dbFile.seek(m_startPosOfDb);
    return StreamUtil.copyStreams(new RandomAccessToInputStreamAdapter(m_dbFile), new RandomAccessToOutputStreamAdapter(ra), m_bufferSize);
  }
View Full Code Here

    assertNotClosed();
    assertNotReadOnly();
    assert dataSize > 0;
    m_dbFile.seek(m_startPosOfDb);
    m_dbFile.setLength(m_startPosOfDb);
    long noCopied = StreamUtil.copyStreams(new RandomAccessToInputStreamAdapter(ra), new RandomAccessToOutputStreamAdapter(m_dbFile), m_bufferSize, dataSize);
    if (noCopied != dataSize)
    {
      throw new NotEnoughDataException(dataSize, noCopied, m_startPosOfDb);
    }
    updateContentsVersion();
View Full Code Here

  }

  public T read(RandomAccess ra, int size)
  {
    long beforePos = ra.getFilePointer();
    T res = read(new RandomAccessToInputStreamAdapter(ra), size);
    long afterPos = ra.getFilePointer();
    if (afterPos - beforePos != size)
    {
      throw new SerializationException("Was told to read " + size + " bytes, but the object occupied " + (afterPos - beforePos) + " bytes");
    }
View Full Code Here

  public long writeContentsTo(RandomAccess ra)
  {
    assertNotClosed();
    m_dbFile.seek(m_startPosOfDb);
    return StreamUtil.copyStreams(new RandomAccessToInputStreamAdapter(m_dbFile), new RandomAccessToOutputStreamAdapter(ra), m_bufferSize);
  }
View Full Code Here

    {
      throw new IllegalArgumentException("Invalid data size " + dataSize + ". It must be a multiple of the key size + record size");
    }
    m_dbFile.seek(m_startPosOfDb);
    m_dbFile.setLength(m_startPosOfDb);
    long noCopied = StreamUtil.copyStreams(new RandomAccessToInputStreamAdapter(ra), new RandomAccessToOutputStreamAdapter(m_dbFile), m_bufferSize, dataSize);
    if (noCopied != dataSize)
    {
      throw new DatabaseException("Wanted to copy " + dataSize + " bytes. Got " + noCopied);
    }
    updateContentsVersion();
View Full Code Here

    assertNotClosed();
    assertNotReadOnly();
    assert dataSize > 0;
    long treeLen = LongSerializer.INSTANCE.readLong(ra);
    getProxied().replaceContentsWith(ra, treeLen);
    m_tree.replaceContentsWith(new RandomAccessToInputStreamAdapter(ra), dataSize - treeLen - LongSerializer.DATA_SIZE);
  }
View Full Code Here

TOP

Related Classes of org.entityfs.util.io.RandomAccessToInputStreamAdapter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.