Author: mturk
Date: Mon Oct 19 17:33:28 2009
New Revision: 826728
URL: http://svn.apache.org/viewvc?rev=826728&view=rev
Log:
Add Seekable interface
Added:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/SeekMethod.java
- copied, changed from r826371,
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSeekMethod.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Seekable.java
(with props)
Removed:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSeekMethod.java
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileStream.java
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileStream.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileStream.java?rev=826728&r1=826727&r2=826728&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileStream.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileStream.java
Mon Oct 19 17:33:28 2009
@@ -410,7 +410,7 @@
throw new IllegalArgumentException();
}
synchronized (sync) {
- FileWrapper.seek(fd, FileSeekMethod.SET.valueOf(), pos);
+ FileWrapper.seek(fd, SeekMethod.SET.valueOf(), pos);
}
}
@@ -424,7 +424,7 @@
* Move offset in bytes.
*
* @throws IllegalArgumentException
- * If {...@code moveMethod == FileSeekMethod.SET} and
+ * If {...@code moveMethod == SeekMethod.SET} and
* {...@code off < 0}.
* @throws ClosedDescriptorException
* If this file is closed.
@@ -433,12 +433,12 @@
* operation is in progress.
* @throws IOException
* If some other I/O error occurs.
- * @see FileSeekMethod
+ * @see SeekMethod
*/
- public void moveFilePointer(FileSeekMethod moveMethod, long off)
+ public void moveFilePointer(SeekMethod moveMethod, long off)
throws IOException
{
- if (moveMethod == FileSeekMethod.SET && off < 0L) {
+ if (moveMethod == SeekMethod.SET && off < 0L) {
// seek position is negative
throw new IllegalArgumentException();
}
@@ -471,11 +471,11 @@
{
if (count > 0) {
synchronized (sync) {
- long cur = FileWrapper.seek(fd, FileSeekMethod.CUR.valueOf(),
0L);
- long eof = FileWrapper.seek(fd, FileSeekMethod.END.valueOf(),
0L);
+ long cur = FileWrapper.seek(fd, SeekMethod.CUR.valueOf(), 0L);
+ long eof = FileWrapper.seek(fd, SeekMethod.END.valueOf(), 0L);
int cnt = (int)((cur + count > eof) ? eof - cur : count);
- FileWrapper.seek(fd, FileSeekMethod.SET.valueOf(), cnt);
+ FileWrapper.seek(fd, SeekMethod.SET.valueOf(), cnt);
return cnt;
}
}
@@ -499,7 +499,7 @@
public long getFilePointer()
throws IOException
{
- return FileWrapper.seek(fd, FileSeekMethod.CUR.valueOf(), 0L);
+ return FileWrapper.seek(fd, SeekMethod.CUR.valueOf(), 0L);
}
/**
@@ -519,10 +519,10 @@
throws IOException
{
synchronized (sync) {
- long cur = FileWrapper.seek(fd, FileSeekMethod.CUR.valueOf(), 0L);
- long end = FileWrapper.seek(fd, FileSeekMethod.END.valueOf(), 0L);
+ long cur = FileWrapper.seek(fd, SeekMethod.CUR.valueOf(), 0L);
+ long end = FileWrapper.seek(fd, SeekMethod.END.valueOf(), 0L);
- FileWrapper.seek(fd, FileSeekMethod.SET.valueOf(), cur);
+ FileWrapper.seek(fd, SeekMethod.SET.valueOf(), cur);
return end;
}
}
Copied:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/SeekMethod.java
(from r826371,
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSeekMethod.java)
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/SeekMethod.java?p2=commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/SeekMethod.java&p1=commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSeekMethod.java&r1=826371&r2=826728&rev=826728&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileSeekMethod.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/SeekMethod.java
Mon Oct 19 17:33:28 2009
@@ -17,20 +17,20 @@
package org.apache.commons.runtime.io;
/**
- * FileSeekMethod determines how the seek operation
+ * SeekMethod determines how the seek operation
* should be performed.
*/
-public enum FileSeekMethod
+public enum SeekMethod
{
/** Seek from the current position. */
CUR( 0),
- /** Seek from the file begin. */
+ /** Seek from the begin. */
SET( 1),
- /** Seek from the currect end-of-file position. */
+ /** Seek from the currect end position. */
END( 2);
private int value;
- private FileSeekMethod(int v)
+ private SeekMethod(int v)
{
value = v;
}
Added:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Seekable.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Seekable.java?rev=826728&view=auto
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Seekable.java
(added)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Seekable.java
Mon Oct 19 17:33:28 2009
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.commons.runtime.io;
+
+import java.io.IOException;
+
+/**
+ * The base class for seekable devices.
+ */
+public interface Seekable
+{
+
+ /**
+ * Moves this object's pointer to a new position, from where following
+ * {...@code read}, {...@code write} or {...@code skip} operations are
done.
+ *
+ * @param how
+ * Starting point for the pointer move.
+ * @param off
+ * Move offset in bytes.
+ * @return new position
+ *
+ * @throws IllegalArgumentException
+ * If {...@code how == SeekMethod.SET} and
+ * {...@code off < 0}.
+ * @throws IOException
+ * If some other I/O error occurs.
+ * @see SeekMethod
+ */
+ public long seek(SeekMethod how, long off)
+ throws IOException;
+
+}
Propchange:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Seekable.java
------------------------------------------------------------------------------
svn:eol-style = native