You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/08/18 03:45:39 UTC
svn commit: r432462 [7/21] -
/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermission.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermission.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermission.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermission.java Thu Aug 17 18:45:35 2006
@@ -1,363 +1,363 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed 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 java.io;
-
-import java.security.AccessController;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.PrivilegedAction;
-
-import org.apache.harmony.luni.util.Msg;
-
-/**
- * The class FilePermission is responsible for granting access to files or
- * directories. The FilePermission is made up of a pathname and a set of actions
- * which are valid for the pathname.
- * <P>
- * The <code>File.separatorChar</code> must be used in all pathnames when
- * constructing a FilePermission. The following descriptions will assume the
- * char is </code>/</code>. A pathname which ends in "/*", implies all the
- * files and directories contained in that directory. If the pathname ends in
- * "/-", it indicates all the files and directories in that directory
- * <b>recursively</b>.
- *
- */
-public final class FilePermission extends Permission implements Serializable {
- private static final long serialVersionUID = 7930732926638008763L;
-
- // canonical path of this permission
- private transient String canonPath;
-
- // list of actions permitted for socket permission in order
- private static final String[] actionList = { "read", "write", "execute", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "delete" }; //$NON-NLS-1$
-
- // "canonicalized" action list
- private String actions;
-
- // the numeric representation of this action list
- // for implies() to check if one action list is the subset of another.
- transient int mask = -1;
-
- // global include all permission?
- private transient boolean includeAll = false;
-
- private transient boolean allDir = false;
-
- private transient boolean allSubdir = false;
-
- /**
- * Constructs a new FilePermission with the path and actions specified.
- *
- *
- * @param path
- * the path to apply the actions to.
- * @param actions
- * the actions for the <code>path<code>. May be any
- * combination of read, write, execute, or delete.
- */
- public FilePermission(String path, String actions) {
- super(path);
- init(path, actions);
- }
-
- private void init(final String path, String pathActions) {
- if (pathActions == null || pathActions.equals("")) { //$NON-NLS-1$
- throw new IllegalArgumentException(Msg.getString("K006d")); //$NON-NLS-1$
- }
- this.actions = toCanonicalActionString(pathActions);
-
- if (path == null) {
- throw new NullPointerException(Msg.getString("K006e")); //$NON-NLS-1$
- }
- if (path.equals("<<ALL FILES>>")) { //$NON-NLS-1$
- includeAll = true;
- } else {
- canonPath = AccessController
- .doPrivileged(new PrivilegedAction<String>() {
- public String run() {
- try {
- return new File(path).getCanonicalPath();
- } catch (IOException e) {
- return path;
- }
- }
- });
- if (path.equals("*") || path.endsWith(File.separator + "*")) { //$NON-NLS-1$ //$NON-NLS-2$
- allDir = true;
- }
- if (path.equals("-") || path.endsWith(File.separator + "-")) { //$NON-NLS-1$ //$NON-NLS-2$
- allSubdir = true;
- }
- }
- }
-
- /**
- * Answer the string representing this permissions actions. It must be of
- * the form "read,write,execute,delete", all lower case and in the correct
- * order if there is more than one action.
- *
- * @param action
- * the action name
- * @return the string representing this permission's actions
- */
- private String toCanonicalActionString(String action) {
- actions = action.trim().toLowerCase();
-
- // get the numerical representation of the action list
- mask = getMask(actions);
-
- // convert the mask to a canonical action list.
- int len = actionList.length;
- // the test mask - shift the 1 to the leftmost position of the
- // actionList
- int highestBitMask = 1 << (len - 1);
-
- // if a bit of mask is set, append the corresponding action to result
- StringBuilder result = new StringBuilder();
- boolean addedItem = false;
- for (int i = 0; i < len; i++) {
- if ((highestBitMask & mask) != 0) {
- if (addedItem) {
- result.append(","); //$NON-NLS-1$
- }
- result.append(actionList[i]);
- addedItem = true;
- }
- highestBitMask = highestBitMask >> 1;
- }
- return result.toString();
- }
-
- /**
- * Answers the numerical representation of the argument.
- *
- * @param actionNames
- * the action names
- * @return the action mask
- */
- private int getMask(String actionNames) {
- int actionInt = 0, head = 0, tail = 0;
- do {
- tail = actionNames.indexOf(",", head); //$NON-NLS-1$
- String action = tail > 0 ? actionNames.substring(head, tail).trim()
- : actionNames.substring(head).trim();
- if (action.equals("read")) { //$NON-NLS-1$
- actionInt |= 8;
- } else if (action.equals("write")) { //$NON-NLS-1$
- actionInt |= 4;
- } else if (action.equals("execute")) { //$NON-NLS-1$
- actionInt |= 2;
- } else if (action.equals("delete")) { //$NON-NLS-1$
- actionInt |= 1;
- } else {
- throw new IllegalArgumentException(Msg.getString(
- "K006f", action)); //$NON-NLS-1$
- }
- head = tail + 1;
- } while (tail > 0);
- return actionInt;
- }
-
- /**
- * Answers the actions associated with the receiver.
- *
- * @return the actions associated with the receiver.
- */
- @Override
- public String getActions() {
- return actions;
- }
-
- /**
- * Check to see if this permission is equal to another. The two are equal if
- * <code>obj</code> is a FilePermission, they have the same path, and they
- * have the same actions.
- *
- * @param obj
- * the object to check equality with.
- * @return <code>true</code> if the two are equal, <code>false</code>
- * otherwise.
- */
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof FilePermission) {
- FilePermission fp = (FilePermission) obj;
- if (fp.actions != actions) {
- if (fp.actions == null || !fp.actions.equals(actions)) {
- return false;
- }
- }
-
- /* Matching actions and both are <<ALL FILES>> ? */
- if (fp.includeAll || includeAll) {
- return fp.includeAll == includeAll;
- }
- return fp.canonPath.equals(canonPath);
- }
- return false;
- }
-
- /**
- * Indicates whether the argument permission is implied by the receiver.
- *
- * @param p
- * java.security.Permission the permission to check.
- * @return <code>true</code> if the argument permission is implied by the
- * receiver, and <code>false</code> if it is not.
- */
- @Override
- public boolean implies(Permission p) {
- int match = impliesMask(p);
- return match != 0 && match == ((FilePermission) p).mask;
- }
-
- /**
- * Answers an int describing what masks are implied by a specific
- * permission.
- *
- * @param p
- * the permission
- * @return the mask applied to the given permission
- */
- int impliesMask(Permission p) {
- if (!(p instanceof FilePermission)) {
- return 0;
- }
- FilePermission fp = (FilePermission) p;
- int matchedMask = mask & fp.mask;
- // Can't match any bits?
- if (matchedMask == 0) {
- return 0;
- }
-
- // Is this permission <<ALL FILES>>
- if (includeAll) {
- return matchedMask;
- }
-
- // We can't imply all files
- if (fp.includeAll) {
- return 0;
- }
-
- // Scan the length of p checking all match possibilities
- // \- implies everything except \
- int thisLength = canonPath.length();
- if (allSubdir && thisLength == 2
- && !fp.canonPath.equals(File.separator)) {
- return matchedMask;
- }
- // need /- to imply /-
- if (fp.allSubdir && !allSubdir) {
- return 0;
- }
- // need /- or /* to imply /*
- if (fp.allDir && !allSubdir && !allDir) {
- return 0;
- }
-
- boolean includeDir = false;
- int pLength = fp.canonPath.length();
- // do not compare the * or -
- if (allDir || allSubdir) {
- thisLength--;
- }
- if (fp.allDir || fp.allSubdir) {
- pLength--;
- }
- for (int i = 0; i < pLength; i++) {
- char pChar = fp.canonPath.charAt(i);
- // Is p longer than this permissions canonLength?
- if (i >= thisLength) {
- if (i == thisLength) {
- // Is this permission include all? (must have matched up
- // until this point).
- if (allSubdir) {
- return matchedMask;
- }
- // Is this permission include a dir? Continue the check
- // afterwards.
- if (allDir) {
- includeDir = true;
- }
- }
- // If not includeDir then is has to be a mismatch.
- if (!includeDir) {
- return 0;
- }
- /**
- * If we have * for this and find a separator it is invalid. IE:
- * this is '/a/*' and p is '/a/b/c' we should fail on the
- * separator after the b. Except for root, canonical paths do
- * not end in a separator.
- */
- if (pChar == File.separatorChar) {
- return 0;
- }
- } else {
- // Are the characters matched?
- if (canonPath.charAt(i) != pChar) {
- return 0;
- }
- }
- }
- // Must have matched upto this point or it's a valid file in an include
- // all directory
- if (pLength == thisLength) {
- if (allSubdir) {
- // /- implies /- or /*
- return fp.allSubdir || fp.allDir ? matchedMask : 0;
- } else {
- return allDir == fp.allDir ? matchedMask : 0;
- }
- }
- return includeDir ? matchedMask : 0;
- }
-
- /**
- * Answers a new PermissionCollection in which to place FilePermission
- * Objects.
- *
- * @return A new PermissionCollection suitable for storing FilePermission
- * objects.
- */
- @Override
- public PermissionCollection newPermissionCollection() {
- return new FilePermissionCollection();
- }
-
- /**
- * Answers an int representing the hash code value for this FilePermission.
- *
- * @return int the hash code value for this FilePermission.
- */
- @Override
- public int hashCode() {
- return (canonPath == null ?
- getName().hashCode() : canonPath.hashCode()) + mask;
- }
-
- private void writeObject(ObjectOutputStream stream) throws IOException {
- stream.defaultWriteObject();
- }
-
- private void readObject(ObjectInputStream stream) throws IOException,
- ClassNotFoundException {
- stream.defaultReadObject();
- init(getName(), actions);
- }
-}
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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 java.io;
+
+import java.security.AccessController;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.PrivilegedAction;
+
+import org.apache.harmony.luni.util.Msg;
+
+/**
+ * The class FilePermission is responsible for granting access to files or
+ * directories. The FilePermission is made up of a pathname and a set of actions
+ * which are valid for the pathname.
+ * <P>
+ * The <code>File.separatorChar</code> must be used in all pathnames when
+ * constructing a FilePermission. The following descriptions will assume the
+ * char is </code>/</code>. A pathname which ends in "/*", implies all the
+ * files and directories contained in that directory. If the pathname ends in
+ * "/-", it indicates all the files and directories in that directory
+ * <b>recursively</b>.
+ *
+ */
+public final class FilePermission extends Permission implements Serializable {
+ private static final long serialVersionUID = 7930732926638008763L;
+
+ // canonical path of this permission
+ private transient String canonPath;
+
+ // list of actions permitted for socket permission in order
+ private static final String[] actionList = { "read", "write", "execute", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "delete" }; //$NON-NLS-1$
+
+ // "canonicalized" action list
+ private String actions;
+
+ // the numeric representation of this action list
+ // for implies() to check if one action list is the subset of another.
+ transient int mask = -1;
+
+ // global include all permission?
+ private transient boolean includeAll = false;
+
+ private transient boolean allDir = false;
+
+ private transient boolean allSubdir = false;
+
+ /**
+ * Constructs a new FilePermission with the path and actions specified.
+ *
+ *
+ * @param path
+ * the path to apply the actions to.
+ * @param actions
+ * the actions for the <code>path<code>. May be any
+ * combination of read, write, execute, or delete.
+ */
+ public FilePermission(String path, String actions) {
+ super(path);
+ init(path, actions);
+ }
+
+ private void init(final String path, String pathActions) {
+ if (pathActions == null || pathActions.equals("")) { //$NON-NLS-1$
+ throw new IllegalArgumentException(Msg.getString("K006d")); //$NON-NLS-1$
+ }
+ this.actions = toCanonicalActionString(pathActions);
+
+ if (path == null) {
+ throw new NullPointerException(Msg.getString("K006e")); //$NON-NLS-1$
+ }
+ if (path.equals("<<ALL FILES>>")) { //$NON-NLS-1$
+ includeAll = true;
+ } else {
+ canonPath = AccessController
+ .doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+ try {
+ return new File(path).getCanonicalPath();
+ } catch (IOException e) {
+ return path;
+ }
+ }
+ });
+ if (path.equals("*") || path.endsWith(File.separator + "*")) { //$NON-NLS-1$ //$NON-NLS-2$
+ allDir = true;
+ }
+ if (path.equals("-") || path.endsWith(File.separator + "-")) { //$NON-NLS-1$ //$NON-NLS-2$
+ allSubdir = true;
+ }
+ }
+ }
+
+ /**
+ * Answer the string representing this permissions actions. It must be of
+ * the form "read,write,execute,delete", all lower case and in the correct
+ * order if there is more than one action.
+ *
+ * @param action
+ * the action name
+ * @return the string representing this permission's actions
+ */
+ private String toCanonicalActionString(String action) {
+ actions = action.trim().toLowerCase();
+
+ // get the numerical representation of the action list
+ mask = getMask(actions);
+
+ // convert the mask to a canonical action list.
+ int len = actionList.length;
+ // the test mask - shift the 1 to the leftmost position of the
+ // actionList
+ int highestBitMask = 1 << (len - 1);
+
+ // if a bit of mask is set, append the corresponding action to result
+ StringBuilder result = new StringBuilder();
+ boolean addedItem = false;
+ for (int i = 0; i < len; i++) {
+ if ((highestBitMask & mask) != 0) {
+ if (addedItem) {
+ result.append(","); //$NON-NLS-1$
+ }
+ result.append(actionList[i]);
+ addedItem = true;
+ }
+ highestBitMask = highestBitMask >> 1;
+ }
+ return result.toString();
+ }
+
+ /**
+ * Answers the numerical representation of the argument.
+ *
+ * @param actionNames
+ * the action names
+ * @return the action mask
+ */
+ private int getMask(String actionNames) {
+ int actionInt = 0, head = 0, tail = 0;
+ do {
+ tail = actionNames.indexOf(",", head); //$NON-NLS-1$
+ String action = tail > 0 ? actionNames.substring(head, tail).trim()
+ : actionNames.substring(head).trim();
+ if (action.equals("read")) { //$NON-NLS-1$
+ actionInt |= 8;
+ } else if (action.equals("write")) { //$NON-NLS-1$
+ actionInt |= 4;
+ } else if (action.equals("execute")) { //$NON-NLS-1$
+ actionInt |= 2;
+ } else if (action.equals("delete")) { //$NON-NLS-1$
+ actionInt |= 1;
+ } else {
+ throw new IllegalArgumentException(Msg.getString(
+ "K006f", action)); //$NON-NLS-1$
+ }
+ head = tail + 1;
+ } while (tail > 0);
+ return actionInt;
+ }
+
+ /**
+ * Answers the actions associated with the receiver.
+ *
+ * @return the actions associated with the receiver.
+ */
+ @Override
+ public String getActions() {
+ return actions;
+ }
+
+ /**
+ * Check to see if this permission is equal to another. The two are equal if
+ * <code>obj</code> is a FilePermission, they have the same path, and they
+ * have the same actions.
+ *
+ * @param obj
+ * the object to check equality with.
+ * @return <code>true</code> if the two are equal, <code>false</code>
+ * otherwise.
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof FilePermission) {
+ FilePermission fp = (FilePermission) obj;
+ if (fp.actions != actions) {
+ if (fp.actions == null || !fp.actions.equals(actions)) {
+ return false;
+ }
+ }
+
+ /* Matching actions and both are <<ALL FILES>> ? */
+ if (fp.includeAll || includeAll) {
+ return fp.includeAll == includeAll;
+ }
+ return fp.canonPath.equals(canonPath);
+ }
+ return false;
+ }
+
+ /**
+ * Indicates whether the argument permission is implied by the receiver.
+ *
+ * @param p
+ * java.security.Permission the permission to check.
+ * @return <code>true</code> if the argument permission is implied by the
+ * receiver, and <code>false</code> if it is not.
+ */
+ @Override
+ public boolean implies(Permission p) {
+ int match = impliesMask(p);
+ return match != 0 && match == ((FilePermission) p).mask;
+ }
+
+ /**
+ * Answers an int describing what masks are implied by a specific
+ * permission.
+ *
+ * @param p
+ * the permission
+ * @return the mask applied to the given permission
+ */
+ int impliesMask(Permission p) {
+ if (!(p instanceof FilePermission)) {
+ return 0;
+ }
+ FilePermission fp = (FilePermission) p;
+ int matchedMask = mask & fp.mask;
+ // Can't match any bits?
+ if (matchedMask == 0) {
+ return 0;
+ }
+
+ // Is this permission <<ALL FILES>>
+ if (includeAll) {
+ return matchedMask;
+ }
+
+ // We can't imply all files
+ if (fp.includeAll) {
+ return 0;
+ }
+
+ // Scan the length of p checking all match possibilities
+ // \- implies everything except \
+ int thisLength = canonPath.length();
+ if (allSubdir && thisLength == 2
+ && !fp.canonPath.equals(File.separator)) {
+ return matchedMask;
+ }
+ // need /- to imply /-
+ if (fp.allSubdir && !allSubdir) {
+ return 0;
+ }
+ // need /- or /* to imply /*
+ if (fp.allDir && !allSubdir && !allDir) {
+ return 0;
+ }
+
+ boolean includeDir = false;
+ int pLength = fp.canonPath.length();
+ // do not compare the * or -
+ if (allDir || allSubdir) {
+ thisLength--;
+ }
+ if (fp.allDir || fp.allSubdir) {
+ pLength--;
+ }
+ for (int i = 0; i < pLength; i++) {
+ char pChar = fp.canonPath.charAt(i);
+ // Is p longer than this permissions canonLength?
+ if (i >= thisLength) {
+ if (i == thisLength) {
+ // Is this permission include all? (must have matched up
+ // until this point).
+ if (allSubdir) {
+ return matchedMask;
+ }
+ // Is this permission include a dir? Continue the check
+ // afterwards.
+ if (allDir) {
+ includeDir = true;
+ }
+ }
+ // If not includeDir then is has to be a mismatch.
+ if (!includeDir) {
+ return 0;
+ }
+ /**
+ * If we have * for this and find a separator it is invalid. IE:
+ * this is '/a/*' and p is '/a/b/c' we should fail on the
+ * separator after the b. Except for root, canonical paths do
+ * not end in a separator.
+ */
+ if (pChar == File.separatorChar) {
+ return 0;
+ }
+ } else {
+ // Are the characters matched?
+ if (canonPath.charAt(i) != pChar) {
+ return 0;
+ }
+ }
+ }
+ // Must have matched upto this point or it's a valid file in an include
+ // all directory
+ if (pLength == thisLength) {
+ if (allSubdir) {
+ // /- implies /- or /*
+ return fp.allSubdir || fp.allDir ? matchedMask : 0;
+ } else {
+ return allDir == fp.allDir ? matchedMask : 0;
+ }
+ }
+ return includeDir ? matchedMask : 0;
+ }
+
+ /**
+ * Answers a new PermissionCollection in which to place FilePermission
+ * Objects.
+ *
+ * @return A new PermissionCollection suitable for storing FilePermission
+ * objects.
+ */
+ @Override
+ public PermissionCollection newPermissionCollection() {
+ return new FilePermissionCollection();
+ }
+
+ /**
+ * Answers an int representing the hash code value for this FilePermission.
+ *
+ * @return int the hash code value for this FilePermission.
+ */
+ @Override
+ public int hashCode() {
+ return (canonPath == null ?
+ getName().hashCode() : canonPath.hashCode()) + mask;
+ }
+
+ private void writeObject(ObjectOutputStream stream) throws IOException {
+ stream.defaultWriteObject();
+ }
+
+ private void readObject(ObjectInputStream stream) throws IOException,
+ ClassNotFoundException {
+ stream.defaultReadObject();
+ init(getName(), actions);
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermission.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermissionCollection.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermissionCollection.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermissionCollection.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermissionCollection.java Thu Aug 17 18:45:35 2006
@@ -1,90 +1,90 @@
-/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed 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 java.io;
-
-
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.util.Enumeration;
-import java.util.Vector;
-
-/**
- * FilePermissionCollection is a class which holds a collection of
- * FilePermission objects and can answer a boolean indicating whether or not a
- * specific permissions is implied by a FilePermissionCollection.
- *
- */
-final class FilePermissionCollection extends PermissionCollection
- implements Serializable {
- private static final long serialVersionUID = 2202956749081564585L;
-
- Vector<Permission> permissions = new Vector<Permission>();
-
- /**
- * Construct a new FilePermissionCollection.
- */
- public FilePermissionCollection() {
- super();
- }
-
- /**
- * Add a permission Object to the permission collection.
- *
- * @see java.security.PermissionCollection#add(java.security.Permission)
- */
- public void add(Permission permission) {
- if (!isReadOnly()) {
- if (permission instanceof FilePermission) {
- permissions.addElement(permission);
- } else {
- throw new IllegalArgumentException(permission.toString());
- }
- } else
- throw new IllegalStateException();
- }
-
- /**
- * Answers an enumeration for the collection of permissions.
- *
- * @see java.security.PermissionCollection#elements()
- */
- public Enumeration<Permission> elements() {
- return permissions.elements();
- }
-
- /**
- * Answers a boolean indicating whether or not this permissions collection
- * implies a specific <code>permission</code>.
- *
- * @see java.security.PermissionCollection#implies(java.security.Permission)
- */
- public boolean implies(Permission permission) {
- if (permission instanceof FilePermission) {
- FilePermission fp = (FilePermission) permission;
- int matchedMask = 0;
- int i = 0;
- while (i < permissions.size()
- && ((matchedMask & fp.mask) != fp.mask)) {
- // Cast will not fail since we added it
- matchedMask |= ((FilePermission) permissions.elementAt(i))
- .impliesMask(permission);
- i++;
- }
- return ((matchedMask & fp.mask) == fp.mask);
- }
- return false;
- }
-}
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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 java.io;
+
+
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ * FilePermissionCollection is a class which holds a collection of
+ * FilePermission objects and can answer a boolean indicating whether or not a
+ * specific permissions is implied by a FilePermissionCollection.
+ *
+ */
+final class FilePermissionCollection extends PermissionCollection
+ implements Serializable {
+ private static final long serialVersionUID = 2202956749081564585L;
+
+ Vector<Permission> permissions = new Vector<Permission>();
+
+ /**
+ * Construct a new FilePermissionCollection.
+ */
+ public FilePermissionCollection() {
+ super();
+ }
+
+ /**
+ * Add a permission Object to the permission collection.
+ *
+ * @see java.security.PermissionCollection#add(java.security.Permission)
+ */
+ public void add(Permission permission) {
+ if (!isReadOnly()) {
+ if (permission instanceof FilePermission) {
+ permissions.addElement(permission);
+ } else {
+ throw new IllegalArgumentException(permission.toString());
+ }
+ } else
+ throw new IllegalStateException();
+ }
+
+ /**
+ * Answers an enumeration for the collection of permissions.
+ *
+ * @see java.security.PermissionCollection#elements()
+ */
+ public Enumeration<Permission> elements() {
+ return permissions.elements();
+ }
+
+ /**
+ * Answers a boolean indicating whether or not this permissions collection
+ * implies a specific <code>permission</code>.
+ *
+ * @see java.security.PermissionCollection#implies(java.security.Permission)
+ */
+ public boolean implies(Permission permission) {
+ if (permission instanceof FilePermission) {
+ FilePermission fp = (FilePermission) permission;
+ int matchedMask = 0;
+ int i = 0;
+ while (i < permissions.size()
+ && ((matchedMask & fp.mask) != fp.mask)) {
+ // Cast will not fail since we added it
+ matchedMask |= ((FilePermission) permissions.elementAt(i))
+ .impliesMask(permission);
+ i++;
+ }
+ return ((matchedMask & fp.mask) == fp.mask);
+ }
+ return false;
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilePermissionCollection.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileReader.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileReader.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileReader.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileReader.java Thu Aug 17 18:45:35 2006
@@ -1,71 +1,71 @@
-/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed 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 java.io;
-
-
-/**
- * FileReader is class for turning a file into a character Stream. Data read
- * from the source is converted into characters. The encoding is assumed to
- * 8859_1. The FileReader contains a buffer of bytes read from the source and
- * converts these into characters as needed. The buffer size is 8K.
- *
- * @see FileWriter
- */
-public class FileReader extends InputStreamReader {
-
- /**
- * Construct a new FileReader on the given File <code>file</code>. If the
- * <code>file</code> specified cannot be found, throw a
- * FileNotFoundException.
- *
- * @param file
- * a File to be opened for reading characters from.
- *
- * @throws FileNotFoundException
- * if the file cannot be opened for reading.
- */
- public FileReader(File file) throws FileNotFoundException {
- super(new FileInputStream(file));
- }
-
- /**
- * Construct a new FileReader on the given FileDescriptor <code>fd</code>.
- * Since a previously opened FileDescriptor is passed as an argument, no
- * FileNotFoundException is thrown.
- *
- * @param fd
- * the previously opened file descriptor.
- */
- public FileReader(FileDescriptor fd) {
- super(new FileInputStream(fd));
- }
-
- /**
- * Construct a new FileReader on the given file named <code>filename</code>.
- * If the <code>filename</code> specified cannot be found, throw a
- * FileNotFoundException.
- *
- * @param filename
- * an absolute or relative path specifying the file to open.
- *
- * @throws FileNotFoundException
- * if the filename cannot be opened for reading.
- */
- public FileReader(String filename) throws FileNotFoundException {
- super(new FileInputStream(filename));
- }
-
-}
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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 java.io;
+
+
+/**
+ * FileReader is class for turning a file into a character Stream. Data read
+ * from the source is converted into characters. The encoding is assumed to
+ * 8859_1. The FileReader contains a buffer of bytes read from the source and
+ * converts these into characters as needed. The buffer size is 8K.
+ *
+ * @see FileWriter
+ */
+public class FileReader extends InputStreamReader {
+
+ /**
+ * Construct a new FileReader on the given File <code>file</code>. If the
+ * <code>file</code> specified cannot be found, throw a
+ * FileNotFoundException.
+ *
+ * @param file
+ * a File to be opened for reading characters from.
+ *
+ * @throws FileNotFoundException
+ * if the file cannot be opened for reading.
+ */
+ public FileReader(File file) throws FileNotFoundException {
+ super(new FileInputStream(file));
+ }
+
+ /**
+ * Construct a new FileReader on the given FileDescriptor <code>fd</code>.
+ * Since a previously opened FileDescriptor is passed as an argument, no
+ * FileNotFoundException is thrown.
+ *
+ * @param fd
+ * the previously opened file descriptor.
+ */
+ public FileReader(FileDescriptor fd) {
+ super(new FileInputStream(fd));
+ }
+
+ /**
+ * Construct a new FileReader on the given file named <code>filename</code>.
+ * If the <code>filename</code> specified cannot be found, throw a
+ * FileNotFoundException.
+ *
+ * @param filename
+ * an absolute or relative path specifying the file to open.
+ *
+ * @throws FileNotFoundException
+ * if the filename cannot be opened for reading.
+ */
+ public FileReader(String filename) throws FileNotFoundException {
+ super(new FileInputStream(filename));
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileWriter.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileWriter.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileWriter.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileWriter.java Thu Aug 17 18:45:35 2006
@@ -1,100 +1,100 @@
-/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed 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 java.io;
-
-
-/**
- * FileWriter is a class for writing characters out to a file. The default
- * character encoding, 8859_1 is currently used to convert characters to bytes
- * in the file.
- *
- * @see FileReader
- */
-public class FileWriter extends OutputStreamWriter {
-
- /**
- * Creates a FileWriter using the File <code>file</code>.
- *
- * @param file
- * the non-null File to write bytes to.
- *
- * @throws IOException
- * If the given file is not found
- */
- public FileWriter(File file) throws IOException {
- super(new FileOutputStream(file));
- }
-
- /**
- * Creates a FileWriter using the File <code>file</code>. The parameter
- * <code>append</code> determines whether or not the file is opened and
- * appended to or just opened empty.
- *
- * @param file
- * the non-null File to write bytes to.
- * @param append
- * should the file be appened to or opened empty.
- *
- * @throws IOException
- * If the given file is not found
- */
- public FileWriter(File file, boolean append) throws IOException {
- super(new FileOutputStream(file, append));
- }
-
- /**
- * Creates a FileWriter using the existing FileDescriptor <code>fd</code>.
- *
- * @param fd
- * the non-null FileDescriptor to write bytes to.
- */
- public FileWriter(FileDescriptor fd) {
- super(new FileOutputStream(fd));
- }
-
- /**
- * Creates a FileWriter using the platform dependent <code>filename</code>.
- * See the class description for how characters are converted to bytes.
- *
- * @param filename
- * the non-null name of the file to write bytes to.
- *
- * @throws IOException
- * If the given file is not found
- */
- public FileWriter(String filename) throws IOException {
- super(new FileOutputStream(new File(filename)));
- }
-
- /**
- * Creates a FileWriter using the platform dependent <code>filename</code>.
- * See the class description for how characters are converted to bytes. The
- * parameter <code>append</code> determines whether or not the file is
- * opened and appended to or just opened empty.
- *
- * @param filename
- * the non-null name of the file to write bytes to.
- * @param append
- * should the file be appened to or opened empty.
- *
- * @throws IOException
- * If the given file is not found
- */
- public FileWriter(String filename, boolean append) throws IOException {
- super(new FileOutputStream(filename, append));
- }
-
-}
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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 java.io;
+
+
+/**
+ * FileWriter is a class for writing characters out to a file. The default
+ * character encoding, 8859_1 is currently used to convert characters to bytes
+ * in the file.
+ *
+ * @see FileReader
+ */
+public class FileWriter extends OutputStreamWriter {
+
+ /**
+ * Creates a FileWriter using the File <code>file</code>.
+ *
+ * @param file
+ * the non-null File to write bytes to.
+ *
+ * @throws IOException
+ * If the given file is not found
+ */
+ public FileWriter(File file) throws IOException {
+ super(new FileOutputStream(file));
+ }
+
+ /**
+ * Creates a FileWriter using the File <code>file</code>. The parameter
+ * <code>append</code> determines whether or not the file is opened and
+ * appended to or just opened empty.
+ *
+ * @param file
+ * the non-null File to write bytes to.
+ * @param append
+ * should the file be appened to or opened empty.
+ *
+ * @throws IOException
+ * If the given file is not found
+ */
+ public FileWriter(File file, boolean append) throws IOException {
+ super(new FileOutputStream(file, append));
+ }
+
+ /**
+ * Creates a FileWriter using the existing FileDescriptor <code>fd</code>.
+ *
+ * @param fd
+ * the non-null FileDescriptor to write bytes to.
+ */
+ public FileWriter(FileDescriptor fd) {
+ super(new FileOutputStream(fd));
+ }
+
+ /**
+ * Creates a FileWriter using the platform dependent <code>filename</code>.
+ * See the class description for how characters are converted to bytes.
+ *
+ * @param filename
+ * the non-null name of the file to write bytes to.
+ *
+ * @throws IOException
+ * If the given file is not found
+ */
+ public FileWriter(String filename) throws IOException {
+ super(new FileOutputStream(new File(filename)));
+ }
+
+ /**
+ * Creates a FileWriter using the platform dependent <code>filename</code>.
+ * See the class description for how characters are converted to bytes. The
+ * parameter <code>append</code> determines whether or not the file is
+ * opened and appended to or just opened empty.
+ *
+ * @param filename
+ * the non-null name of the file to write bytes to.
+ * @param append
+ * should the file be appened to or opened empty.
+ *
+ * @throws IOException
+ * If the given file is not found
+ */
+ public FileWriter(String filename, boolean append) throws IOException {
+ super(new FileOutputStream(filename, append));
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FileWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilenameFilter.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilenameFilter.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilenameFilter.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilenameFilter.java Thu Aug 17 18:45:35 2006
@@ -1,38 +1,38 @@
-/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed 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 java.io;
-
-
-/**
- * FilenameFilter is an interface which declares methods for filtering file names
- * in the <code>list</code> method of File.
- *
- * @see File
- * @see File#list(FilenameFilter)
- */
-public interface FilenameFilter {
-
-/**
- * Answers a boolean if a specific filename matches a filter.
- *
- * @param dir the directory in which the <code>filename</code> was found.
- * @param filename the name of the file in <code>dir</dir> to test.
- * @return boolean <code>true</code> if the filename matches the filter and can be included
- * in the list, <code>false</code> otherwise.
- */
-public abstract boolean accept(File dir, String filename);
-
-}
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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 java.io;
+
+
+/**
+ * FilenameFilter is an interface which declares methods for filtering file names
+ * in the <code>list</code> method of File.
+ *
+ * @see File
+ * @see File#list(FilenameFilter)
+ */
+public interface FilenameFilter {
+
+/**
+ * Answers a boolean if a specific filename matches a filter.
+ *
+ * @param dir the directory in which the <code>filename</code> was found.
+ * @param filename the name of the file in <code>dir</dir> to test.
+ * @return boolean <code>true</code> if the filename matches the filter and can be included
+ * in the list, <code>false</code> otherwise.
+ */
+public abstract boolean accept(File dir, String filename);
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilenameFilter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterInputStream.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterInputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterInputStream.java Thu Aug 17 18:45:35 2006
@@ -1,187 +1,187 @@
-/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed 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 java.io;
-
-
-/**
- * FilteredInputStream is a class which takes an input stream and
- * <em>filters</em> the input in some way. The filtered view may be a buffered
- * view or one which uncompresses data before returning bytes read.
- * FilterInputStreams are meant for byte streams.
- *
- * @see FilterOutputStream
- */
-public class FilterInputStream extends InputStream {
-
- /**
- * The target InputStream which is being filtered.
- */
- protected volatile InputStream in;
-
- /**
- * Constructs a new FilterInputStream on the InputStream <code>in</code>.
- * All reads are now filtered through this stream.
- *
- * @param in
- * The non-null InputStream to filter reads on.
- */
- protected FilterInputStream(InputStream in) {
- super();
- this.in = in;
- }
-
- /**
- * Answers a int representing the number of bytes that are available before
- * this FilterInputStream will block. This method returns the number of
- * bytes available in the target stream.
- *
- * @return the number of bytes available before blocking.
- *
- * @throws IOException
- * If an error occurs in this stream.
- */
- public int available() throws IOException {
- return in.available();
- }
-
- /**
- * Close this FilterInputStream. This implementation closes the target
- * stream.
- *
- * @throws IOException
- * If an error occurs attempting to close this stream.
- */
- public void close() throws IOException {
- in.close();
- }
-
- /**
- * Set a Mark position in this FilterInputStream. The parameter
- * <code>readLimit</code> indicates how many bytes can be read before a
- * mark is invalidated. Sending reset() will reposition the Stream back to
- * the marked position provided <code>readLimit</code> has not been
- * surpassed.
- * <p>
- * This implementation sets a mark in the target stream.
- *
- * @param readlimit
- * the number of bytes to be able to read before invalidating the
- * mark.
- */
- public synchronized void mark(int readlimit) {
- in.mark(readlimit);
- }
-
- /**
- * Answers a boolean indicating whether or not this FilterInputStream
- * supports mark() and reset(). This implementation answers whether or not
- * the target stream supports marking.
- *
- * @return <code>true</code> if mark() and reset() are supported,
- * <code>false</code> otherwise.
- */
- public boolean markSupported() {
- return in.markSupported();
- }
-
- /**
- * Reads a single byte from this FilterInputStream and returns the result as
- * an int. The low-order byte is returned or -1 of the end of stream was
- * encountered. This implementation returns a byte from the target stream.
- *
- * @return the byte read or -1 if end of stream.
- *
- * @throws IOException
- * If the stream is already closed or another IOException
- * occurs.
- */
- public int read() throws IOException {
- return in.read();
- }
-
- /**
- * Reads bytes from this FilterInputStream and stores them in byte array
- * <code>buffer</code>. Answer the number of bytes actually read or -1 if
- * no bytes were read and end of stream was encountered. This implementation
- * reads bytes from the target stream.
- *
- * @param buffer
- * the byte array in which to store the read bytes.
- * @return the number of bytes actually read or -1 if end of stream.
- *
- * @throws IOException
- * If the stream is already closed or another IOException
- * occurs.
- */
- public int read(byte[] buffer) throws IOException {
- return read(buffer, 0, buffer.length);
- }
-
- /**
- * Reads at most <code>count</code> bytes from this FilterInputStream and
- * stores them in byte array <code>buffer</code> starting at
- * <code>offset</code>. Answer the number of bytes actually read or -1 if
- * no bytes were read and end of stream was encountered. This implementation
- * reads bytes from the target stream.
- *
- * @param buffer
- * the byte array in which to store the read bytes.
- * @param offset
- * the offset in <code>buffer</code> to store the read bytes.
- * @param count
- * the maximum number of bytes to store in <code>buffer</code>.
- * @return the number of bytes actually read or -1 if end of stream.
- *
- * @throws IOException
- * If the stream is already closed or another IOException
- * occurs.
- */
- public int read(byte[] buffer, int offset, int count) throws IOException {
- return in.read(buffer, offset, count);
- }
-
- /**
- * Reset this FilterInputStream to the last marked location. If the
- * <code>readlimit</code> has been passed or no <code>mark</code> has
- * been set, throw IOException. This implementation resets the target
- * stream.
- *
- * @throws IOException
- * If the stream is already closed or another IOException
- * occurs.
- */
- public synchronized void reset() throws IOException {
- in.reset();
- }
-
- /**
- * Skips <code>count</code> number of bytes in this InputStream.
- * Subsequent <code>read()</code>'s will not return these bytes unless
- * <code>reset()</code> is used. This implementation skips
- * <code>count</code> number of bytes in the target stream.
- *
- * @param count
- * the number of bytes to skip.
- * @return the number of bytes actually skipped.
- *
- * @throws IOException
- * If the stream is already closed or another IOException
- * occurs.
- */
- public long skip(long count) throws IOException {
- return in.skip(count);
- }
-}
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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 java.io;
+
+
+/**
+ * FilteredInputStream is a class which takes an input stream and
+ * <em>filters</em> the input in some way. The filtered view may be a buffered
+ * view or one which uncompresses data before returning bytes read.
+ * FilterInputStreams are meant for byte streams.
+ *
+ * @see FilterOutputStream
+ */
+public class FilterInputStream extends InputStream {
+
+ /**
+ * The target InputStream which is being filtered.
+ */
+ protected volatile InputStream in;
+
+ /**
+ * Constructs a new FilterInputStream on the InputStream <code>in</code>.
+ * All reads are now filtered through this stream.
+ *
+ * @param in
+ * The non-null InputStream to filter reads on.
+ */
+ protected FilterInputStream(InputStream in) {
+ super();
+ this.in = in;
+ }
+
+ /**
+ * Answers a int representing the number of bytes that are available before
+ * this FilterInputStream will block. This method returns the number of
+ * bytes available in the target stream.
+ *
+ * @return the number of bytes available before blocking.
+ *
+ * @throws IOException
+ * If an error occurs in this stream.
+ */
+ public int available() throws IOException {
+ return in.available();
+ }
+
+ /**
+ * Close this FilterInputStream. This implementation closes the target
+ * stream.
+ *
+ * @throws IOException
+ * If an error occurs attempting to close this stream.
+ */
+ public void close() throws IOException {
+ in.close();
+ }
+
+ /**
+ * Set a Mark position in this FilterInputStream. The parameter
+ * <code>readLimit</code> indicates how many bytes can be read before a
+ * mark is invalidated. Sending reset() will reposition the Stream back to
+ * the marked position provided <code>readLimit</code> has not been
+ * surpassed.
+ * <p>
+ * This implementation sets a mark in the target stream.
+ *
+ * @param readlimit
+ * the number of bytes to be able to read before invalidating the
+ * mark.
+ */
+ public synchronized void mark(int readlimit) {
+ in.mark(readlimit);
+ }
+
+ /**
+ * Answers a boolean indicating whether or not this FilterInputStream
+ * supports mark() and reset(). This implementation answers whether or not
+ * the target stream supports marking.
+ *
+ * @return <code>true</code> if mark() and reset() are supported,
+ * <code>false</code> otherwise.
+ */
+ public boolean markSupported() {
+ return in.markSupported();
+ }
+
+ /**
+ * Reads a single byte from this FilterInputStream and returns the result as
+ * an int. The low-order byte is returned or -1 of the end of stream was
+ * encountered. This implementation returns a byte from the target stream.
+ *
+ * @return the byte read or -1 if end of stream.
+ *
+ * @throws IOException
+ * If the stream is already closed or another IOException
+ * occurs.
+ */
+ public int read() throws IOException {
+ return in.read();
+ }
+
+ /**
+ * Reads bytes from this FilterInputStream and stores them in byte array
+ * <code>buffer</code>. Answer the number of bytes actually read or -1 if
+ * no bytes were read and end of stream was encountered. This implementation
+ * reads bytes from the target stream.
+ *
+ * @param buffer
+ * the byte array in which to store the read bytes.
+ * @return the number of bytes actually read or -1 if end of stream.
+ *
+ * @throws IOException
+ * If the stream is already closed or another IOException
+ * occurs.
+ */
+ public int read(byte[] buffer) throws IOException {
+ return read(buffer, 0, buffer.length);
+ }
+
+ /**
+ * Reads at most <code>count</code> bytes from this FilterInputStream and
+ * stores them in byte array <code>buffer</code> starting at
+ * <code>offset</code>. Answer the number of bytes actually read or -1 if
+ * no bytes were read and end of stream was encountered. This implementation
+ * reads bytes from the target stream.
+ *
+ * @param buffer
+ * the byte array in which to store the read bytes.
+ * @param offset
+ * the offset in <code>buffer</code> to store the read bytes.
+ * @param count
+ * the maximum number of bytes to store in <code>buffer</code>.
+ * @return the number of bytes actually read or -1 if end of stream.
+ *
+ * @throws IOException
+ * If the stream is already closed or another IOException
+ * occurs.
+ */
+ public int read(byte[] buffer, int offset, int count) throws IOException {
+ return in.read(buffer, offset, count);
+ }
+
+ /**
+ * Reset this FilterInputStream to the last marked location. If the
+ * <code>readlimit</code> has been passed or no <code>mark</code> has
+ * been set, throw IOException. This implementation resets the target
+ * stream.
+ *
+ * @throws IOException
+ * If the stream is already closed or another IOException
+ * occurs.
+ */
+ public synchronized void reset() throws IOException {
+ in.reset();
+ }
+
+ /**
+ * Skips <code>count</code> number of bytes in this InputStream.
+ * Subsequent <code>read()</code>'s will not return these bytes unless
+ * <code>reset()</code> is used. This implementation skips
+ * <code>count</code> number of bytes in the target stream.
+ *
+ * @param count
+ * the number of bytes to skip.
+ * @return the number of bytes actually skipped.
+ *
+ * @throws IOException
+ * If the stream is already closed or another IOException
+ * occurs.
+ */
+ public long skip(long count) throws IOException {
+ return in.skip(count);
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterInputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterOutputStream.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterOutputStream.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterOutputStream.java Thu Aug 17 18:45:35 2006
@@ -1,137 +1,137 @@
-/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed 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 java.io;
-
-
-/**
- * FilteredOutputStream is a class which takes an output stream and
- * <em>filters</em> the output in some way. The filtered view may be a
- * buffered output or one which compresses data before actually writing the
- * bytes. FilterOutputStreams are meant for byte streams.
- *
- * @see FilterInputStream
- */
-public class FilterOutputStream extends OutputStream {
-
- /**
- * The target OutputStream for this filter.
- */
- protected OutputStream out;
-
- /**
- * Constructs a new FilterOutputStream on the OutputStream <code>out</code>.
- * All writes are now filtered through this stream.
- *
- * @param out
- * the target OutputStream to filter writes on.
- */
- public FilterOutputStream(OutputStream out) {
- this.out = out;
- }
-
- /**
- * Close this FilterOutputStream. This implementation closes the target
- * stream.
- *
- * @throws IOException
- * If an error occurs attempting to close this stream.
- */
- public void close() throws IOException {
- try {
- flush();
- } catch (IOException e) {
- }
- /* Make sure we clean up this stream if exception fires */
- out.close();
- }
-
- /**
- * Flush this FilterOutputStream to ensure all pending data is sent out to
- * the target OutputStream. This implementation flushes the target
- * OutputStream.
- *
- * @throws IOException
- * If an error occurs attempting to flush this
- * FilterOutputStream.
- */
- public void flush() throws IOException {
- out.flush();
- }
-
- /**
- * Writes the entire contents of the byte array <code>buffer</code> to
- * this FilterOutputStream. This implementation writes the
- * <code>buffer</code> to the target stream.
- *
- * @param buffer
- * the buffer to be written
- *
- * @throws IOException
- * If an error occurs attempting to write to this
- * FilterOutputStream.
- */
- public void write(byte buffer[]) throws IOException {
- write(buffer, 0, buffer.length);
- }
-
- /**
- * Writes <code>count</code> <code>bytes</code> from the byte array
- * <code>buffer</code> starting at <code>offset</code> to this
- * FilterOutputStream. This implementation writes the <code>buffer</code>
- * to the target OutputStream.
- *
- * @param buffer
- * the buffer to be written
- * @param offset
- * offset in buffer to get bytes
- * @param count
- * number of bytes in buffer to write
- *
- * @throws IOException
- * If an error occurs attempting to write to this
- * FilterOutputStream.
- * @throws IndexOutOfBoundsException
- * If offset or count are outside of bounds.
- */
- public void write(byte buffer[], int offset, int count) throws IOException {
- // avoid int overflow, check null buffer
- if (offset <= buffer.length && 0 <= offset && 0 <= count
- && count <= buffer.length - offset) {
- for (int i = 0; i < count; i++)
- // Call write() instead of out.write() since subclasses could
- // override the write() method.
- write(buffer[offset + i]);
- } else
- throw new ArrayIndexOutOfBoundsException(org.apache.harmony.luni.util.Msg
- .getString("K002f")); //$NON-NLS-1$
- }
-
- /**
- * Writes the specified byte <code>oneByte</code> to this
- * FilterOutputStream. Only the low order byte of <code>oneByte</code> is
- * written. This implementation writes the byte to the target OutputStream.
- *
- * @param oneByte
- * the byte to be written
- *
- * @throws IOException
- * If an error occurs attempting to write to this
- * FilterOutputStream.
- */
- public void write(int oneByte) throws IOException {
- out.write(oneByte);
- }
-}
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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 java.io;
+
+
+/**
+ * FilteredOutputStream is a class which takes an output stream and
+ * <em>filters</em> the output in some way. The filtered view may be a
+ * buffered output or one which compresses data before actually writing the
+ * bytes. FilterOutputStreams are meant for byte streams.
+ *
+ * @see FilterInputStream
+ */
+public class FilterOutputStream extends OutputStream {
+
+ /**
+ * The target OutputStream for this filter.
+ */
+ protected OutputStream out;
+
+ /**
+ * Constructs a new FilterOutputStream on the OutputStream <code>out</code>.
+ * All writes are now filtered through this stream.
+ *
+ * @param out
+ * the target OutputStream to filter writes on.
+ */
+ public FilterOutputStream(OutputStream out) {
+ this.out = out;
+ }
+
+ /**
+ * Close this FilterOutputStream. This implementation closes the target
+ * stream.
+ *
+ * @throws IOException
+ * If an error occurs attempting to close this stream.
+ */
+ public void close() throws IOException {
+ try {
+ flush();
+ } catch (IOException e) {
+ }
+ /* Make sure we clean up this stream if exception fires */
+ out.close();
+ }
+
+ /**
+ * Flush this FilterOutputStream to ensure all pending data is sent out to
+ * the target OutputStream. This implementation flushes the target
+ * OutputStream.
+ *
+ * @throws IOException
+ * If an error occurs attempting to flush this
+ * FilterOutputStream.
+ */
+ public void flush() throws IOException {
+ out.flush();
+ }
+
+ /**
+ * Writes the entire contents of the byte array <code>buffer</code> to
+ * this FilterOutputStream. This implementation writes the
+ * <code>buffer</code> to the target stream.
+ *
+ * @param buffer
+ * the buffer to be written
+ *
+ * @throws IOException
+ * If an error occurs attempting to write to this
+ * FilterOutputStream.
+ */
+ public void write(byte buffer[]) throws IOException {
+ write(buffer, 0, buffer.length);
+ }
+
+ /**
+ * Writes <code>count</code> <code>bytes</code> from the byte array
+ * <code>buffer</code> starting at <code>offset</code> to this
+ * FilterOutputStream. This implementation writes the <code>buffer</code>
+ * to the target OutputStream.
+ *
+ * @param buffer
+ * the buffer to be written
+ * @param offset
+ * offset in buffer to get bytes
+ * @param count
+ * number of bytes in buffer to write
+ *
+ * @throws IOException
+ * If an error occurs attempting to write to this
+ * FilterOutputStream.
+ * @throws IndexOutOfBoundsException
+ * If offset or count are outside of bounds.
+ */
+ public void write(byte buffer[], int offset, int count) throws IOException {
+ // avoid int overflow, check null buffer
+ if (offset <= buffer.length && 0 <= offset && 0 <= count
+ && count <= buffer.length - offset) {
+ for (int i = 0; i < count; i++)
+ // Call write() instead of out.write() since subclasses could
+ // override the write() method.
+ write(buffer[offset + i]);
+ } else
+ throw new ArrayIndexOutOfBoundsException(org.apache.harmony.luni.util.Msg
+ .getString("K002f")); //$NON-NLS-1$
+ }
+
+ /**
+ * Writes the specified byte <code>oneByte</code> to this
+ * FilterOutputStream. Only the low order byte of <code>oneByte</code> is
+ * written. This implementation writes the byte to the target OutputStream.
+ *
+ * @param oneByte
+ * the byte to be written
+ *
+ * @throws IOException
+ * If an error occurs attempting to write to this
+ * FilterOutputStream.
+ */
+ public void write(int oneByte) throws IOException {
+ out.write(oneByte);
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterOutputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterReader.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterReader.java?rev=432462&r1=432461&r2=432462&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterReader.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterReader.java Thu Aug 17 18:45:35 2006
@@ -1,192 +1,192 @@
-/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
- *
- * Licensed 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 java.io;
-
-
-/**
- * FilterReader is a class which takes a Reader and <em>filters</em> the input
- * in some way. The filtered view may be a buffered view or one which
- * uncompresses data before returning characters read.
- *
- * @see FilterWriter
- */
-public abstract class FilterReader extends Reader {
-
- /**
- * The target Reader which is being filtered.
- */
- protected Reader in;
-
- /**
- * Constructs a new FilterReader on the Reader <code>in</code>. All reads
- * are now filtered through this Reader.
- *
- * @param in
- * The non-null Reader to filter reads on.
- */
- protected FilterReader(Reader in) {
- super(in);
- this.in = in;
- }
-
- /**
- * Close this FilterReader. This implementation closes the target Reader.
- *
- * @throws IOException
- * If an error occurs attempting to close this Reader.
- */
- public void close() throws IOException {
- synchronized (lock) {
- in.close();
- }
- }
-
- /**
- * Set a Mark position in this FilterReader. The parameter
- * <code>readLimit</code> indicates how many characters can be read before
- * a mark is invalidated. Sending reset() will reposition the Reader back to
- * the marked position provided <code>readLimit</code> has not been
- * surpassed.
- * <p>
- * This implementation sets a mark in the target Reader.
- *
- * @param readlimit
- * the number of characters to be able to read before
- * invalidating the mark.
- *
- * @throws IOException
- * If an error occurs attempting mark this Reader.
- */
- public synchronized void mark(int readlimit) throws IOException {
- synchronized (lock) {
- in.mark(readlimit);
- }
- }
-
- /**
- * Answers a boolean indicating whether or not this FilterReader supports
- * mark() and reset(). This implementation answers whether or not the target
- * Reader supports marking.
- *
- * @return indicates whether or not mark() and reset() are supported.
- */
- public boolean markSupported() {
- synchronized (lock) {
- return in.markSupported();
- }
- }
-
- /**
- * Reads a single char from this FilterReader and returns the result as an
- * int. The 2 lowest order bytes are returned or -1 of the end of reader was
- * encountered. This implementation returns a char from the target Reader.
- *
- * @return The byte read or -1 if end of reader.
- *
- * @throws IOException
- * If an error occurs attempting to read from this Reader.
- */
- public int read() throws IOException {
- synchronized (lock) {
- return in.read();
- }
- }
-
- /**
- * Reads at most <code>count</code> chars from this FilterReader and
- * stores them in char array <code>buffer</code> starting at offset
- * <code>offset</code>. Answer the number of chars actually read or -1 if
- * no chars were read and end of reader was encountered. This implementation
- * reads chars from the target reader.
- *
- * @param buffer
- * the char array in which to store the read chars.
- * @param offset
- * the offset in <code>buffer</code> to store the read chars.
- * @param count
- * the maximum number of chars to store in <code>buffer</code>.
- * @return the number of chars actually read or -1 if end of reader.
- *
- * @throws IOException
- * If an error occurs attempting to read from this Reader.
- */
- public int read(char[] buffer, int offset, int count) throws IOException {
- synchronized (lock) {
- return in.read(buffer, offset, count);
- }
- }
-
- /**
- * Answers a <code>boolean</code> indicating whether or not this Reader is
- * ready to be read without blocking. If the result is <code>true</code>,
- * the next <code>read()</code> will not block. If the result is
- * <code>false</code> this Reader may or may not block when
- * <code>read()</code> is sent.
- *
- * @return <code>true</code> if the receiver will not block when
- * <code>read()</code> is called, <code>false</code> if unknown
- * or blocking will occur.
- *
- * @throws IOException
- * If the Reader is already closed or some other IO error
- * occurs.
- */
-
- public boolean ready() throws IOException {
- synchronized (lock) {
- return in.ready();
- }
- }
-
- /**
- * Reset this Readers position to the last <code>mark()</code> location.
- * Invocations of <code>read()/skip()</code> will occur from this new
- * location. If this Reader was not marked, the implementation of
- * <code>reset()</code> is implementation specific. See the comment for
- * the specific Reader subclass for implementation details. The default
- * action is to throw <code>IOException</code>.
- *
- * @throws IOException
- * if a problem occured or the target Reader does not support
- * <code>mark()/reset()</code>.
- */
- public void reset() throws IOException {
- synchronized (lock) {
- in.reset();
- }
- }
-
- /**
- * Skips <code>count</code> number of characters in this Reader.
- * Subsequent <code>read()</code>'s will not return these characters
- * unless <code>reset()</code> is used. The default implementation is to
- * skip chars in the filtered Reader.
- *
- * @param count
- * the maximum number of characters to skip.
- * @return the number of characters actually skipped.
- *
- * @throws IOException
- * If the Reader is already closed or some other IO error
- * occurs.
- */
- public long skip(long count) throws IOException {
- synchronized (lock) {
- return in.skip(count);
- }
- }
-
-}
+/* Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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 java.io;
+
+
+/**
+ * FilterReader is a class which takes a Reader and <em>filters</em> the input
+ * in some way. The filtered view may be a buffered view or one which
+ * uncompresses data before returning characters read.
+ *
+ * @see FilterWriter
+ */
+public abstract class FilterReader extends Reader {
+
+ /**
+ * The target Reader which is being filtered.
+ */
+ protected Reader in;
+
+ /**
+ * Constructs a new FilterReader on the Reader <code>in</code>. All reads
+ * are now filtered through this Reader.
+ *
+ * @param in
+ * The non-null Reader to filter reads on.
+ */
+ protected FilterReader(Reader in) {
+ super(in);
+ this.in = in;
+ }
+
+ /**
+ * Close this FilterReader. This implementation closes the target Reader.
+ *
+ * @throws IOException
+ * If an error occurs attempting to close this Reader.
+ */
+ public void close() throws IOException {
+ synchronized (lock) {
+ in.close();
+ }
+ }
+
+ /**
+ * Set a Mark position in this FilterReader. The parameter
+ * <code>readLimit</code> indicates how many characters can be read before
+ * a mark is invalidated. Sending reset() will reposition the Reader back to
+ * the marked position provided <code>readLimit</code> has not been
+ * surpassed.
+ * <p>
+ * This implementation sets a mark in the target Reader.
+ *
+ * @param readlimit
+ * the number of characters to be able to read before
+ * invalidating the mark.
+ *
+ * @throws IOException
+ * If an error occurs attempting mark this Reader.
+ */
+ public synchronized void mark(int readlimit) throws IOException {
+ synchronized (lock) {
+ in.mark(readlimit);
+ }
+ }
+
+ /**
+ * Answers a boolean indicating whether or not this FilterReader supports
+ * mark() and reset(). This implementation answers whether or not the target
+ * Reader supports marking.
+ *
+ * @return indicates whether or not mark() and reset() are supported.
+ */
+ public boolean markSupported() {
+ synchronized (lock) {
+ return in.markSupported();
+ }
+ }
+
+ /**
+ * Reads a single char from this FilterReader and returns the result as an
+ * int. The 2 lowest order bytes are returned or -1 of the end of reader was
+ * encountered. This implementation returns a char from the target Reader.
+ *
+ * @return The byte read or -1 if end of reader.
+ *
+ * @throws IOException
+ * If an error occurs attempting to read from this Reader.
+ */
+ public int read() throws IOException {
+ synchronized (lock) {
+ return in.read();
+ }
+ }
+
+ /**
+ * Reads at most <code>count</code> chars from this FilterReader and
+ * stores them in char array <code>buffer</code> starting at offset
+ * <code>offset</code>. Answer the number of chars actually read or -1 if
+ * no chars were read and end of reader was encountered. This implementation
+ * reads chars from the target reader.
+ *
+ * @param buffer
+ * the char array in which to store the read chars.
+ * @param offset
+ * the offset in <code>buffer</code> to store the read chars.
+ * @param count
+ * the maximum number of chars to store in <code>buffer</code>.
+ * @return the number of chars actually read or -1 if end of reader.
+ *
+ * @throws IOException
+ * If an error occurs attempting to read from this Reader.
+ */
+ public int read(char[] buffer, int offset, int count) throws IOException {
+ synchronized (lock) {
+ return in.read(buffer, offset, count);
+ }
+ }
+
+ /**
+ * Answers a <code>boolean</code> indicating whether or not this Reader is
+ * ready to be read without blocking. If the result is <code>true</code>,
+ * the next <code>read()</code> will not block. If the result is
+ * <code>false</code> this Reader may or may not block when
+ * <code>read()</code> is sent.
+ *
+ * @return <code>true</code> if the receiver will not block when
+ * <code>read()</code> is called, <code>false</code> if unknown
+ * or blocking will occur.
+ *
+ * @throws IOException
+ * If the Reader is already closed or some other IO error
+ * occurs.
+ */
+
+ public boolean ready() throws IOException {
+ synchronized (lock) {
+ return in.ready();
+ }
+ }
+
+ /**
+ * Reset this Readers position to the last <code>mark()</code> location.
+ * Invocations of <code>read()/skip()</code> will occur from this new
+ * location. If this Reader was not marked, the implementation of
+ * <code>reset()</code> is implementation specific. See the comment for
+ * the specific Reader subclass for implementation details. The default
+ * action is to throw <code>IOException</code>.
+ *
+ * @throws IOException
+ * if a problem occured or the target Reader does not support
+ * <code>mark()/reset()</code>.
+ */
+ public void reset() throws IOException {
+ synchronized (lock) {
+ in.reset();
+ }
+ }
+
+ /**
+ * Skips <code>count</code> number of characters in this Reader.
+ * Subsequent <code>read()</code>'s will not return these characters
+ * unless <code>reset()</code> is used. The default implementation is to
+ * skip chars in the filtered Reader.
+ *
+ * @param count
+ * the maximum number of characters to skip.
+ * @return the number of characters actually skipped.
+ *
+ * @throws IOException
+ * If the Reader is already closed or some other IO error
+ * occurs.
+ */
+ public long skip(long count) throws IOException {
+ synchronized (lock) {
+ return in.skip(count);
+ }
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/FilterReader.java
------------------------------------------------------------------------------
svn:eol-style = native