Package java.nio.channels

Examples of java.nio.channels.FileLock.position()


    synchronized void addLock(FileLock lock)
            throws OverlappingFileLockException {
        long lockEnd = lock.position() + lock.size();
        for (Iterator<FileLock> keyItr = locks.iterator(); keyItr.hasNext();) {
            FileLock existingLock = keyItr.next();
            if (existingLock.position() > lockEnd) {
                // This, and all remaining locks, start beyond our end (so
                // cannot overlap).
                break;
            }
            if (existingLock.overlaps(lock.position(), lock.size())) {
View Full Code Here


  /**
   * @tests java.nio.channels.FileLock#position()
   */
  public void test_position() {
    FileLock fileLock1 = new MockFileLock(readWriteChannel, 20, 100, true);
    assertEquals(20, fileLock1.position());

    final long position = ((long) Integer.MAX_VALUE + 1);
    FileLock fileLock2 = new MockFileLock(readWriteChannel, position, 100,
        true);
    assertEquals(position, fileLock2.position());
View Full Code Here

    assertEquals(20, fileLock1.position());

    final long position = ((long) Integer.MAX_VALUE + 1);
    FileLock fileLock2 = new MockFileLock(readWriteChannel, position, 100,
        true);
    assertEquals(position, fileLock2.position());
  }

  /**
   * @tests java.nio.channels.FileLock#size()
   */
 
View Full Code Here

    synchronized void addLock(FileLock lock)
            throws OverlappingFileLockException {
        long lockEnd = lock.position() + lock.size();
        for (Iterator<FileLock> keyItr = locks.iterator(); keyItr.hasNext();) {
            FileLock existingLock = keyItr.next();
            if (existingLock.position() > lockEnd) {
                // This, and all remaining locks, start beyond our end (so
                // cannot overlap).
                break;
            }
            if (existingLock.overlaps(lock.position(), lock.size())) {
View Full Code Here

  /**
   * @tests java.nio.channels.FileLock#position()
   */
  public void test_position() {
    FileLock fileLock1 = new MockFileLock(readWriteChannel, 20, 100, true);
    assertEquals(20, fileLock1.position());

    final long position = ((long) Integer.MAX_VALUE + 1);
    FileLock fileLock2 = new MockFileLock(readWriteChannel, position, 100,
        true);
    assertEquals(position, fileLock2.position());
View Full Code Here

    assertEquals(20, fileLock1.position());

    final long position = ((long) Integer.MAX_VALUE + 1);
    FileLock fileLock2 = new MockFileLock(readWriteChannel, position, 100,
        true);
    assertEquals(position, fileLock2.position());
  }

  /**
   * @tests java.nio.channels.FileLock#size()
   */
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.