1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 07:50:52 -07:00

Updates to the Javadoc for exceptions

This commit is contained in:
John J. Aylward 2016-07-18 14:12:06 -04:00
parent 42e0944708
commit 93704371bb

View file

@ -71,7 +71,7 @@ public class JSONTokener {
* Construct a JSONTokener from an InputStream. * Construct a JSONTokener from an InputStream.
* @param inputStream The source. * @param inputStream The source.
*/ */
public JSONTokener(InputStream inputStream) throws JSONException { public JSONTokener(InputStream inputStream) {
this(new InputStreamReader(inputStream)); this(new InputStreamReader(inputStream));
} }
@ -90,6 +90,8 @@ public class JSONTokener {
* Back up one character. This provides a sort of lookahead capability, * Back up one character. This provides a sort of lookahead capability,
* so that you can test for a digit or letter before attempting to parse * so that you can test for a digit or letter before attempting to parse
* the next number or identifier. * the next number or identifier.
* @throws JSONException Thrown if trying to step back more than 1 step
* or if already at the start of the string
*/ */
public void back() throws JSONException { public void back() throws JSONException {
if (this.usePrevious || this.index <= 0) { if (this.usePrevious || this.index <= 0) {
@ -121,6 +123,9 @@ public class JSONTokener {
return -1; return -1;
} }
/**
* @return true if at the end of the file and we didn't step back
*/
public boolean end() { public boolean end() {
return this.eof && !this.usePrevious; return this.eof && !this.usePrevious;
} }
@ -130,6 +135,8 @@ public class JSONTokener {
* Determine if the source string still contains characters that next() * Determine if the source string still contains characters that next()
* can consume. * can consume.
* @return true if not yet at the end of the source. * @return true if not yet at the end of the source.
* @throws JSONException thrown if there is an error stepping forward
* or backward while checking for more data.
*/ */
public boolean more() throws JSONException { public boolean more() throws JSONException {
this.next(); this.next();
@ -145,6 +152,7 @@ public class JSONTokener {
* Get the next character in the source string. * Get the next character in the source string.
* *
* @return The next character, or 0 if past the end of the source string. * @return The next character, or 0 if past the end of the source string.
* @throws JSONException Thrown if there is an error reading the source string.
*/ */
public char next() throws JSONException { public char next() throws JSONException {
int c; int c;
@ -225,7 +233,7 @@ public class JSONTokener {
/** /**
* Get the next char in the string, skipping whitespace. * Get the next char in the string, skipping whitespace.
* @throws JSONException * @throws JSONException Thrown if there is an error reading the source string.
* @return A character, or 0 if there are no more characters. * @return A character, or 0 if there are no more characters.
*/ */
public char nextClean() throws JSONException { public char nextClean() throws JSONException {
@ -309,6 +317,8 @@ public class JSONTokener {
* end of line, whichever comes first. * end of line, whichever comes first.
* @param delimiter A delimiter character. * @param delimiter A delimiter character.
* @return A string. * @return A string.
* @throws JSONException Thrown if there is an error while searching
* for the delimiter
*/ */
public String nextTo(char delimiter) throws JSONException { public String nextTo(char delimiter) throws JSONException {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -330,6 +340,8 @@ public class JSONTokener {
* characters or the end of line, whichever comes first. * characters or the end of line, whichever comes first.
* @param delimiters A set of delimiter characters. * @param delimiters A set of delimiter characters.
* @return A string, trimmed. * @return A string, trimmed.
* @throws JSONException Thrown if there is an error while searching
* for the delimiter
*/ */
public String nextTo(String delimiters) throws JSONException { public String nextTo(String delimiters) throws JSONException {
char c; char c;
@ -401,6 +413,8 @@ public class JSONTokener {
* @param to A character to skip to. * @param to A character to skip to.
* @return The requested character, or zero if the requested character * @return The requested character, or zero if the requested character
* is not found. * is not found.
* @throws JSONException Thrown if there is an error while searching
* for the to character
*/ */
public char skipTo(char to) throws JSONException { public char skipTo(char to) throws JSONException {
char c; char c;
@ -453,6 +467,7 @@ public class JSONTokener {
* *
* @return " at {index} [character {character} line {line}]" * @return " at {index} [character {character} line {line}]"
*/ */
@Override
public String toString() { public String toString() {
return " at " + this.index + " [character " + this.character + " line " + return " at " + this.index + " [character " + this.character + " line " +
this.line + "]"; this.line + "]";