http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-core/src/main/java/org/apache/juneau/parser/ParserGroup.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/parser/ParserGroup.java b/juneau-core/src/main/java/org/apache/juneau/parser/ParserGroup.java index 800db11..6f2247b 100644 --- a/juneau-core/src/main/java/org/apache/juneau/parser/ParserGroup.java +++ b/juneau-core/src/main/java/org/apache/juneau/parser/ParserGroup.java @@ -73,7 +73,7 @@ public final class ParserGroup extends Lockable { /** * Adds the specified parser to the beginning of this group. * - * @param p - The parser to add to this group. + * @param p The parser to add to this group. * @return This object (for method chaining). */ public ParserGroup append(Parser p) { @@ -203,103 +203,727 @@ public final class ParserGroup extends Lockable { return l; } + //-------------------------------------------------------------------------------- - // Convenience methods for setting properties on all parsers. + // Properties //-------------------------------------------------------------------------------- /** - * Shortcut for calling {@link Parser#setProperty(String, Object)} on all parsers in this group. + * Calls {@link Parser#setTrimStrings(boolean)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see ParserContext#PARSER_trimStrings + */ + public ParserGroup setTrimStrings(boolean value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setTrimStrings(value); + return this; + } + + /** + * Calls {@link Parser#setStrict(boolean)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see ParserContext#PARSER_strict + */ + public ParserGroup setStrict(boolean value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setStrict(value); + return this; + } + + /** + * Calls {@link Parser#setInputStreamCharset(String)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see ParserContext#PARSER_inputStreamCharset + */ + public ParserGroup setInputStreamCharset(String value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setInputStreamCharset(value); + return this; + } + + /** + * Calls {@link Parser#setFileCharset(String)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see ParserContext#PARSER_fileCharset + */ + public ParserGroup setFileCharset(String value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setFileCharset(value); + return this; + } + + /** + * Calls {@link Parser#setBeansRequireDefaultConstructor(boolean)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beansRequireDefaultConstructor + */ + public ParserGroup setBeansRequireDefaultConstructor(boolean value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setBeansRequireDefaultConstructor(value); + return this; + } + + /** + * Calls {@link Parser#setBeansRequireSerializable(boolean)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beansRequireSerializable + */ + public ParserGroup setBeansRequireSerializable(boolean value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setBeansRequireSerializable(value); + return this; + } + + /** + * Calls {@link Parser#setBeansRequireSettersForGetters(boolean)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beansRequireSettersForGetters + */ + public ParserGroup setBeansRequireSettersForGetters(boolean value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setBeansRequireSettersForGetters(value); + return this; + } + + /** + * Calls {@link Parser#setBeansRequireSomeProperties(boolean)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beansRequireSomeProperties + */ + public ParserGroup setBeansRequireSomeProperties(boolean value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setBeansRequireSomeProperties(value); + return this; + } + + /** + * Calls {@link Parser#setBeanMapPutReturnsOldValue(boolean)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beanMapPutReturnsOldValue + */ + public ParserGroup setBeanMapPutReturnsOldValue(boolean value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setBeanMapPutReturnsOldValue(value); + return this; + } + + /** + * Calls {@link Parser#setBeanConstructorVisibility(Visibility)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beanConstructorVisibility + */ + public ParserGroup setBeanConstructorVisibility(Visibility value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setBeanConstructorVisibility(value); + return this; + } + + /** + * Calls {@link Parser#setBeanClassVisibility(Visibility)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beanClassVisibility + */ + public ParserGroup setBeanClassVisibility(Visibility value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setBeanClassVisibility(value); + return this; + } + + /** + * Calls {@link Parser#setBeanFieldVisibility(Visibility)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beanFieldVisibility + */ + public ParserGroup setBeanFieldVisibility(Visibility value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setBeanFieldVisibility(value); + return this; + } + + /** + * Calls {@link Parser#setMethodVisibility(Visibility)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_methodVisibility + */ + public ParserGroup setMethodVisibility(Visibility value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setMethodVisibility(value); + return this; + } + + /** + * Calls {@link Parser#setUseJavaBeanIntrospector(boolean)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_useJavaBeanIntrospector + */ + public ParserGroup setUseJavaBeanIntrospector(boolean value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setUseJavaBeanIntrospector(value); + return this; + } + + /** + * Calls {@link Parser#setUseInterfaceProxies(boolean)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_useInterfaceProxies + */ + public ParserGroup setUseInterfaceProxies(boolean value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setUseInterfaceProxies(value); + return this; + } + + /** + * Calls {@link Parser#setIgnoreUnknownBeanProperties(boolean)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_ignoreUnknownBeanProperties + */ + public ParserGroup setIgnoreUnknownBeanProperties(boolean value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setIgnoreUnknownBeanProperties(value); + return this; + } + + /** + * Calls {@link Parser#setIgnoreUnknownNullBeanProperties(boolean)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_ignoreUnknownNullBeanProperties + */ + public ParserGroup setIgnoreUnknownNullBeanProperties(boolean value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setIgnoreUnknownNullBeanProperties(value); + return this; + } + + /** + * Calls {@link Parser#setIgnorePropertiesWithoutSetters(boolean)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_ignorePropertiesWithoutSetters + */ + public ParserGroup setIgnorePropertiesWithoutSetters(boolean value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setIgnorePropertiesWithoutSetters(value); + return this; + } + + /** + * Calls {@link Parser#setIgnoreInvocationExceptionsOnGetters(boolean)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_ignoreInvocationExceptionsOnGetters + */ + public ParserGroup setIgnoreInvocationExceptionsOnGetters(boolean value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setIgnoreInvocationExceptionsOnGetters(value); + return this; + } + + /** + * Calls {@link Parser#setIgnoreInvocationExceptionsOnSetters(boolean)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_ignoreInvocationExceptionsOnSetters + */ + public ParserGroup setIgnoreInvocationExceptionsOnSetters(boolean value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setIgnoreInvocationExceptionsOnSetters(value); + return this; + } + + /** + * Calls {@link Parser#setSortProperties(boolean)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_sortProperties + */ + public ParserGroup setSortProperties(boolean value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setSortProperties(value); + return this; + } + + /** + * Calls {@link Parser#setNotBeanPackages(String...)} on all parsers in this group. + * + * @param values The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_notBeanPackages + */ + public ParserGroup setNotBeanPackages(String...values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setNotBeanPackages(values); + return this; + } + + /** + * Calls {@link Parser#setNotBeanPackages(Collection)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_notBeanPackages + */ + public ParserGroup setNotBeanPackages(Collection<String> value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setNotBeanPackages(value); + return this; + } + + /** + * Calls {@link Parser#addNotBeanPackages(String...)} on all parsers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_notBeanPackages + * @see BeanContext#BEAN_notBeanPackages_remove + */ + public ParserGroup addNotBeanPackages(String...values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.addNotBeanPackages(values); + return this; + } + + /** + * Calls {@link Parser#addNotBeanPackages(Collection)} on all parsers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_notBeanPackages + * @see BeanContext#BEAN_notBeanPackages_remove + */ + public ParserGroup addNotBeanPackages(Collection<String> values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.addNotBeanPackages(values); + return this; + } + + /** + * Calls {@link Parser#removeNotBeanPackages(String...)} on all parsers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_notBeanPackages + * @see BeanContext#BEAN_notBeanPackages_remove + */ + public ParserGroup removeNotBeanPackages(String...values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.removeNotBeanPackages(values); + return this; + } + + /** + * Calls {@link Parser#removeNotBeanPackages(Collection)} on all parsers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_notBeanPackages + * @see BeanContext#BEAN_notBeanPackages_remove + */ + public ParserGroup removeNotBeanPackages(Collection<String> values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.removeNotBeanPackages(values); + return this; + } + + /** + * Calls {@link Parser#setNotBeanClasses(Class...)} on all parsers in this group. + * + * @param values The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_notBeanClasses + */ + public ParserGroup setNotBeanClasses(Class<?>...values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setNotBeanClasses(values); + return this; + } + + /** + * Calls {@link Parser#setNotBeanClasses(Collection)} on all parsers in this group. + * + * @param values The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_notBeanPackages + */ + public ParserGroup setNotBeanClasses(Collection<Class<?>> values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setNotBeanClasses(values); + return this; + } + + /** + * Calls {@link Parser#addNotBeanClasses(Class...)} on all parsers in this group. + * + * @param values The values to add to this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_notBeanClasses + * @see BeanContext#BEAN_notBeanClasses_add + */ + public ParserGroup addNotBeanClasses(Class<?>...values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.addNotBeanClasses(values); + return this; + } + + /** + * Calls {@link Parser#addNotBeanClasses(Collection)} on all parsers in this group. + * + * @param values The values to add to this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_notBeanClasses + * @see BeanContext#BEAN_notBeanClasses_add + */ + public ParserGroup addNotBeanClasses(Collection<Class<?>> values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.addNotBeanClasses(values); + return this; + } + + /** + * Calls {@link Parser#removeNotBeanClasses(Class...)} on all parsers in this group. * - * @param property The property name. - * @param value The property value. - * @throws LockedException If {@link #lock()} was called on this object. + * @param values The values to remove from this property. * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_notBeanClasses + * @see BeanContext#BEAN_notBeanClasses_remove */ - public ParserGroup setProperty(String property, Object value) throws LockedException { + public ParserGroup removeNotBeanClasses(Class<?>...values) throws LockedException { checkLock(); for (Parser p : parsers) - p.setProperty(property, value); + p.removeNotBeanClasses(values); return this; } /** - * Shortcut for calling {@link Parser#setProperties(ObjectMap)} on all parsers in this group. + * Calls {@link Parser#removeNotBeanClasses(Collection)} on all parsers in this group. * - * @param properties The properties to set. Ignored if <jk>null</jk>. - * @throws LockedException If {@link #lock()} was called on this object. + * @param values The values to remove from this property. * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_notBeanClasses + * @see BeanContext#BEAN_notBeanClasses_remove */ - public ParserGroup setProperties(ObjectMap properties) { + public ParserGroup removeNotBeanClasses(Collection<Class<?>> values) throws LockedException { checkLock(); for (Parser p : parsers) - p.setProperties(properties); + p.removeNotBeanClasses(values); + return this; + } + + /** + * Calls {@link Parser#setBeanFilters(Class...)} on all parsers in this group. + * + * @param values The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beanFilters + */ + public ParserGroup setBeanFilters(Class<?>...values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setBeanFilters(values); + return this; + } + + /** + * Calls {@link Parser#setBeanFilters(Collection)} on all parsers in this group. + * + * @param values The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beanFilters + */ + public ParserGroup setBeanFilters(Collection<Class<?>> values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setBeanFilters(values); + return this; + } + + /** + * Calls {@link Parser#addBeanFilters(Class...)} on all parsers in this group. + * + * @param values The values to add to this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beanFilters + * @see BeanContext#BEAN_beanFilters_add + */ + public ParserGroup addBeanFilters(Class<?>...values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.addBeanFilters(values); + return this; + } + + /** + * Calls {@link Parser#addBeanFilters(Collection)} on all parsers in this group. + * + * @param values The values to add to this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beanFilters + * @see BeanContext#BEAN_beanFilters_add + */ + public ParserGroup addBeanFilters(Collection<Class<?>> values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.addBeanFilters(values); + return this; + } + + /** + * Calls {@link Parser#removeBeanFilters(Class...)} on all parsers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beanFilters + * @see BeanContext#BEAN_beanFilters_remove + */ + public ParserGroup removeBeanFilters(Class<?>...values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.removeBeanFilters(values); + return this; + } + + /** + * Calls {@link Parser#removeBeanFilters(Collection)} on all parsers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beanFilters + * @see BeanContext#BEAN_beanFilters_remove + */ + public ParserGroup removeBeanFilters(Collection<Class<?>> values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.removeBeanFilters(values); + return this; + } + + /** + * Calls {@link Parser#setPojoSwaps(Class...)} on all parsers in this group. + * + * @param values The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_pojoSwaps + */ + public ParserGroup setPojoSwaps(Class<?>...values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setPojoSwaps(values); + return this; + } + + /** + * Calls {@link Parser#setPojoSwaps(Collection)} on all parsers in this group. + * + * @param values The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_pojoSwaps + */ + public ParserGroup setPojoSwaps(Collection<Class<?>> values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setPojoSwaps(values); + return this; + } + + /** + * Calls {@link Parser#addPojoSwaps(Class...)} on all parsers in this group. + * + * @param values The values to add to this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_pojoSwaps + * @see BeanContext#BEAN_pojoSwaps_add + */ + public ParserGroup addPojoSwaps(Class<?>...values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.addPojoSwaps(values); return this; } /** - * Shortcut for calling {@link Parser#addNotBeanClasses(Class[])} on all parsers in this group. + * Calls {@link Parser#addPojoSwaps(Collection)} on all parsers in this group. * - * @param classes The classes to specify as not-beans to the underlying bean context of all parsers in this group. - * @throws LockedException If {@link #lock()} was called on this object. + * @param values The values to add to this property. * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_pojoSwaps + * @see BeanContext#BEAN_pojoSwaps_add */ - public ParserGroup addNotBeanClasses(Class<?>...classes) throws LockedException { + public ParserGroup addPojoSwaps(Collection<Class<?>> values) throws LockedException { checkLock(); for (Parser p : parsers) - p.addNotBeanClasses(classes); + p.addPojoSwaps(values); return this; } /** - * Shortcut for calling {@link Parser#addBeanFilters(Class[])} on all parsers in this group. + * Calls {@link Parser#removePojoSwaps(Class...)} on all parsers in this group. * - * @param classes The classes to add bean filters for to the underlying bean context of all parsers in this group. - * @throws LockedException If {@link #lock()} was called on this object. + * @param values The values to remove from this property. * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_pojoSwaps + * @see BeanContext#BEAN_pojoSwaps_remove */ - public ParserGroup addBeanFilters(Class<?>...classes) throws LockedException { + public ParserGroup removePojoSwaps(Class<?>...values) throws LockedException { checkLock(); for (Parser p : parsers) - p.addBeanFilters(classes); + p.removePojoSwaps(values); return this; } /** - * Shortcut for calling {@link Parser#addPojoSwaps(Class[])} on all parsers in this group. + * Calls {@link Parser#removePojoSwaps(Collection)} on all parsers in this group. * - * @param classes The classes to add POJO swaps for to the underlying bean context of all parsers in this group. - * @throws LockedException If {@link #lock()} was called on this object. + * @param values The values to remove from this property. * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_pojoSwaps + * @see BeanContext#BEAN_pojoSwaps_remove */ - public ParserGroup addPojoSwaps(Class<?>...classes) throws LockedException { + public ParserGroup removePojoSwaps(Collection<Class<?>> values) throws LockedException { checkLock(); for (Parser p : parsers) - p.addPojoSwaps(classes); + p.removePojoSwaps(values); return this; } /** - * Shortcut for calling {@link Parser#addToDictionary(Class[])} on all parsers in this group. + * Calls {@link Parser#setImplClasses(Map)} on all parsers in this group. * - * @param classes The classes to add to the bean dictionary on the underlying bean context of all parsers in this group. - * @throws LockedException If {@link #lock()} was called on this object. + * @param values The new value for this property. * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_implClasses */ - public ParserGroup addToDictionary(Class<?>...classes) throws LockedException { + public ParserGroup setImplClasses(Map<Class<?>,Class<?>> values) throws LockedException { checkLock(); for (Parser p : parsers) - p.addToDictionary(classes); + p.setImplClasses(values); return this; } /** - * Shortcut for calling {@link Parser#addImplClass(Class, Class)} on all parsers in this group. + * Calls {@link Parser#addImplClass(Class,Class)} on all parsers in this group. * - * @param <T> The interface or abstract class type. - * @param interfaceClass The interface or abstract class. + * @param interfaceClass The interface class. * @param implClass The implementation class. - * @throws LockedException If {@link #lock()} was called on this object. + * @param <T> The class type of the interface. * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_implClasses + * @see BeanContext#BEAN_implClasses_put */ public <T> ParserGroup addImplClass(Class<T> interfaceClass, Class<? extends T> implClass) throws LockedException { checkLock(); @@ -308,11 +932,308 @@ public final class ParserGroup extends Lockable { return this; } + /** + * Calls {@link Parser#setBeanDictionary(Class...)} on all parsers in this group. + * + * @param values The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beanDictionary + */ + public ParserGroup setBeanDictionary(Class<?>...values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setBeanDictionary(values); + return this; + } + + /** + * Calls {@link Parser#setBeanDictionary(Collection)} on all parsers in this group. + * + * @param values The values to add to this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beanDictionary + * @see BeanContext#BEAN_beanDictionary_add + */ + public ParserGroup setBeanDictionary(Collection<Class<?>> values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setBeanDictionary(values); + return this; + } + + /** + * Calls {@link Parser#addToBeanDictionary(Class...)} on all parsers in this group. + * + * @param values The values to add to this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beanDictionary + * @see BeanContext#BEAN_beanDictionary_add + */ + public ParserGroup addToBeanDictionary(Class<?>...values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.addToBeanDictionary(values); + return this; + } + + /** + * Calls {@link Parser#addToBeanDictionary(Collection)} on all parsers in this group. + * + * @param values The values to add to this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beanDictionary + * @see BeanContext#BEAN_beanDictionary_add + */ + public ParserGroup addToBeanDictionary(Collection<Class<?>> values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.addToBeanDictionary(values); + return this; + } + + /** + * Calls {@link Parser#removeFromBeanDictionary(Class...)} on all parsers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beanDictionary + * @see BeanContext#BEAN_beanDictionary_remove + */ + public ParserGroup removeFromBeanDictionary(Class<?>...values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.removeFromBeanDictionary(values); + return this; + } + + /** + * Calls {@link Parser#removeFromBeanDictionary(Collection)} on all parsers in this group. + * + * @param values The values to remove from this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beanDictionary + * @see BeanContext#BEAN_beanDictionary_remove + */ + public ParserGroup removeFromBeanDictionary(Collection<Class<?>> values) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.removeFromBeanDictionary(values); + return this; + } + + /** + * Calls {@link Parser#setBeanTypePropertyName(String)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_beanTypePropertyName + */ + public ParserGroup setBeanTypePropertyName(String value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setBeanTypePropertyName(value); + return this; + } + + /** + * Calls {@link Parser#setDefaultParser(Class)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_defaultParser + */ + public ParserGroup setDefaultParser(Class<?> value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setDefaultParser(value); + return this; + } + + /** + * Calls {@link Parser#setLocale(Locale)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_locale + */ + public ParserGroup setLocale(Locale value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setLocale(value); + return this; + } + + /** + * Calls {@link Parser#setTimeZone(TimeZone)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_timeZone + */ + public ParserGroup setTimeZone(TimeZone value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setTimeZone(value); + return this; + } + + /** + * Calls {@link Parser#setMediaType(MediaType)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_mediaType + */ + public ParserGroup setMediaType(MediaType value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setMediaType(value); + return this; + } + + /** + * Calls {@link Parser#setDebug(boolean)} on all parsers in this group. + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see BeanContext#BEAN_debug + */ + public ParserGroup setDebug(boolean value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setDebug(value); + return this; + } + + /** + * Calls {@link Parser#setProperty(String,Object)} on all parsers in this group. + * + * @param name The property name. + * @param value The property value. + * @return This class (for method chaining). + * @throws LockedException If {@link #lock()} has been called on this object or {@link ContextFactory} object. + * @see ContextFactory#setProperty(String, Object) + */ + public ParserGroup setProperty(String name, Object value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setProperty(name, value); + return this; + } + + /** + * Calls {@link Parser#setProperties(ObjectMap)} on all parsers in this group. + * + * @param properties The properties to set on this class. + * @return This class (for method chaining). + * @throws LockedException If {@link #lock()} has been called on this object. + * @see ContextFactory#setProperties(java.util.Map) + */ + public ParserGroup setProperties(ObjectMap properties) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setProperties(properties); + return this; + } + + /** + * Calls {@link Parser#addToProperty(String,Object)} on all parsers in this group. + * + * @param name The property name. + * @param value The new value to add to the SET property. + * @return This object (for method chaining). + * @throws ConfigException If property is not a SET property. + * @throws LockedException If {@link #lock()} has been called on this object. + */ + public ParserGroup addToProperty(String name, Object value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.addToProperty(name, value); + return this; + } + + /** + * Calls {@link Parser#putToProperty(String,Object,Object)} on all parsers in this group. + * + * @param name The property name. + * @param key The property value map key. + * @param value The property value map value. + * @return This object (for method chaining). + * @throws ConfigException If property is not a MAP property. + * @throws LockedException If {@link #lock()} has been called on this object. + */ + public ParserGroup putToProperty(String name, Object key, Object value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.putToProperty(name, key, value); + return this; + } + + /** + * Calls {@link Parser#putToProperty(String,Object)} on all parsers in this group. + * + * @param name The property value. + * @param value The property value map value. + * @return This object (for method chaining). + * @throws ConfigException If property is not a MAP property. + * @throws LockedException If {@link #lock()} has been called on this object. + */ + public ParserGroup putToProperty(String name, Object value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.putToProperty(name, value); + return this; + } + + /** + * Calls {@link Parser#removeFromProperty(String,Object)} on all parsers in this group. + * + * @param name The property name. + * @param value The property value in the SET property. + * @return This object (for method chaining). + * @throws ConfigException If property is not a SET property. + * @throws LockedException If {@link #lock()} has been called on this object. + */ + public ParserGroup removeFromProperty(String name, Object value) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.removeFromProperty(name, value); + return this; + } + + //-------------------------------------------------------------------------------- // Overridden methods //-------------------------------------------------------------------------------- /** + * Calls {@link Parser#setClassLoader(ClassLoader)} on all parsers in this group. + * + * @param classLoader The new classloader. + * @throws LockedException If {@link ContextFactory#lock()} was called on this class or the bean context. + * @return This object (for method chaining). + * @see ContextFactory#setClassLoader(ClassLoader) + */ + public ParserGroup setClassLoader(ClassLoader classLoader) throws LockedException { + checkLock(); + for (Parser p : parsers) + p.setClassLoader(classLoader); + return this; + } + + /** * Locks this group and all parsers in this group. */ @Override /* Lockable */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-core/src/main/java/org/apache/juneau/parser/ParserMatch.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/parser/ParserMatch.java b/juneau-core/src/main/java/org/apache/juneau/parser/ParserMatch.java index a7ee50e..a08c07a 100644 --- a/juneau-core/src/main/java/org/apache/juneau/parser/ParserMatch.java +++ b/juneau-core/src/main/java/org/apache/juneau/parser/ParserMatch.java @@ -25,8 +25,8 @@ public final class ParserMatch { /** * Constructor. * - * @param mediaType - The media type of the match. - * @param parser - The parser that matched. + * @param mediaType The media type of the match. + * @param parser The parser that matched. */ public ParserMatch(MediaType mediaType, Parser parser) { this.mediaType = mediaType; http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializer.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializer.java b/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializer.java index 9fddf75..0c8f215 100644 --- a/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializer.java +++ b/juneau-core/src/main/java/org/apache/juneau/serializer/OutputStreamSerializer.java @@ -41,6 +41,7 @@ public abstract class OutputStreamSerializer extends Serializer { return false; } + //-------------------------------------------------------------------------------- // Other methods //-------------------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-core/src/main/java/org/apache/juneau/serializer/Serializer.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/Serializer.java b/juneau-core/src/main/java/org/apache/juneau/serializer/Serializer.java index ccd0cc8..ac43ecb 100644 --- a/juneau-core/src/main/java/org/apache/juneau/serializer/Serializer.java +++ b/juneau-core/src/main/java/org/apache/juneau/serializer/Serializer.java @@ -12,6 +12,8 @@ // *************************************************************************************************************************** package org.apache.juneau.serializer; +import static org.apache.juneau.serializer.SerializerContext.*; + import java.io.*; import java.lang.reflect.*; import java.text.*; @@ -283,47 +285,849 @@ public abstract class Serializer extends CoreApi { return contentType; } + //-------------------------------------------------------------------------------- - // Overridden methods + // Properties //-------------------------------------------------------------------------------- + /** + * <b>Configuration property:</b> Max serialization depth. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.maxDepth"</js> + * <li><b>Data type:</b> <code>Integer</code> + * <li><b>Default:</b> <code>100</code> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * Abort serialization if specified depth is reached in the POJO tree. + * If this depth is exceeded, an exception is thrown. + * This prevents stack overflows from occurring when trying to serialize models with recursive references. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>SERIALIZER_maxDepth</jsf>, value)</code>. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see SerializerContext#SERIALIZER_maxDepth + */ + public Serializer setMaxDepth(int value) throws LockedException { + return setProperty(SERIALIZER_maxDepth, value); + } + + /** + * <b>Configuration property:</b> Initial depth. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.initialDepth"</js> + * <li><b>Data type:</b> <code>Integer</code> + * <li><b>Default:</b> <code>0</code> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * The initial indentation level at the root. + * Useful when constructing document fragments that need to be indented at a certain level. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>SERIALIZER_initialDepth</jsf>, value)</code>. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see SerializerContext#SERIALIZER_initialDepth + */ + public Serializer setInitialDepth(int value) throws LockedException { + return setProperty(SERIALIZER_initialDepth, value); + } + + /** + * <b>Configuration property:</b> Automatically detect POJO recursions. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.detectRecursions"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * Specifies that recursions should be checked for during serialization. + * <p> + * Recursions can occur when serializing models that aren't true trees, but rather contain loops. + * <p> + * The behavior when recursions are detected depends on the value for {@link SerializerContext#SERIALIZER_ignoreRecursions}. + * <p> + * For example, if a model contains the links A->B->C->A, then the JSON generated will look like + * the following when <jsf>SERIALIZER_ignoreRecursions</jsf> is <jk>true</jk>... + * <code>{A:{B:{C:null}}}</code><br> + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>SERIALIZER_detectRecursions</jsf>, value)</code>. + * <li>Checking for recursion can cause a small performance penalty. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see SerializerContext#SERIALIZER_detectRecursions + */ + public Serializer setDetectRecursions(boolean value) throws LockedException { + return setProperty(SERIALIZER_detectRecursions, value); + } + + /** + * <b>Configuration property:</b> Ignore recursion errors. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.ignoreRecursions"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * Used in conjunction with {@link SerializerContext#SERIALIZER_detectRecursions}. + * Setting is ignored if <jsf>SERIALIZER_detectRecursions</jsf> is <jk>false</jk>. + * <p> + * If <jk>true</jk>, when we encounter the same object when serializing a tree, + * we set the value to <jk>null</jk>. + * Otherwise, an exception is thrown. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>SERIALIZER_ignoreRecursions</jsf>, value)</code>. + * <li>Checking for recursion can cause a small performance penalty. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see SerializerContext#SERIALIZER_ignoreRecursions + */ + public Serializer setIgnoreRecursions(boolean value) throws LockedException { + return setProperty(SERIALIZER_ignoreRecursions, value); + } + + /** + * <b>Configuration property:</b> Use indentation. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.useIndentation"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * If <jk>true</jk>, newlines and indentation is added to the output to improve readability. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>SERIALIZER_useIndentation</jsf>, value)</code>. + * <li>Checking for recursion can cause a small performance penalty. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see SerializerContext#SERIALIZER_useIndentation + */ + public Serializer setUseIndentation(boolean value) throws LockedException { + return setProperty(SERIALIZER_useIndentation, value); + } + + /** + * <b>Configuration property:</b> Add <js>"_type"</js> properties when needed. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.addBeanTypeProperties"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * <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. + * 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. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>SERIALIZER_addBeanTypeProperties</jsf>, value)</code>. + * <li>Checking for recursion can cause a small performance penalty. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see SerializerContext#SERIALIZER_addBeanTypeProperties + */ + public Serializer setAddBeanTypeProperties(boolean value) throws LockedException { + return setProperty(SERIALIZER_addBeanTypeProperties, value); + } + + /** + * <b>Configuration property:</b> Quote character. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.quoteChar"</js> + * <li><b>Data type:</b> <code>Character</code> + * <li><b>Default:</b> <js>'"'</js> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * This is the character used for quoting attributes and values. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>SERIALIZER_quoteChar</jsf>, value)</code>. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see SerializerContext#SERIALIZER_quoteChar + */ + public Serializer setQuoteChar(char value) throws LockedException { + return setProperty(SERIALIZER_quoteChar, value); + } + + /** + * <b>Configuration property:</b> Trim null bean property values. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.trimNullProperties"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>true</jk> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * If <jk>true</jk>, null bean values will not be serialized to the output. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>SERIALIZER_trimNullProperties</jsf>, value)</code>. + * <li>Enabling this setting has the following effects on parsing: + * <ul> + * <li>Map entries with <jk>null</jk> values will be lost. + * </ul> + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see SerializerContext#SERIALIZER_trimNullProperties + */ + public Serializer setTrimNullProperties(boolean value) throws LockedException { + return setProperty(SERIALIZER_trimNullProperties, value); + } + + /** + * <b>Configuration property:</b> Trim empty lists and arrays. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.trimEmptyLists"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * If <jk>true</jk>, empty list values will not be serialized to the output. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>SERIALIZER_trimEmptyCollections</jsf>, value)</code>. + * <li>Enabling this setting has the following effects on parsing: + * <ul> + * <li>Map entries with empty list values will be lost. + * <li>Bean properties with empty list values will not be set. + * </ul> + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see SerializerContext#SERIALIZER_trimEmptyCollections + */ + public Serializer setTrimEmptyCollections(boolean value) throws LockedException { + return setProperty(SERIALIZER_trimEmptyCollections, value); + } + + /** + * <b>Configuration property:</b> Trim empty maps. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.trimEmptyMaps"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * If <jk>true</jk>, empty map values will not be serialized to the output. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>SERIALIZER_trimEmptyMaps</jsf>, value)</code>. + * <li>Enabling this setting has the following effects on parsing: + * <ul> + * <li>Bean properties with empty map values will not be set. + * </ul> + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see SerializerContext#SERIALIZER_trimEmptyMaps + */ + public Serializer setTrimEmptyMaps(boolean value) throws LockedException { + return setProperty(SERIALIZER_trimEmptyMaps, value); + } + + /** + * <b>Configuration property:</b> Trim strings. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.trimStrings"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * If <jk>true</jk>, string values will be trimmed of whitespace using {@link String#trim()} before being serialized. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>SERIALIZER_trimStrings</jsf>, value)</code>. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see SerializerContext#SERIALIZER_trimStrings + */ + public Serializer setTrimStrings(boolean value) throws LockedException { + return setProperty(SERIALIZER_trimStrings, value); + } + + /** + * <b>Configuration property:</b> URI base for relative URIs. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.relativeUriBase"</js> + * <li><b>Data type:</b> <code>String</code> + * <li><b>Default:</b> <js>""</js> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * Prepended to relative URIs during serialization (along with the {@link SerializerContext#SERIALIZER_absolutePathUriBase} if specified. + * (i.e. URIs not containing a schema and not starting with <js>'/'</js>). + * (e.g. <js>"foo/bar"</js>) + * + * <h5 class='section'>Example:</h5> + * <table class='styled'> + * <tr><th>SERIALIZER_relativeUriBase</th><th>URI</th><th>Serialized URI</th></tr> + * <tr> + * <td><code>http://foo:9080/bar/baz</code></td> + * <td><code>mywebapp</code></td> + * <td><code>http://foo:9080/bar/baz/mywebapp</code></td> + * </tr> + * <tr> + * <td><code>http://foo:9080/bar/baz</code></td> + * <td><code>/mywebapp</code></td> + * <td><code>/mywebapp</code></td> + * </tr> + * <tr> + * <td><code>http://foo:9080/bar/baz</code></td> + * <td><code>http://mywebapp</code></td> + * <td><code>http://mywebapp</code></td> + * </tr> + * </table> + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>SERIALIZER_relativeUriBase</jsf>, value)</code>. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see SerializerContext#SERIALIZER_relativeUriBase + */ + public Serializer setRelativeUriBase(String value) throws LockedException { + return setProperty(SERIALIZER_relativeUriBase, value); + } + + /** + * <b>Configuration property:</b> URI base for relative URIs with absolute paths. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.absolutePathUriBase"</js> + * <li><b>Data type:</b> <code>String</code> + * <li><b>Default:</b> <js>""</js> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * Prepended to relative absolute-path URIs during serialization. + * (i.e. URIs starting with <js>'/'</js>). + * (e.g. <js>"/foo/bar"</js>) + * + * <h5 class='section'>Examples:</h5> + * <table class='styled'> + * <tr><th>SERIALIZER_absolutePathUriBase</th><th>URI</th><th>Serialized URI</th></tr> + * <tr> + * <td><code>http://foo:9080/bar/baz</code></td> + * <td><code>mywebapp</code></td> + * <td><code>mywebapp</code></td> + * </tr> + * <tr> + * <td><code>http://foo:9080/bar/baz</code></td> + * <td><code>/mywebapp</code></td> + * <td><code>http://foo:9080/bar/baz/mywebapp</code></td> + * </tr> + * <tr> + * <td><code>http://foo:9080/bar/baz</code></td> + * <td><code>http://mywebapp</code></td> + * <td><code>http://mywebapp</code></td> + * </tr> + * </table> + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>SERIALIZER_absolutePathUriBase</jsf>, value)</code>. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see SerializerContext#SERIALIZER_absolutePathUriBase + */ + public Serializer setAbsolutePathUriBase(String value) throws LockedException { + return setProperty(SERIALIZER_absolutePathUriBase, value); + } + + /** + * <b>Configuration property:</b> Sort arrays and collections alphabetically. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.sortCollections"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>SERIALIZER_sortCollections</jsf>, value)</code>. + * <li>This introduces a slight performance penalty. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see SerializerContext#SERIALIZER_sortCollections + */ + public Serializer setSortCollections(boolean value) throws LockedException { + return setProperty(SERIALIZER_sortCollections, value); + } + + /** + * <b>Configuration property:</b> Sort maps alphabetically. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.sortMaps"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>SERIALIZER_sortMaps</jsf>, value)</code>. + * <li>This introduces a slight performance penalty. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see SerializerContext#SERIALIZER_sortMaps + */ + public Serializer setSortMaps(boolean value) throws LockedException { + return setProperty(SERIALIZER_sortMaps, value); + } + + @Override /* CoreApi */ + public Serializer setBeansRequireDefaultConstructor(boolean value) throws LockedException { + super.setBeansRequireDefaultConstructor(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setBeansRequireSerializable(boolean value) throws LockedException { + super.setBeansRequireSerializable(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setBeansRequireSettersForGetters(boolean value) throws LockedException { + super.setBeansRequireSettersForGetters(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setBeansRequireSomeProperties(boolean value) throws LockedException { + super.setBeansRequireSomeProperties(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setBeanMapPutReturnsOldValue(boolean value) throws LockedException { + super.setBeanMapPutReturnsOldValue(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setBeanConstructorVisibility(Visibility value) throws LockedException { + super.setBeanConstructorVisibility(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setBeanClassVisibility(Visibility value) throws LockedException { + super.setBeanClassVisibility(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setBeanFieldVisibility(Visibility value) throws LockedException { + super.setBeanFieldVisibility(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setMethodVisibility(Visibility value) throws LockedException { + super.setMethodVisibility(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setUseJavaBeanIntrospector(boolean value) throws LockedException { + super.setUseJavaBeanIntrospector(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setUseInterfaceProxies(boolean value) throws LockedException { + super.setUseInterfaceProxies(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setIgnoreUnknownBeanProperties(boolean value) throws LockedException { + super.setIgnoreUnknownBeanProperties(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setIgnoreUnknownNullBeanProperties(boolean value) throws LockedException { + super.setIgnoreUnknownNullBeanProperties(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setIgnorePropertiesWithoutSetters(boolean value) throws LockedException { + super.setIgnorePropertiesWithoutSetters(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setIgnoreInvocationExceptionsOnGetters(boolean value) throws LockedException { + super.setIgnoreInvocationExceptionsOnGetters(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setIgnoreInvocationExceptionsOnSetters(boolean value) throws LockedException { + super.setIgnoreInvocationExceptionsOnSetters(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setSortProperties(boolean value) throws LockedException { + super.setSortProperties(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setNotBeanPackages(String...values) throws LockedException { + super.setNotBeanPackages(values); + return this; + } + + @Override /* CoreApi */ + public Serializer setNotBeanPackages(Collection<String> values) throws LockedException { + super.setNotBeanPackages(values); + return this; + } + + @Override /* CoreApi */ + public Serializer addNotBeanPackages(String...values) throws LockedException { + super.addNotBeanPackages(values); + return this; + } + + @Override /* CoreApi */ + public Serializer addNotBeanPackages(Collection<String> values) throws LockedException { + super.addNotBeanPackages(values); + return this; + } + + @Override /* CoreApi */ + public Serializer removeNotBeanPackages(String...values) throws LockedException { + super.removeNotBeanPackages(values); + return this; + } + + @Override /* CoreApi */ + public Serializer removeNotBeanPackages(Collection<String> values) throws LockedException { + super.removeNotBeanPackages(values); + return this; + } + + @Override /* CoreApi */ + public Serializer setNotBeanClasses(Class<?>...values) throws LockedException { + super.setNotBeanClasses(values); + return this; + } + + @Override /* CoreApi */ + public Serializer setNotBeanClasses(Collection<Class<?>> values) throws LockedException { + super.setNotBeanClasses(values); + return this; + } + + @Override /* CoreApi */ + public Serializer addNotBeanClasses(Class<?>...values) throws LockedException { + super.addNotBeanClasses(values); + return this; + } + + @Override /* CoreApi */ + public Serializer addNotBeanClasses(Collection<Class<?>> values) throws LockedException { + super.addNotBeanClasses(values); + return this; + } + + @Override /* CoreApi */ + public Serializer removeNotBeanClasses(Class<?>...values) throws LockedException { + super.removeNotBeanClasses(values); + return this; + } + + @Override /* CoreApi */ + public Serializer removeNotBeanClasses(Collection<Class<?>> values) throws LockedException { + super.removeNotBeanClasses(values); + return this; + } + + @Override /* CoreApi */ + public Serializer setBeanFilters(Class<?>...values) throws LockedException { + super.setBeanFilters(values); + return this; + } + + @Override /* CoreApi */ + public Serializer setBeanFilters(Collection<Class<?>> values) throws LockedException { + super.setBeanFilters(values); + return this; + } + + @Override /* CoreApi */ + public Serializer addBeanFilters(Class<?>...values) throws LockedException { + super.addBeanFilters(values); + return this; + } + + @Override /* CoreApi */ + public Serializer addBeanFilters(Collection<Class<?>> values) throws LockedException { + super.addBeanFilters(values); + return this; + } + + @Override /* CoreApi */ + public Serializer removeBeanFilters(Class<?>...values) throws LockedException { + super.removeBeanFilters(values); + return this; + } + @Override /* CoreApi */ - public Serializer setProperty(String property, Object value) throws LockedException { - super.setProperty(property, value); + public Serializer removeBeanFilters(Collection<Class<?>> values) throws LockedException { + super.removeBeanFilters(values); return this; } @Override /* CoreApi */ - public Serializer addNotBeanClasses(Class<?>...classes) throws LockedException { - super.addNotBeanClasses(classes); + public Serializer setPojoSwaps(Class<?>...values) throws LockedException { + super.setPojoSwaps(values); return this; } @Override /* CoreApi */ - public Serializer addBeanFilters(Class<?>...classes) throws LockedException { - super.addBeanFilters(classes); + public Serializer setPojoSwaps(Collection<Class<?>> values) throws LockedException { + super.setPojoSwaps(values); return this; } @Override /* CoreApi */ - public Serializer addPojoSwaps(Class<?>...classes) throws LockedException { - super.addPojoSwaps(classes); + public Serializer addPojoSwaps(Class<?>...values) throws LockedException { + super.addPojoSwaps(values); return this; } @Override /* CoreApi */ - public Serializer addToDictionary(Class<?>...classes) throws LockedException { - super.addToDictionary(classes); + public Serializer addPojoSwaps(Collection<Class<?>> values) throws LockedException { + super.addPojoSwaps(values); return this; } @Override /* CoreApi */ - public <T> Serializer addImplClass(Class<T> interfaceClass, Class<? extends T> implClass) throws LockedException { + public Serializer removePojoSwaps(Class<?>...values) throws LockedException { + super.removePojoSwaps(values); + return this; + } + + @Override /* CoreApi */ + public Serializer removePojoSwaps(Collection<Class<?>> values) throws LockedException { + super.removePojoSwaps(values); + return this; + } + + @Override /* CoreApi */ + public Serializer setImplClasses(Map<Class<?>,Class<?>> values) throws LockedException { + super.setImplClasses(values); + return this; + } + + @Override /* CoreApi */ + public <T> CoreApi addImplClass(Class<T> interfaceClass, Class<? extends T> implClass) throws LockedException { super.addImplClass(interfaceClass, implClass); return this; } @Override /* CoreApi */ + public Serializer setBeanDictionary(Class<?>...values) throws LockedException { + super.setBeanDictionary(values); + return this; + } + + @Override /* CoreApi */ + public Serializer setBeanDictionary(Collection<Class<?>> values) throws LockedException { + super.setBeanDictionary(values); + return this; + } + + @Override /* CoreApi */ + public Serializer addToBeanDictionary(Class<?>...values) throws LockedException { + super.addToBeanDictionary(values); + return this; + } + + @Override /* CoreApi */ + public Serializer addToBeanDictionary(Collection<Class<?>> values) throws LockedException { + super.addToBeanDictionary(values); + return this; + } + + @Override /* CoreApi */ + public Serializer removeFromBeanDictionary(Class<?>...values) throws LockedException { + super.removeFromBeanDictionary(values); + return this; + } + + @Override /* CoreApi */ + public Serializer removeFromBeanDictionary(Collection<Class<?>> values) throws LockedException { + super.removeFromBeanDictionary(values); + return this; + } + + @Override /* CoreApi */ + public Serializer setBeanTypePropertyName(String value) throws LockedException { + super.setBeanTypePropertyName(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setDefaultParser(Class<?> value) throws LockedException { + super.setDefaultParser(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setLocale(Locale value) throws LockedException { + super.setLocale(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setTimeZone(TimeZone value) throws LockedException { + super.setTimeZone(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setMediaType(MediaType value) throws LockedException { + super.setMediaType(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setDebug(boolean value) throws LockedException { + super.setDebug(value); + return this; + } + + @Override /* CoreApi */ + public Serializer setProperty(String name, Object value) throws LockedException { + super.setProperty(name, value); + return this; + } + + @Override /* CoreApi */ + public Serializer setProperties(ObjectMap properties) throws LockedException { + super.setProperties(properties); + return this; + } + + @Override /* CoreApi */ + public Serializer addToProperty(String name, Object value) throws LockedException { + super.addToProperty(name, value); + return this; + } + + @Override /* CoreApi */ + public Serializer putToProperty(String name, Object key, Object value) throws LockedException { + super.putToProperty(name, key, value); + return this; + } + + @Override /* CoreApi */ + public Serializer putToProperty(String name, Object value) throws LockedException { + super.putToProperty(name, value); + return this; + } + + @Override /* CoreApi */ + public Serializer removeFromProperty(String name, Object value) throws LockedException { + super.removeFromProperty(name, value); + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden methods + //-------------------------------------------------------------------------------- + + @Override /* CoreApi */ public Serializer setClassLoader(ClassLoader classLoader) throws LockedException { super.setClassLoader(classLoader); return this; http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java index 7031b12..7abdd45 100644 --- a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java @@ -17,116 +17,6 @@ import org.apache.juneau.internal.*; /** * Configurable properties common to all serializers. - * - * <h6 class='topic' id='ConfigProperties'>Configurable properties common to all serializers</h6> - * <table class='styled' style='border-collapse: collapse;'> - * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th><th>Session overridable</th></tr> - * <tr> - * <td>{@link #SERIALIZER_maxDepth}</td> - * <td>Max serialization depth.</td> - * <td><code>Integer</code></td> - * <td><code>100</code></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #SERIALIZER_initialDepth}</td> - * <td>Initial depth.</td> - * <td><code>Integer</code></td> - * <td><code>0</code></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #SERIALIZER_detectRecursions}</td> - * <td>Automatically detect POJO recursions.</td> - * <td><code>Boolean</code></td> - * <td><jk>false</jk></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #SERIALIZER_ignoreRecursions}</td> - * <td>Ignore recursion errors.</td> - * <td><code>Boolean</code></td> - * <td><jk>false</jk></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #SERIALIZER_useIndentation}</td> - * <td>Use indentation.</td> - * <td><code>Boolean</code></td> - * <td><jk>false</jk></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #SERIALIZER_addBeanTypeProperties}</td> - * <td>Add <js>"_type"</js> properties when needed.</td> - * <td><code>Boolean</code></td> - * <td><jk>false</jk></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #SERIALIZER_quoteChar}</td> - * <td>Quote character.</td> - * <td><code>Character</code></td> - * <td><js>'"'</js></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #SERIALIZER_trimNullProperties}</td> - * <td>Trim null bean property values.</td> - * <td><code>Boolean</code></td> - * <td><jk>true</jk></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #SERIALIZER_trimEmptyCollections}</td> - * <td>Trim empty lists and arrays.</td> - * <td><code>Boolean</code></td> - * <td><jk>false</jk></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #SERIALIZER_trimEmptyMaps}</td> - * <td>Trim empty maps.</td> - * <td><code>Boolean</code></td> - * <td><jk>false</jk></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #SERIALIZER_trimStrings}</td> - * <td>Trim strings.</td> - * <td><code>Boolean</code></td> - * <td><jk>false</jk></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #SERIALIZER_relativeUriBase}</td> - * <td>URI base for relative URIs.</td> - * <td><code>String</code></td> - * <td><js>""</js></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #SERIALIZER_absolutePathUriBase}</td> - * <td>URI base for relative URIs with absolute paths.</td> - * <td><code>String</code></td> - * <td><js>""</js></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #SERIALIZER_sortCollections}</td> - * <td>Sort arrays and collections alphabetically.</td> - * <td><code>Boolean</code></td> - * <td><jk>false</jk></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #SERIALIZER_sortMaps}</td> - * <td>Sort maps alphabetically.</td> - * <td><code>Boolean</code></td> - * <td><jk>false</jk></td> - * <td><jk>true</jk></td> - * </tr> - * </table> */ public class SerializerContext extends BeanContext {
