-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated Java version to 18 * StringNotClosedException now shows the startIndex of the expected string * InvalidCharacterException now shows the startIndex of the invalid character. * Specific exceptions thrown for invalid negative and invalid decimal numbers with index of where the error is found. * InvalidKeywordException now shows index the invalid keyword starts * InvalidControlCharacterException now shows index where the control character starts Added InvalidUnicodeCharacterException to specifically call out those exceptions * InvalidSyntaxException now says the expected token types and where the invalid actual token was found. * readme update * Added javadoc for JsonMapper * JsonElement serialize now works for line separator and paragraph separator
- Loading branch information
1 parent
eb55cc2
commit 699c2ca
Showing
18 changed files
with
272 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 16 additions & 2 deletions
18
src/main/java/technology/sola/json/exception/InvalidCharacterException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
package technology.sola.json.exception; | ||
|
||
public class InvalidCharacterException extends RuntimeException { | ||
public InvalidCharacterException(char invalidCharacter) { | ||
super(String.format("Invalid character [%s]", invalidCharacter)); | ||
private final char invalidCharacter; | ||
private final int startIndex; | ||
|
||
public InvalidCharacterException(char invalidCharacter, int startIndex) { | ||
super(String.format("Invalid character [%s] at [%s]", invalidCharacter, startIndex)); | ||
|
||
this.invalidCharacter = invalidCharacter; | ||
this.startIndex = startIndex; | ||
} | ||
|
||
public char getInvalidCharacter() { | ||
return invalidCharacter; | ||
} | ||
|
||
public int getStartIndex() { | ||
return startIndex; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/technology/sola/json/exception/InvalidControlCharacterException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
package technology.sola.json.exception; | ||
|
||
public class InvalidControlCharacterException extends RuntimeException { | ||
private final int startIndex; | ||
|
||
public InvalidControlCharacterException(int startIndex) { | ||
super("Invalid control character at [" + startIndex + "]"); | ||
this.startIndex = startIndex; | ||
} | ||
|
||
public int getStartIndex() { | ||
return startIndex; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/technology/sola/json/exception/InvalidDecimalNumberException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package technology.sola.json.exception; | ||
|
||
public class InvalidDecimalNumberException extends RuntimeException { | ||
private final int startIndex; | ||
|
||
public InvalidDecimalNumberException(int startIndex) { | ||
super("Number for decimal expected starting at [" + startIndex + "]"); | ||
this.startIndex = startIndex; | ||
} | ||
|
||
public int getStartIndex() { | ||
return startIndex; | ||
} | ||
} |
23 changes: 21 additions & 2 deletions
23
src/main/java/technology/sola/json/exception/InvalidKeywordException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,26 @@ | ||
package technology.sola.json.exception; | ||
|
||
public class InvalidKeywordException extends RuntimeException { | ||
public InvalidKeywordException(String keyword, String current, char invalidChar) { | ||
super("Expected keyword [" + keyword + "] but have [" + current + invalidChar + "]"); | ||
private final String expectedKeyword; | ||
private final String receivedKeyword; | ||
private final int startIndex; | ||
|
||
public InvalidKeywordException(String keyword, String current, char invalidChar, int startIndex) { | ||
super("Expected keyword [" + keyword + "] but received [" + current + invalidChar + "] at [" + startIndex + "]"); | ||
this.expectedKeyword = keyword; | ||
this.receivedKeyword = current + invalidChar; | ||
this.startIndex = startIndex; | ||
} | ||
|
||
public String getExpectedKeyword() { | ||
return expectedKeyword; | ||
} | ||
|
||
public String getReceivedKeyword() { | ||
return receivedKeyword; | ||
} | ||
|
||
public int getStartIndex() { | ||
return startIndex; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/technology/sola/json/exception/InvalidNegativeNumberException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package technology.sola.json.exception; | ||
|
||
public class InvalidNegativeNumberException extends RuntimeException { | ||
private final int startIndex; | ||
|
||
public InvalidNegativeNumberException(int startIndex) { | ||
super("Negative number expected following '-' at [" + startIndex + "]"); | ||
this.startIndex = startIndex; | ||
} | ||
|
||
public int getStartIndex() { | ||
return startIndex; | ||
} | ||
} |
4 changes: 0 additions & 4 deletions
4
src/main/java/technology/sola/json/exception/InvalidNumberException.java
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
src/main/java/technology/sola/json/exception/InvalidSyntaxException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
package technology.sola.json.exception; | ||
|
||
import technology.sola.json.token.TokenType; | ||
|
||
import java.util.Arrays; | ||
import java.util.stream.Collectors; | ||
|
||
public class InvalidSyntaxException extends RuntimeException { | ||
public InvalidSyntaxException(TokenType actual, int index, TokenType ...expected) { | ||
super("Expected [" + Arrays.stream(expected).map(TokenType::name).collect(Collectors.joining(" or ")) + "] but received [" + actual.name() + "] at [" + index + "]"); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/technology/sola/json/exception/InvalidUnicodeCharacterException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package technology.sola.json.exception; | ||
|
||
public class InvalidUnicodeCharacterException extends RuntimeException { | ||
private final int startIndex; | ||
|
||
public InvalidUnicodeCharacterException(int startIndex) { | ||
super("Invalid unicode character must be 4 numbers in length at [" + startIndex + "]"); | ||
this.startIndex = startIndex; | ||
} | ||
|
||
public int getStartIndex() { | ||
return startIndex; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/technology/sola/json/exception/StringNotClosedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,15 @@ | ||
package technology.sola.json.exception; | ||
|
||
public class StringNotClosedException extends RuntimeException { | ||
private final int startIndex; | ||
|
||
public StringNotClosedException(int startIndex) { | ||
super("String starting at [" + startIndex + "] not closed"); | ||
|
||
this.startIndex = startIndex; | ||
} | ||
|
||
public int getStartIndex() { | ||
return startIndex; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.