http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/internal/TeeWriter.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/internal/TeeWriter.java b/juneau-core/src/main/java/org/apache/juneau/internal/TeeWriter.java index b52a2b9..dd1dee5 100644 --- a/juneau-core/src/main/java/org/apache/juneau/internal/TeeWriter.java +++ b/juneau-core/src/main/java/org/apache/juneau/internal/TeeWriter.java @@ -44,8 +44,8 @@ public class TeeWriter extends Writer { * Adds a writer to this tee writer. * * @param w The writer to add to this tee writer. - * @param close If <jk>false</jk>, then calling {@link #close()} on this tee writer - * will not filter to the specified writer. + * @param close If <jk>false</jk>, then calling {@link #close()} on this tee writer will not filter to the + * specified writer. * @return This object (for method chaining). */ public TeeWriter add(Writer w, boolean close) { @@ -68,8 +68,8 @@ public class TeeWriter extends Writer { } /** - * Same as {@link #add(Writer, boolean)} but associates the writer with an identifier - * so the writer can be retrieved through {@link #getWriter(String)}. + * Same as {@link #add(Writer, boolean)} but associates the writer with an identifier so the writer can be retrieved + * through {@link #getWriter(String)}. * * @param id The ID to associate the writer with. * @param w The writer to add. @@ -95,8 +95,8 @@ public class TeeWriter extends Writer { } /** - * Returns the writer identified through the <code>id</code> parameter - * passed in through the {@link #add(String, Writer, boolean)} method. + * Returns the writer identified through the <code>id</code> parameter passed in through the + * {@link #add(String, Writer, boolean)} method. * * @param id The ID associated with the writer. * @return The writer, or <jk>null</jk> if no identifier was specified when the writer was added.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/internal/Utils.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/internal/Utils.java b/juneau-core/src/main/java/org/apache/juneau/internal/Utils.java index 741b6d2..2aeb77a 100644 --- a/juneau-core/src/main/java/org/apache/juneau/internal/Utils.java +++ b/juneau-core/src/main/java/org/apache/juneau/internal/Utils.java @@ -22,13 +22,9 @@ public class Utils { * * @param i1 Integer #1 * @param i2 Integer #2 - * @return the value <code>0</code> if Integer #1 is - * equal to Integer #2; a value less than - * <code>0</code> if Integer #1 numerically less - * than Integer #2; and a value greater - * than <code>0</code> if Integer #1 is numerically - * greater than Integer #2 (signed - * comparison). + * @return The value <code>0</code> if Integer #1 is equal to Integer #2; a value less than <code>0</code> if + * Integer #1 numerically less than Integer #2; and a value greater than <code>0</code> if Integer #1 is numerically + * greater than Integer #2 (signed comparison). */ public static final int compare(int i1, int i2) { return (i1<i2 ? -1 : (i1==i2 ? 0 : 1)); http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/internal/Version.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/internal/Version.java b/juneau-core/src/main/java/org/apache/juneau/internal/Version.java index 942043e..4630c37 100644 --- a/juneau-core/src/main/java/org/apache/juneau/internal/Version.java +++ b/juneau-core/src/main/java/org/apache/juneau/internal/Version.java @@ -27,13 +27,13 @@ public class Version { * Constructor * * @param versionString A string of the form <js>"#.#..."</js> where there can be any number of parts. - * <br>Valid values: - * <ul> - * <li><js>"1.2"</js> - * <li><js>"1.2.3"</js> - * <li><js>"0.1"</js> - * <li><js>".1"</js> - * </ul> + * <br>Valid values: + * <ul> + * <li><js>"1.2"</js> + * <li><js>"1.2.3"</js> + * <li><js>"0.1"</js> + * <li><js>".1"</js> + * </ul> * Any parts that are not numeric are interpreted as {@link Integer#MAX_VALUE} */ public Version(String versionString) { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/internal/WrappedMap.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/internal/WrappedMap.java b/juneau-core/src/main/java/org/apache/juneau/internal/WrappedMap.java index d1f0adf..534786d 100644 --- a/juneau-core/src/main/java/org/apache/juneau/internal/WrappedMap.java +++ b/juneau-core/src/main/java/org/apache/juneau/internal/WrappedMap.java @@ -16,6 +16,7 @@ import java.util.*; /** * Wraps an existing map inside an extensible interface so that convenience methods can be added to the subclass. + * * @param <K> The key type. * @param <V> The value type. */ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/jso/JsoParser.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/jso/JsoParser.java b/juneau-core/src/main/java/org/apache/juneau/jso/JsoParser.java index fad986f..ca975d0 100644 --- a/juneau-core/src/main/java/org/apache/juneau/jso/JsoParser.java +++ b/juneau-core/src/main/java/org/apache/juneau/jso/JsoParser.java @@ -34,6 +34,7 @@ public final class JsoParser extends InputStreamParser { /** * Constructor. + * * @param propertyStore The property store containing all the settings for this object. */ public JsoParser(PropertyStore propertyStore) { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/jso/JsoParserBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/jso/JsoParserBuilder.java b/juneau-core/src/main/java/org/apache/juneau/jso/JsoParserBuilder.java index 2052f42..f0a8c58 100644 --- a/juneau-core/src/main/java/org/apache/juneau/jso/JsoParserBuilder.java +++ b/juneau-core/src/main/java/org/apache/juneau/jso/JsoParserBuilder.java @@ -32,6 +32,7 @@ public class JsoParserBuilder extends ParserBuilder { /** * Constructor. + * * @param propertyStore The initial configuration settings for this builder. */ public JsoParserBuilder(PropertyStore propertyStore) { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializer.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializer.java b/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializer.java index d95cdbe..6989905 100644 --- a/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializer.java +++ b/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializer.java @@ -36,6 +36,7 @@ public class JsoSerializer extends OutputStreamSerializer { /** * Constructor. + * * @param propertyStore The property store containing all the settings for this object. */ public JsoSerializer(PropertyStore propertyStore) { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializerBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializerBuilder.java b/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializerBuilder.java index 5bb072d..d768a67 100644 --- a/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializerBuilder.java +++ b/juneau-core/src/main/java/org/apache/juneau/jso/JsoSerializerBuilder.java @@ -32,6 +32,7 @@ public class JsoSerializerBuilder extends SerializerBuilder { /** * Constructor. + * * @param propertyStore The initial configuration settings for this builder. */ public JsoSerializerBuilder(PropertyStore propertyStore) { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/json/JsonClassMeta.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonClassMeta.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonClassMeta.java index b274365..0598923 100644 --- a/juneau-core/src/main/java/org/apache/juneau/json/JsonClassMeta.java +++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonClassMeta.java @@ -19,7 +19,8 @@ import org.apache.juneau.internal.*; import org.apache.juneau.json.annotation.*; /** - * Metadata on classes specific to the JSON serializers and parsers pulled from the {@link Json @Json} annotation on the class. + * Metadata on classes specific to the JSON serializers and parsers pulled from the {@link Json @Json} annotation on + * the class. */ public class JsonClassMeta extends ClassMetaExtended { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/json/JsonParser.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonParser.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonParser.java index 17825a5..c86e207 100644 --- a/juneau-core/src/main/java/org/apache/juneau/json/JsonParser.java +++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonParser.java @@ -36,38 +36,42 @@ import org.apache.juneau.transform.*; * <h5 class='section'>Description:</h5> * <p> * This parser uses a state machine, which makes it very fast and efficient. It parses JSON in about 70% of the - * time that it takes the built-in Java DOM parsers to parse equivalent XML. + * time that it takes the built-in Java DOM parsers to parse equivalent XML. * <p> * This parser handles all valid JSON syntax. * In addition, when strict mode is disable, the parser also handles the following: - * <ul class='spaced-list'> - * <li> Javascript comments (both {@code /*} and {@code //}) are ignored. - * <li> Both single and double quoted strings. - * <li> Automatically joins concatenated strings (e.g. <code><js>"aaa"</js> + <js>'bbb'</js></code>). - * <li> Unquoted attributes. - * </ul> + * <ul class='spaced-list'> + * <li> Javascript comments (both {@code /*} and {@code //}) are ignored. + * <li> Both single and double quoted strings. + * <li> Automatically joins concatenated strings (e.g. <code><js>"aaa"</js> + <js>'bbb'</js></code>). + * <li> Unquoted attributes. + * </ul> * Also handles negative, decimal, hexadecimal, octal, and double numbers, including exponential notation. * <p> * This parser handles the following input, and automatically returns the corresponding Java class. - * <ul class='spaced-list'> - * <li> JSON objects (<js>"{...}"</js>) are converted to {@link ObjectMap ObjectMaps}. <br> - * <b>Note:</b> If a <code><xa>_type</xa>=<xs>'xxx'</xs></code> attribute is specified on the object, then an attempt is made to convert the object - * to an instance of the specified Java bean class. See the <code>beanTypeName</code> setting on the {@link PropertyStore} for more information - * about parsing beans from JSON. - * <li> JSON arrays (<js>"[...]"</js>) are converted to {@link ObjectList ObjectLists}. - * <li> JSON string literals (<js>"'xyz'"</js>) are converted to {@link String Strings}. - * <li> JSON numbers (<js>"123"</js>, including octal/hexadecimal/exponential notation) are converted to {@link Integer Integers}, - * {@link Long Longs}, {@link Float Floats}, or {@link Double Doubles} depending on whether the number is decimal, and the size of the number. - * <li> JSON booleans (<js>"false"</js>) are converted to {@link Boolean Booleans}. - * <li> JSON nulls (<js>"null"</js>) are converted to <jk>null</jk>. - * <li> Input consisting of only whitespace or JSON comments are converted to <jk>null</jk>. - * </ul> + * <ul class='spaced-list'> + * <li> JSON objects (<js>"{...}"</js>) are converted to {@link ObjectMap ObjectMaps}. <br> + * <b>Note:</b> If a <code><xa>_type</xa>=<xs>'xxx'</xs></code> attribute is specified on the object, then an + * attempt is made to convert the object to an instance of the specified Java bean class. + * See the <code>beanTypeName</code> setting on the {@link PropertyStore} for more information about parsing + * beans from JSON. + * <li> JSON arrays (<js>"[...]"</js>) are converted to {@link ObjectList ObjectLists}. + * <li> JSON string literals (<js>"'xyz'"</js>) are converted to {@link String Strings}. + * <li> JSON numbers (<js>"123"</js>, including octal/hexadecimal/exponential notation) are converted to + * {@link Integer Integers}, {@link Long Longs}, {@link Float Floats}, or {@link Double Doubles} depending on + * whether the number is decimal, and the size of the number. + * <li> JSON booleans (<js>"false"</js>) are converted to {@link Boolean Booleans}. + * <li> JSON nulls (<js>"null"</js>) are converted to <jk>null</jk>. + * <li> Input consisting of only whitespace or JSON comments are converted to <jk>null</jk>. + * </ul> * <p> - * Input can be any of the following:<br> + * Input can be any of the following: * <ul class='spaced-list'> - * <li> <js>"{...}"</js> - Converted to a {@link ObjectMap} or an instance of a Java bean if a <xa>_type</xa> attribute is present. + * <li> <js>"{...}"</js> - Converted to a {@link ObjectMap} or an instance of a Java bean if a <xa>_type</xa> + * attribute is present. * <li> <js>"[...]"</js> - Converted to a {@link ObjectList}. - * <li> <js>"123..."</js> - Converted to a {@link Number} (either {@link Integer}, {@link Long}, {@link Float}, or {@link Double}). + * <li> <js>"123..."</js> - Converted to a {@link Number} (either {@link Integer}, {@link Long}, {@link Float}, + * or {@link Double}). * <li> <js>"true"</js>/<js>"false"</js> - Converted to a {@link Boolean}. * <li> <js>"null"</js> - Returns <jk>null</jk>. * <li> <js>"'xxx'"</js> - Converted to a {@link String}. @@ -75,8 +79,10 @@ import org.apache.juneau.transform.*; * <li> <js>"'xxx' + \"yyy\""</js> - Converted to a concatenated {@link String}. * </ul> * <p> - * TIP: If you know you're parsing a JSON object or array, it can be easier to parse it using the {@link ObjectMap#ObjectMap(CharSequence) ObjectMap(CharSequence)} - * or {@link ObjectList#ObjectList(CharSequence) ObjectList(CharSequence)} constructors instead of using this class. The end result should be the same. + * TIP: If you know you're parsing a JSON object or array, it can be easier to parse it using the + * {@link ObjectMap#ObjectMap(CharSequence) ObjectMap(CharSequence)} or {@link ObjectList#ObjectList(CharSequence) + * ObjectList(CharSequence)} constructors instead of using this class. + * The end result should be the same. * * <h5 class='section'>Configurable properties:</h5> * <p> @@ -103,6 +109,7 @@ public class JsonParser extends ReaderParser { /** * Constructor. + * * @param propertyStore The property store containing all the settings for this object. */ public Strict(PropertyStore propertyStore) { @@ -120,6 +127,7 @@ public class JsonParser extends ReaderParser { /** * Constructor. + * * @param propertyStore The property store containing all the settings for this object. */ public JsonParser(PropertyStore propertyStore) { @@ -132,7 +140,8 @@ public class JsonParser extends ReaderParser { return new JsonParserBuilder(propertyStore); } - private <T> T parseAnything(JsonParserSession session, ClassMeta<T> eType, ParserReader r, Object outer, BeanPropertyMeta pMeta) throws Exception { + private <T> T parseAnything(JsonParserSession session, ClassMeta<T> eType, ParserReader r, Object outer, + BeanPropertyMeta pMeta) throws Exception { if (eType == null) eType = (ClassMeta<T>)object(); @@ -220,11 +229,13 @@ public class JsonParser extends ReaderParser { if (m.containsKey(session.getBeanTypePropertyName(eType))) o = session.cast((ObjectMap)m, pMeta, eType); else - throw new ParseException(session, "Class ''{0}'' could not be instantiated. Reason: ''{1}''", sType.getInnerClass().getName(), sType.getNotABeanReason()); + throw new ParseException(session, "Class ''{0}'' could not be instantiated. Reason: ''{1}''", + sType.getInnerClass().getName(), sType.getNotABeanReason()); } else if (sType.canCreateNewInstanceFromString(outer) && ! session.isStrict()) { o = sType.newInstanceFromString(outer, parseString(session, r)); } else { - throw new ParseException(session, "Unrecognized syntax for class type ''{0}'', starting character ''{1}''", sType, (char)c); + throw new ParseException(session, "Unrecognized syntax for class type ''{0}'', starting character ''{1}''", + sType, (char)c); } if (wrapperAttr != null) @@ -299,7 +310,8 @@ public class JsonParser extends ReaderParser { } - private <K,V> Map<K,V> parseIntoMap2(JsonParserSession session, ParserReader r, Map<K,V> m, ClassMeta<K> keyType, ClassMeta<V> valueType, BeanPropertyMeta pMeta) throws Exception { + private <K,V> Map<K,V> parseIntoMap2(JsonParserSession session, ParserReader r, Map<K,V> m, ClassMeta<K> keyType, + ClassMeta<V> valueType, BeanPropertyMeta pMeta) throws Exception { if (keyType == null) keyType = (ClassMeta<K>)string(); @@ -401,7 +413,8 @@ public class JsonParser extends ReaderParser { throw new ParseException(session, "Could not find the end of the field name."); } - private <E> Collection<E> parseIntoCollection2(JsonParserSession session, ParserReader r, Collection<E> l, ClassMeta<?> type, BeanPropertyMeta pMeta) throws Exception { + private <E> Collection<E> parseIntoCollection2(JsonParserSession session, ParserReader r, Collection<E> l, + ClassMeta<?> type, BeanPropertyMeta pMeta) throws Exception { int S0=0; // Looking for outermost [ int S1=1; // Looking for starting [ or { or " or ' or LITERAL or ] @@ -545,7 +558,11 @@ public class JsonParser extends ReaderParser { r.mark(); int qc = r.read(); // The quote character being used (" or ') if (qc != '"' && session.isStrict()) { - String msg = (qc == '\'' ? "Invalid quote character \"{0}\" being used." : "Did not find quote character marking beginning of string. Character=\"{0}\""); + String msg = ( + qc == '\'' + ? "Invalid quote character \"{0}\" being used." + : "Did not find quote character marking beginning of string. Character=\"{0}\"" + ); throw new ParseException(session, msg, (char)qc); } final boolean isQuoted = (qc == '\'' || qc == '"'); @@ -679,7 +696,8 @@ public class JsonParser extends ReaderParser { } else { currAttr = parseFieldName(session, r.unread()); if (! currAttr.equals(wrapperAttr)) - throw new ParseException(session, "Expected to find wrapper attribute ''{0}'' but found attribute ''{1}''", wrapperAttr, currAttr); + throw new ParseException(session, + "Expected to find wrapper attribute ''{0}'' but found attribute ''{1}''", wrapperAttr, currAttr); state = S3; } } else if (state == S3) { @@ -765,7 +783,8 @@ public class JsonParser extends ReaderParser { //-------------------------------------------------------------------------------- @Override /* Parser */ - public JsonParserSession createSession(Object input, ObjectMap op, Method javaMethod, Object outer, Locale locale, TimeZone timeZone, MediaType mediaType) { + public JsonParserSession createSession(Object input, ObjectMap op, Method javaMethod, Object outer, Locale locale, + TimeZone timeZone, MediaType mediaType) { return new JsonParserSession(ctx, op, input, javaMethod, outer, locale, timeZone, mediaType); } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/json/JsonParserBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonParserBuilder.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonParserBuilder.java index 94b3340..d3eb7b8 100644 --- a/juneau-core/src/main/java/org/apache/juneau/json/JsonParserBuilder.java +++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonParserBuilder.java @@ -32,6 +32,7 @@ public class JsonParserBuilder extends ParserBuilder { /** * Constructor. + * * @param propertyStore The initial configuration settings for this builder. */ public JsonParserBuilder(PropertyStore propertyStore) { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/json/JsonParserContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonParserContext.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonParserContext.java index 04a034f..949b64e 100644 --- a/juneau-core/src/main/java/org/apache/juneau/json/JsonParserContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonParserContext.java @@ -25,9 +25,11 @@ import org.apache.juneau.parser.*; * * <h6 class='topic'>Inherited configurable properties</h6> * <ul class='doctree'> - * <li class='jc'><a class="doclink" href="../BeanContext.html#ConfigProperties">BeanContext</a> - Properties associated with handling beans on serializers and parsers. + * <li class='jc'><a class="doclink" href="../BeanContext.html#ConfigProperties">BeanContext</a> - Properties + * associated with handling beans on serializers and parsers. * <ul> - * <li class='jc'><a class="doclink" href="../parser/ParserContext.html#ConfigProperties">ParserContext</a> - Configurable properties common to all parsers. + * <li class='jc'><a class="doclink" href="../parser/ParserContext.html#ConfigProperties">ParserContext</a> - + * Configurable properties common to all parsers. * </ul> * </ul> */ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/json/JsonParserSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonParserSession.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonParserSession.java index f495bca..34128be 100644 --- a/juneau-core/src/main/java/org/apache/juneau/json/JsonParserSession.java +++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonParserSession.java @@ -52,7 +52,8 @@ public final class JsonParserSession extends ParserSession { * If <jk>null</jk>, then the timezone defined on the context is used. * @param mediaType The session media type (e.g. <js>"application/json"</js>). */ - public JsonParserSession(JsonParserContext ctx, ObjectMap op, Object input, Method javaMethod, Object outer, Locale locale, TimeZone timeZone, MediaType mediaType) { + public JsonParserSession(JsonParserContext ctx, ObjectMap op, Object input, Method javaMethod, Object outer, + Locale locale, TimeZone timeZone, MediaType mediaType) { super(ctx, op, input, javaMethod, outer, locale, timeZone, mediaType); } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java index a85fbfe..0c43381 100644 --- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java +++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java @@ -44,6 +44,7 @@ public final class JsonSchemaSerializer extends JsonSerializer { /** * Constructor. + * * @param propertyStore Initialize with the specified config property store. */ public JsonSchemaSerializer(PropertyStore propertyStore) { @@ -52,6 +53,7 @@ public final class JsonSchemaSerializer extends JsonSerializer { /** * Constructor. + * * @param propertyStore Initialize with the specified config property store. * @param overrideProperties */ @@ -62,7 +64,8 @@ public final class JsonSchemaSerializer extends JsonSerializer { @Override /* CoreObject */ protected ObjectMap getOverrideProperties() { - return super.getOverrideProperties().append(SERIALIZER_detectRecursions, true).append(SERIALIZER_ignoreRecursions, true); + return super.getOverrideProperties().append(SERIALIZER_detectRecursions, true) + .append(SERIALIZER_ignoreRecursions, true); } @@ -71,7 +74,8 @@ public final class JsonSchemaSerializer extends JsonSerializer { //-------------------------------------------------------------------------------- @Override /* Serializer */ - public JsonSerializerSession createSession(Object output, ObjectMap op, Method javaMethod, Locale locale, TimeZone timeZone, MediaType mediaType, UriContext uriContext) { + public JsonSerializerSession createSession(Object output, ObjectMap op, Method javaMethod, Locale locale, + TimeZone timeZone, MediaType mediaType, UriContext uriContext) { return new JsonSerializerSession(ctx, op, output, javaMethod, locale, timeZone, mediaType, uriContext); } @@ -92,7 +96,8 @@ public final class JsonSchemaSerializer extends JsonSerializer { * @throws SerializeException If a problem occurred trying to convert the output. */ @SuppressWarnings({ "unchecked", "rawtypes" }) - private ObjectMap getSchema(JsonSerializerSession session, ClassMeta<?> eType, String attrName, String[] pNames) throws Exception { + private ObjectMap getSchema(JsonSerializerSession session, ClassMeta<?> eType, String attrName, String[] pNames) + throws Exception { ObjectMap out = new ObjectMap(); if (eType == null) http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializerBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializerBuilder.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializerBuilder.java index df08b02..e15384a 100644 --- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializerBuilder.java +++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSchemaSerializerBuilder.java @@ -32,6 +32,7 @@ public class JsonSchemaSerializerBuilder extends JsonSerializerBuilder { /** * Constructor. + * * @param propertyStore The initial configuration settings for this builder. */ public JsonSchemaSerializerBuilder(PropertyStore propertyStore) { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java index 4f2de4c..031017d 100644 --- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java +++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializer.java @@ -37,7 +37,8 @@ import org.apache.juneau.transform.*; * The conversion is as follows... * <ul class='spaced-list'> * <li>Maps (e.g. {@link HashMap HashMaps}, {@link TreeMap TreeMaps}) are converted to JSON objects. - * <li>Collections (e.g. {@link HashSet HashSets}, {@link LinkedList LinkedLists}) and Java arrays are converted to JSON arrays. + * <li>Collections (e.g. {@link HashSet HashSets}, {@link LinkedList LinkedLists}) and Java arrays are converted to + * JSON arrays. * <li>{@link String Strings} are converted to JSON strings. * <li>{@link Number Numbers} (e.g. {@link Integer}, {@link Long}, {@link Double}) are converted to JSON numbers. * <li>{@link Boolean Booleans} are converted to JSON booleans. @@ -47,10 +48,12 @@ import org.apache.juneau.transform.*; * </ul> * <p> * The types above are considered "JSON-primitive" object types. Any non-JSON-primitive object types are transformed - * into JSON-primitive object types through {@link org.apache.juneau.transform.PojoSwap PojoSwaps} associated through the {@link CoreObjectBuilder#pojoSwaps(Class...)} - * method. Several default transforms are provided for transforming Dates, Enums, Iterators, etc... + * into JSON-primitive object types through {@link org.apache.juneau.transform.PojoSwap PojoSwaps} associated + * through the {@link CoreObjectBuilder#pojoSwaps(Class...)} method. + * Several default transforms are provided for transforming Dates, Enums, Iterators, etc... * <p> - * This serializer provides several serialization options. Typically, one of the predefined DEFAULT serializers will be sufficient. + * This serializer provides several serialization options. Typically, one of the predefined DEFAULT serializers will + * be sufficient. * However, custom serializers can be constructed to fine-tune behavior. * * <h5 class='section'>Configurable properties:</h5> @@ -112,6 +115,7 @@ public class JsonSerializer extends WriterSerializer { /** * Constructor. + * * @param propertyStore The property store containing all the settings for this object. */ public Readable(PropertyStore propertyStore) { @@ -130,6 +134,7 @@ public class JsonSerializer extends WriterSerializer { /** * Constructor. + * * @param propertyStore The property store containing all the settings for this object. */ public Simple(PropertyStore propertyStore) { @@ -147,6 +152,7 @@ public class JsonSerializer extends WriterSerializer { /** * Constructor. + * * @param propertyStore The property store containing all the settings for this object. */ public SimpleReadable(PropertyStore propertyStore) { @@ -155,7 +161,8 @@ public class JsonSerializer extends WriterSerializer { @Override /* CoreObject */ protected ObjectMap getOverrideProperties() { - return super.getOverrideProperties().append(JSON_simpleMode, true).append(SERIALIZER_quoteChar, '\'').append(SERIALIZER_useWhitespace, true); + return super.getOverrideProperties().append(JSON_simpleMode, true).append(SERIALIZER_quoteChar, '\'') + .append(SERIALIZER_useWhitespace, true); } } @@ -167,6 +174,7 @@ public class JsonSerializer extends WriterSerializer { /** * Constructor. + * * @param propertyStore The property store containing all the settings for this object. */ public SimpleReadableSafe(PropertyStore propertyStore) { @@ -175,7 +183,8 @@ public class JsonSerializer extends WriterSerializer { @Override /* CoreObject */ protected ObjectMap getOverrideProperties() { - return super.getOverrideProperties().append(JSON_simpleMode, true).append(SERIALIZER_quoteChar, '\'').append(SERIALIZER_useWhitespace, true).append(SERIALIZER_detectRecursions, true); + return super.getOverrideProperties().append(JSON_simpleMode, true).append(SERIALIZER_quoteChar, '\'') + .append(SERIALIZER_useWhitespace, true).append(SERIALIZER_detectRecursions, true); } } @@ -185,12 +194,12 @@ public class JsonSerializer extends WriterSerializer { /** * Constructor. + * * @param propertyStore The property store containing all the settings for this object. */ public JsonSerializer(PropertyStore propertyStore) { super(propertyStore); this.ctx = createContext(JsonSerializerContext.class); -// this.schemaSerializer = new JsonSchemaSerializer(propertyStore, getOverrideProperties()); } @Override /* CoreObject */ @@ -203,7 +212,8 @@ public class JsonSerializer extends WriterSerializer { * appropriate type-specific serialization method. */ @SuppressWarnings({ "rawtypes", "unchecked" }) - SerializerWriter serializeAnything(JsonSerializerSession session, JsonWriter out, Object o, ClassMeta<?> eType, String attrName, BeanPropertyMeta pMeta) throws Exception { + SerializerWriter serializeAnything(JsonSerializerSession session, JsonWriter out, Object o, ClassMeta<?> eType, + String attrName, BeanPropertyMeta pMeta) throws Exception { if (o == null) { out.append("null"); @@ -280,7 +290,8 @@ public class JsonSerializer extends WriterSerializer { } @SuppressWarnings({ "rawtypes", "unchecked" }) - private SerializerWriter serializeMap(JsonSerializerSession session, JsonWriter out, Map m, ClassMeta<?> type) throws Exception { + private SerializerWriter serializeMap(JsonSerializerSession session, JsonWriter out, Map m, ClassMeta<?> type) + throws Exception { ClassMeta<?> keyType = type.getKeyType(), valueType = type.getValueType(); @@ -310,7 +321,8 @@ public class JsonSerializer extends WriterSerializer { return out; } - private SerializerWriter serializeBeanMap(JsonSerializerSession session, JsonWriter out, BeanMap<?> m, String typeName) throws Exception { + private SerializerWriter serializeBeanMap(JsonSerializerSession session, JsonWriter out, BeanMap<?> m, + String typeName) throws Exception { int i = session.getIndent(); out.append('{'); @@ -341,7 +353,8 @@ public class JsonSerializer extends WriterSerializer { } @SuppressWarnings({"rawtypes", "unchecked"}) - private SerializerWriter serializeCollection(JsonSerializerSession session, JsonWriter out, Collection c, ClassMeta<?> type) throws Exception { + private SerializerWriter serializeCollection(JsonSerializerSession session, JsonWriter out, Collection c, + ClassMeta<?> type) throws Exception { ClassMeta<?> elementType = type.getElementType(); @@ -367,6 +380,7 @@ public class JsonSerializer extends WriterSerializer { /** * Returns the schema serializer based on the settings of this serializer. + * * @return The schema serializer. */ public JsonSchemaSerializer getSchemaSerializer() { @@ -381,7 +395,8 @@ public class JsonSerializer extends WriterSerializer { //-------------------------------------------------------------------------------- @Override /* Serializer */ - public JsonSerializerSession createSession(Object output, ObjectMap op, Method javaMethod, Locale locale, TimeZone timeZone, MediaType mediaType, UriContext uriContext) { + public JsonSerializerSession createSession(Object output, ObjectMap op, Method javaMethod, Locale locale, + TimeZone timeZone, MediaType mediaType, UriContext uriContext) { return new JsonSerializerSession(ctx, op, output, javaMethod, locale, timeZone, mediaType, uriContext); } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerBuilder.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerBuilder.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerBuilder.java index 1454d67..a7539fe1 100644 --- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerBuilder.java +++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerBuilder.java @@ -34,6 +34,7 @@ public class JsonSerializerBuilder extends SerializerBuilder { /** * Constructor. + * * @param propertyStore The initial configuration settings for this builder. */ public JsonSerializerBuilder(PropertyStore propertyStore) { @@ -97,8 +98,8 @@ public class JsonSerializerBuilder extends SerializerBuilder { * <p> * If <jk>true</jk>, solidus (e.g. slash) characters should be escaped. * The JSON specification allows for either format. - * However, if you're embedding JSON in an HTML script tag, this setting prevents - * confusion when trying to serialize <xt><\/script></xt>. + * However, if you're embedding JSON in an HTML script tag, this setting prevents confusion when trying to + * serialize <xt><\/script></xt>. * <p> * <h5 class='section'>Notes:</h5> * <ul> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerContext.java index 837113c..354fab0 100644 --- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerContext.java @@ -25,9 +25,12 @@ import org.apache.juneau.serializer.*; * * <h6 class='topic'>Inherited configurable properties</h6> * <ul class='doctree'> - * <li class='jc'><a class="doclink" href="../BeanContext.html#ConfigProperties">BeanContext</a> - Properties associated with handling beans on serializers and parsers. + * <li class='jc'><a class="doclink" href="../BeanContext.html#ConfigProperties">BeanContext</a> + * - Properties associated with handling beans on serializers and parsers. * <ul> - * <li class='jc'><a class="doclink" href="../serializer/SerializerContext.html#ConfigProperties">SerializerContext</a> - Configurable properties common to all serializers. + * <li class='jc'><a class="doclink" + * href="../serializer/SerializerContext.html#ConfigProperties">SerializerContext</a> + * - Configurable properties common to all serializers. * </ul> * </ul> */ @@ -60,8 +63,8 @@ public final class JsonSerializerContext extends SerializerContext { * <p> * If <jk>true</jk>, solidus (e.g. slash) characters should be escaped. * The JSON specification allows for either format. - * However, if you're embedding JSON in an HTML script tag, this setting prevents - * confusion when trying to serialize <xt><\/script></xt>. + * However, if you're embedding JSON in an HTML script tag, this setting prevents confusion when trying to + * serialize <xt><\/script></xt>. */ public static final String JSON_escapeSolidus = "JsonSerializer.escapeSolidus"; @@ -75,9 +78,11 @@ public final class JsonSerializerContext extends SerializerContext { * <li><b>Session-overridable:</b> <jk>true</jk> * </ul> * <p> - * If <jk>true</jk>, then <js>"_type"</js> properties will be added to beans if their type cannot be inferred through reflection. + * If <jk>true</jk>, then <js>"_type"</js> properties will be added to beans if their type cannot be inferred + * through reflection. * This is used to recreate the correct objects during parsing if the object types cannot be inferred. - * For example, when serializing a {@code Map<String,Object>} field, where the bean class cannot be determined from the value type. + * For example, when serializing a {@code Map<String,Object>} field, where the bean class cannot be determined from + * the value type. * <p> * When present, this value overrides the {@link SerializerContext#SERIALIZER_addBeanTypeProperties} setting and is * provided to customize the behavior of specific serializers in a {@link SerializerGroup}. @@ -100,7 +105,8 @@ public final class JsonSerializerContext extends SerializerContext { super(ps); simpleMode = ps.getProperty(JSON_simpleMode, boolean.class, false); escapeSolidus = ps.getProperty(JSON_escapeSolidus, boolean.class, false); - addBeanTypeProperties = ps.getProperty(JSON_addBeanTypeProperties, boolean.class, ps.getProperty(SERIALIZER_addBeanTypeProperties, boolean.class, true)); + addBeanTypeProperties = ps.getProperty(JSON_addBeanTypeProperties, boolean.class, + ps.getProperty(SERIALIZER_addBeanTypeProperties, boolean.class, true)); } @Override /* Context */ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerSession.java index b5e7a46..3f21ab2 100644 --- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerSession.java +++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerSession.java @@ -37,20 +37,21 @@ public final class JsonSerializerSession extends SerializerSession { * Create a new session using properties specified in the context. * * @param ctx The context creating this session object. - * The context contains all the configuration settings for this object. + * The context contains all the configuration settings for this object. * @param output The output object. See {@link JsonSerializerSession#getWriter()} for valid class types. * @param op The override properties. - * These override any context properties defined in the context. + * These override any context properties defined in the context. * @param javaMethod The java method that called this serializer, usually the method in a REST servlet. * @param locale The session locale. - * If <jk>null</jk>, then the locale defined on the context is used. + * If <jk>null</jk>, then the locale defined on the context is used. * @param timeZone The session timezone. - * If <jk>null</jk>, then the timezone defined on the context is used. + * If <jk>null</jk>, then the timezone defined on the context is used. * @param mediaType The session media type (e.g. <js>"application/json"</js>). * @param uriContext The URI context. - * Identifies the current request URI used for resolution of URIs to absolute or root-relative form. + * Identifies the current request URI used for resolution of URIs to absolute or root-relative form. */ - protected JsonSerializerSession(JsonSerializerContext ctx, ObjectMap op, Object output, Method javaMethod, Locale locale, TimeZone timeZone, MediaType mediaType, UriContext uriContext) { + protected JsonSerializerSession(JsonSerializerContext ctx, ObjectMap op, Object output, Method javaMethod, + Locale locale, TimeZone timeZone, MediaType mediaType, UriContext uriContext) { super(ctx, op, output, javaMethod, locale, timeZone, mediaType, uriContext); if (op == null || op.isEmpty()) { simpleMode = ctx.simpleMode; @@ -96,6 +97,7 @@ public final class JsonSerializerSession extends SerializerSession { Object output = getOutput(); if (output instanceof JsonWriter) return (JsonWriter)output; - return new JsonWriter(super.getWriter(), isUseWhitespace(), getMaxIndent(), isEscapeSolidus(), getQuoteChar(), isSimpleMode(), isTrimStrings(), getUriResolver()); + return new JsonWriter(super.getWriter(), isUseWhitespace(), getMaxIndent(), isEscapeSolidus(), getQuoteChar(), + isSimpleMode(), isTrimStrings(), getUriResolver()); } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5c4762ee/juneau-core/src/main/java/org/apache/juneau/json/JsonWriter.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonWriter.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonWriter.java index cc371d5..620ccf1 100644 --- a/juneau-core/src/main/java/org/apache/juneau/json/JsonWriter.java +++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonWriter.java @@ -55,6 +55,7 @@ public final class JsonWriter extends SerializerWriter { /** * Constructor. + * * @param out The writer being wrapped. * @param useWhitespace If <jk>true</jk>, tabs and spaces will be used in output. * @param maxIndent The maximum indentation level. @@ -64,7 +65,8 @@ public final class JsonWriter extends SerializerWriter { * @param trimStrings If <jk>true</jk>, strings will be trimmed before being serialized. * @param uriResolver The URI resolver for resolving URIs to absolute or root-relative form. */ - protected JsonWriter(Writer out, boolean useWhitespace, int maxIndent, boolean escapeSolidus, char quoteChar, boolean laxMode, boolean trimStrings, UriResolver uriResolver) { + protected JsonWriter(Writer out, boolean useWhitespace, int maxIndent, boolean escapeSolidus, char quoteChar, + boolean laxMode, boolean trimStrings, UriResolver uriResolver) { super(out, useWhitespace, maxIndent, trimStrings, quoteChar, uriResolver); this.laxMode = laxMode; this.escapeSolidus = escapeSolidus; @@ -73,6 +75,7 @@ public final class JsonWriter extends SerializerWriter { /** * Serializes the specified object as a JSON string value. + * * @param s The object being serialized. * @return This object (for method chaining). * @throws IOException Should never happen. @@ -119,6 +122,7 @@ public final class JsonWriter extends SerializerWriter { /** * Serializes the specified object as a JSON attribute name. + * * @param s The object being serialized. * @return This object (for method chaining). * @throws IOException Should never happen.
