From 3dcedd2b6838ef29abb179557b6e42479e93834b Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sat, 10 Jan 2015 20:15:06 -0800 Subject: [PATCH] Fix #178. Also fix a few javadoc processor warnings --- release-notes/VERSION | 12 ++++-- .../jackson/core/Base64Variants.java | 2 +- .../fasterxml/jackson/core/JsonGenerator.java | 42 ++++++++++++------- .../fasterxml/jackson/core/JsonParser.java | 11 ++--- .../core/sym/CharsToNameCanonicalizer.java | 2 +- .../jackson/core/type/TypeReference.java | 4 +- .../core/util/DefaultPrettyPrinter.java | 21 ++++++++-- 7 files changed, 65 insertions(+), 29 deletions(-) diff --git a/release-notes/VERSION b/release-notes/VERSION index 2b0f90ed79..d148fd3e84 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -1,18 +1,24 @@ Project: jackson-core Contains core streaming reader (`JsonParser`) and writer (`JsonGenerator`) abstractions, -factory for constructing readers/writers (JsonFactory). as well as a minimal set +factory for constructing readers/writers (JsonFactory), as well as a minimal set of interfaces needed for streaming level to make callbacks and call-throughs, via `ObjectCodec` and `TreeNode`. -Also includes implementation of abstractsion for JSON, +Also includes implementation of this API for JSON. Forms the base for other data formats as well, despite naming that suggests -json-specificity (naming due to historical reasons). +JSON-specificity: naming is due to history, as Jackson started out as pure +JSON library. ------------------------------------------------------------------------ === Releases === ------------------------------------------------------------------------ +2.5.1 (not yet released) + +#178: Add `Lf2SpacesIndenter.withLinefeed` back to keep binary-compatibility with 2.4.x + (reported by ansell@github) + 2.5.0 (01-Jan-2015) #148: BytesToNameCanonicalizer can mishandle leading null byte(s). diff --git a/src/main/java/com/fasterxml/jackson/core/Base64Variants.java b/src/main/java/com/fasterxml/jackson/core/Base64Variants.java index 4e65bdc1bb..36867949ef 100644 --- a/src/main/java/com/fasterxml/jackson/core/Base64Variants.java +++ b/src/main/java/com/fasterxml/jackson/core/Base64Variants.java @@ -23,7 +23,7 @@ public final class Base64Variants * This variant is what most people would think of "the standard" * Base64 encoding. *

- * See wikipedia Base64 entry for details. + * See wikipedia Base64 entry for details. *

