Skip to content

Commit 32e4e91

Browse files
committed
More stylistic tweaks, moving to more compact format (sorry!)
1 parent 0e791ab commit 32e4e91

14 files changed

+153
-398
lines changed

src/main/java/com/fasterxml/jackson/core/JsonFactory.java

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,7 @@ public final boolean isEnabled(JsonGenerator.Feature f) {
588588
* Method for accessing custom escapes factory uses for {@link JsonGenerator}s
589589
* it creates.
590590
*/
591-
public CharacterEscapes getCharacterEscapes() {
592-
return _characterEscapes;
593-
}
591+
public CharacterEscapes getCharacterEscapes() { return _characterEscapes; }
594592

595593
/**
596594
* Method for defining custom escapes factory uses for {@link JsonGenerator}s
@@ -678,9 +676,7 @@ public JsonFactory setCodec(ObjectCodec oc) {
678676
*
679677
* @since 2.1
680678
*/
681-
public JsonParser createParser(File f)
682-
throws IOException, JsonParseException
683-
{
679+
public JsonParser createParser(File f) throws IOException, JsonParseException {
684680
// true, since we create InputStream from File
685681
IOContext ctxt = _createContext(f, true);
686682
InputStream in = new FileInputStream(f);
@@ -706,9 +702,7 @@ public JsonParser createParser(File f)
706702
*
707703
* @since 2.1
708704
*/
709-
public JsonParser createParser(URL url)
710-
throws IOException, JsonParseException
711-
{
705+
public JsonParser createParser(URL url) throws IOException, JsonParseException {
712706
// true, since we create InputStream from URL
713707
IOContext ctxt = _createContext(url, true);
714708
InputStream in = _optimizedStreamFromURL(url);
@@ -736,9 +730,7 @@ public JsonParser createParser(URL url)
736730
*
737731
* @since 2.1
738732
*/
739-
public JsonParser createParser(InputStream in)
740-
throws IOException, JsonParseException
741-
{
733+
public JsonParser createParser(InputStream in) throws IOException, JsonParseException {
742734
IOContext ctxt = _createContext(in, false);
743735
// [JACKSON-512]: allow wrapping with InputDecorator
744736
if (_inputDecorator != null) {
@@ -761,9 +753,7 @@ public JsonParser createParser(InputStream in)
761753
*
762754
* @since 2.1
763755
*/
764-
public JsonParser createParser(Reader r)
765-
throws IOException, JsonParseException
766-
{
756+
public JsonParser createParser(Reader r) throws IOException, JsonParseException {
767757
// false -> we do NOT own Reader (did not create it)
768758
IOContext ctxt = _createContext(r, false);
769759
// [JACKSON-512]: allow wrapping with InputDecorator
@@ -779,9 +769,7 @@ public JsonParser createParser(Reader r)
779769
*
780770
* @since 2.1
781771
*/
782-
public JsonParser createParser(byte[] data)
783-
throws IOException, JsonParseException
784-
{
772+
public JsonParser createParser(byte[] data) throws IOException, JsonParseException {
785773
IOContext ctxt = _createContext(data, true);
786774
// [JACKSON-512]: allow wrapping with InputDecorator
787775
if (_inputDecorator != null) {
@@ -803,9 +791,7 @@ public JsonParser createParser(byte[] data)
803791
*
804792
* @since 2.1
805793
*/
806-
public JsonParser createParser(byte[] data, int offset, int len)
807-
throws IOException, JsonParseException
808-
{
794+
public JsonParser createParser(byte[] data, int offset, int len) throws IOException, JsonParseException {
809795
IOContext ctxt = _createContext(data, true);
810796
// [JACKSON-512]: allow wrapping with InputDecorator
811797
if (_inputDecorator != null) {
@@ -823,8 +809,7 @@ public JsonParser createParser(byte[] data, int offset, int len)
823809
*
824810
* @since 2.1
825811
*/
826-
public JsonParser createParser(String content) throws IOException, JsonParseException
827-
{
812+
public JsonParser createParser(String content) throws IOException, JsonParseException {
828813
Reader r = new StringReader(content);
829814
// true -> we own the Reader (and must close); not a big deal
830815
IOContext ctxt = _createContext(r, true);

src/main/java/com/fasterxml/jackson/core/JsonParseException.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,14 @@
1010
* (content that does not conform to JSON syntax as per specification)
1111
* is encountered.
1212
*/
13-
public class JsonParseException
14-
extends JsonProcessingException
15-
{
13+
public class JsonParseException extends JsonProcessingException {
1614
private static final long serialVersionUID = 1L;
1715

18-
public JsonParseException(String msg, JsonLocation loc)
19-
{
16+
public JsonParseException(String msg, JsonLocation loc) {
2017
super(msg, loc);
2118
}
2219

23-
public JsonParseException(String msg, JsonLocation loc, Throwable root)
24-
{
20+
public JsonParseException(String msg, JsonLocation loc, Throwable root) {
2521
super(msg, loc, root);
2622
}
2723
}

src/main/java/com/fasterxml/jackson/core/JsonParser.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ public JsonParser setFeatureMask(int mask) {
493493
* @return Next token from the stream, if any found, or null
494494
* to indicate end-of-input
495495
*/
496-
public abstract JsonToken nextToken() throws IOException;
496+
public abstract JsonToken nextToken() throws IOException, JsonParseException;
497497

498498
/**
499499
* Iteration method that will advance stream enough
@@ -512,7 +512,7 @@ public JsonParser setFeatureMask(int mask) {
512512
* parsers, {@link JsonToken#NOT_AVAILABLE} if no tokens were
513513
* available yet)
514514
*/
515-
public abstract JsonToken nextValue() throws IOException;
515+
public abstract JsonToken nextValue() throws IOException, JsonParseException;
516516

517517
/**
518518
* Method that fetches next token (as if calling {@link #nextToken}) and
@@ -527,7 +527,7 @@ public JsonParser setFeatureMask(int mask) {
527527
*
528528
* @param str Property name to compare next token to (if next token is <code>JsonToken.FIELD_NAME<code>)
529529
*/
530-
public boolean nextFieldName(SerializableString str) throws IOException {
530+
public boolean nextFieldName(SerializableString str) throws IOException, JsonParseException {
531531
return (nextToken() == JsonToken.FIELD_NAME) && str.getValue().equals(getCurrentName());
532532
}
533533

@@ -542,7 +542,7 @@ public boolean nextFieldName(SerializableString str) throws IOException {
542542
* but may be faster for parser to process, and can therefore be used if caller
543543
* expects to get a String value next from input.
544544
*/
545-
public String nextTextValue() throws IOException {
545+
public String nextTextValue() throws IOException, JsonParseException {
546546
return (nextToken() == JsonToken.VALUE_STRING) ? getText() : null;
547547
}
548548

@@ -557,7 +557,7 @@ public String nextTextValue() throws IOException {
557557
* but may be faster for parser to process, and can therefore be used if caller
558558
* expects to get a String value next from input.
559559
*/
560-
public int nextIntValue(int defaultValue) throws IOException {
560+
public int nextIntValue(int defaultValue) throws IOException, JsonParseException {
561561
return (nextToken() == JsonToken.VALUE_NUMBER_INT) ? getIntValue() : defaultValue;
562562
}
563563

@@ -572,7 +572,7 @@ public int nextIntValue(int defaultValue) throws IOException {
572572
* but may be faster for parser to process, and can therefore be used if caller
573573
* expects to get a String value next from input.
574574
*/
575-
public long nextLongValue(long defaultValue) throws IOException {
575+
public long nextLongValue(long defaultValue) throws IOException, JsonParseException {
576576
return (nextToken() == JsonToken.VALUE_NUMBER_INT) ? getLongValue() : defaultValue;
577577
}
578578

@@ -590,7 +590,7 @@ public long nextLongValue(long defaultValue) throws IOException {
590590
* but may be faster for parser to process, and can therefore be used if caller
591591
* expects to get a String value next from input.
592592
*/
593-
public Boolean nextBooleanValue() throws IOException {
593+
public Boolean nextBooleanValue() throws IOException, JsonParseException {
594594
JsonToken t = nextToken();
595595
if (t == JsonToken.VALUE_TRUE) { return Boolean.TRUE; }
596596
if (t == JsonToken.VALUE_FALSE) { return Boolean.FALSE; }
@@ -611,7 +611,7 @@ public Boolean nextBooleanValue() throws IOException {
611611
* will call {@link #nextToken} to point to the next
612612
* available token, if any.
613613
*/
614-
public abstract JsonParser skipChildren() throws IOException;
614+
public abstract JsonParser skipChildren() throws IOException, JsonParseException;
615615

616616
/**
617617
* Method that can be called to determine whether this parser

src/main/java/com/fasterxml/jackson/core/JsonPointer.java

Lines changed: 18 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ public class JsonPointer
5252
* Constructor used for creating "empty" instance, used to represent
5353
* state that matches current node.
5454
*/
55-
protected JsonPointer()
56-
{
55+
protected JsonPointer() {
5756
_nextSegment = null;
5857
_matchingPropertyName = "";
5958
_matchingElementIndex = -1;
@@ -63,8 +62,7 @@ protected JsonPointer()
6362
/**
6463
* Constructor used for creating non-empty Segments
6564
*/
66-
protected JsonPointer(String fullString, String segment, JsonPointer next)
67-
{
65+
protected JsonPointer(String fullString, String segment, JsonPointer next) {
6866
_asString = fullString;
6967
_nextSegment = next;
7068
// Ok; may always be a property
@@ -87,17 +85,15 @@ protected JsonPointer(String fullString, String segment, JsonPointer next)
8785
* expression: currently the only such expression is one that does NOT start with
8886
* a slash ('/').
8987
*/
90-
public static JsonPointer compile(String input)
91-
throws IllegalArgumentException
88+
public static JsonPointer compile(String input) throws IllegalArgumentException
9289
{
9390
// First quick checks for well-known 'empty' pointer
9491
if ((input == null) || input.length() == 0) {
9592
return EMPTY;
9693
}
9794
// And then quick validity check:
9895
if (input.charAt(0) != '/') {
99-
throw new IllegalArgumentException("Invalid input: JSON Pointer expression must start with '/': "
100-
+"\""+input+"\"");
96+
throw new IllegalArgumentException("Invalid input: JSON Pointer expression must start with '/': "+"\""+input+"\"");
10197
}
10298
return _parseTail(input);
10399
}
@@ -108,10 +104,7 @@ public static JsonPointer compile(String input)
108104
*/
109105
public static JsonPointer valueOf(String input) { return compile(input); }
110106

111-
/*
112-
113-
/**
114-
* Factory method that composes a pointer instance, given a set
107+
/* Factory method that composes a pointer instance, given a set
115108
* of 'raw' segments: raw meaning that no processing will be done,
116109
* no escaping may is present.
117110
*
@@ -139,25 +132,11 @@ public static JsonPointer fromSegment(String... segments)
139132
/**********************************************************
140133
*/
141134

142-
public boolean matches() {
143-
return _nextSegment == null;
144-
}
145-
146-
public String getMatchingProperty() {
147-
return _matchingPropertyName;
148-
}
149-
150-
public int getMatchingIndex() {
151-
return _matchingElementIndex;
152-
}
153-
154-
public boolean mayMatchProperty() {
155-
return _matchingPropertyName != null;
156-
}
157-
158-
public boolean mayMatchElement() {
159-
return _matchingElementIndex >= 0;
160-
}
135+
public boolean matches() { return _nextSegment == null; }
136+
public String getMatchingProperty() { return _matchingPropertyName; }
137+
public int getMatchingIndex() { return _matchingElementIndex; }
138+
public boolean mayMatchProperty() { return _matchingPropertyName != null; }
139+
public boolean mayMatchElement() { return _matchingElementIndex >= 0; }
161140

162141
public JsonPointer matchProperty(String name) {
163142
if (_nextSegment == null || !_matchingPropertyName.equals(name)) {
@@ -187,24 +166,13 @@ public JsonPointer tail() {
187166
/**********************************************************
188167
*/
189168

190-
@Override
191-
public String toString() {
192-
return _asString;
193-
}
194-
195-
@Override
196-
public int hashCode() {
197-
return _asString.hashCode();
198-
}
169+
@Override public String toString() { return _asString; }
170+
@Override public int hashCode() { return _asString.hashCode(); }
199171

200-
@Override
201-
public boolean equals(Object o)
202-
{
172+
@Override public boolean equals(Object o) {
203173
if (o == this) return true;
204174
if (o == null) return false;
205-
if (!(o instanceof JsonPointer)) {
206-
return false;
207-
}
175+
if (!(o instanceof JsonPointer)) return false;
208176
return _asString.equals(((JsonPointer) o)._asString);
209177
}
210178

@@ -214,8 +182,7 @@ public boolean equals(Object o)
214182
/**********************************************************
215183
*/
216184

217-
private final static int _parseInt(String str)
218-
{
185+
private final static int _parseInt(String str) {
219186
final int len = str.length();
220187
if (len == 0) {
221188
return -1;
@@ -230,8 +197,7 @@ private final static int _parseInt(String str)
230197
return NumberInput.parseInt(str);
231198
}
232199

233-
protected static JsonPointer _parseTail(String input)
234-
{
200+
protected static JsonPointer _parseTail(String input) {
235201
final int end = input.length();
236202

237203
// first char is the contextual slash, skip
@@ -259,8 +225,7 @@ protected static JsonPointer _parseTail(String input)
259225
* @param input Full input for the tail being parsed
260226
* @param i Offset to character after tilde
261227
*/
262-
protected static JsonPointer _parseQuotedTail(String input, int i)
263-
{
228+
protected static JsonPointer _parseQuotedTail(String input, int i) {
264229
final int end = input.length();
265230
StringBuilder sb = new StringBuilder(Math.max(16, end));
266231
if (i > 2) {
@@ -284,8 +249,7 @@ protected static JsonPointer _parseQuotedTail(String input, int i)
284249
return new JsonPointer(input, sb.toString(), EMPTY);
285250
}
286251

287-
private static void _appendEscape(StringBuilder sb, char c)
288-
{
252+
private static void _appendEscape(StringBuilder sb, char c) {
289253
if (c == '0') {
290254
c = '~';
291255
} else if (c == '1') {

0 commit comments

Comments
 (0)