Author: mturk
Date: Tue Oct 20 11:21:49 2009
New Revision: 827036
URL: http://svn.apache.org/viewvc?rev=827036&view=rev
Log:
Use var args where appropriate
Added:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Container.java
(with props)
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/SeekableStream.java
(with props)
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Detachable.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/File.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileAttributes.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileInstance.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileLock.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileLockImpl.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileLockType.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileOpenMode.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileProtection.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileStream.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Seekable.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/KeyAccessRights.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceControlsAccepted.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceType.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/VariantType.java
Added:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Container.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Container.java?rev=827036&view=auto
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Container.java
(added)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Container.java
Tue Oct 20 11:21:49 2009
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+/**
+ * The base class for all classes offerering
+ * detach method to it's child objects.
+ */
+public interface Container
+{
+
+ /**
+ * Detach {...@code data} from it's container.
+ * <p>
+ * Called from the object that was created by {...@code this}
+ * object informing it that it should destroy the reference
+ * to the {...@code data} object.
+ * </p>
+ *
+ * @param data Object to detach.
+ */
+ public void detach(Detachable data);
+
+}
Propchange:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Container.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Detachable.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Detachable.java?rev=827036&r1=827035&r2=827036&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Detachable.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Detachable.java
Tue Oct 20 11:21:49 2009
@@ -25,16 +25,4 @@
public interface Detachable
{
- /**
- * Detach {...@code data} from it's container.
- * <p>
- * Called from the object that was created by {...@code this}
- * object informing it that it should destroy the reference
- * to the {...@code data} object.
- * </p>
- *
- * @param data Object to detach.
- */
- public void detach(Object data);
-
}
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/File.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/File.java?rev=827036&r1=827035&r2=827036&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/File.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/File.java
Tue Oct 20 11:21:49 2009
@@ -248,19 +248,25 @@
return chmod0(getPath(), FileProtection.bitmapOf(prot));
}
- public boolean setFileOwner(User user, Group group)
+ public boolean setFileProtection(FileProtection... prot)
+ throws IOException, SecurityException
+ {
+ return chmod0(getPath(), FileProtection.bitmapOf(prot));
+ }
+
+ public boolean setOwner(User user, Group group)
throws IOException, SecurityException
{
return chown0(getPath(), user.Id, group.Id);
}
- public boolean setFileOwner(User user)
+ public boolean setOwner(User user)
throws IOException, SecurityException
{
return chown0(getPath(), user.Id, null);
}
- public boolean setFileOwner(Group group)
+ public boolean setOwner(Group group)
throws IOException, SecurityException
{
return chown0(getPath(), null, group.Id);
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileAttributes.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileAttributes.java?rev=827036&r1=827035&r2=827036&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileAttributes.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileAttributes.java
Tue Oct 20 11:21:49 2009
@@ -76,6 +76,22 @@
}
/**
+ * Integer representing the sum of the integer values
+ * of the {...@code FileAttributes} enums.
+ * @param set arguments of {...@code FileAttributes} which values to get.
+ * @return sum of {...@code FileAttributes} values
+ */
+ public static int bitmapOf(FileAttributes... set)
+ {
+ int bitmap = 0;
+ if (set.length != 0) {
+ for (FileAttributes a : set)
+ bitmap += a.valueOf();
+ }
+ return bitmap;
+ }
+
+ /**
* Returns {...@code EnumSet} of {...@code FileAttributes} enums
* from the integer bitmap value.
* @param value Integer used to construct the {...@code EnumSet}
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileInstance.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileInstance.java?rev=827036&r1=827035&r2=827036&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileInstance.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileInstance.java
Tue Oct 20 11:21:49 2009
@@ -51,6 +51,13 @@
return fd;
}
+ public static Descriptor create(File file, FileOpenMode... mode)
+ throws FileNotFoundException, IOException, IllegalArgumentException,
+ SecurityException
+ {
+ return create(file, FileOpenMode.of(mode));
+ }
+
public static Descriptor create(File file, EnumSet<FileOpenMode> mode,
EnumSet<FileProtection> prot)
throws FileNotFoundException, IOException, IllegalArgumentException,
@@ -116,7 +123,7 @@
*
*/
public static FileStream createStdStream(int which,
- EnumSet<FileOpenMode> mode)
+ EnumSet<FileOpenMode> mode)
throws IllegalArgumentException
{
if (which < 0 || which > 2) {
@@ -126,6 +133,13 @@
return new FileStream(fd);
}
+ public static FileStream createStdStream(int which,
+ FileOpenMode... mode)
+ throws IllegalArgumentException
+ {
+ return createStdStream(which, FileOpenMode.of(mode));
+ }
+
/**
* Create new temporary file inside {...@code directory}.
*
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileLock.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileLock.java?rev=827036&r1=827035&r2=827036&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileLock.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileLock.java
Tue Oct 20 11:21:49 2009
@@ -16,7 +16,9 @@
package org.apache.commons.runtime.io;
+import org.apache.commons.runtime.Container;
import org.apache.commons.runtime.Descriptor;
+import org.apache.commons.runtime.Detachable;
import org.apache.commons.runtime.exception.ClosedDescriptorException;
import org.apache.commons.runtime.exception.AsyncClosedDescriptorException;
import org.apache.commons.runtime.exception.InvalidDescriptorException;
@@ -73,7 +75,7 @@
* Further care should be exercised when locking files maintained on network
* file systems, since they often have further limitations.
*/
-public abstract class FileLock
+public abstract class FileLock implements Detachable
{
/*
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileLockImpl.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileLockImpl.java?rev=827036&r1=827035&r2=827036&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileLockImpl.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileLockImpl.java
Tue Oct 20 11:21:49 2009
@@ -16,6 +16,7 @@
package org.apache.commons.runtime.io;
+import org.apache.commons.runtime.Container;
import org.apache.commons.runtime.Descriptor;
import org.apache.commons.runtime.Detachable;
import org.apache.commons.runtime.exception.ClosedDescriptorException;
@@ -28,7 +29,7 @@
/**
* A {...@code FileLock} implementatiom.
*/
-class FileLockImpl extends FileLock
+class FileLockImpl extends FileLock implements Detachable
{
/*
@@ -47,13 +48,13 @@
/*
* FileLock container object
*/
- private Detachable container;
+ private Container container;
/**
* Create new {...@code FileLock} that locks the entire file.
*
*/
- public FileLockImpl(Detachable container, Descriptor fd,
+ public FileLockImpl(Container container, Descriptor fd,
EnumSet<FileLockType> mode)
{
super(mode);
@@ -67,7 +68,7 @@
* Create new {...@code FileLock} that locks the region of file.
*
*/
- public FileLockImpl(Detachable container, Descriptor fd,
+ public FileLockImpl(Container container, Descriptor fd,
EnumSet<FileLockType> mode, long start, long len)
{
super(mode);
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileLockType.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileLockType.java?rev=827036&r1=827035&r2=827036&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileLockType.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileLockType.java
Tue Oct 20 11:21:49 2009
@@ -71,6 +71,22 @@
}
/**
+ * Integer representing the sum of the integer values
+ * of the {...@code FileLockType} enums.
+ * @param set arguments of {...@code FileLockType} which values to get.
+ * @return sum of {...@code FileLockType} values
+ */
+ public static int bitmapOf(FileLockType... set)
+ {
+ int bitmap = 0;
+ if (set.length != 0) {
+ for (FileLockType t : set)
+ bitmap += t.valueOf();
+ }
+ return bitmap;
+ }
+
+ /**
* Returns {...@code EnumSet} of {...@code FileLockType} enums
* from the integer bitmap value.
* @param value Integer used to construct the {...@code EnumSet}
@@ -86,4 +102,15 @@
}
return set;
}
+
+ public static EnumSet<FileLockType> of(FileLockType... of)
+ {
+ EnumSet<FileLockType> set = EnumSet.noneOf(FileLockType.class);
+ if (of != null && of.length != 0) {
+ for (FileLockType t : of)
+ set.add(t);
+ }
+ return set;
+ }
+
}
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileOpenMode.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileOpenMode.java?rev=827036&r1=827035&r2=827036&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileOpenMode.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileOpenMode.java
Tue Oct 20 11:21:49 2009
@@ -89,6 +89,22 @@
}
/**
+ * Integer representing the sum of the integer values
+ * of the {...@code FileOpenMode} enums.
+ * @param set arguments of {...@code FileOpenMode} which values to get.
+ * @return sum of {...@code FileOpenMode} values
+ */
+ public static int bitmapOf(FileOpenMode... set)
+ {
+ int bitmap = 0;
+ if (set.length != 0) {
+ for (FileOpenMode m : set)
+ bitmap += m.valueOf();
+ }
+ return bitmap;
+ }
+
+ /**
* Returns {...@code EnumSet} of {...@code FileOpenMode} enums
* from the integer bitmap value.
* @param value Integer used to construct the {...@code EnumSet}
@@ -109,4 +125,15 @@
}
return set;
}
+
+ public static EnumSet<FileOpenMode> of(FileOpenMode... of)
+ {
+ EnumSet<FileOpenMode> set = EnumSet.noneOf(FileOpenMode.class);
+ if (of != null && of.length != 0) {
+ for (FileOpenMode m : of)
+ set.add(m);
+ }
+ return set;
+ }
+
}
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileProtection.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileProtection.java?rev=827036&r1=827035&r2=827036&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileProtection.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileProtection.java
Tue Oct 20 11:21:49 2009
@@ -83,6 +83,22 @@
}
/**
+ * Integer representing the sum of the integer values
+ * of the {...@code FileProtection} enums.
+ * @param set arguments of {...@code FileProtection} which values to get.
+ * @return sum of {...@code FileProtection} values
+ */
+ public static int bitmapOf(FileProtection... set)
+ {
+ int bitmap = 0;
+ if (set.length != 0) {
+ for (FileProtection p : set)
+ bitmap += p.valueOf();
+ }
+ return bitmap;
+ }
+
+ /**
* Returns {...@code EnumSet} of {...@code FileProtection} enums
* from the integer bitmap value.
* @param value Integer used to construct the {...@code EnumSet}
@@ -119,4 +135,14 @@
}
return set;
}
+
+ public static EnumSet<FileProtection> of(FileProtection... of)
+ {
+ EnumSet<FileProtection> set = EnumSet.noneOf(FileProtection.class);
+ if (of != null && of.length != 0) {
+ for (FileProtection p : of)
+ set.add(p);
+ }
+ return set;
+ }
}
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=827036&r1=827035&r2=827036&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
Tue Oct 20 11:21:49 2009
@@ -16,6 +16,7 @@
package org.apache.commons.runtime.io;
+import org.apache.commons.runtime.Container;
import org.apache.commons.runtime.Descriptor;
import org.apache.commons.runtime.Detachable;
import org.apache.commons.runtime.Pointer;
@@ -41,7 +42,7 @@
* position of the next read or write operation can be moved forwards and
* backwards after every operation.
*/
-public class FileStream extends Stream implements Detachable
+public class FileStream extends SeekableStream implements Container
{
/* File's descriptor object
*/
@@ -54,12 +55,6 @@
*/
private Vector<FileLockImpl> locks = new Vector<FileLockImpl>(2);
- public void detach(Object what)
- {
- FileLockImpl lck = (FileLockImpl)what;
- locks.remove(lck);
- }
-
/**
* Return the {...@link Descriptor} accosicated with this file.
*
@@ -70,6 +65,11 @@
return fd;
}
+ public void detach(Detachable data)
+ {
+ locks.remove(data);
+ }
+
@Override
public boolean valid()
{
@@ -327,6 +327,13 @@
return lock;
}
+ public FileLock lock(FileLockType... type)
+ throws OverlappingFileLockException, IOException
+ {
+ EnumSet<FileLockType> typeset = FileLockType.of(type);
+ return lock(typeset);
+ }
+
/**
* Lock the file region.
* <p>
@@ -360,7 +367,7 @@
* If some other I/O error occurs.
* @see FileLock#release
*/
- public FileLock lock(EnumSet<FileLockType> type, long offset, long length)
+ public FileLock lock(long offset, long length, EnumSet<FileLockType> type)
throws OverlappingFileLockException, IllegalArgumentException,
IOException
{
@@ -383,6 +390,14 @@
return lock;
}
+ public FileLock lock(long offset, long length, FileLockType... type)
+ throws OverlappingFileLockException, IllegalArgumentException,
+ IOException
+ {
+ EnumSet<FileLockType> typeset = FileLockType.of(type);
+ return lock(offset, length, typeset);
+ }
+
/**
* Moves this file's file pointer to a new position, from where following
* {...@code read}, {...@code write} or {...@code skip} operations are
done. The
@@ -402,7 +417,7 @@
* @throws IOException
* If some other I/O error occurs.
*/
- public void setFilePointer(long pos)
+ public void seek(long pos)
throws IllegalArgumentException, IOException
{
if (pos < 0) {
@@ -435,7 +450,7 @@
* If some other I/O error occurs.
* @see SeekMethod
*/
- public void moveFilePointer(SeekMethod moveMethod, long off)
+ public long seek(SeekMethod moveMethod, long off)
throws IOException
{
if (moveMethod == SeekMethod.SET && off < 0L) {
@@ -443,7 +458,7 @@
throw new IllegalArgumentException();
}
synchronized (sync) {
- FileWrapper.seek(fd, moveMethod.valueOf(), off);
+ return FileWrapper.seek(fd, moveMethod.valueOf(), off);
}
}
@@ -466,7 +481,7 @@
* @throws IOException
* If some other I/O error occurs.
*/
- public int skipBytes(int count)
+ public int skip(int count)
throws IOException
{
if (count > 0) {
Modified:
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=827036&r1=827035&r2=827036&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Seekable.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Seekable.java
Tue Oct 20 11:21:49 2009
@@ -27,8 +27,9 @@
{
/**
- * Moves this object's pointer to a new position, from where following
- * {...@code read}, {...@code write} or {...@code skip} operations are
done.
+ * Moves this device position 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.
@@ -40,10 +41,27 @@
* If {...@code how == SeekMethod.SET} and
* {...@code off < 0}.
* @throws IOException
- * If some other I/O error occurs.
+ * If some error occurs.
* @see SeekMethod
*/
public long seek(SeekMethod how, long off)
throws IOException;
+ /**
+ * Skips over {...@code count} bytes in this device. Less than {...@code
count}
+ * bytes are skipped if the end of the content is reached or an exception
is
+ * thrown during the operation. Nothing is done if {...@code count} is
+ * negative.
+ *
+ * @param count
+ * The number of bytes to skip.
+ *
+ * @return The number of bytes actually skipped.
+ *
+ * @throws IOException
+ * If some error occurs.
+ */
+ public int skip(int count)
+ throws IOException;
+
}
Added:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/SeekableStream.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/SeekableStream.java?rev=827036&view=auto
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/SeekableStream.java
(added)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/SeekableStream.java
Tue Oct 20 11:21:49 2009
@@ -0,0 +1,77 @@
+/*
+ * 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;
+import org.apache.commons.runtime.exception.ClosedDescriptorException;
+import org.apache.commons.runtime.exception.AsyncClosedDescriptorException;
+import org.apache.commons.runtime.exception.InvalidDescriptorException;
+import org.apache.commons.runtime.exception.OverlappingFileLockException;
+import org.apache.commons.runtime.exception.TimeoutException;
+
+/**
+ * Bidirectional Seekable Stream.
+ */
+public abstract class SeekableStream extends Stream
+ implements Seekable
+{
+
+ /**
+ * Moves this stream 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 abstract long seek(SeekMethod how, long off)
+ throws IOException;
+
+ /**
+ * Skips over {...@code count} bytes in this stream. Less than {...@code
count}
+ * bytes are skipped if the end of the stream is reached or an exception is
+ * thrown during the operation. Nothing is done if {...@code count} is
+ * negative.
+ *
+ * @param count
+ * The number of bytes to skip.
+ *
+ * @return The number of bytes actually skipped.
+ *
+ * @throws ClosedDescriptorException
+ * If this stream is closed.
+ * @throws AsyncClosedDescriptorException
+ * If another thread closes this stream while this
+ * operation is in progress.
+ * @throws IOException
+ * If some other I/O error occurs.
+ */
+ public abstract int skip(int count)
+ throws IOException;
+
+}
Propchange:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/SeekableStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/KeyAccessRights.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/KeyAccessRights.java?rev=827036&r1=827035&r2=827036&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/KeyAccessRights.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/KeyAccessRights.java
Tue Oct 20 11:21:49 2009
@@ -70,6 +70,22 @@
}
/**
+ * Integer representing the sum of the integer values
+ * of the {...@code KeyAccessRights} enums.
+ * @param set arguments of {...@code KeyAccessRights} which values to get.
+ * @return sum of {...@code KeyAccessRights} values
+ */
+ public static int bitmapOf(KeyAccessRights... set)
+ {
+ int bitmap = 0;
+ if (set.length != 0) {
+ for (KeyAccessRights a : set)
+ bitmap += a.valueOf();
+ }
+ return bitmap;
+ }
+
+ /**
* Returns {...@code EnumSet} of {...@code KeyAccessRights} enums
* from the integer bitmap value.
* @param value Integer used to construct the {...@code EnumSet}
@@ -85,4 +101,15 @@
}
return set;
}
+
+ public static EnumSet<KeyAccessRights> of(KeyAccessRights... of)
+ {
+ EnumSet<KeyAccessRights> set = EnumSet.noneOf(KeyAccessRights.class);
+ if (of != null && of.length != 0) {
+ for (KeyAccessRights a : of)
+ set.add(a);
+ }
+ return set;
+ }
+
}
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceControlsAccepted.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceControlsAccepted.java?rev=827036&r1=827035&r2=827036&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceControlsAccepted.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceControlsAccepted.java
Tue Oct 20 11:21:49 2009
@@ -78,6 +78,16 @@
return bitmap;
}
+ public static int bitmapOf(ServiceControlsAccepted... set)
+ {
+ int bitmap = 0;
+ if (set.length != 0) {
+ for (ServiceControlsAccepted a : set)
+ bitmap += a.valueOf();
+ }
+ return bitmap;
+ }
+
public static EnumSet<ServiceControlsAccepted> valueOf(int value)
{
EnumSet<ServiceControlsAccepted> set =
EnumSet.noneOf(ServiceControlsAccepted.class);
@@ -93,4 +103,16 @@
}
return set;
}
+
+ public static EnumSet<ServiceControlsAccepted>
of(ServiceControlsAccepted... of)
+ {
+ EnumSet<ServiceControlsAccepted> set =
EnumSet.noneOf(ServiceControlsAccepted.class);
+ if (of != null && of.length != 0) {
+ for (ServiceControlsAccepted a : of)
+ set.add(a);
+ }
+ return set;
+ }
+
+
}
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceType.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceType.java?rev=827036&r1=827035&r2=827036&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceType.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/ServiceType.java
Tue Oct 20 11:21:49 2009
@@ -53,8 +53,18 @@
{
int bitmap = 0;
if (set != null) {
- for (ServiceType a : set)
- bitmap += a.valueOf();
+ for (ServiceType t : set)
+ bitmap += t.valueOf();
+ }
+ return bitmap;
+ }
+
+ public static int bitmapOf(ServiceType... set)
+ {
+ int bitmap = 0;
+ if (set.length != 0) {
+ for (ServiceType t : set)
+ bitmap += t.valueOf();
}
return bitmap;
}
@@ -75,4 +85,14 @@
return set;
}
+ public static EnumSet<ServiceType> of(ServiceType... of)
+ {
+ EnumSet<ServiceType> set = EnumSet.noneOf(ServiceType.class);
+ if (of != null && of.length != 0) {
+ for (ServiceType t : of)
+ set.add(t);
+ }
+ return set;
+ }
+
}
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/VariantType.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/VariantType.java?rev=827036&r1=827035&r2=827036&view=diff
==============================================================================
---
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/VariantType.java
(original)
+++
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/VariantType.java
Tue Oct 20 11:21:49 2009
@@ -110,6 +110,22 @@
}
/**
+ * Integer representing the sum of the integer values
+ * of the {...@code VariantTypes} enums.
+ * @param set arguments of {...@code VariantType} which values to get.
+ * @return sum of {...@code VariantType} values
+ */
+ public static int bitmapOf(VariantType... set)
+ {
+ int bitmap = 0;
+ if (set.length != 0) {
+ for (VariantType v : set)
+ bitmap += v.valueOf();
+ }
+ return bitmap;
+ }
+
+ /**
* Returns {...@code EnumSet} of {...@code VariantType} enums
* from the integer bitmap value.
* @param value Integer used to construct the {...@code EnumSet}
@@ -132,4 +148,14 @@
return set;
}
+ public static EnumSet<VariantType> of(VariantType... of)
+ {
+ EnumSet<VariantType> set = EnumSet.noneOf(VariantType.class);
+ if (of != null && of.length != 0) {
+ for (VariantType t : of)
+ set.add(t);
+ }
+ return set;
+ }
+
}