* Note that although this can be thought of as the standard variant, * it is not the default for Jackson: no-linefeeds alternative diff --git a/src/main/java/com/fasterxml/jackson/core/JsonGenerator.java b/src/main/java/com/fasterxml/jackson/core/JsonGenerator.java index 60fdfbf51d..9167f3ccd0 100644 --- a/src/main/java/com/fasterxml/jackson/core/JsonGenerator.java +++ b/src/main/java/com/fasterxml/jackson/core/JsonGenerator.java @@ -293,7 +293,7 @@ public Object getOutputTarget() { * Helper method, usually equivalent to: * * getOutputContext().getCurrentValue(); - * + * * * @since 2.5 */ @@ -306,7 +306,7 @@ public Object getCurrentValue() { * Helper method, usually equivalent to: * * getOutputContext().setCurrentValue(v); - * + * * * @since 2.5 */ @@ -965,69 +965,83 @@ public abstract int writeBinary(Base64Variant bv, */ /** - * Method for outputting given value as Json number. + * Method for outputting given value as JSON number. * Can be called in any context where a value is expected * (Array value, Object field value, root-level value). * Additional white space may be added around the value * if pretty-printing is enabled. * + * @param v Number value to write + * * @since 2.2 */ public void writeNumber(short v) throws IOException { writeNumber((int) v); } /** - * Method for outputting given value as Json number. + * Method for outputting given value as JSON number. * Can be called in any context where a value is expected * (Array value, Object field value, root-level value). * Additional white space may be added around the value * if pretty-printing is enabled. + * + * @param v Number value to write */ public abstract void writeNumber(int v) throws IOException; /** - * Method for outputting given value as Json number. + * Method for outputting given value as JSON number. * Can be called in any context where a value is expected * (Array value, Object field value, root-level value). * Additional white space may be added around the value * if pretty-printing is enabled. + * + * @param v Number value to write */ public abstract void writeNumber(long v) throws IOException; /** - * Method for outputting given value as Json number. + * Method for outputting given value as JSON number. * Can be called in any context where a value is expected * (Array value, Object field value, root-level value). * Additional white space may be added around the value * if pretty-printing is enabled. + * + * @param v Number value to write */ public abstract void writeNumber(BigInteger v) throws IOException; /** - * Method for outputting indicate Json numeric value. + * Method for outputting indicate JSON numeric value. * Can be called in any context where a value is expected * (Array value, Object field value, root-level value). * Additional white space may be added around the value * if pretty-printing is enabled. + * + * @param v Number value to write */ - public abstract void writeNumber(double d) throws IOException; + public abstract void writeNumber(double v) throws IOException; /** - * Method for outputting indicate Json numeric value. + * Method for outputting indicate JSON numeric value. * Can be called in any context where a value is expected * (Array value, Object field value, root-level value). * Additional white space may be added around the value * if pretty-printing is enabled. + * + * @param v Number value to write */ - public abstract void writeNumber(float f) throws IOException; + public abstract void writeNumber(float v) throws IOException; /** - * Method for outputting indicate Json numeric value. + * Method for outputting indicate JSON numeric value. * Can be called in any context where a value is expected * (Array value, Object field value, root-level value). * Additional white space may be added around the value * if pretty-printing is enabled. + * + * @param v Number value to write */ - public abstract void writeNumber(BigDecimal dec) throws IOException; + public abstract void writeNumber(BigDecimal v) throws IOException; /** * Write method that can be used for custom numeric types that can @@ -1039,9 +1053,9 @@ public abstract int writeBinary(Base64Variant bv, *

* Note: because of lack of type safety, some generator * implementations may not be able to implement this - * method. For example, if a binary json format is used, + * method. For example, if a binary JSON format is used, * it may require type information for encoding; similarly - * for generator-wrappers around Java objects or Json nodes. + * for generator-wrappers around Java objects or JSON nodes. * If implementation does not implement this method, * it needs to throw {@link UnsupportedOperationException}. * diff --git a/src/main/java/com/fasterxml/jackson/core/JsonParser.java b/src/main/java/com/fasterxml/jackson/core/JsonParser.java index fd145003a2..1241164aba 100644 --- a/src/main/java/com/fasterxml/jackson/core/JsonParser.java +++ b/src/main/java/com/fasterxml/jackson/core/JsonParser.java @@ -281,7 +281,7 @@ protected JsonParser() { } * Helper method, usually equivalent to: * * getParsingContext().getCurrentValue(); - * + * * * @since 2.5 */ @@ -294,7 +294,7 @@ public Object getCurrentValue() { * Helper method, usually equivalent to: * * getParsingContext().setCurrentValue(v); - * + * * * @since 2.5 */ @@ -548,12 +548,13 @@ public JsonParser setFeatureMask(int mask) { * and returns result of that comparison. * It is functionally equivalent to: *

-     *  return (nextToken() == JsonToken.FIELD_NAME) && str.getValue().equals(getCurrentName());
+     *  return (nextToken() == JsonToken.FIELD_NAME) && str.getValue().equals(getCurrentName());
      *
* but may be faster for parser to verify, and can therefore be used if caller * expects to get such a property name from input next. * - * @param str Property name to compare next token to (if next token is JsonToken.FIELD_NAME) + * @param str Property name to compare next token to (if next token is + * JsonToken.FIELD_NAME) */ public boolean nextFieldName(SerializableString str) throws IOException, JsonParseException { return (nextToken() == JsonToken.FIELD_NAME) && str.getValue().equals(getCurrentName()); @@ -714,7 +715,7 @@ public Boolean nextBooleanValue() throws IOException, JsonParseException { * Method that is functionally equivalent to: * * return getCurrentTokenId() == id - * + * * but may be more efficiently implemented. *

* Note that no traversal or conversion is performed; so in some diff --git a/src/main/java/com/fasterxml/jackson/core/sym/CharsToNameCanonicalizer.java b/src/main/java/com/fasterxml/jackson/core/sym/CharsToNameCanonicalizer.java index 819d224599..43fa7c79c4 100644 --- a/src/main/java/com/fasterxml/jackson/core/sym/CharsToNameCanonicalizer.java +++ b/src/main/java/com/fasterxml/jackson/core/sym/CharsToNameCanonicalizer.java @@ -21,7 +21,7 @@ * maps/sets, that hash codes are uniformly distributed. Also, collisions * are slightly more expensive than with HashMap or HashSet, since hash codes * are not used in resolving collisions; that is, equals() comparison is - * done with all symbols in same bucket index.
+ * done with all symbols in same bucket index.
* Finally, rehashing is also more expensive, as hash codes are not * stored; rehashing requires all entries' hash codes to be recalculated. * Reason for not storing hash codes is reduced memory usage, hoping diff --git a/src/main/java/com/fasterxml/jackson/core/type/TypeReference.java b/src/main/java/com/fasterxml/jackson/core/type/TypeReference.java index a3ec246980..ec1c1e0a50 100644 --- a/src/main/java/com/fasterxml/jackson/core/type/TypeReference.java +++ b/src/main/java/com/fasterxml/jackson/core/type/TypeReference.java @@ -17,9 +17,9 @@ * to ensure that a Type argument is indeed given. *

* Usage is by sub-classing: here is one way to instantiate reference - * to generic type List<Integer>: + * to generic type List<Integer>: *

- *  TypeReference ref = new TypeReference<List<Integer>>() { };
+ *  TypeReference ref = new TypeReference<List<Integer>>() { };
  *
* which can be passed to methods that accept TypeReference, or resolved * using TypeFactory to obtain {@link ResolvedType}. diff --git a/src/main/java/com/fasterxml/jackson/core/util/DefaultPrettyPrinter.java b/src/main/java/com/fasterxml/jackson/core/util/DefaultPrettyPrinter.java index ac8b4964c8..ebe0c75c1e 100644 --- a/src/main/java/com/fasterxml/jackson/core/util/DefaultPrettyPrinter.java +++ b/src/main/java/com/fasterxml/jackson/core/util/DefaultPrettyPrinter.java @@ -412,21 +412,36 @@ public void writeIndentation(JsonGenerator jg, int level) @Deprecated public static class Lf2SpacesIndenter extends DefaultIndenter { - /** @deprecated Use {@link DefaultIndenter#SYSTEM_LINEFEED_INSTANCE} instead */ + /** @deprecated Use {@link DefaultIndenter#SYSTEM_LINEFEED_INSTANCE} instead. + */ @SuppressWarnings("hiding") @Deprecated public static final Lf2SpacesIndenter instance = new Lf2SpacesIndenter(); - /** @deprecated Use {@code new DefaultIndenter(" ", DefaultIndenter.SYS_LF)} instead */ + /** @deprecated Use {@code new DefaultIndenter(" ", DefaultIndenter.SYS_LF)} instead + */ @Deprecated public Lf2SpacesIndenter() { super(" ", DefaultIndenter.SYS_LF); } - /** @deprecated Use {@code new DefaultIndenter(" ", lf)} instead */ + /** @deprecated Use {@code new DefaultIndenter(" ", lf)} instead + */ @Deprecated public Lf2SpacesIndenter(String lf) { super(" ", lf); } + + /** + * Note: method was accidentally missing from 2.5.0; put back for 2.5.1 and + * later 2.5.x versions. + */ + @Override + public Lf2SpacesIndenter withLinefeed(String lf) { + if (lf.equals(getEol())) { + return this; + } + return new Lf2SpacesIndenter(lf); + } } }