You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2007/01/04 18:47:05 UTC
svn commit: r492652 [12/13] -
/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SequenceInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SequenceInputStream.java?view=diff&rev=492652&r1=492651&r2=492652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SequenceInputStream.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SequenceInputStream.java Thu Jan 4 09:47:01 2007
@@ -27,165 +27,165 @@
*
*/
public class SequenceInputStream extends InputStream {
- /**
- * An enumeration which will return types of InputStream.
- */
- private Enumeration<? extends InputStream> e;
-
- /**
- * The current input stream.
- */
- private InputStream in;
-
- /**
- * Constructs a new SequenceInputStream using the two streams
- * <code>s1</code> and <code>s2</code> as the sequence of streams to
- * read from.
- *
- * @param s1
- * the first stream to get bytes from
- * @param s2
- * the second stream to get bytes from
- */
- public SequenceInputStream(InputStream s1, InputStream s2) {
- if (s1 == null) {
- throw new NullPointerException();
- }
- Vector<InputStream> inVector = new Vector<InputStream>(1);
- inVector.addElement(s2);
- e = inVector.elements();
- in = s1;
- }
-
- /**
- * Constructs a new SequenceInputStream using the elements returned from
- * Enumeration <code>e</code> as the stream sequence. The types returned
- * from nextElement() must be of InputStream.
- *
- * @param e
- * the Enumeration of InputStreams to get bytes from
- */
- public SequenceInputStream(Enumeration<? extends InputStream> e) {
- this.e = e;
- if (e.hasMoreElements()) {
- in = e.nextElement();
- if (in == null) {
+ /**
+ * An enumeration which will return types of InputStream.
+ */
+ private Enumeration<? extends InputStream> e;
+
+ /**
+ * The current input stream.
+ */
+ private InputStream in;
+
+ /**
+ * Constructs a new SequenceInputStream using the two streams
+ * <code>s1</code> and <code>s2</code> as the sequence of streams to
+ * read from.
+ *
+ * @param s1
+ * the first stream to get bytes from
+ * @param s2
+ * the second stream to get bytes from
+ */
+ public SequenceInputStream(InputStream s1, InputStream s2) {
+ if (s1 == null) {
+ throw new NullPointerException();
+ }
+ Vector<InputStream> inVector = new Vector<InputStream>(1);
+ inVector.addElement(s2);
+ e = inVector.elements();
+ in = s1;
+ }
+
+ /**
+ * Constructs a new SequenceInputStream using the elements returned from
+ * Enumeration <code>e</code> as the stream sequence. The types returned
+ * from nextElement() must be of InputStream.
+ *
+ * @param e
+ * the Enumeration of InputStreams to get bytes from
+ */
+ public SequenceInputStream(Enumeration<? extends InputStream> e) {
+ this.e = e;
+ if (e.hasMoreElements()) {
+ in = e.nextElement();
+ if (in == null) {
throw new NullPointerException();
}
- }
- }
+ }
+ }
- /**
- * Answers a int representing then number of bytes that are available before
- * this InputStream will block.
- *
- * @return the number of bytes available before blocking.
- *
- * @throws IOException
- * If an error occurs in this InputStream.
- */
- @Override
+ /**
+ * Answers a int representing then number of bytes that are available before
+ * this InputStream will block.
+ *
+ * @return the number of bytes available before blocking.
+ *
+ * @throws IOException
+ * If an error occurs in this InputStream.
+ */
+ @Override
public int available() throws IOException {
- if (e != null && in != null) {
+ if (e != null && in != null) {
return in.available();
}
- return 0;
- }
+ return 0;
+ }
- /**
- * Close the SequenceInputStream. All streams in this sequence are closed
- * before returning from this method. This stream cannot be used for input
- * once it has been closed.
- *
- * @throws IOException
- * If an error occurs attempting to close this FileInputStream.
- */
- @Override
+ /**
+ * Close the SequenceInputStream. All streams in this sequence are closed
+ * before returning from this method. This stream cannot be used for input
+ * once it has been closed.
+ *
+ * @throws IOException
+ * If an error occurs attempting to close this FileInputStream.
+ */
+ @Override
public void close() throws IOException {
- while (in != null) {
- nextStream();
- }
- e = null;
- }
-
- /**
- * Sets up the next InputStream or leaves it alone if there are none left.
- *
- * @throws IOException
- */
- private void nextStream() throws IOException {
- if (in != null) {
+ while (in != null) {
+ nextStream();
+ }
+ e = null;
+ }
+
+ /**
+ * Sets up the next InputStream or leaves it alone if there are none left.
+ *
+ * @throws IOException
+ */
+ private void nextStream() throws IOException {
+ if (in != null) {
in.close();
}
- if (e.hasMoreElements()) {
- in = e.nextElement();
- if (in == null) {
+ if (e.hasMoreElements()) {
+ in = e.nextElement();
+ if (in == null) {
throw new NullPointerException();
}
- } else {
- in = null;
- }
- }
-
- /**
- * Reads a single byte from this SequenceInputStream and returns the result
- * as an int. The low-order byte is returned or -1 of the end of stream was
- * encountered. The current stream is read from. If it reaches the end of
- * file, the next stream is read from.
- *
- * @return the byte read or -1 if end of stream.
- *
- * @throws IOException
- * If an error occurs while reading the stream
- */
- @Override
+ } else {
+ in = null;
+ }
+ }
+
+ /**
+ * Reads a single byte from this SequenceInputStream and returns the result
+ * as an int. The low-order byte is returned or -1 of the end of stream was
+ * encountered. The current stream is read from. If it reaches the end of
+ * file, the next stream is read from.
+ *
+ * @return the byte read or -1 if end of stream.
+ *
+ * @throws IOException
+ * If an error occurs while reading the stream
+ */
+ @Override
public int read() throws IOException {
- while (in != null) {
- int result = in.read();
- if (result >= 0) {
+ while (in != null) {
+ int result = in.read();
+ if (result >= 0) {
return result;
}
- nextStream();
- }
- return -1;
- }
-
- /**
- * Reads at most <code>count</code> bytes from this SequenceInputStream
- * 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.
- *
- * @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 an error occurs while reading the stream
- */
- @Override
+ nextStream();
+ }
+ return -1;
+ }
+
+ /**
+ * Reads at most <code>count</code> bytes from this SequenceInputStream
+ * 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.
+ *
+ * @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 an error occurs while reading the stream
+ */
+ @Override
public int read(byte[] buffer, int offset, int count) throws IOException {
- if (in == null) {
- return -1;
- }
- if (buffer == null) {
- throw new NullPointerException();
- }
- // avoid int overflow
- if (offset < 0 || offset > buffer.length - count || count < 0) {
- throw new IndexOutOfBoundsException();
- }
- while (in != null) {
- int result = in.read(buffer, offset, count);
- if (result >= 0) {
- return result;
- }
- nextStream();
- }
- return -1;
- }
+ if (in == null) {
+ return -1;
+ }
+ if (buffer == null) {
+ throw new NullPointerException();
+ }
+ // avoid int overflow
+ if (offset < 0 || offset > buffer.length - count || count < 0) {
+ throw new IndexOutOfBoundsException();
+ }
+ while (in != null) {
+ int result = in.read(buffer, offset, count);
+ if (result >= 0) {
+ return result;
+ }
+ nextStream();
+ }
+ return -1;
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Serializable.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Serializable.java?view=diff&rev=492652&r1=492651&r2=492652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Serializable.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/Serializable.java Thu Jan 4 09:47:01 2007
@@ -22,5 +22,5 @@
* ObjectOutputStream/ObjectInputStream should implement this interface.
*/
public interface Serializable {
- /* empty */
+ /* empty */
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SerializablePermission.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SerializablePermission.java?view=diff&rev=492652&r1=492651&r2=492652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SerializablePermission.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SerializablePermission.java Thu Jan 4 09:47:01 2007
@@ -19,7 +19,6 @@
import java.security.BasicPermission;
-
/**
* SerializablePermission objects represent permission to access unsafe
* serialization operations. The name of the permission should be one of:
@@ -33,32 +32,32 @@
* @see ObjectStreamConstants
*/
public final class SerializablePermission extends BasicPermission {
- private static final long serialVersionUID = 8537212141160296410L;
+ private static final long serialVersionUID = 8537212141160296410L;
- //Serializable field
- @SuppressWarnings("unused")
+ // Serializable field
+ @SuppressWarnings("unused")
private String actions;
- /**
- * Creates an instance of this class with the given name.
- *
- * @param permissionName
- * the name of the new permission.
- */
- public SerializablePermission(String permissionName) {
- super(permissionName);
- }
+ /**
+ * Creates an instance of this class with the given name.
+ *
+ * @param permissionName
+ * the name of the new permission.
+ */
+ public SerializablePermission(String permissionName) {
+ super(permissionName);
+ }
- /**
- * Creates an instance of this class with the given name and action list.
- * The action list is ignored.
- *
- * @param name
- * the name of the new permission.
- * @param actions
- * ignored.
- */
- public SerializablePermission(String name, String actions) {
- super(name, actions);
- }
+ /**
+ * Creates an instance of this class with the given name and action list.
+ * The action list is ignored.
+ *
+ * @param name
+ * the name of the new permission.
+ * @param actions
+ * ignored.
+ */
+ public SerializablePermission(String name, String actions) {
+ super(name, actions);
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StreamCorruptedException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StreamCorruptedException.java?view=diff&rev=492652&r1=492651&r2=492652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StreamCorruptedException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StreamCorruptedException.java Thu Jan 4 09:47:01 2007
@@ -17,7 +17,6 @@
package java.io;
-
/**
* When readObject() cannot read an object from the input stream due to missing
* information (cyclic reference that doesn't match previous instance or missing
@@ -29,24 +28,23 @@
*/
public class StreamCorruptedException extends ObjectStreamException {
- private static final long serialVersionUID = 8983558202217591746L;
-
- /**
- * Constructs a new instance of this class with its walkback filled in.
- */
- public StreamCorruptedException() {
- super();
- }
+ private static final long serialVersionUID = 8983558202217591746L;
- /**
- * Constructs a new instance of this class with its walkback and message
- * filled in.
- *
- * @param detailMessage
- * the detail message for the exception.
- */
- public StreamCorruptedException(String detailMessage) {
- super(detailMessage);
- }
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ */
+ public StreamCorruptedException() {
+ super();
+ }
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ * @param detailMessage
+ * the detail message for the exception.
+ */
+ public StreamCorruptedException(String detailMessage) {
+ super(detailMessage);
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StreamTokenizer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StreamTokenizer.java?view=diff&rev=492652&r1=492651&r2=492652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StreamTokenizer.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StreamTokenizer.java Thu Jan 4 09:47:01 2007
@@ -17,453 +17,449 @@
package java.io;
-
/**
* StreamTokenizer takes a stream and a set of tokens and parses them one at a
* time. The different types of tokens that can be found are numbers,
* identifiers, quoted strings, and different comment styles.
- *
*/
public class StreamTokenizer {
- /**
- * Contains a number if the current token is a number (<code>ttype</code>
- * is <code>TT_NUMBER</code>)
- */
- public double nval;
-
- /**
- * Contains a string if the current token is a word (<code>ttype</code>
- * is <code>TT_WORD</code>)
- */
- public String sval;
-
- /**
- * After calling <code>nextToken</code>, the field <code>ttype</code>
- * contains the type of token that has been read. When a single character is
- * read, it's integer value is used. For a quoted string, the value is the
- * quoted character. If not one of those, then it is one of the following:
- * <UL>
- * <LI> <code>TT_WORD</code> - the token is a word.</LI>
- * <LI> <code>TT_NUMBER</code> - the token is a number.</LI>
- * <LI> <code>TT_EOL</code> - the end of line has been reached. Depends on
- * whether <code>eolIsSignificant</code> is <code>true</code>.</LI>
- * <LI> <code>TT_EOF</code> - the end of the stream has been reached.</LI>
- * </UL>
- */
-
- /**
- * The constant representing end of stream.
- */
- public static final int TT_EOF = -1;
-
- /**
- * The constant representing end of line.
- */
- public static final int TT_EOL = '\n';
-
- /**
- * The constant representing a number token.
- */
- public static final int TT_NUMBER = -2;
-
- /**
- * The constant representing a word token.
- */
- public static final int TT_WORD = -3;
-
- /**
- * Internal representation of unknown state.
- */
- private static final int TT_UNKNOWN = -4;
-
- /**
- * The token type
- */
- public int ttype = TT_UNKNOWN;
-
- /**
- * Internal character meanings, 0 implies TOKEN_ORDINARY
- */
- private byte tokenTypes[] = new byte[256];
-
- private static final byte TOKEN_COMMENT = 1;
-
- private static final byte TOKEN_QUOTE = 2;
-
- private static final byte TOKEN_WHITE = 4;
-
- private static final byte TOKEN_WORD = 8;
-
- private static final byte TOKEN_DIGIT = 16;
-
- private int lineNumber = 1;
-
- private boolean forceLowercase;
-
- private boolean isEOLSignificant;
-
- private boolean slashStarComments;
-
- private boolean slashSlashComments;
-
- private boolean pushBackToken;
-
- private boolean lastCr;
-
- /* One of these will have the stream */
- private InputStream inStream;
-
- private Reader inReader;
-
- private int peekChar = -2;
-
- /**
- * Private constructor to initialize the default values according to the
- * specification.
- */
- private StreamTokenizer() {
- /**
- * Initialize the default state per specification. All byte values 'A'
- * through 'Z', 'a' through 'z', and '\u00A0' through '\u00FF' are
- * considered to be alphabetic.
- */
- wordChars('A', 'Z');
- wordChars('a', 'z');
- wordChars(160, 255);
- /**
- * All byte values '\u0000' through '\u0020' are considered to be white
- * space.
- */
- whitespaceChars(0, 32);
- /**
- * '/' is a comment character. Single quote '\'' and double quote '"'
- * are string quote characters.
- */
- commentChar('/');
- quoteChar('"');
- quoteChar('\'');
- /**
- * Numbers are parsed.
- */
- parseNumbers();
- /**
- * Ends of lines are treated as white space, not as separate tokens.
- * C-style and C++-style comments are not recognized. These are the
- * defaults and are not needed in constructor.
- */
- }
-
- /**
- * Construct a new StreamTokenizer on the InputStream is. This usage of this
- * method should be replaced with the constructor which takes a Reader.
- *
- * @param is
- * The InputStream to parse tokens on.
- *
- * @deprecated Use StreamTokenizer(Reader)
- */
- @Deprecated
+ /**
+ * Contains a number if the current token is a number (<code>ttype</code>
+ * is <code>TT_NUMBER</code>)
+ */
+ public double nval;
+
+ /**
+ * Contains a string if the current token is a word (<code>ttype</code>
+ * is <code>TT_WORD</code>)
+ */
+ public String sval;
+
+ /**
+ * After calling <code>nextToken</code>, the field <code>ttype</code>
+ * contains the type of token that has been read. When a single character is
+ * read, it's integer value is used. For a quoted string, the value is the
+ * quoted character. If not one of those, then it is one of the following:
+ * <UL>
+ * <LI> <code>TT_WORD</code> - the token is a word.</LI>
+ * <LI> <code>TT_NUMBER</code> - the token is a number.</LI>
+ * <LI> <code>TT_EOL</code> - the end of line has been reached. Depends on
+ * whether <code>eolIsSignificant</code> is <code>true</code>.</LI>
+ * <LI> <code>TT_EOF</code> - the end of the stream has been reached.</LI>
+ * </UL>
+ */
+
+ /**
+ * The constant representing end of stream.
+ */
+ public static final int TT_EOF = -1;
+
+ /**
+ * The constant representing end of line.
+ */
+ public static final int TT_EOL = '\n';
+
+ /**
+ * The constant representing a number token.
+ */
+ public static final int TT_NUMBER = -2;
+
+ /**
+ * The constant representing a word token.
+ */
+ public static final int TT_WORD = -3;
+
+ /**
+ * Internal representation of unknown state.
+ */
+ private static final int TT_UNKNOWN = -4;
+
+ /**
+ * The token type
+ */
+ public int ttype = TT_UNKNOWN;
+
+ /**
+ * Internal character meanings, 0 implies TOKEN_ORDINARY
+ */
+ private byte tokenTypes[] = new byte[256];
+
+ private static final byte TOKEN_COMMENT = 1;
+
+ private static final byte TOKEN_QUOTE = 2;
+
+ private static final byte TOKEN_WHITE = 4;
+
+ private static final byte TOKEN_WORD = 8;
+
+ private static final byte TOKEN_DIGIT = 16;
+
+ private int lineNumber = 1;
+
+ private boolean forceLowercase;
+
+ private boolean isEOLSignificant;
+
+ private boolean slashStarComments;
+
+ private boolean slashSlashComments;
+
+ private boolean pushBackToken;
+
+ private boolean lastCr;
+
+ /* One of these will have the stream */
+ private InputStream inStream;
+
+ private Reader inReader;
+
+ private int peekChar = -2;
+
+ /**
+ * Private constructor to initialize the default values according to the
+ * specification.
+ */
+ private StreamTokenizer() {
+ /**
+ * Initialize the default state per specification. All byte values 'A'
+ * through 'Z', 'a' through 'z', and '\u00A0' through '\u00FF' are
+ * considered to be alphabetic.
+ */
+ wordChars('A', 'Z');
+ wordChars('a', 'z');
+ wordChars(160, 255);
+ /**
+ * All byte values '\u0000' through '\u0020' are considered to be white
+ * space.
+ */
+ whitespaceChars(0, 32);
+ /**
+ * '/' is a comment character. Single quote '\'' and double quote '"'
+ * are string quote characters.
+ */
+ commentChar('/');
+ quoteChar('"');
+ quoteChar('\'');
+ /**
+ * Numbers are parsed.
+ */
+ parseNumbers();
+ /**
+ * Ends of lines are treated as white space, not as separate tokens.
+ * C-style and C++-style comments are not recognized. These are the
+ * defaults and are not needed in constructor.
+ */
+ }
+
+ /**
+ * Construct a new StreamTokenizer on the InputStream is. This usage of this
+ * method should be replaced with the constructor which takes a Reader.
+ *
+ * @param is
+ * The InputStream to parse tokens on.
+ *
+ * @deprecated Use StreamTokenizer(Reader)
+ */
+ @Deprecated
public StreamTokenizer(InputStream is) {
- this();
- if (is != null) {
- inStream = is;
- } else {
+ this();
+ if (is == null) {
throw new NullPointerException();
}
- }
+ inStream = is;
+ }
- /**
- * Construct a new StreamTokenizer on the Reader <code>r</code>.
- * Initialize the default state per specification.
- * <UL>
- * <LI>All byte values 'A' through 'Z', 'a' through 'z', and '\u00A0'
- * through '\u00FF' are considered to be alphabetic.</LI>
- * <LI>All byte values '\u0000' through '\u0020' are considered to be white
- * space. '/' is a comment character.</LI>
- * <LI>Single quote '\'' and double quote '"' are string quote characters.</LI>
- * <LI>Numbers are parsed.</LI>
- * <LI>Ends of lines are considered to be white space rather than separate
- * tokens.</LI>
- * <LI>C-style and C++-style comments are not recognized.</LI>
- * </UL>
- * These are the defaults and are not needed in constructor.
- *
- * @param r
- * The InputStream to parse tokens on.
- */
- public StreamTokenizer(Reader r) {
- this();
- if (r != null) {
- inReader = r;
- } else {
+ /**
+ * Construct a new StreamTokenizer on the Reader <code>r</code>.
+ * Initialize the default state per specification.
+ * <UL>
+ * <LI>All byte values 'A' through 'Z', 'a' through 'z', and '\u00A0'
+ * through '\u00FF' are considered to be alphabetic.</LI>
+ * <LI>All byte values '\u0000' through '\u0020' are considered to be white
+ * space. '/' is a comment character.</LI>
+ * <LI>Single quote '\'' and double quote '"' are string quote characters.</LI>
+ * <LI>Numbers are parsed.</LI>
+ * <LI>Ends of lines are considered to be white space rather than separate
+ * tokens.</LI>
+ * <LI>C-style and C++-style comments are not recognized.</LI>
+ * </UL>
+ * These are the defaults and are not needed in constructor.
+ *
+ * @param r
+ * The InputStream to parse tokens on.
+ */
+ public StreamTokenizer(Reader r) {
+ this();
+ if (r == null) {
throw new NullPointerException();
}
- }
+ inReader = r;
+ }
- /**
- * Set the character <code>ch</code> to be regarded as a comment
- * character.
- *
- * @param ch
- * The character to be considered a comment character.
- */
- public void commentChar(int ch) {
- if (0 <= ch && ch < tokenTypes.length) {
+ /**
+ * Set the character <code>ch</code> to be regarded as a comment
+ * character.
+ *
+ * @param ch
+ * The character to be considered a comment character.
+ */
+ public void commentChar(int ch) {
+ if (0 <= ch && ch < tokenTypes.length) {
tokenTypes[ch] = TOKEN_COMMENT;
}
- }
+ }
- /**
- * Set a boolean indicating whether or not end of line is significant and
- * should be returned as <code>TT_EOF</code> in <code>ttype</code>.
- *
- * @param flag
- * <code>true</code> if EOL is significant, <code>false</code>
- * otherwise.
- */
- public void eolIsSignificant(boolean flag) {
- isEOLSignificant = flag;
- }
-
- /**
- * Answer the current line number.
- *
- * @return the current line number.
- */
- public int lineno() {
- return lineNumber;
- }
-
- /**
- * Set a boolean indicating whether or not tokens should be uppercased when
- * present in <code>sval</code>.
- *
- * @param flag
- * <code>true</code> if <code>sval</code> should be forced
- * uppercase, <code>false</code> otherwise.
- */
- public void lowerCaseMode(boolean flag) {
- forceLowercase = flag;
- }
-
- /**
- * Answer the next token type.
- *
- * @return The next token to be parsed.
- *
- * @throws IOException
- * If an IO error occurs while getting the token
- */
- public int nextToken() throws IOException {
- if (pushBackToken) {
- pushBackToken = false;
- if (ttype != TT_UNKNOWN) {
+ /**
+ * Set a boolean indicating whether or not end of line is significant and
+ * should be returned as <code>TT_EOF</code> in <code>ttype</code>.
+ *
+ * @param flag
+ * <code>true</code> if EOL is significant, <code>false</code>
+ * otherwise.
+ */
+ public void eolIsSignificant(boolean flag) {
+ isEOLSignificant = flag;
+ }
+
+ /**
+ * Answer the current line number.
+ *
+ * @return the current line number.
+ */
+ public int lineno() {
+ return lineNumber;
+ }
+
+ /**
+ * Set a boolean indicating whether or not tokens should be uppercased when
+ * present in <code>sval</code>.
+ *
+ * @param flag
+ * <code>true</code> if <code>sval</code> should be forced
+ * uppercase, <code>false</code> otherwise.
+ */
+ public void lowerCaseMode(boolean flag) {
+ forceLowercase = flag;
+ }
+
+ /**
+ * Answer the next token type.
+ *
+ * @return The next token to be parsed.
+ *
+ * @throws IOException
+ * If an IO error occurs while getting the token
+ */
+ public int nextToken() throws IOException {
+ if (pushBackToken) {
+ pushBackToken = false;
+ if (ttype != TT_UNKNOWN) {
return ttype;
}
- }
- sval = null; // Always reset sval to null
- int currentChar = peekChar == -2 ? read() : peekChar;
-
- if (lastCr && currentChar == '\n') {
- lastCr = false;
- currentChar = read();
- }
- if (currentChar == -1) {
+ }
+ sval = null; // Always reset sval to null
+ int currentChar = peekChar == -2 ? read() : peekChar;
+
+ if (lastCr && currentChar == '\n') {
+ lastCr = false;
+ currentChar = read();
+ }
+ if (currentChar == -1) {
return (ttype = TT_EOF);
}
- byte currentType = currentChar > 255 ? TOKEN_WORD
- : tokenTypes[currentChar];
- while ((currentType & TOKEN_WHITE) != 0) {
- /**
- * Skip over white space until we hit a new line or a real token
- */
- if (currentChar == '\r') {
- lineNumber++;
- if (isEOLSignificant) {
- lastCr = true;
- peekChar = -2;
- return (ttype = TT_EOL);
- }
- if ((currentChar = read()) == '\n') {
+ byte currentType = currentChar > 255 ? TOKEN_WORD
+ : tokenTypes[currentChar];
+ while ((currentType & TOKEN_WHITE) != 0) {
+ /**
+ * Skip over white space until we hit a new line or a real token
+ */
+ if (currentChar == '\r') {
+ lineNumber++;
+ if (isEOLSignificant) {
+ lastCr = true;
+ peekChar = -2;
+ return (ttype = TT_EOL);
+ }
+ if ((currentChar = read()) == '\n') {
currentChar = read();
}
- } else if (currentChar == '\n') {
- lineNumber++;
- if (isEOLSignificant) {
- peekChar = -2;
- return (ttype = TT_EOL);
- }
- currentChar = read();
- } else {
- // Advance over this white space character and try again.
- currentChar = read();
- }
- if (currentChar == -1) {
+ } else if (currentChar == '\n') {
+ lineNumber++;
+ if (isEOLSignificant) {
+ peekChar = -2;
+ return (ttype = TT_EOL);
+ }
+ currentChar = read();
+ } else {
+ // Advance over this white space character and try again.
+ currentChar = read();
+ }
+ if (currentChar == -1) {
return (ttype = TT_EOF);
}
- currentType = currentChar > 255 ? TOKEN_WORD
- : tokenTypes[currentChar];
- }
-
- /**
- * Check for digits before checking for words since digits can be
- * contained within words.
- */
- if ((currentType & TOKEN_DIGIT) != 0) {
+ currentType = currentChar > 255 ? TOKEN_WORD
+ : tokenTypes[currentChar];
+ }
+
+ /**
+ * Check for digits before checking for words since digits can be
+ * contained within words.
+ */
+ if ((currentType & TOKEN_DIGIT) != 0) {
StringBuilder digits = new StringBuilder(20);
- boolean haveDecimal = false, checkJustNegative = currentChar == '-';
- while (true) {
- if (currentChar == '.') {
+ boolean haveDecimal = false, checkJustNegative = currentChar == '-';
+ while (true) {
+ if (currentChar == '.') {
haveDecimal = true;
}
- digits.append((char) currentChar);
- currentChar = read();
- if ((currentChar < '0' || currentChar > '9')
- && (haveDecimal || currentChar != '.')) {
+ digits.append((char) currentChar);
+ currentChar = read();
+ if ((currentChar < '0' || currentChar > '9')
+ && (haveDecimal || currentChar != '.')) {
break;
}
- }
- peekChar = currentChar;
- if (checkJustNegative && digits.length() == 1) {
+ }
+ peekChar = currentChar;
+ if (checkJustNegative && digits.length() == 1) {
// Didn't get any other digits other than '-'
- return (ttype = '-');
+ return (ttype = '-');
+ }
+ try {
+ nval = Double.valueOf(digits.toString()).doubleValue();
+ } catch (NumberFormatException e) {
+ // Unsure what to do, will write test.
+ nval = 0;
}
- try {
- nval = Double.valueOf(digits.toString()).doubleValue();
- } catch (NumberFormatException e) {
- // Unsure what to do, will write test.
- nval = 0;
- }
- return (ttype = TT_NUMBER);
- }
- // Check for words
- if ((currentType & TOKEN_WORD) != 0) {
- StringBuffer word = new StringBuffer(20);
- while (true) {
- word.append((char) currentChar);
- currentChar = read();
- if (currentChar == -1
- || (currentChar < 256 && (tokenTypes[currentChar] & (TOKEN_WORD | TOKEN_DIGIT)) == 0)) {
+ return (ttype = TT_NUMBER);
+ }
+ // Check for words
+ if ((currentType & TOKEN_WORD) != 0) {
+ StringBuffer word = new StringBuffer(20);
+ while (true) {
+ word.append((char) currentChar);
+ currentChar = read();
+ if (currentChar == -1
+ || (currentChar < 256 && (tokenTypes[currentChar] & (TOKEN_WORD | TOKEN_DIGIT)) == 0)) {
break;
}
- }
- peekChar = currentChar;
- sval = forceLowercase ? word.toString().toLowerCase() : word
- .toString();
- return (ttype = TT_WORD);
- }
- // Check for quoted character
- if (currentType == TOKEN_QUOTE) {
- int matchQuote = currentChar;
- StringBuffer quoteString = new StringBuffer();
- int peekOne = read();
- while (peekOne >= 0 && peekOne != matchQuote && peekOne != '\r'
- && peekOne != '\n') {
- boolean readPeek = true;
- if (peekOne == '\\') {
- int c1 = read();
- // Check for quoted octal IE: \377
- if (c1 <= '7' && c1 >= '0') {
- int digitValue = c1 - '0';
- c1 = read();
- if (c1 > '7' || c1 < '0') {
- readPeek = false;
- } else {
- digitValue = digitValue * 8 + (c1 - '0');
- c1 = read();
- // limit the digit value to a byte
- if (digitValue > 037 || c1 > '7' || c1 < '0') {
+ }
+ peekChar = currentChar;
+ sval = forceLowercase ? word.toString().toLowerCase() : word
+ .toString();
+ return (ttype = TT_WORD);
+ }
+ // Check for quoted character
+ if (currentType == TOKEN_QUOTE) {
+ int matchQuote = currentChar;
+ StringBuffer quoteString = new StringBuffer();
+ int peekOne = read();
+ while (peekOne >= 0 && peekOne != matchQuote && peekOne != '\r'
+ && peekOne != '\n') {
+ boolean readPeek = true;
+ if (peekOne == '\\') {
+ int c1 = read();
+ // Check for quoted octal IE: \377
+ if (c1 <= '7' && c1 >= '0') {
+ int digitValue = c1 - '0';
+ c1 = read();
+ if (c1 > '7' || c1 < '0') {
+ readPeek = false;
+ } else {
+ digitValue = digitValue * 8 + (c1 - '0');
+ c1 = read();
+ // limit the digit value to a byte
+ if (digitValue > 037 || c1 > '7' || c1 < '0') {
readPeek = false;
} else {
digitValue = digitValue * 8 + (c1 - '0');
}
- }
- if (!readPeek) {
- // We've consumed one to many
- quoteString.append((char) digitValue);
- peekOne = c1;
- } else {
- peekOne = digitValue;
- }
- } else {
- switch (c1) {
- case 'a':
- peekOne = 0x7;
- break;
- case 'b':
- peekOne = 0x8;
- break;
- case 'f':
- peekOne = 0xc;
- break;
- case 'n':
- peekOne = 0xA;
- break;
- case 'r':
- peekOne = 0xD;
- break;
- case 't':
- peekOne = 0x9;
- break;
- case 'v':
- peekOne = 0xB;
- break;
- default:
- peekOne = c1;
- }
- }
- }
- if (readPeek) {
- quoteString.append((char) peekOne);
- peekOne = read();
- }
- }
- if (peekOne == matchQuote) {
+ }
+ if (!readPeek) {
+ // We've consumed one to many
+ quoteString.append((char) digitValue);
+ peekOne = c1;
+ } else {
+ peekOne = digitValue;
+ }
+ } else {
+ switch (c1) {
+ case 'a':
+ peekOne = 0x7;
+ break;
+ case 'b':
+ peekOne = 0x8;
+ break;
+ case 'f':
+ peekOne = 0xc;
+ break;
+ case 'n':
+ peekOne = 0xA;
+ break;
+ case 'r':
+ peekOne = 0xD;
+ break;
+ case 't':
+ peekOne = 0x9;
+ break;
+ case 'v':
+ peekOne = 0xB;
+ break;
+ default:
+ peekOne = c1;
+ }
+ }
+ }
+ if (readPeek) {
+ quoteString.append((char) peekOne);
+ peekOne = read();
+ }
+ }
+ if (peekOne == matchQuote) {
peekOne = read();
}
- peekChar = peekOne;
- ttype = matchQuote;
- sval = quoteString.toString();
- return ttype;
- }
- // Do comments, both "//" and "/*stuff*/"
- if (currentChar == '/' && (slashSlashComments || slashStarComments)) {
- if ((currentChar = read()) == '*' && slashStarComments) {
- int peekOne = read();
- while (true) {
- currentChar = peekOne;
- peekOne = read();
- if (currentChar == -1) {
- peekChar = -1;
- return (ttype = TT_EOF);
- }
- if (currentChar == '\r') {
- if (peekOne == '\n') {
+ peekChar = peekOne;
+ ttype = matchQuote;
+ sval = quoteString.toString();
+ return ttype;
+ }
+ // Do comments, both "//" and "/*stuff*/"
+ if (currentChar == '/' && (slashSlashComments || slashStarComments)) {
+ if ((currentChar = read()) == '*' && slashStarComments) {
+ int peekOne = read();
+ while (true) {
+ currentChar = peekOne;
+ peekOne = read();
+ if (currentChar == -1) {
+ peekChar = -1;
+ return (ttype = TT_EOF);
+ }
+ if (currentChar == '\r') {
+ if (peekOne == '\n') {
peekOne = read();
}
- lineNumber++;
- } else if (currentChar == '\n') {
- lineNumber++;
- } else if (currentChar == '*' && peekOne == '/') {
- peekChar = read();
- return nextToken();
- }
- }
- } else if (currentChar == '/' && slashSlashComments) {
- // Skip to EOF or new line then return the next token
- while ((currentChar = read()) >= 0 && currentChar != '\r'
- && currentChar != '\n') {
- // Intentionally empty
- }
- peekChar = currentChar;
- return nextToken();
- } else if(currentType != TOKEN_COMMENT){
- // Was just a slash by itself
- peekChar = currentChar;
- return (ttype = '/');
- }
- }
+ lineNumber++;
+ } else if (currentChar == '\n') {
+ lineNumber++;
+ } else if (currentChar == '*' && peekOne == '/') {
+ peekChar = read();
+ return nextToken();
+ }
+ }
+ } else if (currentChar == '/' && slashSlashComments) {
+ // Skip to EOF or new line then return the next token
+ while ((currentChar = read()) >= 0 && currentChar != '\r'
+ && currentChar != '\n') {
+ // Intentionally empty
+ }
+ peekChar = currentChar;
+ return nextToken();
+ } else if (currentType != TOKEN_COMMENT) {
+ // Was just a slash by itself
+ peekChar = currentChar;
+ return (ttype = '/');
+ }
+ }
// Check for comment character
if (currentType == TOKEN_COMMENT) {
// Skip to EOF or new line then return the next token
@@ -474,192 +470,192 @@
peekChar = currentChar;
return nextToken();
}
-
- peekChar = read();
- return (ttype = currentChar);
- }
-
- /**
- * Set the character <code>ch</code> to be regarded as an ordinary
- * character.
- *
- * @param ch
- * The character to be considered an ordinary comment character.
- */
- public void ordinaryChar(int ch) {
- if (0 <= ch && ch < tokenTypes.length) {
+
+ peekChar = read();
+ return (ttype = currentChar);
+ }
+
+ /**
+ * Set the character <code>ch</code> to be regarded as an ordinary
+ * character.
+ *
+ * @param ch
+ * The character to be considered an ordinary comment character.
+ */
+ public void ordinaryChar(int ch) {
+ if (0 <= ch && ch < tokenTypes.length) {
tokenTypes[ch] = 0;
}
- }
+ }
- /**
- * Set the characters ranging from <code>low</code> to <code>hi</code>
- * to be regarded as ordinary characters.
- *
- * @param low
- * The starting range for ordinary characters.
- * @param hi
- * The ending range for ordinary characters.
- */
- public void ordinaryChars(int low, int hi) {
- if (low < 0) {
+ /**
+ * Set the characters ranging from <code>low</code> to <code>hi</code>
+ * to be regarded as ordinary characters.
+ *
+ * @param low
+ * The starting range for ordinary characters.
+ * @param hi
+ * The ending range for ordinary characters.
+ */
+ public void ordinaryChars(int low, int hi) {
+ if (low < 0) {
low = 0;
}
- if (hi > tokenTypes.length) {
+ if (hi > tokenTypes.length) {
hi = tokenTypes.length - 1;
}
- for (int i = low; i <= hi; i++) {
+ for (int i = low; i <= hi; i++) {
tokenTypes[i] = 0;
}
- }
+ }
- /**
- * Indicate that numbers should be parsed.
- */
- public void parseNumbers() {
- for (int i = '0'; i <= '9'; i++) {
+ /**
+ * Indicate that numbers should be parsed.
+ */
+ public void parseNumbers() {
+ for (int i = '0'; i <= '9'; i++) {
tokenTypes[i] |= TOKEN_DIGIT;
}
- tokenTypes['.'] |= TOKEN_DIGIT;
- tokenTypes['-'] |= TOKEN_DIGIT;
- }
-
- /**
- * Indicate that the current token should be pushed back and returned the
- * next time <code>nextToken()</code> is called.
- */
- public void pushBack() {
- pushBackToken = true;
- }
-
- /**
- * Set the character <code>ch</code> to be regarded as a quote character.
- *
- * @param ch
- * The character to be considered a quote comment character.
- */
- public void quoteChar(int ch) {
- if (0 <= ch && ch < tokenTypes.length) {
+ tokenTypes['.'] |= TOKEN_DIGIT;
+ tokenTypes['-'] |= TOKEN_DIGIT;
+ }
+
+ /**
+ * Indicate that the current token should be pushed back and returned the
+ * next time <code>nextToken()</code> is called.
+ */
+ public void pushBack() {
+ pushBackToken = true;
+ }
+
+ /**
+ * Set the character <code>ch</code> to be regarded as a quote character.
+ *
+ * @param ch
+ * The character to be considered a quote comment character.
+ */
+ public void quoteChar(int ch) {
+ if (0 <= ch && ch < tokenTypes.length) {
tokenTypes[ch] = TOKEN_QUOTE;
}
- }
+ }
- private int read() throws IOException {
- // Call the read for the appropriate stream
- if (inStream == null) {
+ private int read() throws IOException {
+ // Call the read for the appropriate stream
+ if (inStream == null) {
return inReader.read();
}
- return inStream.read();
- }
+ return inStream.read();
+ }
- /**
- * Reset all characters so that they are ordinary.
- */
- public void resetSyntax() {
- for (int i = 0; i < 256; i++) {
+ /**
+ * Reset all characters so that they are ordinary.
+ */
+ public void resetSyntax() {
+ for (int i = 0; i < 256; i++) {
tokenTypes[i] = 0;
}
- }
+ }
- /**
- * Set a boolean indicating whether or not slash slash comments should be
- * recognized. The comment ends at a new line.
- *
- * @param flag
- * <code>true</code> if <code>//</code> should be recognized
- * as the start of a comment, <code>false</code> otherwise.
- */
- public void slashSlashComments(boolean flag) {
- slashSlashComments = flag;
- }
-
- /**
- * Set a boolean indicating whether or not slash star comments should be
- * recognized. Slash-star comments cannot be nested and end when a
- * star-slash combination is found.
- *
- * @param flag
- * <code>true</code> if <code>/*</code> should be recognized
- * as the start of a comment, <code>false</code> otherwise.
- */
- public void slashStarComments(boolean flag) {
- slashStarComments = flag;
- }
-
- /**
- * Answer the state of this tokenizer in a readable format.
- *
- * @return The current state of this tokenizer.
- */
- @Override
+ /**
+ * Set a boolean indicating whether or not slash slash comments should be
+ * recognized. The comment ends at a new line.
+ *
+ * @param flag
+ * <code>true</code> if <code>//</code> should be recognized
+ * as the start of a comment, <code>false</code> otherwise.
+ */
+ public void slashSlashComments(boolean flag) {
+ slashSlashComments = flag;
+ }
+
+ /**
+ * Set a boolean indicating whether or not slash star comments should be
+ * recognized. Slash-star comments cannot be nested and end when a
+ * star-slash combination is found.
+ *
+ * @param flag
+ * <code>true</code> if <code>/*</code> should be recognized
+ * as the start of a comment, <code>false</code> otherwise.
+ */
+ public void slashStarComments(boolean flag) {
+ slashStarComments = flag;
+ }
+
+ /**
+ * Answer the state of this tokenizer in a readable format.
+ *
+ * @return The current state of this tokenizer.
+ */
+ @Override
public String toString() {
- // Values determined through experimentation
+ // Values determined through experimentation
StringBuilder result = new StringBuilder();
- result.append("Token["); //$NON-NLS-1$
- switch (ttype) {
- case TT_EOF:
- result.append("EOF"); //$NON-NLS-1$
- break;
- case TT_EOL:
- result.append("EOL"); //$NON-NLS-1$
- break;
- case TT_NUMBER:
- result.append("n="); //$NON-NLS-1$
- result.append(nval);
- break;
- case TT_WORD:
- result.append(sval);
- break;
- default:
- result.append('\'');
- result.append((char) ttype);
- result.append('\'');
- break;
- }
- result.append("], line "); //$NON-NLS-1$
- result.append(lineNumber);
- return result.toString();
- }
-
- /**
- * Set the characters ranging from <code>low</code> to <code>hi</code>
- * to be regarded as whitespace characters.
- *
- * @param low
- * The starting range for whitespace characters.
- * @param hi
- * The ending range for whitespace characters.
- */
- public void whitespaceChars(int low, int hi) {
- if (low < 0) {
+ result.append("Token["); //$NON-NLS-1$
+ switch (ttype) {
+ case TT_EOF:
+ result.append("EOF"); //$NON-NLS-1$
+ break;
+ case TT_EOL:
+ result.append("EOL"); //$NON-NLS-1$
+ break;
+ case TT_NUMBER:
+ result.append("n="); //$NON-NLS-1$
+ result.append(nval);
+ break;
+ case TT_WORD:
+ result.append(sval);
+ break;
+ default:
+ result.append('\'');
+ result.append((char) ttype);
+ result.append('\'');
+ break;
+ }
+ result.append("], line "); //$NON-NLS-1$
+ result.append(lineNumber);
+ return result.toString();
+ }
+
+ /**
+ * Set the characters ranging from <code>low</code> to <code>hi</code>
+ * to be regarded as whitespace characters.
+ *
+ * @param low
+ * The starting range for whitespace characters.
+ * @param hi
+ * The ending range for whitespace characters.
+ */
+ public void whitespaceChars(int low, int hi) {
+ if (low < 0) {
low = 0;
}
- if (hi > tokenTypes.length) {
+ if (hi > tokenTypes.length) {
hi = tokenTypes.length - 1;
}
- for (int i = low; i <= hi; i++) {
+ for (int i = low; i <= hi; i++) {
tokenTypes[i] = TOKEN_WHITE;
}
- }
+ }
- /**
- * Set the characters ranging from <code>low</code> to <code>hi</code>
- * to be regarded as word characters.
- *
- * @param low
- * The starting range for word characters.
- * @param hi
- * The ending range for word characters.
- */
- public void wordChars(int low, int hi) {
- if (low < 0) {
+ /**
+ * Set the characters ranging from <code>low</code> to <code>hi</code>
+ * to be regarded as word characters.
+ *
+ * @param low
+ * The starting range for word characters.
+ * @param hi
+ * The ending range for word characters.
+ */
+ public void wordChars(int low, int hi) {
+ if (low < 0) {
low = 0;
}
- if (hi > tokenTypes.length) {
+ if (hi > tokenTypes.length) {
hi = tokenTypes.length - 1;
}
- for (int i = low; i <= hi; i++) {
+ for (int i = low; i <= hi; i++) {
tokenTypes[i] |= TOKEN_WORD;
}
- }
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringBufferInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringBufferInputStream.java?view=diff&rev=492652&r1=492651&r2=492652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringBufferInputStream.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringBufferInputStream.java Thu Jan 4 09:47:01 2007
@@ -17,6 +17,7 @@
package java.io;
+import org.apache.harmony.luni.util.Msg;
/**
* StringBufferInputStream is a class for to allow a String to be used as an
@@ -26,134 +27,133 @@
*/
@Deprecated
public class StringBufferInputStream extends InputStream {
- /**
- * The String containing the data to read.
- */
- protected String buffer;
-
- /**
- * The total number of characters inside the buffer.
- */
- protected int count;
-
- /**
- * The current position within the String buffer.
- */
- protected int pos;
-
- /**
- * Constructs a new StringBufferInputStream on the String <code>str</code>.
- *
- * @param str
- * the String to read characters from.
- */
- public StringBufferInputStream(String str) {
- if (str != null) {
- buffer = str;
- count = str.length();
- } else {
+ /**
+ * The String containing the data to read.
+ */
+ protected String buffer;
+
+ /**
+ * The total number of characters inside the buffer.
+ */
+ protected int count;
+
+ /**
+ * The current position within the String buffer.
+ */
+ protected int pos;
+
+ /**
+ * Constructs a new StringBufferInputStream on the String <code>str</code>.
+ *
+ * @param str
+ * the String to read characters from.
+ */
+ public StringBufferInputStream(String str) {
+ if (str == null) {
throw new NullPointerException();
}
- }
-
- /**
- * Answers an int representing then number of characters that are available
- * to read.
- *
- * @return the number of characters available.
- *
- */
- @Override
+ buffer = str;
+ count = str.length();
+ }
+
+ /**
+ * Answers an int representing then number of characters that are available
+ * to read.
+ *
+ * @return the number of characters available.
+ *
+ */
+ @Override
public synchronized int available() {
- return count - pos;
- }
+ return count - pos;
+ }
- /**
- * Reads a single byte from this InputStream and returns the result as an
- * int. The low-order byte is returned or -1 of the end of stream was
- * encountered.
- *
- * @return the byte read or -1 if end of stream.
- */
- @Override
+ /**
+ * Reads a single byte from this InputStream and returns the result as an
+ * int. The low-order byte is returned or -1 of the end of stream was
+ * encountered.
+ *
+ * @return the byte read or -1 if end of stream.
+ */
+ @Override
public synchronized int read() {
- return pos < count ? buffer.charAt(pos++) & 0xFF : -1;
- }
+ return pos < count ? buffer.charAt(pos++) & 0xFF : -1;
+ }
- /**
- * Reads at most <code>length</code> bytes from this InputStream and
- * stores them in byte array <code>b</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.
- *
- * @param b
- * the byte array in which to store the read bytes.
- * @param offset
- * the offset in <code>b</code> to store the read bytes.
- * @param length
- * the maximum number of bytes to store in <code>b</code>.
- * @return the number of bytes actually read or -1 if end of stream.
- */
- @Override
+ /**
+ * Reads at most <code>length</code> bytes from this InputStream and
+ * stores them in byte array <code>b</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.
+ *
+ * @param b
+ * the byte array in which to store the read bytes.
+ * @param offset
+ * the offset in <code>b</code> to store the read bytes.
+ * @param length
+ * the maximum number of bytes to store in <code>b</code>.
+ * @return the number of bytes actually read or -1 if end of stream.
+ */
+ @Override
public synchronized int read(byte b[], int offset, int length) {
- // According to 22.7.6 should return -1 before checking other
- // parameters.
- if (pos >= count) {
- return -1;
- }
- if (b != null) {
- // avoid int overflow
- if (0 <= offset && offset <= b.length && 0 <= length
- && length <= b.length - offset) {
- if (length == 0) {
- return 0;
- }
-
- int copylen = count - pos < length ? count - pos : length;
- for (int i = 0; i < copylen; i++) {
- b[offset + i] = (byte) buffer.charAt(pos + i);
- }
- pos += copylen;
- return copylen;
- }
- throw new ArrayIndexOutOfBoundsException();
- }
- throw new NullPointerException(org.apache.harmony.luni.util.Msg.getString("K0047")); //$NON-NLS-1$
- }
-
- /**
- * Reset this InputStream to position 0. Reads/Skips will now take place
- * from this position.
- *
- */
- @Override
+ // According to 22.7.6 should return -1 before checking other
+ // parameters.
+ if (pos >= count) {
+ return -1;
+ }
+ if (b == null) {
+ throw new NullPointerException(Msg.getString("K0047")); //$NON-NLS-1$
+ }
+ // avoid int overflow
+ if (offset < 0 || offset > b.length || length < 0
+ || length > b.length - offset) {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+ if (length == 0) {
+ return 0;
+ }
+
+ int copylen = count - pos < length ? count - pos : length;
+ for (int i = 0; i < copylen; i++) {
+ b[offset + i] = (byte) buffer.charAt(pos + i);
+ }
+ pos += copylen;
+ return copylen;
+ }
+
+ /**
+ * Reset this InputStream to position 0. Reads/Skips will now take place
+ * from this position.
+ *
+ */
+ @Override
public synchronized void reset() {
- pos = 0;
- }
+ pos = 0;
+ }
- /**
- * Skips <code>count</code> number of characters in this InputStream.
- * Subsequent <code>read()</code>'s will not return these characters
- * unless <code>reset()</code> is used.
- *
- * @param n
- * the number of characters to skip.
- * @return the number of characters actually skipped.
- */
- @Override
+ /**
+ * Skips <code>count</code> number of characters in this InputStream.
+ * Subsequent <code>read()</code>'s will not return these characters
+ * unless <code>reset()</code> is used.
+ *
+ * @param n
+ * the number of characters to skip.
+ * @return the number of characters actually skipped.
+ */
+ @Override
public synchronized long skip(long n) {
- if (n <= 0) {
+ if (n <= 0) {
return 0;
}
- int numskipped;
- if (this.count - pos < n) {
- numskipped = this.count - pos;
- pos = this.count;
- } else {
- numskipped = (int) n;
- pos += n;
- }
- return numskipped;
- }
+ int numskipped;
+ if (this.count - pos < n) {
+ numskipped = this.count - pos;
+ pos = this.count;
+ } else {
+ numskipped = (int) n;
+ pos += n;
+ }
+ return numskipped;
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringReader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringReader.java?view=diff&rev=492652&r1=492651&r2=492652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringReader.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringReader.java Thu Jan 4 09:47:01 2007
@@ -17,6 +17,7 @@
package java.io;
+import org.apache.harmony.luni.util.Msg;
/**
* StringReader is used as a character input stream on a String.
@@ -24,208 +25,207 @@
* @see StringWriter
*/
public class StringReader extends Reader {
- private String str;
+ private String str;
- private int markpos = -1;
+ private int markpos = -1;
- private int pos;
+ private int pos;
- private int count;
+ private int count;
- /**
- * Construct a StringReader on the String <code>str</code>. The size of
- * the reader is set to the <code>length()</code> of the String and the
- * Object to synchronize access through is set to <code>str</code>.
- *
- * @param str
- * the String to filter reads on.
- */
- public StringReader(String str) {
- super(str);
- this.str = str;
- this.count = str.length();
- }
-
- /**
- * This method closes this StringReader. Once it is closed, you can no
- * longer read from it. Only the first invocation of this method has any
- * effect.
- */
- @Override
+ /**
+ * Construct a StringReader on the String <code>str</code>. The size of
+ * the reader is set to the <code>length()</code> of the String and the
+ * Object to synchronize access through is set to <code>str</code>.
+ *
+ * @param str
+ * the String to filter reads on.
+ */
+ public StringReader(String str) {
+ super(str);
+ this.str = str;
+ this.count = str.length();
+ }
+
+ /**
+ * This method closes this StringReader. Once it is closed, you can no
+ * longer read from it. Only the first invocation of this method has any
+ * effect.
+ */
+ @Override
public void close() {
- synchronized (lock) {
- if (isOpen()) {
- str = null;
- }
- }
- }
-
- /**
- * Answer a boolean indicating whether or not this StringReader is open.
- * @return <code>true</code> if open, otherwise <code>false</code>
- */
- private boolean isOpen() {
- return str != null;
- }
-
- /**
- * Set a Mark position in this Reader. The parameter <code>readLimit</code>
- * is ignored for StringReaders. Sending reset() will reposition the reader
- * back to the marked position provided the mark has not been invalidated.
- *
- * @param readLimit
- * ignored for StringReaders.
- *
- * @throws IOException
- * If an error occurs attempting mark this StringReader.
- */
- @Override
+ synchronized (lock) {
+ if (isClosed()) {
+ return;
+ }
+ str = null;
+ }
+ }
+
+ /**
+ * Answer a boolean indicating whether or not this StringReader is closed.
+ *
+ * @return <code>true</code> if closed, otherwise <code>false</code>.
+ */
+ private boolean isClosed() {
+ return str == null;
+ }
+
+ /**
+ * Set a Mark position in this Reader. The parameter <code>readLimit</code>
+ * is ignored for StringReaders. Sending reset() will reposition the reader
+ * back to the marked position provided the mark has not been invalidated.
+ *
+ * @param readLimit
+ * ignored for StringReaders.
+ *
+ * @throws IOException
+ * If an error occurs attempting mark this StringReader.
+ */
+ @Override
public void mark(int readLimit) throws IOException {
- if (readLimit >= 0) {
- synchronized (lock) {
- if (isOpen()) {
- markpos = pos;
- } else {
- throw new IOException(org.apache.harmony.luni.util.Msg
- .getString("K0083")); //$NON-NLS-1$
- }
- }
- } else {
+ if (readLimit < 0) {
throw new IllegalArgumentException();
}
- }
- /**
- * Answers a boolean indicating whether or not this StringReader supports
- * mark() and reset(). This method always returns true.
- *
- * @return <code>true</code> if mark() and reset() are supported,
- * <code>false</code> otherwise. This implementation always
- * returns <code>true</code>.
- */
- @Override
+ synchronized (lock) {
+ if (isClosed()) {
+ throw new IOException(Msg.getString("K0083")); //$NON-NLS-1$
+ }
+ markpos = pos;
+ }
+ }
+
+ /**
+ * Answers a boolean indicating whether or not this StringReader supports
+ * mark() and reset(). This method always returns true.
+ *
+ * @return <code>true</code> if mark() and reset() are supported,
+ * <code>false</code> otherwise. This implementation always
+ * returns <code>true</code>.
+ */
+ @Override
public boolean markSupported() {
- return true;
- }
+ return true;
+ }
- /**
- * Reads a single character from this StringReader and returns the result as
- * an int. The 2 higher-order bytes are set to 0. If the end of reader was
- * encountered then return -1.
- *
- * @return the character read or -1 if end of reader.
- *
- * @throws IOException
- * If the StringReader is already closed.
- */
- @Override
+ /**
+ * Reads a single character from this StringReader and returns the result as
+ * an int. The 2 higher-order bytes are set to 0. If the end of reader was
+ * encountered then return -1.
+ *
+ * @return the character read or -1 if end of reader.
+ *
+ * @throws IOException
+ * If the StringReader is already closed.
+ */
+ @Override
public int read() throws IOException {
- synchronized (lock) {
- if (isOpen()) {
- if (pos != count) {
- return str.charAt(pos++);
- }
- return -1;
- }
- throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0083")); //$NON-NLS-1$
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.Reader#read(char[], int, int)
- */
- @Override
+ synchronized (lock) {
+ if (isClosed()) {
+ throw new IOException(Msg.getString("K0083")); //$NON-NLS-1$
+ }
+ if (pos != count) {
+ return str.charAt(pos++);
+ }
+ return -1;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.io.Reader#read(char[], int, int)
+ */
+ @Override
public int read(char buf[], int offset, int len) throws IOException {
- // avoid int overflow
- if (0 <= offset && offset <= buf.length && 0 <= len
- && len <= buf.length - offset) {
- synchronized (lock) {
- if (isOpen()) {
- if (pos == this.count) {
- return -1;
- }
- int end = pos + len > this.count ? this.count : pos + len;
- str.getChars(pos, end, buf, offset);
- int read = end - pos;
- pos = end;
- return read;
- }
- throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0083")); //$NON-NLS-1$
- }
- }
- throw new ArrayIndexOutOfBoundsException();
- }
-
- /**
- * Answers a <code>boolean</code> indicating whether or not this
- * StringReader 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. The implementation in StringReader always
- * returns <code>true</code> even when it has been closed.
- *
- * @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 an IO error occurs.
- */
- @Override
+ // avoid int overflow
+ if (offset < 0 || offset > buf.length || len < 0
+ || len > buf.length - offset) {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+ synchronized (lock) {
+ if (isClosed()) {
+ throw new IOException(Msg.getString("K0083")); //$NON-NLS-1$
+ }
+ if (pos == this.count) {
+ return -1;
+ }
+ int end = pos + len > this.count ? this.count : pos + len;
+ str.getChars(pos, end, buf, offset);
+ int read = end - pos;
+ pos = end;
+ return read;
+ }
+ }
+
+ /**
+ * Answers a <code>boolean</code> indicating whether or not this
+ * StringReader 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. The implementation in StringReader always
+ * returns <code>true</code> even when it has been closed.
+ *
+ * @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 an IO error occurs.
+ */
+ @Override
public boolean ready() throws IOException {
- synchronized (lock) {
- if (isOpen()) {
- return true;
- }
- throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0083")); //$NON-NLS-1$
- }
- }
-
- /**
- * Reset this StringReader's 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 StringReader is
- * reset to the beginning of the String.
- *
- * @throws IOException
- * If this StringReader has already been closed.
- */
- @Override
+ synchronized (lock) {
+ if (isClosed()) {
+ throw new IOException(Msg.getString("K0083")); //$NON-NLS-1$
+ }
+ return true;
+ }
+ }
+
+ /**
+ * Reset this StringReader's 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 StringReader is
+ * reset to the beginning of the String.
+ *
+ * @throws IOException
+ * If this StringReader has already been closed.
+ */
+ @Override
public void reset() throws IOException {
- synchronized (lock) {
- if (isOpen()) {
- pos = markpos != -1 ? markpos : 0;
- } else {
- throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0083")); //$NON-NLS-1$
+ synchronized (lock) {
+ if (isClosed()) {
+ throw new IOException(Msg.getString("K0083")); //$NON-NLS-1$
}
- }
- }
+ pos = markpos != -1 ? markpos : 0;
+ }
+ }
- /*
- * (non-Javadoc)
- *
- * @see java.io.Reader#skip(long)
- */
- @Override
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.io.Reader#skip(long)
+ */
+ @Override
public long skip(long ns) throws IOException {
- synchronized (lock) {
- if (isOpen()) {
- if (ns <= 0) {
- return 0;
- }
- long skipped = 0;
- if (ns < this.count - pos) {
- pos = pos + (int) ns;
- skipped = ns;
- } else {
- skipped = this.count - pos;
- pos = this.count;
- }
- return skipped;
- }
- throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0083")); //$NON-NLS-1$
- }
- }
+ synchronized (lock) {
+ if (isClosed()) {
+ throw new IOException(Msg.getString("K0083")); //$NON-NLS-1$
+ }
+ if (ns <= 0) {
+ return 0;
+ }
+ long skipped = 0;
+ if (ns < this.count - pos) {
+ pos = pos + (int) ns;
+ skipped = ns;
+ } else {
+ skipped = this.count - pos;
+ pos = this.count;
+ }
+ return skipped;
+ }
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java?view=diff&rev=492652&r1=492651&r2=492652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/StringWriter.java Thu Jan 4 09:47:01 2007
@@ -17,7 +17,6 @@
package java.io;
-
/**
* StringWriter is an class for writing Character Streams to a StringBuffer. The
* characters written can then be returned as a String. This is used for
@@ -26,229 +25,226 @@
* @see StringReader
*/
public class StringWriter extends Writer {
- private StringBuffer buf;
- /**
- * Constructs a new StringWriter which has a StringBuffer allocated with the
- * default size of 16 characters. The StringBuffer is also the
- * <code>lock</code> used to synchronize access to this Writer.
- */
- public StringWriter() {
- super();
- buf = new StringBuffer(16);
- lock = buf;
- }
-
- /**
- * Constructs a new StringWriter which has a StringBuffer allocated with the
- * size of <code>initialSize</code> characters. The StringBuffer is also
- * the <code>lock</code> used to synchronize access to this Writer.
- *
- * @param initialSize
- * the intial number of characters
- */
- public StringWriter(int initialSize) {
- if (initialSize >= 0) {
- buf = new StringBuffer(initialSize);
- lock = buf;
- } else {
+ private StringBuffer buf;
+
+ /**
+ * Constructs a new StringWriter which has a StringBuffer allocated with the
+ * default size of 16 characters. The StringBuffer is also the
+ * <code>lock</code> used to synchronize access to this Writer.
+ */
+ public StringWriter() {
+ super();
+ buf = new StringBuffer(16);
+ lock = buf;
+ }
+
+ /**
+ * Constructs a new StringWriter which has a StringBuffer allocated with the
+ * size of <code>initialSize</code> characters. The StringBuffer is also
+ * the <code>lock</code> used to synchronize access to this Writer.
+ *
+ * @param initialSize
+ * the intial number of characters
+ */
+ public StringWriter(int initialSize) {
+ if (initialSize < 0) {
throw new IllegalArgumentException();
}
- }
-
- /**
- * Close this Writer. This is the concrete implementation required. This
- * particular implementation does nothing.
- *
- * @throws IOException
- * If an IO error occurs closing this StringWriter.
- */
- @Override
+ buf = new StringBuffer(initialSize);
+ lock = buf;
+ }
+
+ /**
+ * Close this Writer. This is the concrete implementation required. This
+ * particular implementation does nothing.
+ *
+ * @throws IOException
+ * If an IO error occurs closing this StringWriter.
+ */
+ @Override
public void close() throws IOException {
- /*empty*/
- }
+ /* empty */
+ }
- /**
- * Flush this Writer. This is the concrete implementation required. This
- * particular implementation does nothing.
- */
- @Override
+ /**
+ * Flush this Writer. This is the concrete implementation required. This
+ * particular implementation does nothing.
+ */
+ @Override
public void flush() {
- /*empty*/
- }
+ /* empty */
+ }
+
+ /**
+ * Answer the contents of this StringWriter as a StringBuffer. Any changes
+ * made to the StringBuffer by the receiver or the caller are reflected in
+ * this StringWriter.
+ *
+ * @return this StringWriters local StringBuffer.
+ */
+ public StringBuffer getBuffer() {
+ synchronized (lock) {
+ return buf;
+ }
+ }
- /**
- * Answer the contents of this StringWriter as a StringBuffer. Any changes
- * made to the StringBuffer by the receiver or the caller are reflected in
- * this StringWriter.
- *
- * @return this StringWriters local StringBuffer.
- */
- public StringBuffer getBuffer() {
- synchronized (lock) {
- return buf;
- }
- }
-
- /**
- * Answer the contents of this StringWriter as a String. Any changes made to
- * the StringBuffer by the receiver after returning will not be reflected in
- * the String returned to the caller.
- *
- * @return this StringWriters current contents as a String.
- */
- @Override
+ /**
+ * Answer the contents of this StringWriter as a String. Any changes made to
+ * the StringBuffer by the receiver after returning will not be reflected in
+ * the String returned to the caller.
+ *
+ * @return this StringWriters current contents as a String.
+ */
+ @Override
public String toString() {
- synchronized (lock) {
- return buf.toString();
- }
- }
-
- /**
- * Writes <code>count</code> characters starting at <code>offset</code>
- * in <code>cbuf</code> to this StringWriter.
- *
- * @param cbuf
- * the non-null array containing characters to write.
- * @param offset
- * offset in buf to retrieve characters
- * @param count
- * maximum number of characters to write
- *
- * @throws ArrayIndexOutOfBoundsException
- * If offset or count are outside of bounds.
- */
- @Override
+ synchronized (lock) {
+ return buf.toString();
+ }
+ }
+
+ /**
+ * Writes <code>count</code> characters starting at <code>offset</code>
+ * in <code>cbuf</code> to this StringWriter.
+ *
+ * @param cbuf
+ * the non-null array containing characters to write.
+ * @param offset
+ * offset in buf to retrieve characters
+ * @param count
+ * maximum number of characters to write
+ *
+ * @throws ArrayIndexOutOfBoundsException
+ * If offset or count are outside of bounds.
+ */
+ @Override
public void write(char[] cbuf, int offset, int count) {
- // avoid int overflow
- if (0 <= offset && offset <= cbuf.length && 0 <= count
- && count <= cbuf.length - offset) {
- synchronized (lock) {
- this.buf.append(cbuf, offset, count);
- }
- } else {
- throw new IndexOutOfBoundsException();
- }
- }
-
- /**
- * Writes the specified character <code>oneChar</code> to this
- * StringWriter. This implementation writes the low order two bytes to the
- * Stream.
- *
- * @param oneChar
- * The character to write
- *
- */
- @Override
+ // avoid int overflow
+ if (offset < 0 || offset > cbuf.length || count < 0
+ || count > cbuf.length - offset) {
+ throw new IndexOutOfBoundsException();
+ }
+ synchronized (lock) {
+ this.buf.append(cbuf, offset, count);
+ }
+ }
+
+ /**
+ * Writes the specified character <code>oneChar</code> to this
+ * StringWriter. This implementation writes the low order two bytes to the
+ * Stream.
+ *
+ * @param oneChar
+ * The character to write
+ */
+ @Override
public void write(int oneChar) {
- synchronized (lock) {
- buf.append((char) oneChar);
- }
- }
-
- /**
- * Writes the characters from the String <code>str</code> to this
- * StringWriter.
- *
- * @param str
- * the non-null String containing the characters to write.
- *
- */
- @Override
+ synchronized (lock) {
+ buf.append((char) oneChar);
+ }
+ }
+
+ /**
+ * Writes the characters from the String <code>str</code> to this
+ * StringWriter.
+ *
+ * @param str
+ * the non-null String containing the characters to write.
+ */
+ @Override
public void write(String str) {
- synchronized (lock) {
- buf.append(str);
- }
- }
-
- /**
- * Writes <code>count</code> number of characters starting at
- * <code>offset</code> from the String <code>str</code> to this
- * StringWriter.
- *
- * @param str
- * the non-null String containing the characters to write.
- * @param offset
- * the starting point to retrieve characters.
- * @param count
- * the number of characters to retrieve and write.
- *
- * @throws ArrayIndexOutOfBoundsException
- * If offset or count are outside of bounds.
- */
- @Override
+ synchronized (lock) {
+ buf.append(str);
+ }
+ }
+
+ /**
+ * Writes <code>count</code> number of characters starting at
+ * <code>offset</code> from the String <code>str</code> to this
+ * StringWriter.
+ *
+ * @param str
+ * the non-null String containing the characters to write.
+ * @param offset
+ * the starting point to retrieve characters.
+ * @param count
+ * the number of characters to retrieve and write.
+ *
+ * @throws ArrayIndexOutOfBoundsException
+ * If offset or count are outside of bounds.
+ */
+ @Override
public void write(String str, int offset, int count) {
- String sub = str.substring(offset, offset + count);
- synchronized (lock) {
- buf.append(sub);
- }
- }
-
- /**
- * Append a char <code>c</code>to the StringWriter. The
- * StringWriter.append(<code>c</code>) works the same way as
- * StringWriter.write(<code>c</code>).
- *
- * @param c
- * The character appended to the StringWriter.
- * @return The StringWriter.
- */
- @Override
+ String sub = str.substring(offset, offset + count);
+ synchronized (lock) {
+ buf.append(sub);
+ }
+ }
+
+ /**
+ * Append a char <code>c</code>to the StringWriter. The
+ * StringWriter.append(<code>c</code>) works the same way as
+ * StringWriter.write(<code>c</code>).
+ *
+ * @param c
+ * The character appended to the StringWriter.
+ * @return The StringWriter.
+ */
+ @Override
public StringWriter append(char c) {
- write(c);
- return this;
- }
-
- /**
- * Append a CharSequence <code>csq</code> to the StringWriter. The
- * StringWriter.append(<code>csq</code>) works the same way as
- * StringWriter.write(<code>csq</code>.toString()). If <code>csq</code>
- * is null, then "null" will be substituted for <code>csq</code>.
- *
- * @param csq
- * The CharSequence appended to the StringWriter.
- * @return The StringWriter
- */
- @Override
+ write(c);
+ return this;
+ }
+
+ /**
+ * Append a CharSequence <code>csq</code> to the StringWriter. The
+ * StringWriter.append(<code>csq</code>) works the same way as
+ * StringWriter.write(<code>csq</code>.toString()). If <code>csq</code>
+ * is null, then "null" will be substituted for <code>csq</code>.
+ *
+ * @param csq
+ * The CharSequence appended to the StringWriter.
+ * @return The StringWriter
+ */
+ @Override
public StringWriter append(CharSequence csq) {
- if (null == csq) {
- append(TOKEN_NULL, 0, TOKEN_NULL.length());
- } else {
- append(csq, 0, csq.length());
- }
- return this;
- }
-
- /**
- * Append a subsequence of a CharSequence <code>csq</code> to the
- * StringWriter. The first char and the last char of the subsequnce is
- * specified by the parameter <code>start</code> and <code>end</code>.
- * The StringWriter.append(<code>csq</code>) works the same way as
- * StringWriter.write(<code>csq</code>.subSequence(<code>start</code>,<code>end</code>).toString).If
- * <code>csq</code> is null, then "null" will be substituted for
- * <code>csq</code>.
- * s
- * @param csq
- * The CharSequence appended to the StringWriter.
- * @param start
- * The index of the first char in the CharSequence appended to
- * the StringWriter.
- * @param end
- * The index of the char after the last one in the CharSequence
- * appended to the StringWriter.
- * @return The StringWriter.
- * @throws IndexOutOfBoundsException
- * If start is less than end, end is greater than the length of
- * the CharSequence, or start or end is negative.
- */
- @Override
+ if (null == csq) {
+ append(TOKEN_NULL, 0, TOKEN_NULL.length());
+ } else {
+ append(csq, 0, csq.length());
+ }
+ return this;
+ }
+
+ /**
+ * Append a subsequence of a CharSequence <code>csq</code> to the
+ * StringWriter. The first char and the last char of the subsequnce is
+ * specified by the parameter <code>start</code> and <code>end</code>.
+ * The StringWriter.append(<code>csq</code>) works the same way as
+ * StringWriter.write(<code>csq</code>.subSequence(<code>start</code>,<code>end</code>).toString).If
+ * <code>csq</code> is null, then "null" will be substituted for
+ * <code>csq</code>. s
+ *
+ * @param csq
+ * The CharSequence appended to the StringWriter.
+ * @param start
+ * The index of the first char in the CharSequence appended to
+ * the StringWriter.
+ * @param end
+ * The index of the char after the last one in the CharSequence
+ * appended to the StringWriter.
+ * @return The StringWriter.
+ * @throws IndexOutOfBoundsException
+ * If start is less than end, end is greater than the length of
+ * the CharSequence, or start or end is negative.
+ */
+ @Override
public StringWriter append(CharSequence csq, int start, int end) {
- if (null == csq) {
- csq = TOKEN_NULL;
- }
- String output = csq.subSequence(start, end).toString();
- write(output, 0, output.length());
- return this;
- }
+ if (null == csq) {
+ csq = TOKEN_NULL;
+ }
+ String output = csq.subSequence(start, end).toString();
+ write(output, 0, output.length());
+ return this;
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SyncFailedException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SyncFailedException.java?view=diff&rev=492652&r1=492651&r2=492652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SyncFailedException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/SyncFailedException.java Thu Jan 4 09:47:01 2007
@@ -17,7 +17,6 @@
package java.io;
-
/**
* This IO exception is thrown when the method <code>sync()</code> in
* FileDescriptor failed to complete.
@@ -27,16 +26,15 @@
public class SyncFailedException extends IOException {
private static final long serialVersionUID = -2353342684412443330L;
-
- /**
- * Constructs a new instance of this class with its walkback and message
- * filled in.
- *
- * @param detailMessage
- * the detail message for the exception.
- */
- public SyncFailedException(String detailMessage) {
- super(detailMessage);
- }
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ * @param detailMessage
+ * the detail message for the exception.
+ */
+ public SyncFailedException(String detailMessage) {
+ super(detailMessage);
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/UTFDataFormatException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/UTFDataFormatException.java?view=diff&rev=492652&r1=492651&r2=492652
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/UTFDataFormatException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/UTFDataFormatException.java Thu Jan 4 09:47:01 2007
@@ -17,7 +17,6 @@
package java.io;
-
/**
* This IO exception is thrown when a program attempts to read a UTF-8 String
* and the encoding is incorrect.
@@ -27,23 +26,22 @@
public class UTFDataFormatException extends IOException {
private static final long serialVersionUID = 420743449228280612L;
-
- /**
- * Constructs a new instance of this class with its walkback filled in.
- */
- public UTFDataFormatException() {
- super();
- }
- /**
- * Constructs a new instance of this class with its walkback and message
- * filled in.
- *
- * @param detailMessage
- * the detail message for the exception.
- */
- public UTFDataFormatException(String detailMessage) {
- super(detailMessage);
- }
+ /**
+ * Constructs a new instance of this class with its walkback filled in.
+ */
+ public UTFDataFormatException() {
+ super();
+ }
+ /**
+ * Constructs a new instance of this class with its walkback and message
+ * filled in.
+ *
+ * @param detailMessage
+ * the detail message for the exception.
+ */
+ public UTFDataFormatException(String detailMessage) {
+ super(detailMessage);
+ }
}