More stylistic tweaks, moving to more compact format (sorry!)
diff --git a/src/main/java/com/fasterxml/jackson/core/JsonFactory.java b/src/main/java/com/fasterxml/jackson/core/JsonFactory.java index 2e91c46..9aef46d 100644 --- a/src/main/java/com/fasterxml/jackson/core/JsonFactory.java +++ b/src/main/java/com/fasterxml/jackson/core/JsonFactory.java
@@ -588,9 +588,7 @@ * Method for accessing custom escapes factory uses for {@link JsonGenerator}s * it creates. */ - public CharacterEscapes getCharacterEscapes() { - return _characterEscapes; - } + public CharacterEscapes getCharacterEscapes() { return _characterEscapes; } /** * Method for defining custom escapes factory uses for {@link JsonGenerator}s @@ -678,9 +676,7 @@ * * @since 2.1 */ - public JsonParser createParser(File f) - throws IOException, JsonParseException - { + public JsonParser createParser(File f) throws IOException, JsonParseException { // true, since we create InputStream from File IOContext ctxt = _createContext(f, true); InputStream in = new FileInputStream(f); @@ -706,9 +702,7 @@ * * @since 2.1 */ - public JsonParser createParser(URL url) - throws IOException, JsonParseException - { + public JsonParser createParser(URL url) throws IOException, JsonParseException { // true, since we create InputStream from URL IOContext ctxt = _createContext(url, true); InputStream in = _optimizedStreamFromURL(url); @@ -736,9 +730,7 @@ * * @since 2.1 */ - public JsonParser createParser(InputStream in) - throws IOException, JsonParseException - { + public JsonParser createParser(InputStream in) throws IOException, JsonParseException { IOContext ctxt = _createContext(in, false); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { @@ -761,9 +753,7 @@ * * @since 2.1 */ - public JsonParser createParser(Reader r) - throws IOException, JsonParseException - { + public JsonParser createParser(Reader r) throws IOException, JsonParseException { // false -> we do NOT own Reader (did not create it) IOContext ctxt = _createContext(r, false); // [JACKSON-512]: allow wrapping with InputDecorator @@ -779,9 +769,7 @@ * * @since 2.1 */ - public JsonParser createParser(byte[] data) - throws IOException, JsonParseException - { + public JsonParser createParser(byte[] data) throws IOException, JsonParseException { IOContext ctxt = _createContext(data, true); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { @@ -803,9 +791,7 @@ * * @since 2.1 */ - public JsonParser createParser(byte[] data, int offset, int len) - throws IOException, JsonParseException - { + public JsonParser createParser(byte[] data, int offset, int len) throws IOException, JsonParseException { IOContext ctxt = _createContext(data, true); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { @@ -823,8 +809,7 @@ * * @since 2.1 */ - public JsonParser createParser(String content) throws IOException, JsonParseException - { + public JsonParser createParser(String content) throws IOException, JsonParseException { Reader r = new StringReader(content); // true -> we own the Reader (and must close); not a big deal IOContext ctxt = _createContext(r, true);
diff --git a/src/main/java/com/fasterxml/jackson/core/JsonParseException.java b/src/main/java/com/fasterxml/jackson/core/JsonParseException.java index c5fbf86..926f709 100644 --- a/src/main/java/com/fasterxml/jackson/core/JsonParseException.java +++ b/src/main/java/com/fasterxml/jackson/core/JsonParseException.java
@@ -10,18 +10,14 @@ * (content that does not conform to JSON syntax as per specification) * is encountered. */ -public class JsonParseException - extends JsonProcessingException -{ +public class JsonParseException extends JsonProcessingException { private static final long serialVersionUID = 1L; - public JsonParseException(String msg, JsonLocation loc) - { + public JsonParseException(String msg, JsonLocation loc) { super(msg, loc); } - public JsonParseException(String msg, JsonLocation loc, Throwable root) - { + public JsonParseException(String msg, JsonLocation loc, Throwable root) { super(msg, loc, root); } }
diff --git a/src/main/java/com/fasterxml/jackson/core/JsonParser.java b/src/main/java/com/fasterxml/jackson/core/JsonParser.java index c160bcf..41262db 100644 --- a/src/main/java/com/fasterxml/jackson/core/JsonParser.java +++ b/src/main/java/com/fasterxml/jackson/core/JsonParser.java
@@ -493,7 +493,7 @@ * @return Next token from the stream, if any found, or null * to indicate end-of-input */ - public abstract JsonToken nextToken() throws IOException; + public abstract JsonToken nextToken() throws IOException, JsonParseException; /** * Iteration method that will advance stream enough @@ -512,7 +512,7 @@ * parsers, {@link JsonToken#NOT_AVAILABLE} if no tokens were * available yet) */ - public abstract JsonToken nextValue() throws IOException; + public abstract JsonToken nextValue() throws IOException, JsonParseException; /** * Method that fetches next token (as if calling {@link #nextToken}) and @@ -527,7 +527,7 @@ * * @param str Property name to compare next token to (if next token is <code>JsonToken.FIELD_NAME<code>) */ - public boolean nextFieldName(SerializableString str) throws IOException { + public boolean nextFieldName(SerializableString str) throws IOException, JsonParseException { return (nextToken() == JsonToken.FIELD_NAME) && str.getValue().equals(getCurrentName()); } @@ -542,7 +542,7 @@ * but may be faster for parser to process, and can therefore be used if caller * expects to get a String value next from input. */ - public String nextTextValue() throws IOException { + public String nextTextValue() throws IOException, JsonParseException { return (nextToken() == JsonToken.VALUE_STRING) ? getText() : null; } @@ -557,7 +557,7 @@ * but may be faster for parser to process, and can therefore be used if caller * expects to get a String value next from input. */ - public int nextIntValue(int defaultValue) throws IOException { + public int nextIntValue(int defaultValue) throws IOException, JsonParseException { return (nextToken() == JsonToken.VALUE_NUMBER_INT) ? getIntValue() : defaultValue; } @@ -572,7 +572,7 @@ * but may be faster for parser to process, and can therefore be used if caller * expects to get a String value next from input. */ - public long nextLongValue(long defaultValue) throws IOException { + public long nextLongValue(long defaultValue) throws IOException, JsonParseException { return (nextToken() == JsonToken.VALUE_NUMBER_INT) ? getLongValue() : defaultValue; } @@ -590,7 +590,7 @@ * but may be faster for parser to process, and can therefore be used if caller * expects to get a String value next from input. */ - public Boolean nextBooleanValue() throws IOException { + public Boolean nextBooleanValue() throws IOException, JsonParseException { JsonToken t = nextToken(); if (t == JsonToken.VALUE_TRUE) { return Boolean.TRUE; } if (t == JsonToken.VALUE_FALSE) { return Boolean.FALSE; } @@ -611,7 +611,7 @@ * will call {@link #nextToken} to point to the next * available token, if any. */ - public abstract JsonParser skipChildren() throws IOException; + public abstract JsonParser skipChildren() throws IOException, JsonParseException; /** * Method that can be called to determine whether this parser
diff --git a/src/main/java/com/fasterxml/jackson/core/JsonPointer.java b/src/main/java/com/fasterxml/jackson/core/JsonPointer.java index 3d5127f..3ebd91a 100644 --- a/src/main/java/com/fasterxml/jackson/core/JsonPointer.java +++ b/src/main/java/com/fasterxml/jackson/core/JsonPointer.java
@@ -52,8 +52,7 @@ * Constructor used for creating "empty" instance, used to represent * state that matches current node. */ - protected JsonPointer() - { + protected JsonPointer() { _nextSegment = null; _matchingPropertyName = ""; _matchingElementIndex = -1; @@ -63,8 +62,7 @@ /** * Constructor used for creating non-empty Segments */ - protected JsonPointer(String fullString, String segment, JsonPointer next) - { + protected JsonPointer(String fullString, String segment, JsonPointer next) { _asString = fullString; _nextSegment = next; // Ok; may always be a property @@ -87,8 +85,7 @@ * expression: currently the only such expression is one that does NOT start with * a slash ('/'). */ - public static JsonPointer compile(String input) - throws IllegalArgumentException + public static JsonPointer compile(String input) throws IllegalArgumentException { // First quick checks for well-known 'empty' pointer if ((input == null) || input.length() == 0) { @@ -96,8 +93,7 @@ } // And then quick validity check: if (input.charAt(0) != '/') { - throw new IllegalArgumentException("Invalid input: JSON Pointer expression must start with '/': " - +"\""+input+"\""); + throw new IllegalArgumentException("Invalid input: JSON Pointer expression must start with '/': "+"\""+input+"\""); } return _parseTail(input); } @@ -108,10 +104,7 @@ */ public static JsonPointer valueOf(String input) { return compile(input); } - /* - - /** - * Factory method that composes a pointer instance, given a set + /* Factory method that composes a pointer instance, given a set * of 'raw' segments: raw meaning that no processing will be done, * no escaping may is present. * @@ -139,25 +132,11 @@ /********************************************************** */ - public boolean matches() { - return _nextSegment == null; - } - - public String getMatchingProperty() { - return _matchingPropertyName; - } - - public int getMatchingIndex() { - return _matchingElementIndex; - } - - public boolean mayMatchProperty() { - return _matchingPropertyName != null; - } - - public boolean mayMatchElement() { - return _matchingElementIndex >= 0; - } + public boolean matches() { return _nextSegment == null; } + public String getMatchingProperty() { return _matchingPropertyName; } + public int getMatchingIndex() { return _matchingElementIndex; } + public boolean mayMatchProperty() { return _matchingPropertyName != null; } + public boolean mayMatchElement() { return _matchingElementIndex >= 0; } public JsonPointer matchProperty(String name) { if (_nextSegment == null || !_matchingPropertyName.equals(name)) { @@ -187,24 +166,13 @@ /********************************************************** */ - @Override - public String toString() { - return _asString; - } + @Override public String toString() { return _asString; } + @Override public int hashCode() { return _asString.hashCode(); } - @Override - public int hashCode() { - return _asString.hashCode(); - } - - @Override - public boolean equals(Object o) - { + @Override public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; - if (!(o instanceof JsonPointer)) { - return false; - } + if (!(o instanceof JsonPointer)) return false; return _asString.equals(((JsonPointer) o)._asString); } @@ -214,8 +182,7 @@ /********************************************************** */ - private final static int _parseInt(String str) - { + private final static int _parseInt(String str) { final int len = str.length(); if (len == 0) { return -1; @@ -230,8 +197,7 @@ return NumberInput.parseInt(str); } - protected static JsonPointer _parseTail(String input) - { + protected static JsonPointer _parseTail(String input) { final int end = input.length(); // first char is the contextual slash, skip @@ -259,8 +225,7 @@ * @param input Full input for the tail being parsed * @param i Offset to character after tilde */ - protected static JsonPointer _parseQuotedTail(String input, int i) - { + protected static JsonPointer _parseQuotedTail(String input, int i) { final int end = input.length(); StringBuilder sb = new StringBuilder(Math.max(16, end)); if (i > 2) { @@ -284,8 +249,7 @@ return new JsonPointer(input, sb.toString(), EMPTY); } - private static void _appendEscape(StringBuilder sb, char c) - { + private static void _appendEscape(StringBuilder sb, char c) { if (c == '0') { c = '~'; } else if (c == '1') {
diff --git a/src/main/java/com/fasterxml/jackson/core/JsonProcessingException.java b/src/main/java/com/fasterxml/jackson/core/JsonProcessingException.java index 71682dd..4cca715 100644 --- a/src/main/java/com/fasterxml/jackson/core/JsonProcessingException.java +++ b/src/main/java/com/fasterxml/jackson/core/JsonProcessingException.java
@@ -12,15 +12,13 @@ * Regular {@link java.io.IOException}s will be passed through as is. * Sub-class of {@link java.io.IOException} for convenience. */ -public class JsonProcessingException - extends java.io.IOException +public class JsonProcessingException extends java.io.IOException { final static long serialVersionUID = 123; // Stupid eclipse... protected JsonLocation _location; - protected JsonProcessingException(String msg, JsonLocation loc, Throwable rootCause) - { + protected JsonProcessingException(String msg, JsonLocation loc, Throwable rootCause) { /* Argh. IOException(Throwable,String) is only available starting * with JDK 1.6... */ @@ -31,29 +29,23 @@ _location = loc; } - protected JsonProcessingException(String msg) - { + protected JsonProcessingException(String msg) { super(msg); } - protected JsonProcessingException(String msg, JsonLocation loc) - { + protected JsonProcessingException(String msg, JsonLocation loc) { this(msg, loc, null); } - protected JsonProcessingException(String msg, Throwable rootCause) - { + protected JsonProcessingException(String msg, Throwable rootCause) { this(msg, null, rootCause); } - protected JsonProcessingException(Throwable rootCause) - { + protected JsonProcessingException(Throwable rootCause) { this(null, null, rootCause); } - public JsonLocation getLocation() { - return _location; - } + public JsonLocation getLocation() { return _location; } /* /********************************************************** @@ -68,10 +60,7 @@ * * @since 2.1 */ - public String getOriginalMessage() - { - return super.getMessage(); - } + public String getOriginalMessage() { return super.getMessage(); } /* /********************************************************** @@ -84,9 +73,7 @@ * information right after the main message, but before * source location information. */ - protected String getMessageSuffix() { - return null; - } + protected String getMessageSuffix() { return null; } /* /********************************************************** @@ -97,9 +84,7 @@ /** * Default method overridden so that we can add location information */ - @Override - public String getMessage() - { + @Override public String getMessage() { String msg = super.getMessage(); if (msg == null) { msg = "N/A"; @@ -123,8 +108,5 @@ return msg; } - @Override - public String toString() { - return getClass().getName()+": "+getMessage(); - } + @Override public String toString() { return getClass().getName()+": "+getMessage(); } }
diff --git a/src/main/java/com/fasterxml/jackson/core/JsonStreamContext.java b/src/main/java/com/fasterxml/jackson/core/JsonStreamContext.java index ea81b72..ecea546 100644 --- a/src/main/java/com/fasterxml/jackson/core/JsonStreamContext.java +++ b/src/main/java/com/fasterxml/jackson/core/JsonStreamContext.java
@@ -90,18 +90,12 @@ /** * @return Number of entries that are complete and started. */ - public final int getEntryCount() - { - return _index + 1; - } + public final int getEntryCount() { return _index + 1; } /** * @return Index of the currently processed entry, if any */ - public final int getCurrentIndex() - { - return (_index < 0) ? 0 : _index; - } + public final int getCurrentIndex() { return (_index < 0) ? 0 : _index; } /** * Method for accessing name associated with the current location.
diff --git a/src/main/java/com/fasterxml/jackson/core/JsonToken.java b/src/main/java/com/fasterxml/jackson/core/JsonToken.java index 38e73fa..5ac4185 100644 --- a/src/main/java/com/fasterxml/jackson/core/JsonToken.java +++ b/src/main/java/com/fasterxml/jackson/core/JsonToken.java
@@ -169,9 +169,7 @@ public final char[] asCharArray() { return _serializedChars; } public final byte[] asByteArray() { return _serializedBytes; } - public final boolean isNumeric() { - return _isNumber; - } + public final boolean isNumeric() { return _isNumber; } /** * Accessor that is functionally equivalent to: @@ -181,9 +179,7 @@ * * @since 2.3 */ - public final boolean isStructStart() { - return _isStructStart; - } + public final boolean isStructStart() { return _isStructStart; } /** * Accessor that is functionally equivalent to: @@ -193,20 +189,13 @@ * * @since 2.3 */ - public final boolean isStructEnd() { - return _isStructEnd; - } + public final boolean isStructEnd() { return _isStructEnd; } /** * Method that can be used to check whether this token represents * a valid non-structured value. This means all tokens other than * Object/Array start/end markers all field names. */ - public final boolean isScalarValue() { - return _isScalar; - } - - public final boolean isBoolean() { - return _isBoolean; - } + public final boolean isScalarValue() { return _isScalar; } + public final boolean isBoolean() { return _isBoolean; } }
diff --git a/src/main/java/com/fasterxml/jackson/core/TreeCodec.java b/src/main/java/com/fasterxml/jackson/core/TreeCodec.java index 0394e9b..b1037b6 100644 --- a/src/main/java/com/fasterxml/jackson/core/TreeCodec.java +++ b/src/main/java/com/fasterxml/jackson/core/TreeCodec.java
@@ -10,14 +10,9 @@ */ public abstract class TreeCodec { - public abstract <T extends TreeNode> T readTree(JsonParser jp) - throws IOException, JsonProcessingException; - - public abstract void writeTree(JsonGenerator jg, TreeNode tree) - throws IOException, JsonProcessingException; - + public abstract <T extends TreeNode> T readTree(JsonParser jp) throws IOException, JsonProcessingException; + public abstract void writeTree(JsonGenerator jg, TreeNode tree) throws IOException, JsonProcessingException; public abstract TreeNode createArrayNode(); public abstract TreeNode createObjectNode(); - public abstract JsonParser treeAsTokens(TreeNode node); }
diff --git a/src/main/java/com/fasterxml/jackson/core/TreeNode.java b/src/main/java/com/fasterxml/jackson/core/TreeNode.java index 85d6d7e..1e4f659 100644 --- a/src/main/java/com/fasterxml/jackson/core/TreeNode.java +++ b/src/main/java/com/fasterxml/jackson/core/TreeNode.java
@@ -247,8 +247,7 @@ * * @since 2.3 */ - TreeNode at(String jsonPointerExpression) - throws IllegalArgumentException; + TreeNode at(String jsonPointerExpression) throws IllegalArgumentException; /* /**********************************************************
diff --git a/src/main/java/com/fasterxml/jackson/core/Version.java b/src/main/java/com/fasterxml/jackson/core/Version.java index d5e5507..48b9163 100644 --- a/src/main/java/com/fasterxml/jackson/core/Version.java +++ b/src/main/java/com/fasterxml/jackson/core/Version.java
@@ -14,8 +14,7 @@ * if provided, they should align with Maven artifact information. */ public class Version - implements Comparable<Version>, - java.io.Serializable + implements Comparable<Version>, java.io.Serializable { private static final long serialVersionUID = 1L; @@ -79,9 +78,7 @@ return _groupId + '/' + _artifactId + '/' + toString(); } - @Override - public String toString() - { + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(_majorVersion).append('.'); sb.append(_minorVersion).append('.'); @@ -92,8 +89,7 @@ return sb.toString(); } - @Override - public int hashCode() { + @Override public int hashCode() { return _artifactId.hashCode() ^ _groupId.hashCode() + _majorVersion - _minorVersion + _patchLevel; }
diff --git a/src/main/java/com/fasterxml/jackson/core/base/GeneratorBase.java b/src/main/java/com/fasterxml/jackson/core/base/GeneratorBase.java index 07e3f9c..f249133 100644 --- a/src/main/java/com/fasterxml/jackson/core/base/GeneratorBase.java +++ b/src/main/java/com/fasterxml/jackson/core/base/GeneratorBase.java
@@ -13,8 +13,7 @@ * to applications, adds shared internal methods that sub-classes * can use and adds some abstract methods sub-classes must implement. */ -public abstract class GeneratorBase - extends JsonGenerator +public abstract class GeneratorBase extends JsonGenerator { /* /********************************************************** @@ -63,8 +62,7 @@ /********************************************************** */ - protected GeneratorBase(int features, ObjectCodec codec) - { + protected GeneratorBase(int features, ObjectCodec codec) { super(); _features = features; DupDetector dups = Feature.STRICT_DUPLICATE_DETECTION.enabledIn(features) @@ -78,10 +76,7 @@ * Implemented with detection that tries to find "VERSION.txt" in same * package as the implementation class. */ - @Override - public Version version() { - return VersionUtil.versionFor(getClass()); - } + @Override public Version version() { return VersionUtil.versionFor(getClass()); } /* /********************************************************** @@ -113,24 +108,15 @@ //public JsonGenerator configure(Feature f, boolean state) { } - @Override - public final boolean isEnabled(Feature f) { - return (_features & f.getMask()) != 0; - } + @Override public final boolean isEnabled(Feature f) { return (_features & f.getMask()) != 0; } + @Override public int getFeatureMask() { return _features; } - @Override - public int getFeatureMask() { - return _features; - } - - @Override - public JsonGenerator setFeatureMask(int mask) { + @Override public JsonGenerator setFeatureMask(int mask) { _features = mask; return this; } - @Override - public JsonGenerator useDefaultPrettyPrinter() { + @Override public JsonGenerator useDefaultPrettyPrinter() { /* 28-Sep-2012, tatu: As per [Issue#84], should not override a * pretty printer if one already assigned. */ @@ -140,14 +126,12 @@ return setPrettyPrinter(new DefaultPrettyPrinter()); } - @Override - public JsonGenerator setCodec(ObjectCodec oc) { + @Override public JsonGenerator setCodec(ObjectCodec oc) { _objectCodec = oc; return this; } - @Override - public final ObjectCodec getCodec() { return _objectCodec; } + @Override public final ObjectCodec getCodec() { return _objectCodec; } /* /********************************************************** @@ -158,8 +142,7 @@ /** * Note: co-variant return type. */ - @Override - public final JsonWriteContext getOutputContext() { return _writeContext; } + @Override public final JsonWriteContext getOutputContext() { return _writeContext; } /* /********************************************************** @@ -167,10 +150,10 @@ /********************************************************** */ - //public void writeStartArray() throws IOException, JsonGenerationException - //public void writeEndArray() throws IOException, JsonGenerationException - //public void writeStartObject() throws IOException, JsonGenerationException - //public void writeEndObject() throws IOException, JsonGenerationException + //public void writeStartArray() throws IOException + //public void writeEndArray() throws IOException + //public void writeStartObject() throws IOException + //public void writeEndObject() throws IOException /* /********************************************************** @@ -178,50 +161,40 @@ /********************************************************** */ - @Override - public void writeFieldName(SerializableString name) throws IOException, JsonGenerationException { + @Override public void writeFieldName(SerializableString name) throws IOException { writeFieldName(name.getValue()); } - //public abstract void writeString(String text) throws IOException, JsonGenerationException; + //public abstract void writeString(String text) throws IOException; - //public abstract void writeString(char[] text, int offset, int len) throws IOException, JsonGenerationException; + //public abstract void writeString(char[] text, int offset, int len) throws IOException; - //public abstract void writeRaw(String text) throws IOException, JsonGenerationException; + //public abstract void writeRaw(String text) throws IOException,; - //public abstract void writeRaw(char[] text, int offset, int len) throws IOException, JsonGenerationException; + //public abstract void writeRaw(char[] text, int offset, int len) throws IOException; @Override - public void writeString(SerializableString text) throws IOException, JsonGenerationException { + public void writeString(SerializableString text) throws IOException { writeString(text.getValue()); } - @Override - public void writeRawValue(String text) throws IOException, JsonGenerationException - { + @Override public void writeRawValue(String text) throws IOException { _verifyValueWrite("write raw value"); writeRaw(text); } - @Override - public void writeRawValue(String text, int offset, int len) - throws IOException, JsonGenerationException - { + @Override public void writeRawValue(String text, int offset, int len) throws IOException { + _verifyValueWrite("write raw value"); + writeRaw(text, offset, len); + } + + @Override public void writeRawValue(char[] text, int offset, int len) throws IOException { _verifyValueWrite("write raw value"); writeRaw(text, offset, len); } @Override - public void writeRawValue(char[] text, int offset, int len) - throws IOException, JsonGenerationException - { - _verifyValueWrite("write raw value"); - writeRaw(text, offset, len); - } - - @Override - public int writeBinary(Base64Variant b64variant, InputStream data, int dataLength) - throws IOException, JsonGenerationException { + public int writeBinary(Base64Variant b64variant, InputStream data, int dataLength) throws IOException { // Let's implement this as "unsupported" to make it easier to add new parser impls _reportUnsupportedOperation(); return 0; @@ -252,9 +225,7 @@ */ @Override - public void writeObject(Object value) - throws IOException, JsonProcessingException - { + public void writeObject(Object value) throws IOException { if (value == null) { // important: call method that does check value write: writeNull(); @@ -273,9 +244,7 @@ } @Override - public void writeTree(TreeNode rootNode) - throws IOException, JsonProcessingException - { + public void writeTree(TreeNode rootNode) throws IOException { // As with 'writeObject()', we are not check if write would work if (rootNode == null) { writeNull(); @@ -293,17 +262,9 @@ /********************************************************** */ - @Override - public abstract void flush() throws IOException; - - @Override - public void close() throws IOException - { - _closed = true; - } - - @Override - public boolean isClosed() { return _closed; } + @Override public abstract void flush() throws IOException; + @Override public void close() throws IOException { _closed = true; } + @Override public boolean isClosed() { return _closed; } /* /********************************************************** @@ -325,15 +286,5 @@ * @param typeMsg Additional message used for generating exception message * if value output is NOT legal in current generator output state. */ - protected abstract void _verifyValueWrite(String typeMsg) - throws IOException, JsonGenerationException; - - // @Deprecated in 2.3 -- now defined in super-class; remove in 2.4 - @Override - protected void _writeSimpleObject(Object value) - throws IOException, JsonGenerationException - { - // TODO: - super._writeSimpleObject(value); - } + protected abstract void _verifyValueWrite(String typeMsg) throws IOException; }
diff --git a/src/main/java/com/fasterxml/jackson/core/base/ParserBase.java b/src/main/java/com/fasterxml/jackson/core/base/ParserBase.java index 4ef86fd..482f6e4 100644 --- a/src/main/java/com/fasterxml/jackson/core/base/ParserBase.java +++ b/src/main/java/com/fasterxml/jackson/core/base/ParserBase.java
@@ -18,8 +18,7 @@ * implementations. Contains most common things that are independent * of actual underlying input source. */ -public abstract class ParserBase - extends ParserMinimalBase +public abstract class ParserBase extends ParserMinimalBase { /* /********************************************************** @@ -281,8 +280,7 @@ /********************************************************** */ - protected ParserBase(IOContext ctxt, int features) - { + protected ParserBase(IOContext ctxt, int features) { super(); _features = features; _ioContext = ctxt; @@ -292,10 +290,7 @@ _parsingContext = JsonReadContext.createRootContext(dups); } - @Override - public Version version() { - return PackageVersion.VERSION; - } + @Override public Version version() { return PackageVersion.VERSION; } /* /********************************************************** @@ -307,9 +302,7 @@ * Method that can be called to get the name associated with * the current event. */ - @Override - public String getCurrentName() throws IOException - { + @Override public String getCurrentName() throws IOException { // [JACKSON-395]: start markers require information from parent if (_currToken == JsonToken.START_OBJECT || _currToken == JsonToken.START_ARRAY) { JsonReadContext parent = _parsingContext.getParent(); @@ -318,9 +311,7 @@ return _parsingContext.getCurrentName(); } - @Override - public void overrideCurrentName(String name) - { + @Override public void overrideCurrentName(String name) { // Simple, but need to look for START_OBJECT/ARRAY's "off-by-one" thing: JsonReadContext ctxt = _parsingContext; if (_currToken == JsonToken.START_OBJECT || _currToken == JsonToken.START_ARRAY) { @@ -336,8 +327,7 @@ } } - @Override - public void close() throws IOException { + @Override public void close() throws IOException { if (!_closed) { _closed = true; try { @@ -350,13 +340,8 @@ } } - @Override - public boolean isClosed() { return _closed; } - - @Override - public JsonReadContext getParsingContext() { - return _parsingContext; - } + @Override public boolean isClosed() { return _closed; } + @Override public JsonReadContext getParsingContext() { return _parsingContext; } /** * Method that return the <b>starting</b> location of the current @@ -364,8 +349,7 @@ * that starts the current token. */ @Override - public JsonLocation getTokenLocation() - { + public JsonLocation getTokenLocation() { return new JsonLocation(_ioContext.getSourceReference(), -1L, getTokenCharacterOffset(), // bytes, chars getTokenLineNr(), @@ -377,8 +361,7 @@ * usually for error reporting purposes */ @Override - public JsonLocation getCurrentLocation() - { + public JsonLocation getCurrentLocation() { int col = _inputPtr - _currInputRowStart + 1; // 1-based return new JsonLocation(_ioContext.getSourceReference(), -1L, _currInputProcessed + _inputPtr, // bytes, chars @@ -392,22 +375,14 @@ */ @Override - public boolean hasTextCharacters() - { - if (_currToken == JsonToken.VALUE_STRING) { - return true; // usually true - } - if (_currToken == JsonToken.FIELD_NAME) { - return _nameCopied; - } + public boolean hasTextCharacters() { + if (_currToken == JsonToken.VALUE_STRING) { return true; } // usually true + if (_currToken == JsonToken.FIELD_NAME) { return _nameCopied; } return false; } // No embedded objects with base impl... - @Override - public Object getEmbeddedObject() throws IOException { - return null; - } + @Override public Object getEmbeddedObject() throws IOException { return null; } /* /********************************************************** @@ -440,9 +415,7 @@ */ protected abstract boolean loadMore() throws IOException; - protected abstract void _finishString() throws IOException; - protected abstract void _closeInput() throws IOException; /* @@ -457,8 +430,7 @@ * example, when explicitly closing this reader instance), or * separately (if need be). */ - protected void _releaseBuffers() throws IOException - { + protected void _releaseBuffers() throws IOException { _textBuffer.releaseBuffers(); char[] buf = _nameCopyBuffer; if (buf != null) { @@ -473,8 +445,7 @@ * is no open non-root context. */ @Override - protected void _handleEOF() throws JsonParseException - { + protected void _handleEOF() throws JsonParseException { if (!_parsingContext.inRoot()) { _reportInvalidEOF(": expected close marker for "+_parsingContext.getTypeDesc()+" (from "+_parsingContext.getStartLocation(_ioContext.getSourceReference())+")"); } @@ -486,8 +457,7 @@ /********************************************************** */ - protected void _reportMismatchedEndMarker(int actCh, char expCh) throws JsonParseException - { + protected void _reportMismatchedEndMarker(int actCh, char expCh) throws JsonParseException { String startDesc = ""+_parsingContext.getStartLocation(_ioContext.getSourceReference()); _reportError("Unexpected close marker '"+((char) actCh)+"': expected '"+expCh+"' (for "+_parsingContext.getTypeDesc()+" starting at "+startDesc+")"); } @@ -1030,9 +1000,7 @@ return bits; } - protected IllegalArgumentException reportInvalidBase64Char(Base64Variant b64variant, int ch, int bindex) - throws IllegalArgumentException - { + protected IllegalArgumentException reportInvalidBase64Char(Base64Variant b64variant, int ch, int bindex) throws IllegalArgumentException { return reportInvalidBase64Char(b64variant, ch, bindex, null); } @@ -1040,9 +1008,7 @@ * @param bindex Relative index within base64 character unit; between 0 * and 3 (as unit has exactly 4 characters) */ - protected IllegalArgumentException reportInvalidBase64Char(Base64Variant b64variant, int ch, int bindex, String msg) - throws IllegalArgumentException - { + protected IllegalArgumentException reportInvalidBase64Char(Base64Variant b64variant, int ch, int bindex, String msg) throws IllegalArgumentException { String base; if (ch <= INT_SPACE) { base = "Illegal white space character (code 0x"+Integer.toHexString(ch)+") as character #"+(bindex+1)+" of 4-char base64 unit: can only used between units";
diff --git a/src/main/java/com/fasterxml/jackson/core/base/ParserMinimalBase.java b/src/main/java/com/fasterxml/jackson/core/base/ParserMinimalBase.java index 1349cc2..f8574dc 100644 --- a/src/main/java/com/fasterxml/jackson/core/base/ParserMinimalBase.java +++ b/src/main/java/com/fasterxml/jackson/core/base/ParserMinimalBase.java
@@ -19,8 +19,7 @@ * (size) and functionality that is specific to certain types * of parser implementations; but not necessarily to number of methods. */ -public abstract class ParserMinimalBase - extends JsonParser +public abstract class ParserMinimalBase extends JsonParser { // Control chars: protected final static int INT_TAB = '\t'; @@ -65,14 +64,10 @@ */ protected ParserMinimalBase() { } - protected ParserMinimalBase(int features) { - super(features); - } + protected ParserMinimalBase(int features) { super(features); } - @Override - public Version version() { - return VersionUtil.versionFor(getClass()); - } + // NOTE: had base impl in 2.3 and before; but shouldn't + // public abstract Version version(); /* /********************************************************** @@ -93,29 +88,18 @@ /********************************************************** */ - @Override - public abstract JsonToken nextToken() throws IOException, JsonParseException; + @Override public abstract JsonToken nextToken() throws IOException, JsonParseException; + @Override public JsonToken getCurrentToken() { return _currToken; } - @Override - public JsonToken getCurrentToken() { - return _currToken; - } - - @Override - public final int getCurrentTokenId() { + @Override public final int getCurrentTokenId() { final JsonToken t = _currToken; return (t == null) ? JsonTokenId.ID_NO_TOKEN : t.id(); } - @Override - public boolean hasCurrentToken() { - return _currToken != null; - } + @Override public boolean hasCurrentToken() { return _currToken != null; } @Override - public JsonToken nextValue() - throws IOException, JsonParseException - { + public JsonToken nextValue() throws IOException { /* Implementation should be as trivial as follows; only * needs to change if we are to skip other tokens (for * example, if comments were exposed as tokens) @@ -128,7 +112,7 @@ } @Override - public JsonParser skipChildren() throws IOException, JsonParseException + public JsonParser skipChildren() throws IOException { if (_currToken != JsonToken.START_OBJECT && _currToken != JsonToken.START_ARRAY) { @@ -165,20 +149,13 @@ protected abstract void _handleEOF() throws JsonParseException; //public JsonToken getCurrentToken() - //public boolean hasCurrentToken() - @Override - public abstract String getCurrentName() throws IOException, JsonParseException; - - @Override - public abstract void close() throws IOException; + @Override public abstract String getCurrentName() throws IOException; + @Override public abstract void close() throws IOException; + @Override public abstract boolean isClosed(); - @Override - public abstract boolean isClosed(); - - @Override - public abstract JsonStreamContext getParsingContext(); + @Override public abstract JsonStreamContext getParsingContext(); // public abstract JsonLocation getTokenLocation(); @@ -190,21 +167,16 @@ /********************************************************** */ - @Override - public void clearCurrentToken() { + @Override public void clearCurrentToken() { if (_currToken != null) { _lastClearedToken = _currToken; _currToken = null; } } - @Override - public JsonToken getLastClearedToken() { - return _lastClearedToken; - } + @Override public JsonToken getLastClearedToken() { return _lastClearedToken; } - @Override - public abstract void overrideCurrentName(String name); + @Override public abstract void overrideCurrentName(String name); /* /********************************************************** @@ -212,20 +184,11 @@ /********************************************************** */ - @Override - public abstract String getText() throws IOException, JsonParseException; - - @Override - public abstract char[] getTextCharacters() throws IOException, JsonParseException; - - @Override - public abstract boolean hasTextCharacters(); - - @Override - public abstract int getTextLength() throws IOException, JsonParseException; - - @Override - public abstract int getTextOffset() throws IOException, JsonParseException; + @Override public abstract String getText() throws IOException; + @Override public abstract char[] getTextCharacters() throws IOException; + @Override public abstract boolean hasTextCharacters(); + @Override public abstract int getTextLength() throws IOException; + @Override public abstract int getTextOffset() throws IOException; /* /********************************************************** @@ -233,9 +196,7 @@ /********************************************************** */ - @Override - public abstract byte[] getBinaryValue(Base64Variant b64variant) - throws IOException, JsonParseException; + @Override public abstract byte[] getBinaryValue(Base64Variant b64variant) throws IOException; /* /********************************************************** @@ -244,7 +205,7 @@ */ @Override - public boolean getValueAsBoolean(boolean defaultValue) throws IOException, JsonParseException + public boolean getValueAsBoolean(boolean defaultValue) throws IOException { JsonToken t = _currToken; if (t != null) { @@ -281,7 +242,7 @@ } @Override - public int getValueAsInt(int defaultValue) throws IOException, JsonParseException + public int getValueAsInt(int defaultValue) throws IOException { JsonToken t = _currToken; if (t != null) { @@ -312,7 +273,7 @@ } @Override - public long getValueAsLong(long defaultValue) throws IOException, JsonParseException + public long getValueAsLong(long defaultValue) throws IOException { JsonToken t = _currToken; if (t != null) { @@ -342,7 +303,7 @@ } @Override - public double getValueAsDouble(double defaultValue) throws IOException, JsonParseException + public double getValueAsDouble(double defaultValue) throws IOException { JsonToken t = _currToken; if (t != null) { @@ -372,8 +333,7 @@ } @Override - public String getValueAsString(String defaultValue) throws IOException, JsonParseException - { + public String getValueAsString(String defaultValue) throws IOException { if (_currToken != JsonToken.VALUE_STRING) { if (_currToken == null || _currToken == JsonToken.VALUE_NULL || !_currToken.isScalarValue()) { return defaultValue; @@ -392,8 +352,7 @@ * Helper method that can be used for base64 decoding in cases where * encoded content has already been read as a String. */ - protected void _decodeBase64(String str, ByteArrayBuilder builder, Base64Variant b64variant) - throws IOException, JsonParseException + protected void _decodeBase64(String str, ByteArrayBuilder builder, Base64Variant b64variant) throws IOException { // just call helper method introduced in 2.2.3 try { @@ -452,9 +411,7 @@ * * @since 2.3 */ - protected boolean _hasTextualNull(String value) { - return "null".equals(value); - } + protected boolean _hasTextualNull(String value) { return "null".equals(value); } /* /********************************************************** @@ -462,8 +419,7 @@ /********************************************************** */ - protected void _reportUnexpectedChar(int ch, String comment) - throws JsonParseException + protected void _reportUnexpectedChar(int ch, String comment) throws JsonParseException { if (ch < 0) { // sanity check _reportInvalidEOF(); @@ -475,15 +431,11 @@ _reportError(msg); } - protected void _reportInvalidEOF() - throws JsonParseException - { + protected void _reportInvalidEOF() throws JsonParseException { _reportInvalidEOF(" in "+_currToken); } - protected void _reportInvalidEOF(String msg) - throws JsonParseException - { + protected void _reportInvalidEOF(String msg) throws JsonParseException { _reportError("Unexpected end-of-input"+msg); } @@ -495,9 +447,7 @@ _reportUnexpectedChar(ch, "Expected space separating root-level values"); } - protected void _throwInvalidSpace(int i) - throws JsonParseException - { + protected void _throwInvalidSpace(int i) throws JsonParseException { char c = (char) i; String msg = "Illegal character ("+_getCharDesc(c)+"): only regular white space (\\r, \\n, \\t) is allowed between tokens"; _reportError(msg); @@ -508,9 +458,7 @@ * Note: starting with version 1.4, it is possible to suppress * exception by enabling {@link Feature#ALLOW_UNQUOTED_CONTROL_CHARS}. */ - protected void _throwUnquotedSpace(int i, String ctxtDesc) - throws JsonParseException - { + protected void _throwUnquotedSpace(int i, String ctxtDesc) throws JsonParseException { // JACKSON-208; possible to allow unquoted control chars: if (!isEnabled(Feature.ALLOW_UNQUOTED_CONTROL_CHARS) || i >= INT_SPACE) { char c = (char) i; @@ -519,8 +467,7 @@ } } - protected char _handleUnrecognizedCharacterEscape(char ch) throws JsonProcessingException - { + protected char _handleUnrecognizedCharacterEscape(char ch) throws JsonProcessingException { // as per [JACKSON-300] if (isEnabled(Feature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER)) { return ch;
diff --git a/src/main/java/com/fasterxml/jackson/core/format/DataFormatDetector.java b/src/main/java/com/fasterxml/jackson/core/format/DataFormatDetector.java index 516bf3e..1156f88 100644 --- a/src/main/java/com/fasterxml/jackson/core/format/DataFormatDetector.java +++ b/src/main/java/com/fasterxml/jackson/core/format/DataFormatDetector.java
@@ -90,8 +90,7 @@ * Method that will return a detector instance that allows detectors to * read up to specified number of bytes when determining format match strength. */ - public DataFormatDetector withMaxInputLookahead(int lookaheadBytes) - { + public DataFormatDetector withMaxInputLookahead(int lookaheadBytes) { if (lookaheadBytes == _maxInputLookahead) { return this; } @@ -99,9 +98,7 @@ } private DataFormatDetector(JsonFactory[] detectors, - MatchStrength optMatch, MatchStrength minMatch, - int maxInputLookahead) - { + MatchStrength optMatch, MatchStrength minMatch, int maxInputLookahead) { _detectors = detectors; _optimalMatch = optMatch; _minimalMatch = minMatch; @@ -122,8 +119,7 @@ * @return Matcher object which contains result; never null, even in cases * where no match (with specified minimal match strength) is found. */ - public DataFormatMatcher findFormat(InputStream in) throws IOException - { + public DataFormatMatcher findFormat(InputStream in) throws IOException { return _findFormat(new InputAccessor.Std(in, new byte[_maxInputLookahead])); } @@ -134,8 +130,7 @@ * @return Matcher object which contains result; never null, even in cases * where no match (with specified minimal match strength) is found. */ - public DataFormatMatcher findFormat(byte[] fullInputData) throws IOException - { + public DataFormatMatcher findFormat(byte[] fullInputData) throws IOException { return _findFormat(new InputAccessor.Std(fullInputData)); } @@ -148,8 +143,7 @@ * * @since 2.1 */ - public DataFormatMatcher findFormat(byte[] fullInputData, int offset, int len) throws IOException - { + public DataFormatMatcher findFormat(byte[] fullInputData, int offset, int len) throws IOException { return _findFormat(new InputAccessor.Std(fullInputData, offset, len)); } @@ -159,9 +153,7 @@ /********************************************************** */ - @Override - public String toString() - { + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append('['); final int len = _detectors.length; @@ -182,8 +174,7 @@ /********************************************************** */ - private DataFormatMatcher _findFormat(InputAccessor.Std acc) throws IOException - { + private DataFormatMatcher _findFormat(InputAccessor.Std acc) throws IOException { JsonFactory bestMatch = null; MatchStrength bestMatchStrength = null; for (JsonFactory f : _detectors) {