You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2019/05/06 16:05:16 UTC
[juneau] branch master updated: New Serializer/Parser annotations.
This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new 99ce645 New Serializer/Parser annotations.
99ce645 is described below
commit 99ce645a3b71bec120e4ec91a0a184fe431285cd
Author: JamesBognar <ja...@apache.org>
AuthorDate: Mon May 6 12:04:40 2019 -0400
New Serializer/Parser annotations.
---
.../org/apache/juneau/config/ConfigBuilder.java | 6 -
.../apache/juneau/BeanConfigAnnotationTest.java | 312 ++++++++++++++++++
.../java/org/apache/juneau/XmlValidatorParser.java | 4 +-
.../apache/juneau/annotation/BeanConfigTest.java | 296 -----------------
...onfigTest.java => CsvConfigAnnotationTest.java} | 6 +-
.../HtmlConfigAnnotationTest.java} | 72 +++--
...gTest.java => HtmlDocConfigAnnotationTest.java} | 107 ++++---
.../juneau/html/annotation/HtmlConfigTest.java | 143 ---------
.../juneau/jena/RdfConfigAnnotationTest.java | 352 +++++++++++++++++++++
.../juneau/jena/annotation/RdfConfigTest.java | 296 -----------------
...onfigTest.java => JsoConfigAnnotationTest.java} | 14 +-
...nfigTest.java => JsonConfigAnnotationTest.java} | 53 ++--
...st.java => JsonSchemaConfigAnnotationTest.java} | 69 ++--
...gTest.java => MsgPackConfigAnnotationTest.java} | 30 +-
...gTest.java => OpenApiConfigAnnotationTest.java} | 14 +-
...igTest.java => ParserConfigAnnotationTest.java} | 110 +++----
...est.java => PlainTextConfigAnnotationTest.java} | 14 +-
.../serializer/SerializerConfigAnnotationTest.java | 219 +++++++++++++
.../annotation/SerializerConfigTest.java | 201 ------------
...gTest.java => SoapXmlConfigAnnotationTest.java} | 21 +-
...onfigTest.java => UonConfigAnnotationTest.java} | 52 ++-
...t.java => UrlEncodingConfigAnnotationTest.java} | 32 +-
...onfigTest.java => XmlConfigAnnotationTest.java} | 96 +++---
.../java/org/apache/juneau/jena/RdfCommon.java | 23 --
.../java/org/apache/juneau/jena/RdfParser.java | 95 ++++--
.../org/apache/juneau/jena/RdfParserBuilder.java | 112 +------
.../org/apache/juneau/jena/RdfParserSession.java | 82 +++--
.../java/org/apache/juneau/jena/RdfSerializer.java | 155 ++++++---
.../apache/juneau/jena/RdfSerializerBuilder.java | 95 +-----
.../apache/juneau/jena/RdfSerializerSession.java | 125 +++++---
.../apache/juneau/jena/annotation/RdfConfig.java | 48 +--
.../juneau/jena/annotation/RdfConfigApply.java | 110 +++++++
.../main/java/org/apache/juneau/BeanContext.java | 315 ++++++++++++------
.../java/org/apache/juneau/BeanContextBuilder.java | 169 +++-------
.../main/java/org/apache/juneau/BeanSession.java | 340 +++++++++++++-------
.../org/apache/juneau/BeanTraverseBuilder.java | 38 +--
.../org/apache/juneau/BeanTraverseContext.java | 52 +--
.../org/apache/juneau/BeanTraverseSession.java | 44 +--
.../main/java/org/apache/juneau/ConfigApply.java | 163 ++++++++++
.../java/org/apache/juneau/ContextBuilder.java | 33 +-
.../org/apache/juneau/PropertyStoreBuilder.java | 31 ++
.../org/apache/juneau/annotation/BeanConfig.java | 161 +++++++++-
.../apache/juneau/annotation/BeanConfigApply.java | 166 ++++++++++
.../juneau/annotation/{CCEntry.java => CC.java} | 6 +-
.../juneau/annotation/{CSEntry.java => CS.java} | 6 +-
.../PropertyStoreApply.java} | 20 +-
.../juneau/annotation/{SCEntry.java => SC.java} | 6 +-
.../juneau/annotation/{SSEntry.java => SS.java} | 6 +-
.../main/java/org/apache/juneau/csv/CsvParser.java | 7 +-
.../org/apache/juneau/csv/CsvParserBuilder.java | 22 +-
.../java/org/apache/juneau/csv/CsvSerializer.java | 7 +-
.../apache/juneau/csv/CsvSerializerBuilder.java | 23 +-
.../apache/juneau/csv/annotation/CsvConfig.java | 4 +-
.../{CsvConfig.java => CsvConfigApply.java} | 34 +-
.../org/apache/juneau/html/HtmlDocSerializer.java | 106 ++++---
.../juneau/html/HtmlDocSerializerBuilder.java | 111 +++----
.../juneau/html/HtmlDocSerializerSession.java | 96 +++---
.../java/org/apache/juneau/html/HtmlParser.java | 5 +
.../org/apache/juneau/html/HtmlParserBuilder.java | 22 +-
.../juneau/html/HtmlSchemaDocSerializer.java | 5 +
.../apache/juneau/html/HtmlSchemaSerializer.java | 10 +-
.../juneau/html/HtmlSchemaSerializerBuilder.java | 23 +-
.../org/apache/juneau/html/HtmlSerializer.java | 61 ++--
.../apache/juneau/html/HtmlSerializerBuilder.java | 42 +--
.../apache/juneau/html/HtmlSerializerSession.java | 47 +--
.../juneau/html/HtmlStrippedDocSerializer.java | 7 +-
.../html/HtmlStrippedDocSerializerBuilder.java | 23 +-
.../apache/juneau/html/annotation/HtmlConfig.java | 4 +-
.../annotation/HtmlConfigApply.java} | 102 +++---
.../juneau/html/annotation/HtmlDocConfig.java | 4 +-
.../juneau/html/annotation/HtmlDocConfigApply.java | 70 ++++
.../org/apache/juneau/internal/ObjectResolver.java | 120 -------
.../main/java/org/apache/juneau/jso/JsoParser.java | 7 +-
.../org/apache/juneau/jso/JsoParserBuilder.java | 22 +-
.../java/org/apache/juneau/jso/JsoSerializer.java | 7 +-
.../apache/juneau/jso/JsoSerializerBuilder.java | 23 +-
.../apache/juneau/jso/annotation/JsoConfig.java | 4 +-
.../{JsoConfig.java => JsoConfigApply.java} | 34 +-
.../java/org/apache/juneau/json/JsonParser.java | 11 +-
.../org/apache/juneau/json/JsonParserBuilder.java | 31 +-
.../juneau/json/JsonSchemaSerializerBuilder.java | 23 +-
.../org/apache/juneau/json/JsonSerializer.java | 35 +-
.../apache/juneau/json/JsonSerializerBuilder.java | 36 +--
.../apache/juneau/json/JsonSerializerSession.java | 26 +-
.../apache/juneau/json/annotation/JsonConfig.java | 4 +-
.../annotation/JsonConfigApply.java} | 100 +++---
.../juneau/jsonschema/JsonSchemaGenerator.java | 75 +++--
.../jsonschema/JsonSchemaGeneratorBuilder.java | 45 +--
.../jsonschema/JsonSchemaGeneratorSession.java | 62 ++--
.../jsonschema/annotation/JsonSchemaConfig.java | 5 +-
.../annotation/JsonSchemaConfigApply.java} | 106 ++++---
.../org/apache/juneau/msgpack/MsgPackParser.java | 5 +
.../juneau/msgpack/MsgPackParserBuilder.java | 22 +-
.../apache/juneau/msgpack/MsgPackSerializer.java | 7 +-
.../juneau/msgpack/MsgPackSerializerBuilder.java | 32 +-
.../juneau/msgpack/annotation/MsgPackConfig.java | 4 +-
.../annotation/MsgPackConfigApply.java} | 28 +-
.../apache/juneau/oapi/OpenApiParserBuilder.java | 22 +-
.../org/apache/juneau/oapi/OpenApiSerializer.java | 2 +-
.../juneau/oapi/OpenApiSerializerBuilder.java | 23 +-
.../juneau/oapi/annotation/OpenApiConfig.java | 4 +-
...{OpenApiConfig.java => OpenApiConfigApply.java} | 34 +-
.../apache/juneau/parser/InputStreamParser.java | 4 +
.../juneau/parser/InputStreamParserBuilder.java | 31 +-
.../juneau/parser/InputStreamParserSession.java | 4 +
.../main/java/org/apache/juneau/parser/Parser.java | 64 ++--
.../org/apache/juneau/parser/ParserBuilder.java | 41 +--
.../apache/juneau/parser/ParserGroupBuilder.java | 23 +-
.../org/apache/juneau/parser/ParserSession.java | 70 ++--
.../org/apache/juneau/parser/ReaderParser.java | 24 +-
.../apache/juneau/parser/ReaderParserBuilder.java | 33 +-
.../apache/juneau/parser/ReaderParserSession.java | 24 +-
.../juneau/parser/annotation/ParserConfig.java | 4 +-
.../annotation/ParserConfigApply.java} | 112 ++++---
.../apache/juneau/plaintext/PlainTextParser.java | 7 +-
.../juneau/plaintext/PlainTextParserBuilder.java | 22 +-
.../juneau/plaintext/PlainTextSerializer.java | 7 +-
.../plaintext/PlainTextSerializerBuilder.java | 23 +-
.../plaintext/annotation/PlainTextConfig.java | 4 +-
...inTextConfig.java => PlainTextConfigApply.java} | 34 +-
.../org/apache/juneau/reflect/AnnotationsMap.java | 1 -
.../java/org/apache/juneau/reflect/MethodInfo.java | 13 +
.../juneau/serializer/OutputStreamSerializer.java | 9 +
.../serializer/OutputStreamSerializerBuilder.java | 32 +-
.../org/apache/juneau/serializer/Serializer.java | 114 +++----
.../juneau/serializer/SerializerBuilder.java | 56 +---
.../juneau/serializer/SerializerGroupBuilder.java | 23 +-
.../juneau/serializer/SerializerSession.java | 123 ++++---
.../apache/juneau/serializer/WriterSerializer.java | 9 +
.../juneau/serializer/WriterSerializerBuilder.java | 34 +-
.../juneau/serializer/WriterSerializerSession.java | 8 +-
.../serializer/annotation/SerializerConfig.java | 3 +-
.../annotation/SerializerConfigApply.java | 82 +++++
.../org/apache/juneau/soap/SoapXmlSerializer.java | 22 +-
.../juneau/soap/SoapXmlSerializerBuilder.java | 32 +-
.../juneau/soap/SoapXmlSerializerSession.java | 15 +
.../juneau/soap/annotation/SoapXmlConfig.java | 4 +-
.../annotation/SoapXmlConfigApply.java} | 28 +-
.../main/java/org/apache/juneau/uon/UonParser.java | 14 +-
.../org/apache/juneau/uon/UonParserBuilder.java | 33 +-
.../org/apache/juneau/uon/UonParserSession.java | 26 +-
.../java/org/apache/juneau/uon/UonSerializer.java | 39 ++-
.../apache/juneau/uon/UonSerializerBuilder.java | 36 +--
.../apache/juneau/uon/UonSerializerSession.java | 26 +-
.../apache/juneau/uon/annotation/UonConfig.java | 4 +-
.../annotation/UonConfigApply.java} | 102 +++---
.../juneau/urlencoding/UrlEncodingParser.java | 9 +
.../urlencoding/UrlEncodingParserBuilder.java | 31 +-
.../juneau/urlencoding/UrlEncodingSerializer.java | 11 +-
.../urlencoding/UrlEncodingSerializerBuilder.java | 32 +-
.../urlencoding/annotation/UrlEncodingConfig.java | 4 +-
.../annotation/UrlEncodingConfigApply.java} | 30 +-
.../org/apache/juneau/xml/XmlDocSerializer.java | 8 +-
.../main/java/org/apache/juneau/xml/XmlParser.java | 31 +-
.../org/apache/juneau/xml/XmlParserBuilder.java | 39 +--
.../org/apache/juneau/xml/XmlParserSession.java | 21 +-
.../java/org/apache/juneau/xml/XmlSerializer.java | 69 ++--
.../apache/juneau/xml/XmlSerializerBuilder.java | 44 +--
.../apache/juneau/xml/XmlSerializerSession.java | 62 ++--
.../apache/juneau/xml/annotation/XmlConfig.java | 4 +-
.../juneau/xml/annotation/XmlConfigApply.java | 64 ++++
.../juneau/xmlschema/XmlSchemaDocSerializer.java | 7 +-
.../juneau/xmlschema/XmlSchemaSerializer.java | 7 +-
.../xmlschema/XmlSchemaSerializerBuilder.java | 23 +-
.../xmlschema/XmlSchemaSerializerSession.java | 1 +
.../java/org/apache/juneau/svl/VarResolver.java | 4 +-
.../org/apache/juneau/svl/VarResolverSession.java | 4 +-
.../juneau/examples/rest/RequestEchoResource.java | 11 +-
.../apache/juneau/examples/rest/RootResources.java | 15 +-
.../juneau/examples/rest/dto/AtomFeedResource.java | 23 +-
.../juneau/examples/rest/dto/DtoExamples.java | 15 +-
.../examples/rest/dto/JsonSchemaResource.java | 9 +-
.../rest/petstore/rest/PhotosResource.java | 10 +-
.../microservice/resources/DirectoryResource.java | 7 +-
.../microservice/resources/LogsResource.java | 3 +-
.../rest/test/client/InterfaceProxyTest.java | 3 +-
.../rest/test/client/ThirdPartyProxyResource.java | 6 +-
.../juneau/rest/client/RestClientBuilder.java | 22 +-
.../org/apache/juneau/rest/BasicRestConfig.java | 42 +--
.../java/org/apache/juneau/rest/RestContext.java | 103 ++++--
.../org/apache/juneau/rest/RestContextBuilder.java | 7 +-
.../org/apache/juneau/rest/RestJavaMethod.java | 41 ++-
.../java/org/apache/juneau/rest/RestRequest.java | 11 +
.../org/apache/juneau/rest/SwaggerGenerator.java | 3 +-
.../apache/juneau/rest/annotation/RestMethod.java | 13 +
.../juneau/rest/annotation/RestResource.java | 11 +
186 files changed, 4757 insertions(+), 4236 deletions(-)
diff --git a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/ConfigBuilder.java b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/ConfigBuilder.java
index fc60479..b67e16e 100644
--- a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/ConfigBuilder.java
+++ b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/ConfigBuilder.java
@@ -300,12 +300,6 @@ public class ConfigBuilder extends ContextBuilder {
}
@Override /* ContextBuilder */
- public ConfigBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public ConfigBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/BeanConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/BeanConfigAnnotationTest.java
new file mode 100644
index 0000000..82f416c
--- /dev/null
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/BeanConfigAnnotationTest.java
@@ -0,0 +1,312 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau;
+
+import static org.junit.Assert.*;
+
+import java.util.*;
+import java.util.function.*;
+import java.util.stream.*;
+
+import org.apache.juneau.annotation.*;
+import org.apache.juneau.internal.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.marshall.*;
+import org.apache.juneau.reflect.*;
+import org.apache.juneau.transform.*;
+import org.apache.juneau.utils.*;
+import org.junit.*;
+
+/**
+ * Tests the @BeanConfig annotation.
+ */
+public class BeanConfigAnnotationTest {
+
+ private static void check(String expected, Object o) {
+ assertEquals(expected, TO_STRING.apply(o));
+ }
+
+ private static final Function<Object,String> TO_STRING = new Function<Object,String>() {
+ @SuppressWarnings({ "rawtypes" })
+ @Override
+ public String apply(Object t) {
+ if (t == null)
+ return null;
+ if (t instanceof List)
+ return ((List<?>)t)
+ .stream()
+ .map(TO_STRING)
+ .collect(Collectors.joining(","));
+ if (t.getClass().isArray())
+ return apply(ArrayUtils.toList(t, Object.class));
+ if (t instanceof ObjectMap)
+ return ((ObjectMap)t).toString();
+ if (t instanceof Map)
+ return ((Map<?,?>)t)
+ .entrySet()
+ .stream()
+ .map(TO_STRING)
+ .collect(Collectors.joining(","));
+ if (t instanceof Map.Entry) {
+ Map.Entry e = (Map.Entry)t;
+ return apply(e.getKey()) + "=" + apply(e.getValue());
+ }
+ if (t instanceof BeanFilter)
+ return ((BeanFilter)t).getBeanClass().getSimpleName();
+ if (t instanceof Class)
+ return ((Class<?>)t).getSimpleName();
+ if (t instanceof ClassInfo)
+ return ((ClassInfo)t).getSimpleName();
+ if (t instanceof PropertyNamer)
+ return ((PropertyNamer)t).getClass().getSimpleName();
+ if (t instanceof TimeZone)
+ return ((TimeZone)t).getID();
+ return t.toString();
+ }
+ };
+
+ static StringResolver sr = new StringResolver() {
+ @Override
+ public String resolve(String input) {
+ if (input != null && input.startsWith("$"))
+ input = input.substring(1);
+ return input;
+ }
+ };
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // Basic tests
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @Bean(typeName="A1")
+ public static class A1 {
+ public int foo;
+ @Override
+ public String toString() {return SimpleJson.DEFAULT.toString(this);}
+ }
+ @Bean(typeName="A2")
+ public static class A2 {
+ public int foo;
+ }
+ @Bean(typeName="A3")
+ public static class A3 {
+ public int foo;
+ }
+ public static class AB1 extends PojoSwap<String,Integer> {
+ }
+ public static class AB2 extends PojoSwap<String,Integer> {
+ }
+ public static class AB3 extends PojoSwap<String,Integer> {
+ }
+
+ @BeanConfig(
+ beanClassVisibility="$PRIVATE",
+ beanConstructorVisibility="$PRIVATE",
+ beanDictionary={A1.class,A2.class},
+ beanDictionary_replace={A1.class,A2.class,A3.class},
+ beanDictionary_remove=A2.class,
+ beanFieldVisibility="$PRIVATE",
+ beanFilters={A1.class,A2.class},
+ beanFilters_replace={A1.class,A2.class,A3.class},
+ beanFilters_remove=A2.class,
+ beanMapPutReturnsOldValue="$true",
+ beanMethodVisibility="$PRIVATE",
+ beansRequireDefaultConstructor="$true",
+ beansRequireSerializable="$true",
+ beansRequireSettersForGetters="$true",
+ beansRequireSomeProperties="$true",
+ beanTypePropertyName="$foo",
+ debug="$true",
+ detectRecursions="$true",
+ examples="$A1: {foo:1}",
+ excludeProperties=@CS(k=A1.class,v="$foo"),
+ fluentSetters="$true",
+ ignoreInvocationExceptionsOnGetters="$true",
+ ignoreInvocationExceptionsOnSetters="$true",
+ ignorePropertiesWithoutSetters="$true",
+ ignoreRecursions="$true",
+ ignoreUnknownBeanProperties="$true",
+ ignoreUnknownNullBeanProperties="$true",
+ implClasses=@CC(k=A1.class,v=A1.class),
+ includeProperties=@CS(k=A1.class,v="$foo"),
+ initialDepth="$1",
+ locale="$en-US",
+ maxDepth="$1",
+ mediaType="$text/foo",
+ notBeanClasses={A1.class,A2.class},
+ notBeanClasses_replace={A1.class,A2.class,A3.class},
+ notBeanClasses_remove=A2.class,
+ notBeanPackages={"$foo1","$foo2"},
+ notBeanPackages_replace={"$foo1","$foo2","$foo3"},
+ notBeanPackages_remove={"$foo2"},
+ pojoSwaps={AB1.class,AB2.class},
+ pojoSwaps_replace={AB1.class,AB2.class,AB3.class},
+ pojoSwaps_remove=AB2.class,
+ propertyNamer=PropertyNamerULC.class,
+ sortProperties="$true",
+ timeZone="$z",
+ useEnumNames="$true",
+ useInterfaceProxies="$true",
+ useJavaBeanIntrospector="$true"
+ )
+ static class A {}
+ static ClassInfo a = ClassInfo.of(A.class);
+
+ @Test
+ public void basic() throws Exception {
+ AnnotationsMap m = a.getAnnotationsMap();
+ BeanTraverseSession bc = JsonSerializer.create().applyAnnotations(m, sr).build().createSession();
+
+ System.err.println(bc.getImplClasses().values().iterator().next().getClass().getSimpleName());
+
+ check("PRIVATE", bc.getBeanClassVisibility());
+ check("PRIVATE", bc.getBeanConstructorVisibility());
+ check("A1,A3", bc.getBeanDictionaryClasses());
+ check("PRIVATE", bc.getBeanFieldVisibility());
+ check("A1,A3", bc.getBeanFilters());
+ check("true", bc.isBeanMapPutReturnsOldValue());
+ check("PRIVATE", bc.getBeanMethodVisibility());
+ check("true", bc.isBeansRequireDefaultConstructor());
+ check("true", bc.isBeansRequireSerializable());
+ check("true", bc.isBeansRequireSettersForGetters());
+ check("true", bc.isBeansRequireSomeProperties());
+ check("foo", bc.getBeanTypePropertyName());
+ check("true", bc.isDebug());
+ check("true", bc.isDetectRecursions());
+ check("A1={foo:1}", bc.getExamples());
+ check("org.apache.juneau.BeanConfigAnnotationTest$A1=foo", bc.getExcludeProperties());
+ check("true", bc.isFluentSetters());
+ check("true", bc.isIgnoreInvocationExceptionsOnGetters());
+ check("true", bc.isIgnoreInvocationExceptionsOnSetters());
+ check("true", bc.isIgnorePropertiesWithoutSetters());
+ check("true", bc.isIgnoreRecursions());
+ check("true", bc.isIgnoreUnknownBeanProperties());
+ check("true", bc.isIgnoreUnknownNullBeanProperties());
+ check("org.apache.juneau.BeanConfigAnnotationTest$A1=A1", bc.getImplClasses());
+ check("org.apache.juneau.BeanConfigAnnotationTest$A1=foo", bc.getIncludeProperties());
+ check("1", bc.getInitialDepth());
+ check("en_US", bc.getLocale());
+ check("1", bc.getMaxDepth());
+ check("application/json", bc.getMediaType());
+ check("A1,A3", bc.getNotBeanClasses());
+ check("foo1,foo3", bc.getNotBeanPackagesNames());
+ check("AB1<String,Integer>,AB3<String,Integer>", bc.getPojoSwaps());
+ check("PropertyNamerULC", bc.getPropertyNamer());
+ check("true", bc.isSortProperties());
+ check("GMT", bc.getTimeZone());
+ check("true", bc.isUseEnumNames());
+ check("true", bc.isUseInterfaceProxies());
+ check("true", bc.isUseJavaBeanIntrospector());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // Annotation with no values.
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @BeanConfig()
+ static class B {}
+ static ClassInfo b = ClassInfo.of(B.class);
+
+ @Test
+ public void noValues() throws Exception {
+ AnnotationsMap m = b.getAnnotationsMap();
+ JsonSerializer bc = JsonSerializer.create().applyAnnotations(m, sr).build();
+ check("PUBLIC", bc.getBeanClassVisibility());
+ check("PUBLIC", bc.getBeanConstructorVisibility());
+ check("", bc.getBeanDictionaryClasses());
+ check("PUBLIC", bc.getBeanFieldVisibility());
+ check("", bc.getBeanFilters());
+ check("false", bc.isBeanMapPutReturnsOldValue());
+ check("PUBLIC", bc.getBeanMethodVisibility());
+ check("false", bc.isBeansRequireDefaultConstructor());
+ check("false", bc.isBeansRequireSerializable());
+ check("false", bc.isBeansRequireSettersForGetters());
+ check("true", bc.isBeansRequireSomeProperties());
+ check("_type", bc.getBeanTypePropertyName());
+ check("false", bc.isDebug());
+ check("false", bc.isDetectRecursions());
+ check("", bc.getExamples());
+ check("", bc.getExcludeProperties());
+ check("false", bc.isFluentSetters());
+ check("false", bc.isIgnoreInvocationExceptionsOnGetters());
+ check("false", bc.isIgnoreInvocationExceptionsOnSetters());
+ check("true", bc.isIgnorePropertiesWithoutSetters());
+ check("false", bc.isIgnoreRecursions());
+ check("false", bc.isIgnoreUnknownBeanProperties());
+ check("true", bc.isIgnoreUnknownNullBeanProperties());
+ check("", bc.getImplClasses());
+ check("", bc.getIncludeProperties());
+ check("0", bc.getInitialDepth());
+ check(null, bc.getLocale());
+ check("100", bc.getMaxDepth());
+ check(null, bc.getMediaType());
+ check("java.lang,java.lang.annotation,java.lang.ref,java.lang.reflect,java.io,java.net", bc.getNotBeanPackagesNames());
+ check("", bc.getPojoSwaps());
+ check("PropertyNamerDefault", bc.getPropertyNamer());
+ check("false", bc.isSortProperties());
+ check(null, bc.getTimeZone());
+ check("false", bc.isUseEnumNames());
+ check("true", bc.isUseInterfaceProxies());
+ check("false", bc.isUseJavaBeanIntrospector());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // No annotation.
+ //-----------------------------------------------------------------------------------------------------------------
+
+ static class C {}
+ static ClassInfo c = ClassInfo.of(C.class);
+
+ @Test
+ public void noAnnotation() throws Exception {
+ AnnotationsMap m = c.getAnnotationsMap();
+ JsonSerializer bc = JsonSerializer.create().applyAnnotations(m, sr).build();
+ check("PUBLIC", bc.getBeanClassVisibility());
+ check("PUBLIC", bc.getBeanConstructorVisibility());
+ check("", bc.getBeanDictionaryClasses());
+ check("PUBLIC", bc.getBeanFieldVisibility());
+ check("", bc.getBeanFilters());
+ check("false", bc.isBeanMapPutReturnsOldValue());
+ check("PUBLIC", bc.getBeanMethodVisibility());
+ check("false", bc.isBeansRequireDefaultConstructor());
+ check("false", bc.isBeansRequireSerializable());
+ check("false", bc.isBeansRequireSettersForGetters());
+ check("true", bc.isBeansRequireSomeProperties());
+ check("_type", bc.getBeanTypePropertyName());
+ check("false", bc.isDebug());
+ check("false", bc.isDetectRecursions());
+ check("", bc.getExamples());
+ check("", bc.getExcludeProperties());
+ check("false", bc.isFluentSetters());
+ check("false", bc.isIgnoreInvocationExceptionsOnGetters());
+ check("false", bc.isIgnoreInvocationExceptionsOnSetters());
+ check("true", bc.isIgnorePropertiesWithoutSetters());
+ check("false", bc.isIgnoreRecursions());
+ check("false", bc.isIgnoreUnknownBeanProperties());
+ check("true", bc.isIgnoreUnknownNullBeanProperties());
+ check("", bc.getImplClasses());
+ check("", bc.getIncludeProperties());
+ check("0", bc.getInitialDepth());
+ check(null, bc.getLocale());
+ check("100", bc.getMaxDepth());
+ check(null, bc.getMediaType());
+ check("java.lang,java.lang.annotation,java.lang.ref,java.lang.reflect,java.io,java.net", bc.getNotBeanPackagesNames());
+ check("", bc.getPojoSwaps());
+ check("PropertyNamerDefault", bc.getPropertyNamer());
+ check("false", bc.isSortProperties());
+ check(null, bc.getTimeZone());
+ check("false", bc.isUseEnumNames());
+ check("true", bc.isUseInterfaceProxies());
+ check("false", bc.isUseJavaBeanIntrospector());
+ }
+}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/XmlValidatorParser.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/XmlValidatorParser.java
index 88f2983..73a0d52 100755
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/XmlValidatorParser.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/XmlValidatorParser.java
@@ -34,8 +34,8 @@ public class XmlValidatorParser extends XmlParser {
}
@Override /* Parser */
- public ReaderParserSession createSession(ParserSessionArgs args) {
- return new ReaderParserSession(null, args) {
+ public XmlParserSession createSession(ParserSessionArgs args) {
+ return new XmlParserSession(null, args) {
@Override
protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws Exception {
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/annotation/BeanConfigTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/annotation/BeanConfigTest.java
deleted file mode 100644
index 4e55e58..0000000
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/annotation/BeanConfigTest.java
+++ /dev/null
@@ -1,296 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.annotation;
-
-import static org.junit.Assert.*;
-import static org.apache.juneau.BeanContext.*;
-import static org.apache.juneau.BeanTraverseContext.*;
-
-import java.util.*;
-import java.util.function.*;
-import java.util.stream.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.json.*;
-import org.apache.juneau.reflect.*;
-import org.apache.juneau.transform.*;
-import org.apache.juneau.utils.*;
-import org.junit.*;
-
-/**
- * Tests the @BeanConfig annotation.
- */
-public class BeanConfigTest {
-
- private static void check(String expected, Object o) {
- if (o instanceof Set) {
- Set<String> s2 = new TreeSet<>();
- for (Object o2 : (Set<?>)o)
- s2.add(TO_STRING.apply(o2));
- String actual = s2
- .stream()
- .collect(Collectors.joining(","));
- assertEquals(expected, actual);
- } else if (o instanceof List) {
- List<?> l = (List<?>)o;
- String actual = l
- .stream()
- .map(TO_STRING)
- .collect(Collectors.joining(","));
- assertEquals(expected, actual);
- } else if (o instanceof Map) {
- Map<?,?> m = (Map<?,?>)o;
- String actual = m
- .entrySet()
- .stream()
- .map(TO_STRING)
- .collect(Collectors.joining(","));
- assertEquals(expected, actual);
- } else {
- assertEquals(expected, TO_STRING.apply(o));
- }
- }
-
- private static final Function<Object,String> TO_STRING = new Function<Object,String>() {
- @SuppressWarnings({ "rawtypes" })
- @Override
- public String apply(Object t) {
- if (t == null)
- return null;
- if (t instanceof Map.Entry) {
- Map.Entry e = (Map.Entry)t;
- return apply(e.getKey()) + "=" + apply(e.getValue());
- }
- if (t instanceof A1)
- return "A1";
- if (t instanceof Class)
- return ((Class<?>)t).getSimpleName();
- return t.toString();
- }
- };
-
- static StringResolver sr = new StringResolver() {
- @Override
- public String resolve(String input) {
- if (input != null && input.startsWith("$"))
- input = input.substring(1);
- return input;
- }
- };
-
- //-----------------------------------------------------------------------------------------------------------------
- // Basic tests
- //-----------------------------------------------------------------------------------------------------------------
-
- @Bean(typeName="A1")
- public static class A1 {
- public int foo;
- }
- @Bean(typeName="A2")
- public static class A2 {
- public int foo;
- }
- @Bean(typeName="A3")
- public static class A3 {
- public int foo;
- }
- public static class AB1 extends PojoSwap<String,Integer> {
- }
- public static class AB2 extends PojoSwap<String,Integer> {
- }
- public static class AB3 extends PojoSwap<String,Integer> {
- }
-
- @BeanConfig(
- beanClassVisibility="$PRIVATE",
- beanConstructorVisibility="$PRIVATE",
- beanDictionary={A1.class,A2.class},
- beanDictionary_replace={A1.class,A2.class,A3.class},
- beanDictionary_remove=A2.class,
- beanFieldVisibility="$PRIVATE",
- beanFilters={A1.class,A2.class},
- beanFilters_replace={A1.class,A2.class,A3.class},
- beanFilters_remove=A2.class,
- beanMapPutReturnsOldValue="$true",
- beanMethodVisibility="$PRIVATE",
- beansRequireDefaultConstructor="$true",
- beansRequireSerializable="$true",
- beansRequireSettersForGetters="$true",
- beansRequireSomeProperties="$true",
- beanTypePropertyName="$foo",
- debug="$true",
- detectRecursions="$true",
- examples=@CSEntry(key=A1.class,value="${}"),
- excludeProperties=@CSEntry(key=A1.class,value="$foo"),
- fluentSetters="$true",
- ignoreInvocationExceptionsOnGetters="$true",
- ignoreInvocationExceptionsOnSetters="$true",
- ignorePropertiesWithoutSetters="$true",
- ignoreRecursions="$true",
- ignoreUnknownBeanProperties="$true",
- ignoreUnknownNullBeanProperties="$true",
- implClasses=@CCEntry(key=A1.class,value=A1.class),
- includeProperties=@CSEntry(key=A1.class,value="$foo"),
- initialDepth="$1",
- locale="$en-US",
- maxDepth="$1",
- mediaType="$text/foo",
- notBeanClasses={A1.class,A2.class},
- notBeanClasses_replace={A1.class,A2.class,A3.class},
- notBeanClasses_remove=A2.class,
- notBeanPackages={"$foo1","$foo2"},
- notBeanPackages_replace={"$foo1","$foo2","$foo3"},
- notBeanPackages_remove={"$foo2"},
- pojoSwaps={AB1.class,AB2.class},
- pojoSwaps_replace={AB1.class,AB2.class,AB3.class},
- pojoSwaps_remove=AB2.class,
- propertyNamer=PropertyNamerULC.class,
- sortProperties="$true",
- timeZone="$z",
- useEnumNames="$true",
- useInterfaceProxies="$true",
- useJavaBeanIntrospector="$true"
- )
- static class A {}
- static ClassInfo a = ClassInfo.of(A.class);
-
- @Test
- public void basic() throws Exception {
- AnnotationsMap m = a.getAnnotationsMap();
- JsonSerializer bc = JsonSerializer.create().applyAnnotations(m, sr).build();
- check("PRIVATE", bc.getProperty(BEAN_beanClassVisibility));
- check("PRIVATE", bc.getProperty(BEAN_beanConstructorVisibility));
- check("A1,A3", bc.getProperty(BEAN_beanDictionary));
- check(null, bc.getProperty(BEAN_beanDictionary_add));
- check(null, bc.getProperty(BEAN_beanDictionary_remove));
- check("PRIVATE", bc.getProperty(BEAN_beanFieldVisibility));
- check("A1,A3", bc.getProperty(BEAN_beanFilters));
- check(null, bc.getProperty(BEAN_beanFilters_add));
- check(null, bc.getProperty(BEAN_beanFilters_remove));
- check("true", bc.getProperty(BEAN_beanMapPutReturnsOldValue));
- check("PRIVATE", bc.getProperty(BEAN_beanMethodVisibility));
- check("true", bc.getProperty(BEAN_beansRequireDefaultConstructor));
- check("true", bc.getProperty(BEAN_beansRequireSerializable));
- check("true", bc.getProperty(BEAN_beansRequireSettersForGetters));
- check("true", bc.getProperty(BEAN_beansRequireSomeProperties));
- check("foo", bc.getProperty(BEAN_beanTypePropertyName));
- check("true", bc.getProperty(BEAN_debug));
- check("true", bc.getProperty(BEANTRAVERSE_detectRecursions));
- check("org.apache.juneau.annotation.BeanConfigTest$A1=A1", bc.getProperty(BEAN_examples));
- check("org.apache.juneau.annotation.BeanConfigTest$A1=foo", bc.getProperty(BEAN_excludeProperties));
- check("true", bc.getProperty(BEAN_fluentSetters));
- check("true", bc.getProperty(BEAN_ignoreInvocationExceptionsOnGetters));
- check("true", bc.getProperty(BEAN_ignoreInvocationExceptionsOnSetters));
- check("true", bc.getProperty(BEAN_ignorePropertiesWithoutSetters));
- check("true", bc.getProperty(BEANTRAVERSE_ignoreRecursions));
- check("true", bc.getProperty(BEAN_ignoreUnknownBeanProperties));
- check("true", bc.getProperty(BEAN_ignoreUnknownNullBeanProperties));
- check("org.apache.juneau.annotation.BeanConfigTest$A1=A1", bc.getProperty(BEAN_implClasses));
- check("org.apache.juneau.annotation.BeanConfigTest$A1=foo", bc.getProperty(BEAN_includeProperties));
- check("1", bc.getProperty(BEANTRAVERSE_initialDepth));
- check("en-US", bc.getProperty(BEAN_locale));
- check("1", bc.getProperty(BEANTRAVERSE_maxDepth));
- check("text/foo", bc.getProperty(BEAN_mediaType));
- check("A1,A3", bc.getProperty(BEAN_notBeanClasses));
- check(null, bc.getProperty(BEAN_notBeanClasses_add));
- check(null, bc.getProperty(BEAN_notBeanClasses_remove));
- check("foo1,foo3", bc.getProperty(BEAN_notBeanPackages));
- check(null, bc.getProperty(BEAN_notBeanPackages_add));
- check(null, bc.getProperty(BEAN_notBeanPackages_remove));
- check("AB1,AB3", bc.getProperty(BEAN_pojoSwaps));
- check(null, bc.getProperty(BEAN_pojoSwaps_add));
- check(null, bc.getProperty(BEAN_pojoSwaps_remove));
- check("PropertyNamerULC", bc.getProperty(BEAN_propertyNamer));
- check("true", bc.getProperty(BEAN_sortProperties));
- check("GMT", bc.getProperty(BEAN_timeZone));
- check("true", bc.getProperty(BEAN_useEnumNames));
- check("true", bc.getProperty(BEAN_useInterfaceProxies));
- check("true", bc.getProperty(BEAN_useJavaBeanIntrospector));
- }
-
- //-----------------------------------------------------------------------------------------------------------------
- // Annotation with no values.
- //-----------------------------------------------------------------------------------------------------------------
-
- @BeanConfig()
- static class B {}
- static ClassInfo b = ClassInfo.of(B.class);
-
- @Test
- public void noValues() throws Exception {
- AnnotationsMap m = b.getAnnotationsMap();
- JsonSerializer bc = JsonSerializer.create().applyAnnotations(m, sr).build();
- check(null, bc.getProperty(BEAN_beanClassVisibility));
- check(null, bc.getProperty(BEAN_beanConstructorVisibility));
- check(null, bc.getProperty(BEAN_beanDictionary));
- check(null, bc.getProperty(BEAN_beanDictionary_add));
- check(null, bc.getProperty(BEAN_beanDictionary_remove));
- check(null, bc.getProperty(BEAN_beanFieldVisibility));
- check(null, bc.getProperty(BEAN_beanFilters));
- check(null, bc.getProperty(BEAN_beanFilters_add));
- check(null, bc.getProperty(BEAN_beanFilters_remove));
- check(null, bc.getProperty(BEAN_beanMapPutReturnsOldValue));
- check(null, bc.getProperty(BEAN_beanMethodVisibility));
- check(null, bc.getProperty(BEAN_beansRequireDefaultConstructor));
- check(null, bc.getProperty(BEAN_beansRequireSerializable));
- check(null, bc.getProperty(BEAN_beansRequireSettersForGetters));
- check(null, bc.getProperty(BEAN_beansRequireSomeProperties));
- check(null, bc.getProperty(BEAN_beanTypePropertyName));
- check(null, bc.getProperty(BEAN_debug));
- check(null, bc.getProperty(BEANTRAVERSE_detectRecursions));
- check(null, bc.getProperty(BEAN_examples));
- check(null, bc.getProperty(BEAN_excludeProperties));
- check(null, bc.getProperty(BEAN_fluentSetters));
- check(null, bc.getProperty(BEAN_ignoreInvocationExceptionsOnGetters));
- check(null, bc.getProperty(BEAN_ignoreInvocationExceptionsOnSetters));
- check(null, bc.getProperty(BEAN_ignorePropertiesWithoutSetters));
- check(null, bc.getProperty(BEANTRAVERSE_ignoreRecursions));
- check(null, bc.getProperty(BEAN_ignoreUnknownBeanProperties));
- check(null, bc.getProperty(BEAN_ignoreUnknownNullBeanProperties));
- check(null, bc.getProperty(BEAN_implClasses));
- check(null, bc.getProperty(BEAN_includeProperties));
- check(null, bc.getProperty(BEANTRAVERSE_initialDepth));
- check(null, bc.getProperty(BEAN_locale));
- check(null, bc.getProperty(BEANTRAVERSE_maxDepth));
- check(null, bc.getProperty(BEAN_mediaType));
- check(null, bc.getProperty(BEAN_notBeanClasses));
- check(null, bc.getProperty(BEAN_notBeanClasses_add));
- check(null, bc.getProperty(BEAN_notBeanClasses_remove));
- check(null, bc.getProperty(BEAN_notBeanPackages));
- check(null, bc.getProperty(BEAN_notBeanPackages_add));
- check(null, bc.getProperty(BEAN_notBeanPackages_remove));
- check(null, bc.getProperty(BEAN_pojoSwaps));
- check(null, bc.getProperty(BEAN_pojoSwaps_add));
- check(null, bc.getProperty(BEAN_pojoSwaps_remove));
- check(null, bc.getProperty(BEAN_propertyNamer));
- check(null, bc.getProperty(BEAN_sortProperties));
- check(null, bc.getProperty(BEAN_timeZone));
- check(null, bc.getProperty(BEAN_useEnumNames));
- check(null, bc.getProperty(BEAN_useInterfaceProxies));
- check(null, bc.getProperty(BEAN_useJavaBeanIntrospector));
- }
-
- //-----------------------------------------------------------------------------------------------------------------
- // No annotation.
- //-----------------------------------------------------------------------------------------------------------------
-
- static class C {}
- static ClassInfo c = ClassInfo.of(C.class);
-
- @Test
- public void noAnnotation() throws Exception {
- AnnotationsMap m = c.getAnnotationsMap();
- JsonSerializer bc = JsonSerializer.create().applyAnnotations(m, sr).build();
- check(null, bc.getProperty(BEAN_beanClassVisibility));
- }
-}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/csv/annotation/CsvConfigTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/csv/CsvConfigAnnotationTest.java
similarity index 96%
rename from juneau-core/juneau-core-test/src/test/java/org/apache/juneau/csv/annotation/CsvConfigTest.java
rename to juneau-core/juneau-core-test/src/test/java/org/apache/juneau/csv/CsvConfigAnnotationTest.java
index aed8d6d..10c767f 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/csv/annotation/CsvConfigTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/csv/CsvConfigAnnotationTest.java
@@ -10,16 +10,16 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.csv.annotation;
+package org.apache.juneau.csv;
-import org.apache.juneau.csv.*;
+import org.apache.juneau.csv.annotation.*;
import org.apache.juneau.reflect.*;
import org.junit.*;
/**
* Tests the @CsvConfig annotation.
*/
-public class CsvConfigTest {
+public class CsvConfigAnnotationTest {
//-----------------------------------------------------------------------------------------------------------------
// Annotation with no values.
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/uon/annotation/UonConfigTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlConfigAnnotationTest.java
similarity index 68%
copy from juneau-core/juneau-core-test/src/test/java/org/apache/juneau/uon/annotation/UonConfigTest.java
copy to juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlConfigAnnotationTest.java
index fa240bc..daed405 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/uon/annotation/UonConfigTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlConfigAnnotationTest.java
@@ -10,24 +10,21 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.uon.annotation;
+package org.apache.juneau.html;
import static org.junit.Assert.*;
-import static org.apache.juneau.serializer.Serializer.*;
-import static org.apache.juneau.uon.UonSerializer.*;
-import static org.apache.juneau.uon.UonParser.*;
import java.util.function.*;
+import org.apache.juneau.html.annotation.*;
import org.apache.juneau.reflect.*;
-import org.apache.juneau.uon.*;
import org.apache.juneau.utils.*;
import org.junit.*;
/**
- * Tests the @UonConfig annotation.
+ * Tests the @HtmlConfig annotation.
*/
-public class UonConfigTest {
+public class HtmlConfigAnnotationTest {
private static void check(String expected, Object o) {
assertEquals(expected, TO_STRING.apply(o));
@@ -55,12 +52,13 @@ public class UonConfigTest {
// Basic tests
//-----------------------------------------------------------------------------------------------------------------
- @UonConfig(
+ @HtmlConfig(
addBeanTypes="$true",
- decoding="$true",
- encoding="$true",
- paramFormat="$UON",
- validateEnd="$true"
+ addKeyValueTableHeaders="$true",
+ detectLabelParameters="$true",
+ detectLinksInStrings="$true",
+ labelParameter="$foo",
+ uriAnchorText="$TO_STRING"
)
static class A {}
static ClassInfo a = ClassInfo.of(A.class);
@@ -68,45 +66,45 @@ public class UonConfigTest {
@Test
public void basicSerializer() throws Exception {
AnnotationsMap m = a.getAnnotationsMap();
- UonSerializer x = UonSerializer.create().applyAnnotations(m, sr).build();
- check("true", x.getProperty(SERIALIZER_addBeanTypes));
- check(null, x.getProperty(UON_decoding));
- check("true", x.getProperty(UON_encoding));
- check("UON", x.getProperty(UON_paramFormat));
- check(null, x.getProperty(UON_validateEnd));
+ HtmlSerializerSession x = HtmlSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("true", x.isAddBeanTypes());
+ check("true", x.isAddKeyValueTableHeaders());
+ check("true", x.isDetectLabelParameters());
+ check("true", x.isDetectLinksInStrings());
+ check("foo", x.getLabelParameter());
+ check("TO_STRING", x.getUriAnchorText());
}
@Test
public void basicParser() throws Exception {
AnnotationsMap m = a.getAnnotationsMap();
- UonParser x = UonParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- check("true", x.getProperty(UON_decoding));
- check(null, x.getProperty(UON_encoding));
- check(null, x.getProperty(UON_paramFormat));
- check("true", x.getProperty(UON_validateEnd));
+ HtmlParser.create().applyAnnotations(m, sr).build().createSession();
}
//-----------------------------------------------------------------------------------------------------------------
// Annotation with no values.
//-----------------------------------------------------------------------------------------------------------------
- @UonConfig()
+ @HtmlConfig()
static class B {}
static ClassInfo b = ClassInfo.of(B.class);
@Test
- public void noValuesSerializer() throws Exception {
+ public void defaultsSerializer() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- UonSerializer x = UonSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
+ HtmlSerializerSession x = HtmlSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isAddBeanTypes());
+ check("false", x.isAddKeyValueTableHeaders());
+ check("true", x.isDetectLabelParameters());
+ check("true", x.isDetectLinksInStrings());
+ check("label", x.getLabelParameter());
+ check("TO_STRING", x.getUriAnchorText());
}
@Test
- public void noValuesParser() throws Exception {
+ public void defaultsParser() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- UonParser x = UonParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
+ HtmlParser.create().applyAnnotations(m, sr).build().createSession();
}
//-----------------------------------------------------------------------------------------------------------------
@@ -119,14 +117,18 @@ public class UonConfigTest {
@Test
public void noAnnotationSerializer() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- UonSerializer x = UonSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
+ HtmlSerializerSession x = HtmlSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isAddBeanTypes());
+ check("false", x.isAddKeyValueTableHeaders());
+ check("true", x.isDetectLabelParameters());
+ check("true", x.isDetectLinksInStrings());
+ check("label", x.getLabelParameter());
+ check("TO_STRING", x.getUriAnchorText());
}
@Test
public void noAnnotationParser() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- UonParser x = UonParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
+ HtmlParser.create().applyAnnotations(m, sr).build().createSession();
}
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/annotation/HtmlDocConfigTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlDocConfigAnnotationTest.java
similarity index 61%
rename from juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/annotation/HtmlDocConfigTest.java
rename to juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlDocConfigAnnotationTest.java
index 8942a0c..fc31a65 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/annotation/HtmlDocConfigTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlDocConfigAnnotationTest.java
@@ -10,16 +10,16 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.html.annotation;
+package org.apache.juneau.html;
import static org.junit.Assert.*;
-import static org.apache.juneau.html.HtmlDocSerializer.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
-import org.apache.juneau.html.*;
+import org.apache.juneau.html.annotation.*;
+import org.apache.juneau.internal.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.utils.*;
import org.junit.*;
@@ -27,28 +27,24 @@ import org.junit.*;
/**
* Tests the @HtmlDocConfig annotation.
*/
-public class HtmlDocConfigTest {
+public class HtmlDocConfigAnnotationTest {
private static void check(String expected, Object o) {
- if (o instanceof List) {
- List<?> l = (List<?>)o;
- String actual = l
- .stream()
- .map(TO_STRING)
- .collect(Collectors.joining(","));
- assertEquals(expected, actual);
- } else {
- assertEquals(expected, TO_STRING.apply(o));
- }
+ assertEquals(expected, TO_STRING.apply(o));
}
private static final Function<Object,String> TO_STRING = new Function<Object,String>() {
@Override
public String apply(Object t) {
- if (t == null)
- return null;
- if (t instanceof Class)
- return ((Class<?>)t).getSimpleName();
+ if (t.getClass().isArray())
+ return apply(ArrayUtils.toList(t, Object.class));
+ if (t instanceof Collection)
+ return ((Collection<?>)t)
+ .stream()
+ .map(TO_STRING)
+ .collect(Collectors.joining(","));
+ if (t instanceof HtmlDocTemplate)
+ return ((HtmlDocTemplate)t).getClass().getSimpleName();
return t.toString();
}
};
@@ -90,23 +86,19 @@ public class HtmlDocConfigTest {
@Test
public void basic() throws Exception {
AnnotationsMap m = a.getAnnotationsMap();
- HtmlDocSerializer x = HtmlDocSerializer.create().applyAnnotations(m, sr).build();
- check("foo", x.getProperty(HTMLDOC_aside));
- check("foo", x.getProperty(HTMLDOC_footer));
- check("foo", x.getProperty(HTMLDOC_head));
- check("foo", x.getProperty(HTMLDOC_header));
- check("foo", x.getProperty(HTMLDOC_nav));
- check("foo2", x.getProperty(HTMLDOC_navlinks));
- check(null, x.getProperty(HTMLDOC_navlinks_add));
- check("foo", x.getProperty(HTMLDOC_noResultsMessage));
- check("true", x.getProperty(HTMLDOC_nowrap));
- check("foo2", x.getProperty(HTMLDOC_script));
- check(null, x.getProperty(HTMLDOC_script_add));
- check("foo2", x.getProperty(HTMLDOC_style));
- check(null, x.getProperty(HTMLDOC_style_add));
- check("foo2", x.getProperty(HTMLDOC_stylesheet));
- check(null, x.getProperty(HTMLDOC_stylesheet_add));
- check("BasicHtmlDocTemplate", x.getProperty(HTMLDOC_template));
+ HtmlDocSerializerSession x = HtmlDocSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("foo", x.getAside());
+ check("foo", x.getFooter());
+ check("foo", x.getHead());
+ check("foo", x.getHeader());
+ check("foo", x.getNav());
+ check("foo2", x.getNavlinks());
+ check("foo", x.getNoResultsMessage());
+ check("true", x.isNowrap());
+ check("foo2", x.getScript());
+ check("foo2", x.getStyle());
+ check("foo2", x.getStylesheet());
+ check("BasicHtmlDocTemplate", x.getTemplate());
}
//-----------------------------------------------------------------------------------------------------------------
@@ -120,23 +112,19 @@ public class HtmlDocConfigTest {
@Test
public void defaults() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- HtmlDocSerializer x = HtmlDocSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(HTMLDOC_aside));
- check(null, x.getProperty(HTMLDOC_footer));
- check(null, x.getProperty(HTMLDOC_head));
- check(null, x.getProperty(HTMLDOC_header));
- check(null, x.getProperty(HTMLDOC_nav));
- check(null, x.getProperty(HTMLDOC_navlinks));
- check(null, x.getProperty(HTMLDOC_navlinks_add));
- check(null, x.getProperty(HTMLDOC_noResultsMessage));
- check(null, x.getProperty(HTMLDOC_nowrap));
- check(null, x.getProperty(HTMLDOC_script));
- check(null, x.getProperty(HTMLDOC_script_add));
- check(null, x.getProperty(HTMLDOC_style));
- check(null, x.getProperty(HTMLDOC_style_add));
- check(null, x.getProperty(HTMLDOC_stylesheet));
- check(null, x.getProperty(HTMLDOC_stylesheet_add));
- check(null, x.getProperty(HTMLDOC_template));
+ HtmlDocSerializerSession x = HtmlDocSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("", x.getAside());
+ check("", x.getFooter());
+ check("", x.getHead());
+ check("", x.getHeader());
+ check("", x.getNav());
+ check("", x.getNavlinks());
+ check("<p>no results</p>", x.getNoResultsMessage());
+ check("false", x.isNowrap());
+ check("", x.getScript());
+ check("", x.getStyle());
+ check("", x.getStylesheet());
+ check("BasicHtmlDocTemplate", x.getTemplate());
}
//-----------------------------------------------------------------------------------------------------------------
@@ -149,7 +137,18 @@ public class HtmlDocConfigTest {
@Test
public void noAnnotation() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- HtmlDocSerializer x = HtmlDocSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(HTMLDOC_aside));
+ HtmlDocSerializerSession x = HtmlDocSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("", x.getAside());
+ check("", x.getFooter());
+ check("", x.getHead());
+ check("", x.getHeader());
+ check("", x.getNav());
+ check("", x.getNavlinks());
+ check("<p>no results</p>", x.getNoResultsMessage());
+ check("false", x.isNowrap());
+ check("", x.getScript());
+ check("", x.getStyle());
+ check("", x.getStylesheet());
+ check("BasicHtmlDocTemplate", x.getTemplate());
}
}
\ No newline at end of file
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/annotation/HtmlConfigTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/annotation/HtmlConfigTest.java
deleted file mode 100644
index b8ba548..0000000
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/annotation/HtmlConfigTest.java
+++ /dev/null
@@ -1,143 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.html.annotation;
-
-import static org.junit.Assert.*;
-import static org.apache.juneau.html.HtmlSerializer.*;
-
-import java.util.function.*;
-
-import org.apache.juneau.html.*;
-import org.apache.juneau.reflect.*;
-import org.apache.juneau.utils.*;
-import org.junit.*;
-
-/**
- * Tests the @HtmlConfig annotation.
- */
-public class HtmlConfigTest {
-
- private static void check(String expected, Object o) {
- assertEquals(expected, TO_STRING.apply(o));
- }
-
- private static final Function<Object,String> TO_STRING = new Function<Object,String>() {
- @Override
- public String apply(Object t) {
- if (t == null)
- return null;
- return t.toString();
- }
- };
-
- static StringResolver sr = new StringResolver() {
- @Override
- public String resolve(String input) {
- if (input.startsWith("$"))
- input = input.substring(1);
- return input;
- }
- };
-
- //-----------------------------------------------------------------------------------------------------------------
- // Basic tests
- //-----------------------------------------------------------------------------------------------------------------
-
- @HtmlConfig(
- addBeanTypes="$true",
- addKeyValueTableHeaders="$true",
- detectLabelParameters="$true",
- detectLinksInStrings="$true",
- labelParameter="$foo",
- uriAnchorText="$TO_STRING"
- )
- static class A {}
- static ClassInfo a = ClassInfo.of(A.class);
-
- @Test
- public void basicSerializer() throws Exception {
- AnnotationsMap m = a.getAnnotationsMap();
- HtmlSerializer x = HtmlSerializer.create().applyAnnotations(m, sr).build();
- check("true", x.getProperty(SERIALIZER_addBeanTypes));
- check("true", x.getProperty(HTML_addKeyValueTableHeaders));
- check("true", x.getProperty(HTML_detectLabelParameters));
- check("true", x.getProperty(HTML_detectLinksInStrings));
- check("foo", x.getProperty(HTML_labelParameter));
- check("TO_STRING", x.getProperty(HTML_uriAnchorText));
- }
-
- @Test
- public void basicParser() throws Exception {
- AnnotationsMap m = a.getAnnotationsMap();
- HtmlParser x = HtmlParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- check(null, x.getProperty(HTML_addKeyValueTableHeaders));
- check(null, x.getProperty(HTML_detectLabelParameters));
- check(null, x.getProperty(HTML_detectLinksInStrings));
- check(null, x.getProperty(HTML_labelParameter));
- check(null, x.getProperty(HTML_uriAnchorText));
- }
-
- //-----------------------------------------------------------------------------------------------------------------
- // Annotation with no values.
- //-----------------------------------------------------------------------------------------------------------------
-
- @HtmlConfig()
- static class B {}
- static ClassInfo b = ClassInfo.of(B.class);
-
- @Test
- public void defaultsSerializer() throws Exception {
- AnnotationsMap m = b.getAnnotationsMap();
- HtmlSerializer x = HtmlSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- check(null, x.getProperty(HTML_addKeyValueTableHeaders));
- check(null, x.getProperty(HTML_detectLabelParameters));
- check(null, x.getProperty(HTML_detectLinksInStrings));
- check(null, x.getProperty(HTML_labelParameter));
- check(null, x.getProperty(HTML_uriAnchorText));
- }
-
- @Test
- public void defaultsParser() throws Exception {
- AnnotationsMap m = b.getAnnotationsMap();
- HtmlParser x = HtmlParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- check(null, x.getProperty(HTML_addKeyValueTableHeaders));
- check(null, x.getProperty(HTML_detectLabelParameters));
- check(null, x.getProperty(HTML_detectLinksInStrings));
- check(null, x.getProperty(HTML_labelParameter));
- check(null, x.getProperty(HTML_uriAnchorText));
- }
-
- //-----------------------------------------------------------------------------------------------------------------
- // No annotation.
- //-----------------------------------------------------------------------------------------------------------------
-
- static class C {}
- static ClassInfo c = ClassInfo.of(C.class);
-
- @Test
- public void noAnnotationSerializer() throws Exception {
- AnnotationsMap m = c.getAnnotationsMap();
- HtmlSerializer x = HtmlSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- }
-
- @Test
- public void noAnnotationParser() throws Exception {
- AnnotationsMap m = c.getAnnotationsMap();
- HtmlParser x = HtmlParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- }
-}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jena/RdfConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jena/RdfConfigAnnotationTest.java
new file mode 100644
index 0000000..77c4a10
--- /dev/null
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jena/RdfConfigAnnotationTest.java
@@ -0,0 +1,352 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.jena;
+
+import static org.junit.Assert.*;
+import static org.apache.juneau.jena.RdfSerializer.*;
+
+import java.util.*;
+import java.util.function.*;
+import java.util.stream.*;
+
+import org.apache.juneau.internal.*;
+import org.apache.juneau.jena.annotation.*;
+import org.apache.juneau.marshall.*;
+import org.apache.juneau.reflect.*;
+import org.apache.juneau.utils.*;
+import org.junit.*;
+
+/**
+ * Tests the @RdfConfig annotation.
+ */
+public class RdfConfigAnnotationTest {
+
+ private static void check(String expected, Object o) {
+ assertEquals(expected, TO_STRING.apply(o));
+ }
+
+ private static final Function<Object,String> TO_STRING = new Function<Object,String>() {
+ @Override
+ public String apply(Object t) {
+ if (t == null)
+ return null;
+ if (t instanceof List)
+ return ((List<?>)t)
+ .stream()
+ .map(TO_STRING)
+ .collect(Collectors.joining(","));
+ if (t.getClass().isArray())
+ return apply(ArrayUtils.toList(t, Object.class));
+ return t.toString();
+ }
+ };
+
+ static StringResolver sr = new StringResolver() {
+ @Override
+ public String resolve(String input) {
+ if (input.startsWith("$"))
+ input = input.substring(1);
+ return input;
+ }
+ };
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // Basic tests
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RdfConfig(
+ addBeanTypes="$true",
+ addLiteralTypes="$true",
+ addRootProperty="$true",
+ arp_embedding="$true",
+ arp_errorMode="$strict",
+ arp_iriRules="$strict",
+ autoDetectNamespaces="$true",
+ collectionFormat="$SEQ",
+ juneauBpNs="$foo:http://foo",
+ juneauNs="$foo:http://foo",
+ language="$N3",
+ looseCollections="$true",
+ n3_abbrevBaseUri="$true",
+ n3_indentProperty="$1",
+ n3_minGap="$1",
+ n3_objectLists="$true",
+ n3_propertyColumn="$1",
+ n3_subjectColumn="$1",
+ n3_useDoubles="$true",
+ n3_usePropertySymbols="$true",
+ n3_useTripleQuotedStrings="$true",
+ n3_widePropertyLen="$1",
+ namespaces="$foo:http://foo",
+ rdfxml_allowBadUris="$true",
+ rdfxml_attributeQuoteChar="$'",
+ rdfxml_blockRules="$foo",
+ rdfxml_longId="$true",
+ rdfxml_relativeUris="$absolute",
+ rdfxml_showDoctypeDeclaration="$true",
+ rdfxml_showXmlDeclaration="$true",
+ rdfxml_tab="$1",
+ rdfxml_xmlBase="$foo",
+ trimWhitespace="$true",
+ useXmlNamespaces="$true"
+ )
+ static class A {}
+ static ClassInfo a = ClassInfo.of(A.class);
+
+ @Test
+ public void basicSerializer() throws Exception {
+ AnnotationsMap m = a.getAnnotationsMap();
+ RdfSerializerSession x = RdfSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("true", x.isAddBeanTypes());
+ check("true", x.isAddLiteralTypes());
+ check("true", x.isAddRootProperty());
+ check("true", x.isAutoDetectNamespaces());
+ check("SEQ", x.getCollectionFormat());
+ check("foo:http://foo", x.getJuneauBpNs());
+ check("foo:http://foo", x.getJuneauNs());
+ check("N3", x.getLanguage());
+ check("true", x.isLooseCollections());
+ check("foo:http://foo", x.getNamespaces());
+ check("true", x.isUseXmlNamespaces());
+
+ Map<String,Object> jp = x.getJenaProperties();
+ SimpleJson.DEFAULT.println(jp);
+ check("true", jp.get(RDF_arp_embedding.substring(15)));
+ check("strict", jp.get(RDF_arp_errorMode.substring(15)));
+ check("strict", jp.get(RDF_arp_iriRules.substring(15)));
+ check("true", jp.get(RDF_n3_abbrevBaseUri.substring(15)));
+ check("1", jp.get(RDF_n3_indentProperty.substring(15)));
+ check("1", jp.get(RDF_n3_minGap.substring(15)));
+ check("true", jp.get(RDF_n3_objectLists.substring(15)));
+ check("1", jp.get(RDF_n3_propertyColumn.substring(15)));
+ check("1", jp.get(RDF_n3_subjectColumn.substring(15)));
+ check("true", jp.get(RDF_n3_useDoubles.substring(15)));
+ check("true", jp.get(RDF_n3_usePropertySymbols.substring(15)));
+ check("true", jp.get(RDF_n3_useTripleQuotedStrings.substring(15)));
+ check("1", jp.get(RDF_n3_widePropertyLen.substring(15)));
+ check("true", jp.get(RDF_rdfxml_allowBadUris.substring(15)));
+ check("'", jp.get(RDF_rdfxml_attributeQuoteChar.substring(15)));
+ check("foo", jp.get(RDF_rdfxml_blockRules.substring(15)));
+ check("true", jp.get(RDF_rdfxml_longId.substring(15)));
+ check("absolute", jp.get(RDF_rdfxml_relativeUris.substring(15)));
+ check("true", jp.get(RDF_rdfxml_showDoctypeDeclaration.substring(15)));
+ check("true", jp.get(RDF_rdfxml_showXmlDeclaration.substring(15)));
+ check("1", jp.get(RDF_rdfxml_tab.substring(15)));
+ check("foo", jp.get(RDF_rdfxml_xmlBase.substring(15)));
+ }
+
+ @Test
+ public void basicParser() throws Exception {
+ AnnotationsMap m = a.getAnnotationsMap();
+ RdfParserSession x = RdfParser.create().applyAnnotations(m, sr).build().createSession();
+ check("SEQ", x.getCollectionFormat());
+ check("foo:http://foo", x.getJuneauBpNs());
+ check("foo:http://foo", x.getJuneauNs());
+ check("N3", x.getLanguage());
+ check("true", x.isLooseCollections());
+ check("true", x.isTrimWhitespace());
+
+ Map<String,Object> jp = x.getJenaProperties();
+ check("true", jp.get(RDF_arp_embedding.substring(15)));
+ check("strict", jp.get(RDF_arp_errorMode.substring(15)));
+ check("strict", jp.get(RDF_arp_iriRules.substring(15)));
+ check("true", jp.get(RDF_n3_abbrevBaseUri.substring(15)));
+ check("1", jp.get(RDF_n3_indentProperty.substring(15)));
+ check("1", jp.get(RDF_n3_minGap.substring(15)));
+ check("true", jp.get(RDF_n3_objectLists.substring(15)));
+ check("1", jp.get(RDF_n3_propertyColumn.substring(15)));
+ check("1", jp.get(RDF_n3_subjectColumn.substring(15)));
+ check("true", jp.get(RDF_n3_useDoubles.substring(15)));
+ check("true", jp.get(RDF_n3_usePropertySymbols.substring(15)));
+ check("true", jp.get(RDF_n3_useTripleQuotedStrings.substring(15)));
+ check("1", jp.get(RDF_n3_widePropertyLen.substring(15)));
+ check("true", jp.get(RDF_rdfxml_allowBadUris.substring(15)));
+ check("'", jp.get(RDF_rdfxml_attributeQuoteChar.substring(15)));
+ check("foo", jp.get(RDF_rdfxml_blockRules.substring(15)));
+ check("true", jp.get(RDF_rdfxml_longId.substring(15)));
+ check("absolute", jp.get(RDF_rdfxml_relativeUris.substring(15)));
+ check("true", jp.get(RDF_rdfxml_showDoctypeDeclaration.substring(15)));
+ check("true", jp.get(RDF_rdfxml_showXmlDeclaration.substring(15)));
+ check("1", jp.get(RDF_rdfxml_tab.substring(15)));
+ check("foo", jp.get(RDF_rdfxml_xmlBase.substring(15)));
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // Annotation with no values.
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @RdfConfig()
+ static class B {}
+ static ClassInfo b = ClassInfo.of(B.class);
+
+ @Test
+ public void noValuesSerializer() throws Exception {
+ AnnotationsMap m = b.getAnnotationsMap();
+ RdfSerializerSession x = RdfSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isAddBeanTypes());
+ check("false", x.isAddLiteralTypes());
+ check("false", x.isAddRootProperty());
+ check("true", x.isAutoDetectNamespaces());
+ check("DEFAULT", x.getCollectionFormat());
+ check("jp:http://www.apache.org/juneaubp/", x.getJuneauBpNs());
+ check("j:http://www.apache.org/juneau/", x.getJuneauNs());
+ check("RDF/XML-ABBREV", x.getLanguage());
+ check("false", x.isLooseCollections());
+ check("", x.getNamespaces());
+ check("true", x.isUseXmlNamespaces());
+
+ Map<String,Object> jp = x.getJenaProperties();
+ check(null, jp.get(RDF_arp_embedding.substring(15)));
+ check(null, jp.get(RDF_arp_errorMode.substring(15)));
+ check(null, jp.get(RDF_arp_iriRules.substring(15)));
+ check(null, jp.get(RDF_n3_abbrevBaseUri.substring(15)));
+ check(null, jp.get(RDF_n3_indentProperty.substring(15)));
+ check(null, jp.get(RDF_n3_minGap.substring(15)));
+ check(null, jp.get(RDF_n3_objectLists.substring(15)));
+ check(null, jp.get(RDF_n3_propertyColumn.substring(15)));
+ check(null, jp.get(RDF_n3_subjectColumn.substring(15)));
+ check(null, jp.get(RDF_n3_useDoubles.substring(15)));
+ check(null, jp.get(RDF_n3_usePropertySymbols.substring(15)));
+ check(null, jp.get(RDF_n3_useTripleQuotedStrings.substring(15)));
+ check(null, jp.get(RDF_n3_widePropertyLen.substring(15)));
+ check(null, jp.get(RDF_rdfxml_allowBadUris.substring(15)));
+ check(null, jp.get(RDF_rdfxml_attributeQuoteChar.substring(15)));
+ check(null, jp.get(RDF_rdfxml_blockRules.substring(15)));
+ check(null, jp.get(RDF_rdfxml_longId.substring(15)));
+ check(null, jp.get(RDF_rdfxml_relativeUris.substring(15)));
+ check(null, jp.get(RDF_rdfxml_showDoctypeDeclaration.substring(15)));
+ check(null, jp.get(RDF_rdfxml_showXmlDeclaration.substring(15)));
+ check(null, jp.get(RDF_rdfxml_tab.substring(15)));
+ check(null, jp.get(RDF_rdfxml_xmlBase.substring(15)));
+ }
+
+ @Test
+ public void noValuesParser() throws Exception {
+ AnnotationsMap m = b.getAnnotationsMap();
+ RdfParserSession x = RdfParser.create().applyAnnotations(m, sr).build().createSession();
+ check("DEFAULT", x.getCollectionFormat());
+ check("jp:http://www.apache.org/juneaubp/", x.getJuneauBpNs());
+ check("j:http://www.apache.org/juneau/", x.getJuneauNs());
+ check("RDF/XML-ABBREV", x.getLanguage());
+ check("false", x.isLooseCollections());
+ check("false", x.isTrimWhitespace());
+
+ Map<String,Object> jp = x.getJenaProperties();
+ check(null, jp.get(RDF_arp_embedding.substring(15)));
+ check(null, jp.get(RDF_arp_errorMode.substring(15)));
+ check(null, jp.get(RDF_arp_iriRules.substring(15)));
+ check(null, jp.get(RDF_n3_abbrevBaseUri.substring(15)));
+ check(null, jp.get(RDF_n3_indentProperty.substring(15)));
+ check(null, jp.get(RDF_n3_minGap.substring(15)));
+ check(null, jp.get(RDF_n3_objectLists.substring(15)));
+ check(null, jp.get(RDF_n3_propertyColumn.substring(15)));
+ check(null, jp.get(RDF_n3_subjectColumn.substring(15)));
+ check(null, jp.get(RDF_n3_useDoubles.substring(15)));
+ check(null, jp.get(RDF_n3_usePropertySymbols.substring(15)));
+ check(null, jp.get(RDF_n3_useTripleQuotedStrings.substring(15)));
+ check(null, jp.get(RDF_n3_widePropertyLen.substring(15)));
+ check(null, jp.get(RDF_rdfxml_allowBadUris.substring(15)));
+ check(null, jp.get(RDF_rdfxml_attributeQuoteChar.substring(15)));
+ check(null, jp.get(RDF_rdfxml_blockRules.substring(15)));
+ check(null, jp.get(RDF_rdfxml_longId.substring(15)));
+ check(null, jp.get(RDF_rdfxml_relativeUris.substring(15)));
+ check(null, jp.get(RDF_rdfxml_showDoctypeDeclaration.substring(15)));
+ check(null, jp.get(RDF_rdfxml_showXmlDeclaration.substring(15)));
+ check(null, jp.get(RDF_rdfxml_tab.substring(15)));
+ check(null, jp.get(RDF_rdfxml_xmlBase.substring(15)));
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // No annotation.
+ //-----------------------------------------------------------------------------------------------------------------
+
+ static class C {}
+ static ClassInfo c = ClassInfo.of(C.class);
+
+ @Test
+ public void noAnnotationSerializer() throws Exception {
+ AnnotationsMap m = c.getAnnotationsMap();
+ RdfSerializerSession x = RdfSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isAddBeanTypes());
+ check("false", x.isAddLiteralTypes());
+ check("false", x.isAddRootProperty());
+ check("true", x.isAutoDetectNamespaces());
+ check("DEFAULT", x.getCollectionFormat());
+ check("jp:http://www.apache.org/juneaubp/", x.getJuneauBpNs());
+ check("j:http://www.apache.org/juneau/", x.getJuneauNs());
+ check("RDF/XML-ABBREV", x.getLanguage());
+ check("false", x.isLooseCollections());
+ check("", x.getNamespaces());
+ check("true", x.isUseXmlNamespaces());
+
+ Map<String,Object> jp = x.getJenaProperties();
+ check(null, jp.get(RDF_arp_embedding.substring(15)));
+ check(null, jp.get(RDF_arp_errorMode.substring(15)));
+ check(null, jp.get(RDF_arp_iriRules.substring(15)));
+ check(null, jp.get(RDF_n3_abbrevBaseUri.substring(15)));
+ check(null, jp.get(RDF_n3_indentProperty.substring(15)));
+ check(null, jp.get(RDF_n3_minGap.substring(15)));
+ check(null, jp.get(RDF_n3_objectLists.substring(15)));
+ check(null, jp.get(RDF_n3_propertyColumn.substring(15)));
+ check(null, jp.get(RDF_n3_subjectColumn.substring(15)));
+ check(null, jp.get(RDF_n3_useDoubles.substring(15)));
+ check(null, jp.get(RDF_n3_usePropertySymbols.substring(15)));
+ check(null, jp.get(RDF_n3_useTripleQuotedStrings.substring(15)));
+ check(null, jp.get(RDF_n3_widePropertyLen.substring(15)));
+ check(null, jp.get(RDF_rdfxml_allowBadUris.substring(15)));
+ check(null, jp.get(RDF_rdfxml_attributeQuoteChar.substring(15)));
+ check(null, jp.get(RDF_rdfxml_blockRules.substring(15)));
+ check(null, jp.get(RDF_rdfxml_longId.substring(15)));
+ check(null, jp.get(RDF_rdfxml_relativeUris.substring(15)));
+ check(null, jp.get(RDF_rdfxml_showDoctypeDeclaration.substring(15)));
+ check(null, jp.get(RDF_rdfxml_showXmlDeclaration.substring(15)));
+ check(null, jp.get(RDF_rdfxml_tab.substring(15)));
+ check(null, jp.get(RDF_rdfxml_xmlBase.substring(15)));
+ }
+
+ @Test
+ public void noAnnotationParser() throws Exception {
+ AnnotationsMap m = c.getAnnotationsMap();
+ RdfParserSession x = RdfParser.create().applyAnnotations(m, sr).build().createSession();
+ check("DEFAULT", x.getCollectionFormat());
+ check("jp:http://www.apache.org/juneaubp/", x.getJuneauBpNs());
+ check("j:http://www.apache.org/juneau/", x.getJuneauNs());
+ check("RDF/XML-ABBREV", x.getLanguage());
+ check("false", x.isLooseCollections());
+ check("false", x.isTrimWhitespace());
+
+ Map<String,Object> jp = x.getJenaProperties();
+ check(null, jp.get(RDF_arp_embedding.substring(15)));
+ check(null, jp.get(RDF_arp_errorMode.substring(15)));
+ check(null, jp.get(RDF_arp_iriRules.substring(15)));
+ check(null, jp.get(RDF_n3_abbrevBaseUri.substring(15)));
+ check(null, jp.get(RDF_n3_indentProperty.substring(15)));
+ check(null, jp.get(RDF_n3_minGap.substring(15)));
+ check(null, jp.get(RDF_n3_objectLists.substring(15)));
+ check(null, jp.get(RDF_n3_propertyColumn.substring(15)));
+ check(null, jp.get(RDF_n3_subjectColumn.substring(15)));
+ check(null, jp.get(RDF_n3_useDoubles.substring(15)));
+ check(null, jp.get(RDF_n3_usePropertySymbols.substring(15)));
+ check(null, jp.get(RDF_n3_useTripleQuotedStrings.substring(15)));
+ check(null, jp.get(RDF_n3_widePropertyLen.substring(15)));
+ check(null, jp.get(RDF_rdfxml_allowBadUris.substring(15)));
+ check(null, jp.get(RDF_rdfxml_attributeQuoteChar.substring(15)));
+ check(null, jp.get(RDF_rdfxml_blockRules.substring(15)));
+ check(null, jp.get(RDF_rdfxml_longId.substring(15)));
+ check(null, jp.get(RDF_rdfxml_relativeUris.substring(15)));
+ check(null, jp.get(RDF_rdfxml_showDoctypeDeclaration.substring(15)));
+ check(null, jp.get(RDF_rdfxml_showXmlDeclaration.substring(15)));
+ check(null, jp.get(RDF_rdfxml_tab.substring(15)));
+ check(null, jp.get(RDF_rdfxml_xmlBase.substring(15)));
+ }
+}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jena/annotation/RdfConfigTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jena/annotation/RdfConfigTest.java
deleted file mode 100644
index aa5cab7..0000000
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jena/annotation/RdfConfigTest.java
+++ /dev/null
@@ -1,296 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.jena.annotation;
-
-import static org.junit.Assert.*;
-import static org.apache.juneau.serializer.Serializer.*;
-import static org.apache.juneau.jena.RdfSerializer.*;
-import static org.apache.juneau.jena.RdfParser.*;
-
-import java.util.*;
-import java.util.function.*;
-import java.util.stream.*;
-
-import org.apache.juneau.jena.*;
-import org.apache.juneau.reflect.*;
-import org.apache.juneau.utils.*;
-import org.junit.*;
-
-/**
- * Tests the @RdfConfig annotation.
- */
-public class RdfConfigTest {
-
- private static void check(String expected, Object o) {
- if (o instanceof List) {
- List<?> l = (List<?>)o;
- String actual = l
- .stream()
- .map(TO_STRING)
- .collect(Collectors.joining(","));
- assertEquals(expected, actual);
- } else {
- assertEquals(expected, TO_STRING.apply(o));
- }
- }
-
- private static final Function<Object,String> TO_STRING = new Function<Object,String>() {
- @Override
- public String apply(Object t) {
- if (t == null)
- return null;
- return t.toString();
- }
- };
-
- static StringResolver sr = new StringResolver() {
- @Override
- public String resolve(String input) {
- if (input.startsWith("$"))
- input = input.substring(1);
- return input;
- }
- };
-
- //-----------------------------------------------------------------------------------------------------------------
- // Basic tests
- //-----------------------------------------------------------------------------------------------------------------
-
- @RdfConfig(
- addBeanTypes="$true",
- addLiteralTypes="$true",
- addRootProperty="$true",
- arp_embedding="$true",
- arp_errorMode="$strict",
- arp_iriRules="$strict",
- autoDetectNamespaces="$true",
- collectionFormat="$SEQ",
- juneauBpNs="$foo",
- juneauNs="$foo",
- language="$N3",
- looseCollections="$true",
- n3_abbrevBaseUri="$true",
- n3_indentProperty="$1",
- n3_minGap="$1",
- n3_objectLists="$true",
- n3_propertyColumn="$1",
- n3_subjectColumn="$1",
- n3_useDoubles="$true",
- n3_usePropertySymbols="$true",
- n3_useTripleQuotedStrings="$true",
- n3_widePropertyLen="$1",
- namespaces="$foo",
- rdfxml_allowBadUris="$true",
- rdfxml_attributeQuoteChar="$'",
- rdfxml_blockRules="$foo",
- rdfxml_longId="$true",
- rdfxml_relativeUris="$absolute",
- rdfxml_showDoctypeDeclaration="$true",
- rdfxml_showXmlDeclaration="$true",
- rdfxml_tab="$1",
- rdfxml_xmlBase="$foo",
- trimWhitespace="$true",
- useXmlNamespaces="$true"
- )
- static class A {}
- static ClassInfo a = ClassInfo.of(A.class);
-
- @Test
- public void basicSerializer() throws Exception {
- AnnotationsMap m = a.getAnnotationsMap();
- RdfSerializer x = RdfSerializer.create().applyAnnotations(m, sr).build();
- check("true", x.getProperty(SERIALIZER_addBeanTypes));
- check("true", x.getProperty(RDF_addLiteralTypes));
- check("true", x.getProperty(RDF_addRootProperty));
- check("true", x.getProperty(RDF_arp_embedding));
- check("strict", x.getProperty(RDF_arp_errorMode));
- check("strict", x.getProperty(RDF_arp_iriRules));
- check("true", x.getProperty(RDF_autoDetectNamespaces));
- check("SEQ", x.getProperty(RDF_collectionFormat));
- check("foo", x.getProperty(RDF_juneauBpNs));
- check("foo", x.getProperty(RDF_juneauNs));
- check("N3", x.getProperty(RDF_language));
- check("true", x.getProperty(RDF_looseCollections));
- check("true", x.getProperty(RDF_n3_abbrevBaseUri));
- check("1", x.getProperty(RDF_n3_indentProperty));
- check("1", x.getProperty(RDF_n3_minGap));
- check("true", x.getProperty(RDF_n3_objectLists));
- check("1", x.getProperty(RDF_n3_propertyColumn));
- check("1", x.getProperty(RDF_n3_subjectColumn));
- check("true", x.getProperty(RDF_n3_useDoubles));
- check("true", x.getProperty(RDF_n3_usePropertySymbols));
- check("true", x.getProperty(RDF_n3_useTripleQuotedStrings));
- check("1", x.getProperty(RDF_n3_widePropertyLen));
- check("foo", x.getProperty(RDF_namespaces));
- check("true", x.getProperty(RDF_rdfxml_allowBadUris));
- check("'", x.getProperty(RDF_rdfxml_attributeQuoteChar));
- check("foo", x.getProperty(RDF_rdfxml_blockRules));
- check("true", x.getProperty(RDF_rdfxml_longId));
- check("absolute", x.getProperty(RDF_rdfxml_relativeUris));
- check("true", x.getProperty(RDF_rdfxml_showDoctypeDeclaration));
- check("true", x.getProperty(RDF_rdfxml_showXmlDeclaration));
- check("1", x.getProperty(RDF_rdfxml_tab));
- check("foo", x.getProperty(RDF_rdfxml_xmlBase));
- check(null, x.getProperty(RDF_trimWhitespace));
- check("true", x.getProperty(RDF_useXmlNamespaces));
- }
-
- @Test
- public void basicParser() throws Exception {
- AnnotationsMap m = a.getAnnotationsMap();
- RdfParser x = RdfParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- check(null, x.getProperty(RDF_addLiteralTypes));
- check(null, x.getProperty(RDF_addRootProperty));
- check("true", x.getProperty(RDF_arp_embedding));
- check("strict", x.getProperty(RDF_arp_errorMode));
- check("strict", x.getProperty(RDF_arp_iriRules));
- check(null, x.getProperty(RDF_autoDetectNamespaces));
- check("SEQ", x.getProperty(RDF_collectionFormat));
- check("foo", x.getProperty(RDF_juneauBpNs));
- check("foo", x.getProperty(RDF_juneauNs));
- check("N3", x.getProperty(RDF_language));
- check("true", x.getProperty(RDF_looseCollections));
- check("true", x.getProperty(RDF_n3_abbrevBaseUri));
- check("1", x.getProperty(RDF_n3_indentProperty));
- check("1", x.getProperty(RDF_n3_minGap));
- check("true", x.getProperty(RDF_n3_objectLists));
- check("1", x.getProperty(RDF_n3_propertyColumn));
- check("1", x.getProperty(RDF_n3_subjectColumn));
- check("true", x.getProperty(RDF_n3_useDoubles));
- check("true", x.getProperty(RDF_n3_usePropertySymbols));
- check("true", x.getProperty(RDF_n3_useTripleQuotedStrings));
- check("1", x.getProperty(RDF_n3_widePropertyLen));
- check(null, x.getProperty(RDF_namespaces));
- check("true", x.getProperty(RDF_rdfxml_allowBadUris));
- check("'", x.getProperty(RDF_rdfxml_attributeQuoteChar));
- check("foo", x.getProperty(RDF_rdfxml_blockRules));
- check("true", x.getProperty(RDF_rdfxml_longId));
- check("absolute", x.getProperty(RDF_rdfxml_relativeUris));
- check("true", x.getProperty(RDF_rdfxml_showDoctypeDeclaration));
- check("true", x.getProperty(RDF_rdfxml_showXmlDeclaration));
- check("1", x.getProperty(RDF_rdfxml_tab));
- check("foo", x.getProperty(RDF_rdfxml_xmlBase));
- check("true", x.getProperty(RDF_trimWhitespace));
- check("true", x.getProperty(RDF_useXmlNamespaces));
- }
-
- //-----------------------------------------------------------------------------------------------------------------
- // Annotation with no values.
- //-----------------------------------------------------------------------------------------------------------------
-
- @RdfConfig()
- static class B {}
- static ClassInfo b = ClassInfo.of(B.class);
-
- @Test
- public void noValuesSerializer() throws Exception {
- AnnotationsMap m = b.getAnnotationsMap();
- RdfSerializer x = RdfSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- check(null, x.getProperty(RDF_addLiteralTypes));
- check(null, x.getProperty(RDF_addRootProperty));
- check(null, x.getProperty(RDF_arp_embedding));
- check(null, x.getProperty(RDF_arp_errorMode));
- check(null, x.getProperty(RDF_arp_iriRules));
- check(null, x.getProperty(RDF_autoDetectNamespaces));
- check(null, x.getProperty(RDF_collectionFormat));
- check(null, x.getProperty(RDF_juneauBpNs));
- check(null, x.getProperty(RDF_juneauNs));
- check(null, x.getProperty(RDF_language));
- check(null, x.getProperty(RDF_looseCollections));
- check(null, x.getProperty(RDF_n3_abbrevBaseUri));
- check(null, x.getProperty(RDF_n3_indentProperty));
- check(null, x.getProperty(RDF_n3_minGap));
- check(null, x.getProperty(RDF_n3_objectLists));
- check(null, x.getProperty(RDF_n3_propertyColumn));
- check(null, x.getProperty(RDF_n3_subjectColumn));
- check(null, x.getProperty(RDF_n3_useDoubles));
- check(null, x.getProperty(RDF_n3_usePropertySymbols));
- check(null, x.getProperty(RDF_n3_useTripleQuotedStrings));
- check(null, x.getProperty(RDF_n3_widePropertyLen));
- check(null, x.getProperty(RDF_namespaces));
- check(null, x.getProperty(RDF_rdfxml_allowBadUris));
- check(null, x.getProperty(RDF_rdfxml_attributeQuoteChar));
- check(null, x.getProperty(RDF_rdfxml_blockRules));
- check(null, x.getProperty(RDF_rdfxml_longId));
- check(null, x.getProperty(RDF_rdfxml_relativeUris));
- check(null, x.getProperty(RDF_rdfxml_showDoctypeDeclaration));
- check(null, x.getProperty(RDF_rdfxml_showXmlDeclaration));
- check(null, x.getProperty(RDF_rdfxml_tab));
- check(null, x.getProperty(RDF_rdfxml_xmlBase));
- check(null, x.getProperty(RDF_trimWhitespace));
- check(null, x.getProperty(RDF_useXmlNamespaces));
- }
-
- @Test
- public void noValuesParser() throws Exception {
- AnnotationsMap m = b.getAnnotationsMap();
- RdfParser x = RdfParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- check(null, x.getProperty(RDF_addLiteralTypes));
- check(null, x.getProperty(RDF_addRootProperty));
- check(null, x.getProperty(RDF_arp_embedding));
- check(null, x.getProperty(RDF_arp_errorMode));
- check(null, x.getProperty(RDF_arp_iriRules));
- check(null, x.getProperty(RDF_autoDetectNamespaces));
- check(null, x.getProperty(RDF_collectionFormat));
- check(null, x.getProperty(RDF_juneauBpNs));
- check(null, x.getProperty(RDF_juneauNs));
- check(null, x.getProperty(RDF_language));
- check(null, x.getProperty(RDF_looseCollections));
- check(null, x.getProperty(RDF_n3_abbrevBaseUri));
- check(null, x.getProperty(RDF_n3_indentProperty));
- check(null, x.getProperty(RDF_n3_minGap));
- check(null, x.getProperty(RDF_n3_objectLists));
- check(null, x.getProperty(RDF_n3_propertyColumn));
- check(null, x.getProperty(RDF_n3_subjectColumn));
- check(null, x.getProperty(RDF_n3_useDoubles));
- check(null, x.getProperty(RDF_n3_usePropertySymbols));
- check(null, x.getProperty(RDF_n3_useTripleQuotedStrings));
- check(null, x.getProperty(RDF_n3_widePropertyLen));
- check(null, x.getProperty(RDF_namespaces));
- check(null, x.getProperty(RDF_rdfxml_allowBadUris));
- check(null, x.getProperty(RDF_rdfxml_attributeQuoteChar));
- check(null, x.getProperty(RDF_rdfxml_blockRules));
- check(null, x.getProperty(RDF_rdfxml_longId));
- check(null, x.getProperty(RDF_rdfxml_relativeUris));
- check(null, x.getProperty(RDF_rdfxml_showDoctypeDeclaration));
- check(null, x.getProperty(RDF_rdfxml_showXmlDeclaration));
- check(null, x.getProperty(RDF_rdfxml_tab));
- check(null, x.getProperty(RDF_rdfxml_xmlBase));
- check(null, x.getProperty(RDF_trimWhitespace));
- check(null, x.getProperty(RDF_useXmlNamespaces));
- }
-
- //-----------------------------------------------------------------------------------------------------------------
- // No annotation.
- //-----------------------------------------------------------------------------------------------------------------
-
- static class C {}
- static ClassInfo c = ClassInfo.of(C.class);
-
- @Test
- public void noAnnotationSerializer() throws Exception {
- AnnotationsMap m = c.getAnnotationsMap();
- RdfSerializer x = RdfSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- }
-
- @Test
- public void noAnnotationParser() throws Exception {
- AnnotationsMap m = c.getAnnotationsMap();
- RdfParser x = RdfParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- }
-}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jso/annotation/JsoConfigTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jso/JsoConfigAnnotationTest.java
similarity index 86%
rename from juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jso/annotation/JsoConfigTest.java
rename to juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jso/JsoConfigAnnotationTest.java
index 9fa16ab..236b4b6 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jso/annotation/JsoConfigTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jso/JsoConfigAnnotationTest.java
@@ -10,16 +10,16 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.jso.annotation;
+package org.apache.juneau.jso;
-import org.apache.juneau.jso.*;
+import org.apache.juneau.jso.annotation.*;
import org.apache.juneau.reflect.*;
import org.junit.*;
/**
* Tests the @JsoConfig annotation.
*/
-public class JsoConfigTest {
+public class JsoConfigAnnotationTest {
//-----------------------------------------------------------------------------------------------------------------
// Annotation with no values.
@@ -32,13 +32,13 @@ public class JsoConfigTest {
@Test
public void defaultsSerializer() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- JsoSerializer.create().applyAnnotations(m, null).build();
+ JsoSerializer.create().applyAnnotations(m, null).build().createSession();
}
@Test
public void defaultsParser() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- JsoParser.create().applyAnnotations(m, null).build();
+ JsoParser.create().applyAnnotations(m, null).build().createSession();
}
//-----------------------------------------------------------------------------------------------------------------
@@ -51,12 +51,12 @@ public class JsoConfigTest {
@Test
public void noAnnotationSerializer() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- JsoSerializer.create().applyAnnotations(m, null).build();
+ JsoSerializer.create().applyAnnotations(m, null).build().createSession();
}
@Test
public void noAnnotationParser() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- JsoParser.create().applyAnnotations(m, null).build();
+ JsoParser.create().applyAnnotations(m, null).build().createSession();
}
}
\ No newline at end of file
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/json/annotation/JsonConfigTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/json/JsonConfigAnnotationTest.java
similarity index 70%
rename from juneau-core/juneau-core-test/src/test/java/org/apache/juneau/json/annotation/JsonConfigTest.java
rename to juneau-core/juneau-core-test/src/test/java/org/apache/juneau/json/JsonConfigAnnotationTest.java
index c7c7ff7..abd0bf4 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/json/annotation/JsonConfigTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/json/JsonConfigAnnotationTest.java
@@ -10,16 +10,13 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.json.annotation;
+package org.apache.juneau.json;
import static org.junit.Assert.*;
-import static org.apache.juneau.serializer.Serializer.*;
-import static org.apache.juneau.json.JsonSerializer.*;
-import static org.apache.juneau.json.JsonParser.*;
import java.util.function.*;
-import org.apache.juneau.json.*;
+import org.apache.juneau.json.annotation.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.utils.*;
import org.junit.*;
@@ -27,7 +24,7 @@ import org.junit.*;
/**
* Tests the @JsonConfig annotation.
*/
-public class JsonConfigTest {
+public class JsonConfigAnnotationTest {
private static void check(String expected, Object o) {
assertEquals(expected, TO_STRING.apply(o));
@@ -36,8 +33,6 @@ public class JsonConfigTest {
private static final Function<Object,String> TO_STRING = new Function<Object,String>() {
@Override
public String apply(Object t) {
- if (t == null)
- return null;
return t.toString();
}
};
@@ -67,21 +62,17 @@ public class JsonConfigTest {
@Test
public void basicSerializer() throws Exception {
AnnotationsMap m = a.getAnnotationsMap();
- JsonSerializer x = JsonSerializer.create().applyAnnotations(m, sr).build();
- check("true", x.getProperty(SERIALIZER_addBeanTypes));
- check("true", x.getProperty(JSON_escapeSolidus));
- check("true", x.getProperty(JSON_simpleMode));
- check(null, x.getProperty(JSON_validateEnd));
+ JsonSerializerSession x = JsonSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("true", x.isAddBeanTypes());
+ check("true", x.isEscapeSolidus());
+ check("true", x.isSimpleMode());
}
@Test
public void basicParser() throws Exception {
AnnotationsMap m = a.getAnnotationsMap();
- JsonParser x = JsonParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- check(null, x.getProperty(JSON_escapeSolidus));
- check(null, x.getProperty(JSON_simpleMode));
- check("true", x.getProperty(JSON_validateEnd));
+ JsonParserSession x = JsonParser.create().applyAnnotations(m, sr).build().createSession();
+ check("true", x.isValidateEnd());
}
//-----------------------------------------------------------------------------------------------------------------
@@ -95,21 +86,17 @@ public class JsonConfigTest {
@Test
public void noValuesSerializer() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- JsonSerializer x = JsonSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- check(null, x.getProperty(JSON_escapeSolidus));
- check(null, x.getProperty(JSON_simpleMode));
- check(null, x.getProperty(JSON_validateEnd));
+ JsonSerializerSession x = JsonSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isAddBeanTypes());
+ check("false", x.isEscapeSolidus());
+ check("false", x.isSimpleMode());
}
@Test
public void noValuesParser() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- JsonParser x = JsonParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- check(null, x.getProperty(JSON_escapeSolidus));
- check(null, x.getProperty(JSON_simpleMode));
- check(null, x.getProperty(JSON_validateEnd));
+ JsonParserSession x = JsonParser.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isValidateEnd());
}
//-----------------------------------------------------------------------------------------------------------------
@@ -122,14 +109,16 @@ public class JsonConfigTest {
@Test
public void noAnnotationSerializer() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- JsonSerializer x = JsonSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(JSON_escapeSolidus));
+ JsonSerializerSession x = JsonSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isAddBeanTypes());
+ check("false", x.isEscapeSolidus());
+ check("false", x.isSimpleMode());
}
@Test
public void noAnnotationParser() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- JsonParser x = JsonParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(JSON_validateEnd));
+ JsonParserSession x = JsonParser.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isValidateEnd());
}
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfigTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jsonschema/JsonSchemaConfigAnnotationTest.java
similarity index 66%
rename from juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfigTest.java
rename to juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jsonschema/JsonSchemaConfigAnnotationTest.java
index 99d75ea..79bf167 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfigTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jsonschema/JsonSchemaConfigAnnotationTest.java
@@ -10,15 +10,16 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.jsonschema.annotation;
+package org.apache.juneau.jsonschema;
import static org.junit.Assert.*;
-import static org.apache.juneau.jsonschema.JsonSchemaGenerator.*;
+import java.util.*;
import java.util.function.*;
+import java.util.stream.*;
import org.apache.juneau.annotation.*;
-import org.apache.juneau.jsonschema.*;
+import org.apache.juneau.jsonschema.annotation.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.utils.*;
import org.junit.*;
@@ -26,7 +27,7 @@ import org.junit.*;
/**
* Tests the @JsonSchemaConfig annotation.
*/
-public class JsonSchemaConfigTest {
+public class JsonSchemaConfigAnnotationTest {
private static void check(String expected, Object o) {
assertEquals(expected, TO_STRING.apply(o));
@@ -35,10 +36,13 @@ public class JsonSchemaConfigTest {
private static final Function<Object,String> TO_STRING = new Function<Object,String>() {
@Override
public String apply(Object t) {
- if (t == null)
- return null;
- if (t instanceof Class)
- return ((Class<?>)t).getSimpleName();
+ if (t instanceof Collection)
+ return ((Collection<?>)t)
+ .stream()
+ .map(TO_STRING)
+ .collect(Collectors.joining(","));
+ if (t instanceof BeanDefMapper)
+ return ((BeanDefMapper)t).getClass().getSimpleName();
return t.toString();
}
};
@@ -62,7 +66,7 @@ public class JsonSchemaConfigTest {
allowNestedDescriptions="$true",
allowNestedExamples="$true",
beanDefMapper=BasicBeanDefMapper.class,
- defaultSchemas=@CSEntry(key=A.class,value="${foo:'bar'}"),
+ defaultSchemas=@CS(k=A.class,v="{foo:'bar'}"),
ignoreTypes="$foo",
useBeanDefs="$true"
)
@@ -72,15 +76,15 @@ public class JsonSchemaConfigTest {
@Test
public void basic() throws Exception {
AnnotationsMap m = a.getAnnotationsMap();
- JsonSchemaGenerator x = JsonSchemaGenerator.create().applyAnnotations(m, sr).build();
- check("BEAN", x.getProperty(JSONSCHEMA_addDescriptionsTo));
- check("BEAN", x.getProperty(JSONSCHEMA_addExamplesTo));
- check("true", x.getProperty(JSONSCHEMA_allowNestedDescriptions));
- check("true", x.getProperty(JSONSCHEMA_allowNestedExamples));
- check("BasicBeanDefMapper", x.getProperty(JSONSCHEMA_beanDefMapper));
- check("{org.apache.juneau.jsonschema.annotation.JsonSchemaConfigTest$A={foo:'bar'}}", x.getProperty(JSONSCHEMA_defaultSchemas));
- check("foo", x.getProperty(JSONSCHEMA_ignoreTypes));
- check("true", x.getProperty(JSONSCHEMA_useBeanDefs));
+ JsonSchemaGeneratorSession x = JsonSchemaGenerator.create().applyAnnotations(m, sr).build().createSession();
+ check("BEAN", x.getAddDescriptionsTo());
+ check("BEAN", x.getAddExamplesTo());
+ check("true", x.isAllowNestedDescriptions());
+ check("true", x.isAllowNestedExamples());
+ check("BasicBeanDefMapper", x.getBeanDefMapper());
+ check("{org.apache.juneau.jsonschema.JsonSchemaConfigAnnotationTest$A={foo:'bar'}}", x.getDefaultSchemas());
+ check("foo", x.getIgnoreTypes());
+ check("true", x.isUseBeanDefs());
}
//-----------------------------------------------------------------------------------------------------------------
@@ -94,15 +98,15 @@ public class JsonSchemaConfigTest {
@Test
public void noValues() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- JsonSchemaGenerator x = JsonSchemaGenerator.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(JSONSCHEMA_addDescriptionsTo));
- check(null, x.getProperty(JSONSCHEMA_addExamplesTo));
- check(null, x.getProperty(JSONSCHEMA_allowNestedDescriptions));
- check(null, x.getProperty(JSONSCHEMA_allowNestedExamples));
- check(null, x.getProperty(JSONSCHEMA_beanDefMapper));
- check(null, x.getProperty(JSONSCHEMA_defaultSchemas));
- check(null, x.getProperty(JSONSCHEMA_ignoreTypes));
- check(null, x.getProperty(JSONSCHEMA_useBeanDefs));
+ JsonSchemaGeneratorSession x = JsonSchemaGenerator.create().applyAnnotations(m, sr).build().createSession();
+ check("", x.getAddDescriptionsTo());
+ check("", x.getAddExamplesTo());
+ check("false", x.isAllowNestedDescriptions());
+ check("false", x.isAllowNestedExamples());
+ check("BasicBeanDefMapper", x.getBeanDefMapper());
+ check("{}", x.getDefaultSchemas());
+ check("", x.getIgnoreTypes());
+ check("false", x.isUseBeanDefs());
}
//-----------------------------------------------------------------------------------------------------------------
@@ -115,7 +119,14 @@ public class JsonSchemaConfigTest {
@Test
public void noAnnotation() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- JsonSchemaGenerator x = JsonSchemaGenerator.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(JSONSCHEMA_addDescriptionsTo));
+ JsonSchemaGeneratorSession x = JsonSchemaGenerator.create().applyAnnotations(m, sr).build().createSession();
+ check("", x.getAddDescriptionsTo());
+ check("", x.getAddExamplesTo());
+ check("false", x.isAllowNestedDescriptions());
+ check("false", x.isAllowNestedExamples());
+ check("BasicBeanDefMapper", x.getBeanDefMapper());
+ check("{}", x.getDefaultSchemas());
+ check("", x.getIgnoreTypes());
+ check("false", x.isUseBeanDefs());
}
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/msgpack/annotation/MsgPackConfigTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/msgpack/MsgPackConfigAnnotationTest.java
similarity index 79%
rename from juneau-core/juneau-core-test/src/test/java/org/apache/juneau/msgpack/annotation/MsgPackConfigTest.java
rename to juneau-core/juneau-core-test/src/test/java/org/apache/juneau/msgpack/MsgPackConfigAnnotationTest.java
index 090d8e0..1ecbed6 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/msgpack/annotation/MsgPackConfigTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/msgpack/MsgPackConfigAnnotationTest.java
@@ -10,14 +10,13 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.msgpack.annotation;
+package org.apache.juneau.msgpack;
import static org.junit.Assert.*;
-import static org.apache.juneau.serializer.Serializer.*;
import java.util.function.*;
-import org.apache.juneau.msgpack.*;
+import org.apache.juneau.msgpack.annotation.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.utils.*;
import org.junit.*;
@@ -25,7 +24,7 @@ import org.junit.*;
/**
* Tests the @MsgPackConfig annotation.
*/
-public class MsgPackConfigTest {
+public class MsgPackConfigAnnotationTest {
private static void check(String expected, Object o) {
assertEquals(expected, TO_STRING.apply(o));
@@ -34,8 +33,6 @@ public class MsgPackConfigTest {
private static final Function<Object,String> TO_STRING = new Function<Object,String>() {
@Override
public String apply(Object t) {
- if (t == null)
- return null;
return t.toString();
}
};
@@ -62,15 +59,14 @@ public class MsgPackConfigTest {
@Test
public void basicSerializer() throws Exception {
AnnotationsMap m = a.getAnnotationsMap();
- MsgPackSerializer x = MsgPackSerializer.create().applyAnnotations(m, sr).build();
- check("true", x.getProperty(SERIALIZER_addBeanTypes));
+ MsgPackSerializerSession x = MsgPackSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("true", x.isAddBeanTypes());
}
@Test
public void basicParser() throws Exception {
AnnotationsMap m = a.getAnnotationsMap();
- MsgPackParser x = MsgPackParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
+ MsgPackParser.create().applyAnnotations(m, sr).build().createSession();
}
//-----------------------------------------------------------------------------------------------------------------
@@ -84,15 +80,14 @@ public class MsgPackConfigTest {
@Test
public void noValuesSerializer() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- MsgPackSerializer x = MsgPackSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
+ MsgPackSerializerSession x = MsgPackSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isAddBeanTypes());
}
@Test
public void noValuesParser() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- MsgPackParser x = MsgPackParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
+ MsgPackParser.create().applyAnnotations(m, sr).build().createSession();
}
//-----------------------------------------------------------------------------------------------------------------
@@ -105,14 +100,13 @@ public class MsgPackConfigTest {
@Test
public void noAnnotationSerializer() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- MsgPackSerializer x = MsgPackSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
+ MsgPackSerializerSession x = MsgPackSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isAddBeanTypes());
}
@Test
public void noAnnotationParser() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- MsgPackParser x = MsgPackParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
+ MsgPackParser.create().applyAnnotations(m, sr).build().createSession();
}
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/oapi/annotation/OpenApiConfigTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/oapi/OpenApiConfigAnnotationTest.java
similarity index 87%
rename from juneau-core/juneau-core-test/src/test/java/org/apache/juneau/oapi/annotation/OpenApiConfigTest.java
rename to juneau-core/juneau-core-test/src/test/java/org/apache/juneau/oapi/OpenApiConfigAnnotationTest.java
index 6e50d08..b64b2b6 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/oapi/annotation/OpenApiConfigTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/oapi/OpenApiConfigAnnotationTest.java
@@ -10,9 +10,9 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.oapi.annotation;
+package org.apache.juneau.oapi;
-import org.apache.juneau.oapi.*;
+import org.apache.juneau.oapi.annotation.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.utils.*;
import org.junit.*;
@@ -20,7 +20,7 @@ import org.junit.*;
/**
* Tests the @OpenApiConfig annotation.
*/
-public class OpenApiConfigTest {
+public class OpenApiConfigAnnotationTest {
static StringResolver sr = new StringResolver() {
@Override
@@ -42,13 +42,13 @@ public class OpenApiConfigTest {
@Test
public void noValuesSerializer() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- OpenApiSerializer.create().applyAnnotations(m, sr).build();
+ OpenApiSerializer.create().applyAnnotations(m, sr).build().createSession();
}
@Test
public void noValuesParser() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- OpenApiParser.create().applyAnnotations(m, sr).build();
+ OpenApiParser.create().applyAnnotations(m, sr).build().createSession();
}
//-----------------------------------------------------------------------------------------------------------------
@@ -61,12 +61,12 @@ public class OpenApiConfigTest {
@Test
public void noAnnotationSerializer() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- OpenApiSerializer.create().applyAnnotations(m, sr).build();
+ OpenApiSerializer.create().applyAnnotations(m, sr).build().createSession();
}
@Test
public void noAnnotationParser() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- OpenApiParser.create().applyAnnotations(m, sr).build();
+ OpenApiParser.create().applyAnnotations(m, sr).build().createSession();
}
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/parser/annotation/ParserConfigTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/parser/ParserConfigAnnotationTest.java
similarity index 59%
rename from juneau-core/juneau-core-test/src/test/java/org/apache/juneau/parser/annotation/ParserConfigTest.java
rename to juneau-core/juneau-core-test/src/test/java/org/apache/juneau/parser/ParserConfigAnnotationTest.java
index 5f33659..6e4d524 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/parser/annotation/ParserConfigTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/parser/ParserConfigAnnotationTest.java
@@ -10,18 +10,15 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.parser.annotation;
+package org.apache.juneau.parser;
import static org.junit.Assert.*;
-import static org.apache.juneau.parser.Parser.*;
-import static org.apache.juneau.parser.InputStreamParser.*;
-import static org.apache.juneau.parser.ReaderParser.*;
import java.util.function.*;
import org.apache.juneau.json.*;
import org.apache.juneau.msgpack.*;
-import org.apache.juneau.parser.*;
+import org.apache.juneau.parser.annotation.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.utils.*;
import org.junit.*;
@@ -29,7 +26,7 @@ import org.junit.*;
/**
* Tests the @ParserConfig annotation.
*/
-public class ParserConfigTest {
+public class ParserConfigAnnotationTest {
private static void check(String expected, Object o) {
assertEquals(expected, TO_STRING.apply(o));
@@ -40,8 +37,8 @@ public class ParserConfigTest {
public String apply(Object t) {
if (t == null)
return null;
- if (t instanceof Class)
- return ((Class<?>)t).getSimpleName();
+ if (t instanceof AA)
+ return "AA";
return t.toString();
}
};
@@ -59,7 +56,7 @@ public class ParserConfigTest {
// Basic tests
//-----------------------------------------------------------------------------------------------------------------
- static class AA extends ParserListener {}
+ public static class AA extends ParserListener {}
@ParserConfig(
autoCloseStreams="$true",
@@ -78,31 +75,28 @@ public class ParserConfigTest {
@Test
public void basicReaderParser() throws Exception {
AnnotationsMap m = a.getAnnotationsMap();
- JsonParser x = JsonParser.create().applyAnnotations(m, sr).build();
- check("true", x.getProperty(PARSER_autoCloseStreams));
- check(null, x.getProperty(ISPARSER_binaryFormat));
- check("1", x.getProperty(PARSER_debugOutputLines));
- check("foo", x.getProperty(RPARSER_fileCharset));
- check("foo", x.getProperty(RPARSER_inputStreamCharset));
- check("AA", x.getProperty(PARSER_listener));
- check("true", x.getProperty(PARSER_strict));
- check("true", x.getProperty(PARSER_trimStrings));
- check("true", x.getProperty(PARSER_unbuffered));
+ JsonParserSession x = JsonParser.create().applyAnnotations(m, sr).build().createSession();
+ check("true", x.isAutoCloseStreams());
+ check("1", x.getDebugOutputLines());
+ check("foo", x.getFileCharset());
+ check("foo", x.getInputStreamCharset());
+ check("AA", x.getListener());
+ check("true", x.isStrict());
+ check("true", x.isTrimStrings());
+ check("true", x.isUnbuffered());
}
@Test
public void basicInputStreamParser() throws Exception {
AnnotationsMap m = a.getAnnotationsMap();
- MsgPackParser x = MsgPackParser.create().applyAnnotations(m, sr).build();
- check("true", x.getProperty(PARSER_autoCloseStreams));
- check("HEX", x.getProperty(ISPARSER_binaryFormat));
- check("1", x.getProperty(PARSER_debugOutputLines));
- check(null, x.getProperty(RPARSER_fileCharset));
- check(null, x.getProperty(RPARSER_inputStreamCharset));
- check("AA", x.getProperty(PARSER_listener));
- check("true", x.getProperty(PARSER_strict));
- check("true", x.getProperty(PARSER_trimStrings));
- check("true", x.getProperty(PARSER_unbuffered));
+ MsgPackParserSession x = MsgPackParser.create().applyAnnotations(m, sr).build().createSession();
+ check("true", x.isAutoCloseStreams());
+ check("HEX", x.getBinaryFormat());
+ check("1", x.getDebugOutputLines());
+ check("AA", x.getListener());
+ check("true", x.isStrict());
+ check("true", x.isTrimStrings());
+ check("true", x.isUnbuffered());
}
//-----------------------------------------------------------------------------------------------------------------
@@ -116,31 +110,28 @@ public class ParserConfigTest {
@Test
public void noValuesReaderParser() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- JsonParser x = JsonParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(PARSER_autoCloseStreams));
- check(null, x.getProperty(ISPARSER_binaryFormat));
- check(null, x.getProperty(PARSER_debugOutputLines));
- check(null, x.getProperty(RPARSER_fileCharset));
- check(null, x.getProperty(RPARSER_inputStreamCharset));
- check(null, x.getProperty(PARSER_listener));
- check(null, x.getProperty(PARSER_strict));
- check(null, x.getProperty(PARSER_trimStrings));
- check(null, x.getProperty(PARSER_unbuffered));
+ JsonParserSession x = JsonParser.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isAutoCloseStreams());
+ check("5", x.getDebugOutputLines());
+ check("DEFAULT", x.getFileCharset());
+ check("UTF-8", x.getInputStreamCharset());
+ check(null, x.getListener());
+ check("false", x.isStrict());
+ check("false", x.isTrimStrings());
+ check("false", x.isUnbuffered());
}
@Test
public void noValuesInputStreamParser() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- MsgPackParser x = MsgPackParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(PARSER_autoCloseStreams));
- check(null, x.getProperty(ISPARSER_binaryFormat));
- check(null, x.getProperty(PARSER_debugOutputLines));
- check(null, x.getProperty(RPARSER_fileCharset));
- check(null, x.getProperty(RPARSER_inputStreamCharset));
- check(null, x.getProperty(PARSER_listener));
- check(null, x.getProperty(PARSER_strict));
- check(null, x.getProperty(PARSER_trimStrings));
- check(null, x.getProperty(PARSER_unbuffered));
+ MsgPackParserSession x = MsgPackParser.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isAutoCloseStreams());
+ check("HEX", x.getBinaryFormat());
+ check("5", x.getDebugOutputLines());
+ check(null, x.getListener());
+ check("false", x.isStrict());
+ check("false", x.isTrimStrings());
+ check("false", x.isUnbuffered());
}
//-----------------------------------------------------------------------------------------------------------------
@@ -153,14 +144,27 @@ public class ParserConfigTest {
@Test
public void noAnnotationReaderParser() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- JsonParser x = JsonParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(PARSER_autoCloseStreams));
+ JsonParserSession x = JsonParser.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isAutoCloseStreams());
+ check("5", x.getDebugOutputLines());
+ check("DEFAULT", x.getFileCharset());
+ check("UTF-8", x.getInputStreamCharset());
+ check(null, x.getListener());
+ check("false", x.isStrict());
+ check("false", x.isTrimStrings());
+ check("false", x.isUnbuffered());
}
@Test
public void noAnnotationInputStreamParser() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- MsgPackParser x = MsgPackParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(PARSER_autoCloseStreams));
+ MsgPackParserSession x = MsgPackParser.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isAutoCloseStreams());
+ check("HEX", x.getBinaryFormat());
+ check("5", x.getDebugOutputLines());
+ check(null, x.getListener());
+ check("false", x.isStrict());
+ check("false", x.isTrimStrings());
+ check("false", x.isUnbuffered());
}
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/plaintext/annotation/PlainTextConfigTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/plaintext/PlainTextConfigAnnotationTest.java
similarity index 86%
rename from juneau-core/juneau-core-test/src/test/java/org/apache/juneau/plaintext/annotation/PlainTextConfigTest.java
rename to juneau-core/juneau-core-test/src/test/java/org/apache/juneau/plaintext/PlainTextConfigAnnotationTest.java
index 324b09c..af162de 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/plaintext/annotation/PlainTextConfigTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/plaintext/PlainTextConfigAnnotationTest.java
@@ -10,9 +10,9 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.plaintext.annotation;
+package org.apache.juneau.plaintext;
-import org.apache.juneau.plaintext.*;
+import org.apache.juneau.plaintext.annotation.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.utils.*;
import org.junit.*;
@@ -20,7 +20,7 @@ import org.junit.*;
/**
* Tests the @PlainTextConfig annotation.
*/
-public class PlainTextConfigTest {
+public class PlainTextConfigAnnotationTest {
static StringResolver sr = new StringResolver() {
@Override
@@ -42,13 +42,13 @@ public class PlainTextConfigTest {
@Test
public void noValuesSerializer() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- PlainTextSerializer.create().applyAnnotations(m, sr).build();
+ PlainTextSerializer.create().applyAnnotations(m, sr).build().createSession();
}
@Test
public void noValuesParser() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- PlainTextParser.create().applyAnnotations(m, sr).build();
+ PlainTextParser.create().applyAnnotations(m, sr).build().createSession();
}
//-----------------------------------------------------------------------------------------------------------------
@@ -61,12 +61,12 @@ public class PlainTextConfigTest {
@Test
public void noAnnotationSerializer() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- PlainTextSerializer.create().applyAnnotations(m, sr).build();
+ PlainTextSerializer.create().applyAnnotations(m, sr).build().createSession();
}
@Test
public void noAnnotationParser() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- PlainTextParser.create().applyAnnotations(m, sr).build();
+ PlainTextParser.create().applyAnnotations(m, sr).build().createSession();
}
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/SerializerConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/SerializerConfigAnnotationTest.java
new file mode 100644
index 0000000..4b3fbd8
--- /dev/null
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/SerializerConfigAnnotationTest.java
@@ -0,0 +1,219 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.serializer;
+
+import static org.junit.Assert.*;
+
+import java.util.function.*;
+
+import org.apache.juneau.json.*;
+import org.apache.juneau.msgpack.*;
+import org.apache.juneau.reflect.*;
+import org.apache.juneau.serializer.annotation.*;
+import org.apache.juneau.utils.*;
+import org.junit.*;
+
+/**
+ * Tests the @SerializerConfig annotation.
+ */
+public class SerializerConfigAnnotationTest {
+
+ private static void check(String expected, Object o) {
+ assertEquals(expected, TO_STRING.apply(o));
+ }
+
+ private static final Function<Object,String> TO_STRING = new Function<Object,String>() {
+ @Override
+ public String apply(Object t) {
+ if (t == null)
+ return null;
+ if (t instanceof AA)
+ return "AA";
+ return t.toString();
+ }
+ };
+
+ static StringResolver sr = new StringResolver() {
+ @Override
+ public String resolve(String input) {
+ if (input.startsWith("$"))
+ input = input.substring(1);
+ return input;
+ }
+ };
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // Basic tests
+ //-----------------------------------------------------------------------------------------------------------------
+
+ public static class AA extends SerializerListener {}
+
+ @SerializerConfig(
+ addBeanTypes="$true",
+ addRootType="$true",
+ binaryFormat="$HEX",
+ listener=AA.class,
+ maxIndent="$1",
+ quoteChar="$'",
+ sortCollections="$true",
+ sortMaps="$true",
+ trimEmptyCollections="$true",
+ trimEmptyMaps="$true",
+ trimNullProperties="$true",
+ trimStrings="$true",
+ uriContext="${}",
+ uriRelativity="$RESOURCE",
+ uriResolution="$ABSOLUTE",
+ useWhitespace="$true"
+ )
+ static class A {}
+ static ClassInfo a = ClassInfo.of(A.class);
+
+ @Test
+ public void basicWriterSerializer() throws Exception {
+ AnnotationsMap m = a.getAnnotationsMap();
+ JsonSerializerSession x = JsonSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("true", ((SerializerSession)x).isAddBeanTypes());
+ check("true", x.isAddRootType());
+ check("AA", x.getListener());
+ check("1", x.getMaxIndent());
+ check("'", x.getQuoteChar());
+ check("true", x.isSortCollections());
+ check("true", x.isSortMaps());
+ check("true", x.isTrimEmptyCollections());
+ check("true", x.isTrimEmptyMaps());
+ check("true", x.isTrimNullProperties());
+ check("true", x.isTrimStrings());
+ check("{absoluteAuthority:'/',absoluteContextRoot:'/',absolutePathInfo:'/',absolutePathInfoParent:'/',absoluteServletPath:'/',absoluteServletPathParent:'/',rootRelativeContextRoot:'/',rootRelativePathInfo:'/',rootRelativePathInfoParent:'/',rootRelativeServletPath:'/',rootRelativeServletPathParent:'/'}", x.getUriContext());
+ check("RESOURCE", x.getUriRelativity());
+ check("ABSOLUTE", x.getUriResolution());
+ check("true", x.isUseWhitespace());
+ }
+
+ @Test
+ public void basicOutputStreamSerializer() throws Exception {
+ AnnotationsMap m = a.getAnnotationsMap();
+ MsgPackSerializerSession x = MsgPackSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("true", ((SerializerSession)x).isAddBeanTypes());
+ check("true", x.isAddRootType());
+ check("HEX", x.getBinaryFormat());
+ check("AA", x.getListener());
+ check("true", x.isSortCollections());
+ check("true", x.isSortMaps());
+ check("true", x.isTrimEmptyCollections());
+ check("true", x.isTrimEmptyMaps());
+ check("true", x.isTrimNullProperties());
+ check("true", x.isTrimStrings());
+ check("{absoluteAuthority:'/',absoluteContextRoot:'/',absolutePathInfo:'/',absolutePathInfoParent:'/',absoluteServletPath:'/',absoluteServletPathParent:'/',rootRelativeContextRoot:'/',rootRelativePathInfo:'/',rootRelativePathInfoParent:'/',rootRelativeServletPath:'/',rootRelativeServletPathParent:'/'}", x.getUriContext());
+ check("RESOURCE", x.getUriRelativity());
+ check("ABSOLUTE", x.getUriResolution());
+ check("true", x.isUseWhitespace());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // Annotation with no values.
+ //-----------------------------------------------------------------------------------------------------------------
+
+ @SerializerConfig()
+ static class B {}
+ static ClassInfo b = ClassInfo.of(B.class);
+
+ @Test
+ public void noValuesWriterSerializer() throws Exception {
+ AnnotationsMap m = b.getAnnotationsMap();
+ JsonSerializerSession x = JsonSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("false", ((SerializerSession)x).isAddBeanTypes());
+ check("false", x.isAddRootType());
+ check(null, x.getListener());
+ check("100", x.getMaxIndent());
+ check("\"", x.getQuoteChar());
+ check("false", x.isSortCollections());
+ check("false", x.isSortMaps());
+ check("false", x.isTrimEmptyCollections());
+ check("false", x.isTrimEmptyMaps());
+ check("true", x.isTrimNullProperties());
+ check("false", x.isTrimStrings());
+ check("{absoluteAuthority:'/',absoluteContextRoot:'/',absolutePathInfo:'/',absolutePathInfoParent:'/',absoluteServletPath:'/',absoluteServletPathParent:'/',rootRelativeContextRoot:'/',rootRelativePathInfo:'/',rootRelativePathInfoParent:'/',rootRelativeServletPath:'/',rootRelativeServletPathParent:'/'}", x.getUriContext());
+ check("RESOURCE", x.getUriRelativity());
+ check("NONE", x.getUriResolution());
+ check("false", x.isUseWhitespace());
+ }
+
+ @Test
+ public void noValuesOutputStreamSerializer() throws Exception {
+ AnnotationsMap m = b.getAnnotationsMap();
+ MsgPackSerializerSession x = MsgPackSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("false", ((SerializerSession)x).isAddBeanTypes());
+ check("false", x.isAddRootType());
+ check("HEX", x.getBinaryFormat());
+ check(null, x.getListener());
+ check("false", x.isSortCollections());
+ check("false", x.isSortMaps());
+ check("false", x.isTrimEmptyCollections());
+ check("false", x.isTrimEmptyMaps());
+ check("true", x.isTrimNullProperties());
+ check("false", x.isTrimStrings());
+ check("{absoluteAuthority:'/',absoluteContextRoot:'/',absolutePathInfo:'/',absolutePathInfoParent:'/',absoluteServletPath:'/',absoluteServletPathParent:'/',rootRelativeContextRoot:'/',rootRelativePathInfo:'/',rootRelativePathInfoParent:'/',rootRelativeServletPath:'/',rootRelativeServletPathParent:'/'}", x.getUriContext());
+ check("RESOURCE", x.getUriRelativity());
+ check("NONE", x.getUriResolution());
+ check("false", x.isUseWhitespace());
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // No annotation.
+ //-----------------------------------------------------------------------------------------------------------------
+
+ static class C {}
+ static ClassInfo c = ClassInfo.of(C.class);
+
+ @Test
+ public void noAnnotationWriterSerializer() throws Exception {
+ AnnotationsMap m = c.getAnnotationsMap();
+ JsonSerializerSession x = JsonSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("false", ((SerializerSession)x).isAddBeanTypes());
+ check("false", x.isAddRootType());
+ check(null, x.getListener());
+ check("100", x.getMaxIndent());
+ check("\"", x.getQuoteChar());
+ check("false", x.isSortCollections());
+ check("false", x.isSortMaps());
+ check("false", x.isTrimEmptyCollections());
+ check("false", x.isTrimEmptyMaps());
+ check("true", x.isTrimNullProperties());
+ check("false", x.isTrimStrings());
+ check("{absoluteAuthority:'/',absoluteContextRoot:'/',absolutePathInfo:'/',absolutePathInfoParent:'/',absoluteServletPath:'/',absoluteServletPathParent:'/',rootRelativeContextRoot:'/',rootRelativePathInfo:'/',rootRelativePathInfoParent:'/',rootRelativeServletPath:'/',rootRelativeServletPathParent:'/'}", x.getUriContext());
+ check("RESOURCE", x.getUriRelativity());
+ check("NONE", x.getUriResolution());
+ check("false", x.isUseWhitespace());
+ }
+
+ @Test
+ public void noAnnotationOutputStreamSerializer() throws Exception {
+ AnnotationsMap m = c.getAnnotationsMap();
+ MsgPackSerializerSession x = MsgPackSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("false", ((SerializerSession)x).isAddBeanTypes());
+ check("false", x.isAddRootType());
+ check("HEX", x.getBinaryFormat());
+ check(null, x.getListener());
+ check("false", x.isSortCollections());
+ check("false", x.isSortMaps());
+ check("false", x.isTrimEmptyCollections());
+ check("false", x.isTrimEmptyMaps());
+ check("true", x.isTrimNullProperties());
+ check("false", x.isTrimStrings());
+ check("{absoluteAuthority:'/',absoluteContextRoot:'/',absolutePathInfo:'/',absolutePathInfoParent:'/',absoluteServletPath:'/',absoluteServletPathParent:'/',rootRelativeContextRoot:'/',rootRelativePathInfo:'/',rootRelativePathInfoParent:'/',rootRelativeServletPath:'/',rootRelativeServletPathParent:'/'}", x.getUriContext());
+ check("RESOURCE", x.getUriRelativity());
+ check("NONE", x.getUriResolution());
+ check("false", x.isUseWhitespace());
+ }
+}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/annotation/SerializerConfigTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/annotation/SerializerConfigTest.java
deleted file mode 100644
index 3fe34a5..0000000
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/annotation/SerializerConfigTest.java
+++ /dev/null
@@ -1,201 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.serializer.annotation;
-
-import static org.junit.Assert.*;
-import static org.apache.juneau.serializer.Serializer.*;
-import static org.apache.juneau.serializer.WriterSerializer.*;
-import static org.apache.juneau.serializer.OutputStreamSerializer.*;
-
-import java.util.function.*;
-
-import org.apache.juneau.json.*;
-import org.apache.juneau.msgpack.*;
-import org.apache.juneau.reflect.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.utils.*;
-import org.junit.*;
-
-/**
- * Tests the @SerializerConfig annotation.
- */
-public class SerializerConfigTest {
-
- private static void check(String expected, Object o) {
- assertEquals(expected, TO_STRING.apply(o));
- }
-
- private static final Function<Object,String> TO_STRING = new Function<Object,String>() {
- @Override
- public String apply(Object t) {
- if (t == null)
- return null;
- if (t instanceof Class)
- return ((Class<?>)t).getSimpleName();
- return t.toString();
- }
- };
-
- static StringResolver sr = new StringResolver() {
- @Override
- public String resolve(String input) {
- if (input.startsWith("$"))
- input = input.substring(1);
- return input;
- }
- };
-
- //-----------------------------------------------------------------------------------------------------------------
- // Basic tests
- //-----------------------------------------------------------------------------------------------------------------
-
- static class AA extends SerializerListener {}
-
- @SerializerConfig(
- addBeanTypes="$true",
- addRootType="$true",
- binaryFormat="$HEX",
- listener=AA.class,
- maxIndent="$1",
- quoteChar="$'",
- sortCollections="$true",
- sortMaps="$true",
- trimEmptyCollections="$true",
- trimEmptyMaps="$true",
- trimNullProperties="$true",
- trimStrings="$true",
- uriContext="${}",
- uriRelativity="$RESOURCE",
- uriResolution="$ABSOLUTE",
- useWhitespace="$true"
- )
- static class A {}
- static ClassInfo a = ClassInfo.of(A.class);
-
- @Test
- public void basicWriterSerializer() throws Exception {
- AnnotationsMap m = a.getAnnotationsMap();
- JsonSerializer x = JsonSerializer.create().applyAnnotations(m, sr).build();
- check("true", x.getProperty(SERIALIZER_addBeanTypes));
- check("true", x.getProperty(SERIALIZER_addRootType));
- check(null, x.getProperty(OSSERIALIZER_binaryFormat));
- check("AA", x.getProperty(SERIALIZER_listener));
- check("1", x.getProperty(WSERIALIZER_maxIndent));
- check("'", x.getProperty(WSERIALIZER_quoteChar));
- check("true", x.getProperty(SERIALIZER_sortCollections));
- check("true", x.getProperty(SERIALIZER_sortMaps));
- check("true", x.getProperty(SERIALIZER_trimEmptyCollections));
- check("true", x.getProperty(SERIALIZER_trimEmptyMaps));
- check("true", x.getProperty(SERIALIZER_trimNullProperties));
- check("true", x.getProperty(SERIALIZER_trimStrings));
- check("{}", x.getProperty(SERIALIZER_uriContext));
- check("RESOURCE", x.getProperty(SERIALIZER_uriRelativity));
- check("ABSOLUTE", x.getProperty(SERIALIZER_uriResolution));
- check("true", x.getProperty(SERIALIZER_useWhitespace));
- }
-
- @Test
- public void basicOutputStreamSerializer() throws Exception {
- AnnotationsMap m = a.getAnnotationsMap();
- MsgPackSerializer x = MsgPackSerializer.create().applyAnnotations(m, sr).build();
- check("true", x.getProperty(SERIALIZER_addBeanTypes));
- check("true", x.getProperty(SERIALIZER_addRootType));
- check("HEX", x.getProperty(OSSERIALIZER_binaryFormat));
- check("AA", x.getProperty(SERIALIZER_listener));
- check(null, x.getProperty(WSERIALIZER_maxIndent));
- check(null, x.getProperty(WSERIALIZER_quoteChar));
- check("true", x.getProperty(SERIALIZER_sortCollections));
- check("true", x.getProperty(SERIALIZER_sortMaps));
- check("true", x.getProperty(SERIALIZER_trimEmptyCollections));
- check("true", x.getProperty(SERIALIZER_trimEmptyMaps));
- check("true", x.getProperty(SERIALIZER_trimNullProperties));
- check("true", x.getProperty(SERIALIZER_trimStrings));
- check("{}", x.getProperty(SERIALIZER_uriContext));
- check("RESOURCE", x.getProperty(SERIALIZER_uriRelativity));
- check("ABSOLUTE", x.getProperty(SERIALIZER_uriResolution));
- check("true", x.getProperty(SERIALIZER_useWhitespace));
- }
-
- //-----------------------------------------------------------------------------------------------------------------
- // Annotation with no values.
- //-----------------------------------------------------------------------------------------------------------------
-
- @SerializerConfig()
- static class B {}
- static ClassInfo b = ClassInfo.of(B.class);
-
- @Test
- public void noValuesWriterSerializer() throws Exception {
- AnnotationsMap m = b.getAnnotationsMap();
- JsonSerializer x = JsonSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- check(null, x.getProperty(SERIALIZER_addRootType));
- check(null, x.getProperty(OSSERIALIZER_binaryFormat));
- check(null, x.getProperty(SERIALIZER_listener));
- check(null, x.getProperty(WSERIALIZER_maxIndent));
- check(null, x.getProperty(WSERIALIZER_quoteChar));
- check(null, x.getProperty(SERIALIZER_sortCollections));
- check(null, x.getProperty(SERIALIZER_sortMaps));
- check(null, x.getProperty(SERIALIZER_trimEmptyCollections));
- check(null, x.getProperty(SERIALIZER_trimEmptyMaps));
- check(null, x.getProperty(SERIALIZER_trimNullProperties));
- check(null, x.getProperty(SERIALIZER_trimStrings));
- check(null, x.getProperty(SERIALIZER_uriContext));
- check(null, x.getProperty(SERIALIZER_uriRelativity));
- check(null, x.getProperty(SERIALIZER_uriResolution));
- check(null, x.getProperty(SERIALIZER_useWhitespace));
- }
-
- @Test
- public void noValuesOutputStreamSerializer() throws Exception {
- AnnotationsMap m = b.getAnnotationsMap();
- MsgPackSerializer x = MsgPackSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- check(null, x.getProperty(SERIALIZER_addRootType));
- check(null, x.getProperty(OSSERIALIZER_binaryFormat));
- check(null, x.getProperty(SERIALIZER_listener));
- check(null, x.getProperty(WSERIALIZER_maxIndent));
- check(null, x.getProperty(WSERIALIZER_quoteChar));
- check(null, x.getProperty(SERIALIZER_sortCollections));
- check(null, x.getProperty(SERIALIZER_sortMaps));
- check(null, x.getProperty(SERIALIZER_trimEmptyCollections));
- check(null, x.getProperty(SERIALIZER_trimEmptyMaps));
- check(null, x.getProperty(SERIALIZER_trimNullProperties));
- check(null, x.getProperty(SERIALIZER_trimStrings));
- check(null, x.getProperty(SERIALIZER_uriContext));
- check(null, x.getProperty(SERIALIZER_uriRelativity));
- check(null, x.getProperty(SERIALIZER_uriResolution));
- check(null, x.getProperty(SERIALIZER_useWhitespace));
- }
-
- //-----------------------------------------------------------------------------------------------------------------
- // No annotation.
- //-----------------------------------------------------------------------------------------------------------------
-
- static class C {}
- static ClassInfo c = ClassInfo.of(C.class);
-
- @Test
- public void noAnnotationWriterSerializer() throws Exception {
- AnnotationsMap m = c.getAnnotationsMap();
- JsonSerializer x = JsonSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- }
-
- @Test
- public void noAnnotationOutputStreamSerializer() throws Exception {
- AnnotationsMap m = c.getAnnotationsMap();
- MsgPackSerializer x = MsgPackSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- }
-}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/soap/annotation/SoapXmlConfigTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/soap/SoapXmlConfigAnnotationTest.java
similarity index 85%
rename from juneau-core/juneau-core-test/src/test/java/org/apache/juneau/soap/annotation/SoapXmlConfigTest.java
rename to juneau-core/juneau-core-test/src/test/java/org/apache/juneau/soap/SoapXmlConfigAnnotationTest.java
index 65ebf0a..a695936 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/soap/annotation/SoapXmlConfigTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/soap/SoapXmlConfigAnnotationTest.java
@@ -10,22 +10,21 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.soap.annotation;
+package org.apache.juneau.soap;
import static org.junit.Assert.*;
-import static org.apache.juneau.soap.SoapXmlSerializer.*;
import java.util.function.*;
import org.apache.juneau.reflect.*;
-import org.apache.juneau.soap.*;
+import org.apache.juneau.soap.annotation.*;
import org.apache.juneau.utils.*;
import org.junit.*;
/**
* Tests the @SoapXmlConfig annotation.
*/
-public class SoapXmlConfigTest {
+public class SoapXmlConfigAnnotationTest {
private static void check(String expected, Object o) {
assertEquals(expected, TO_STRING.apply(o));
@@ -34,8 +33,6 @@ public class SoapXmlConfigTest {
private static final Function<Object,String> TO_STRING = new Function<Object,String>() {
@Override
public String apply(Object t) {
- if (t == null)
- return null;
return t.toString();
}
};
@@ -62,8 +59,8 @@ public class SoapXmlConfigTest {
@Test
public void basic() throws Exception {
AnnotationsMap m = a.getAnnotationsMap();
- SoapXmlSerializer x = SoapXmlSerializer.create().applyAnnotations(m, sr).build();
- check("foo", x.getProperty(SOAPXML_SOAPAction));
+ SoapXmlSerializerSession x = SoapXmlSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("foo", x.getSoapAction());
}
//-----------------------------------------------------------------------------------------------------------------
@@ -77,8 +74,8 @@ public class SoapXmlConfigTest {
@Test
public void noValues() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- SoapXmlSerializer x = SoapXmlSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SOAPXML_SOAPAction));
+ SoapXmlSerializerSession x = SoapXmlSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("http://www.w3.org/2003/05/soap-envelope", x.getSoapAction());
}
//-----------------------------------------------------------------------------------------------------------------
@@ -91,7 +88,7 @@ public class SoapXmlConfigTest {
@Test
public void noAnnotation() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- SoapXmlSerializer x = SoapXmlSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SOAPXML_SOAPAction));
+ SoapXmlSerializerSession x = SoapXmlSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("http://www.w3.org/2003/05/soap-envelope", x.getSoapAction());
}
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/uon/annotation/UonConfigTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/uon/UonConfigAnnotationTest.java
similarity index 73%
rename from juneau-core/juneau-core-test/src/test/java/org/apache/juneau/uon/annotation/UonConfigTest.java
rename to juneau-core/juneau-core-test/src/test/java/org/apache/juneau/uon/UonConfigAnnotationTest.java
index fa240bc..16e9f6c 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/uon/annotation/UonConfigTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/uon/UonConfigAnnotationTest.java
@@ -10,24 +10,21 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.uon.annotation;
+package org.apache.juneau.uon;
import static org.junit.Assert.*;
-import static org.apache.juneau.serializer.Serializer.*;
-import static org.apache.juneau.uon.UonSerializer.*;
-import static org.apache.juneau.uon.UonParser.*;
import java.util.function.*;
import org.apache.juneau.reflect.*;
-import org.apache.juneau.uon.*;
+import org.apache.juneau.uon.annotation.*;
import org.apache.juneau.utils.*;
import org.junit.*;
/**
* Tests the @UonConfig annotation.
*/
-public class UonConfigTest {
+public class UonConfigAnnotationTest {
private static void check(String expected, Object o) {
assertEquals(expected, TO_STRING.apply(o));
@@ -36,8 +33,6 @@ public class UonConfigTest {
private static final Function<Object,String> TO_STRING = new Function<Object,String>() {
@Override
public String apply(Object t) {
- if (t == null)
- return null;
return t.toString();
}
};
@@ -68,23 +63,18 @@ public class UonConfigTest {
@Test
public void basicSerializer() throws Exception {
AnnotationsMap m = a.getAnnotationsMap();
- UonSerializer x = UonSerializer.create().applyAnnotations(m, sr).build();
- check("true", x.getProperty(SERIALIZER_addBeanTypes));
- check(null, x.getProperty(UON_decoding));
- check("true", x.getProperty(UON_encoding));
- check("UON", x.getProperty(UON_paramFormat));
- check(null, x.getProperty(UON_validateEnd));
+ UonSerializerSession x = UonSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("true", x.isAddBeanTypes());
+ check("true", x.isEncoding());
+ check("UON", x.getParamFormat());
}
@Test
public void basicParser() throws Exception {
AnnotationsMap m = a.getAnnotationsMap();
- UonParser x = UonParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- check("true", x.getProperty(UON_decoding));
- check(null, x.getProperty(UON_encoding));
- check(null, x.getProperty(UON_paramFormat));
- check("true", x.getProperty(UON_validateEnd));
+ UonParserSession x = UonParser.create().applyAnnotations(m, sr).build().createSession();
+ check("true", x.isDecoding());
+ check("true", x.isValidateEnd());
}
//-----------------------------------------------------------------------------------------------------------------
@@ -98,15 +88,18 @@ public class UonConfigTest {
@Test
public void noValuesSerializer() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- UonSerializer x = UonSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
+ UonSerializerSession x = UonSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isAddBeanTypes());
+ check("false", x.isEncoding());
+ check("UON", x.getParamFormat());
}
@Test
public void noValuesParser() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- UonParser x = UonParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
+ UonParserSession x = UonParser.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isDecoding());
+ check("false", x.isValidateEnd());
}
//-----------------------------------------------------------------------------------------------------------------
@@ -119,14 +112,17 @@ public class UonConfigTest {
@Test
public void noAnnotationSerializer() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- UonSerializer x = UonSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
+ UonSerializerSession x = UonSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isAddBeanTypes());
+ check("false", x.isEncoding());
+ check("UON", x.getParamFormat());
}
@Test
public void noAnnotationParser() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- UonParser x = UonParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
+ UonParserSession x = UonParser.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isDecoding());
+ check("false", x.isValidateEnd());
}
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/annotation/UrlEncodingConfigTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UrlEncodingConfigAnnotationTest.java
similarity index 77%
rename from juneau-core/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/annotation/UrlEncodingConfigTest.java
rename to juneau-core/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UrlEncodingConfigAnnotationTest.java
index 352bafa..39ab201 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/annotation/UrlEncodingConfigTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UrlEncodingConfigAnnotationTest.java
@@ -10,21 +10,21 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.urlencoding.annotation;
+package org.apache.juneau.urlencoding;
import static org.junit.Assert.*;
import java.util.function.*;
import org.apache.juneau.reflect.*;
-import org.apache.juneau.urlencoding.*;
+import org.apache.juneau.urlencoding.annotation.*;
import org.apache.juneau.utils.*;
import org.junit.*;
/**
* Tests the @UrlEncodingConfig annotation.
*/
-public class UrlEncodingConfigTest {
+public class UrlEncodingConfigAnnotationTest {
private static void check(String expected, Object o) {
assertEquals(expected, TO_STRING.apply(o));
@@ -33,8 +33,6 @@ public class UrlEncodingConfigTest {
private static final Function<Object,String> TO_STRING = new Function<Object,String>() {
@Override
public String apply(Object t) {
- if (t == null)
- return null;
return t.toString();
}
};
@@ -61,15 +59,15 @@ public class UrlEncodingConfigTest {
@Test
public void basicSerializer() throws Exception {
AnnotationsMap m = a.getAnnotationsMap();
- UrlEncodingSerializer x = UrlEncodingSerializer.create().applyAnnotations(m, sr).build();
- check("true", x.getProperty(UrlEncodingSerializer.URLENC_expandedParams));
+ UrlEncodingSerializerSession x = UrlEncodingSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("true", x.isExpandedParams());
}
@Test
public void basicParser() throws Exception {
AnnotationsMap m = a.getAnnotationsMap();
- UrlEncodingParser x = UrlEncodingParser.create().applyAnnotations(m, sr).build();
- check("true", x.getProperty(UrlEncodingParser.URLENC_expandedParams));
+ UrlEncodingParserSession x = UrlEncodingParser.create().applyAnnotations(m, sr).build().createSession();
+ check("true", x.isExpandedParams());
}
//-----------------------------------------------------------------------------------------------------------------
@@ -83,15 +81,15 @@ public class UrlEncodingConfigTest {
@Test
public void noValuesSerializer() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- UrlEncodingSerializer x = UrlEncodingSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(UrlEncodingSerializer.URLENC_expandedParams));
+ UrlEncodingSerializerSession x = UrlEncodingSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isExpandedParams());
}
@Test
public void noValuesParser() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- UrlEncodingParser x = UrlEncodingParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(UrlEncodingParser.URLENC_expandedParams));
+ UrlEncodingParserSession x = UrlEncodingParser.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isExpandedParams());
}
//-----------------------------------------------------------------------------------------------------------------
@@ -104,14 +102,14 @@ public class UrlEncodingConfigTest {
@Test
public void noAnnotationSerializer() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- UrlEncodingSerializer x = UrlEncodingSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(UrlEncodingSerializer.URLENC_expandedParams));
+ UrlEncodingSerializerSession x = UrlEncodingSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isExpandedParams());
}
@Test
public void noAnnotationParser() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- UrlEncodingParser x = UrlEncodingParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(UrlEncodingParser.URLENC_expandedParams));
+ UrlEncodingParserSession x = UrlEncodingParser.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isExpandedParams());
}
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/annotation/XmlConfigTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlConfigAnnotationTest.java
similarity index 66%
rename from juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/annotation/XmlConfigTest.java
rename to juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlConfigAnnotationTest.java
index 748ded7..9f90283 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/annotation/XmlConfigTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlConfigAnnotationTest.java
@@ -10,12 +10,9 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.xml.annotation;
+package org.apache.juneau.xml;
import static org.junit.Assert.*;
-import static org.apache.juneau.serializer.Serializer.*;
-import static org.apache.juneau.xml.XmlSerializer.*;
-import static org.apache.juneau.xml.XmlParser.*;
import java.util.function.*;
@@ -23,15 +20,16 @@ import javax.xml.stream.*;
import javax.xml.stream.events.*;
import javax.xml.stream.util.*;
+import org.apache.juneau.internal.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.utils.*;
-import org.apache.juneau.xml.*;
+import org.apache.juneau.xml.annotation.*;
import org.junit.*;
/**
* Tests the @XmlConfig annotation.
*/
-public class XmlConfigTest {
+public class XmlConfigAnnotationTest {
private static void check(String expected, Object o) {
assertEquals(expected, TO_STRING.apply(o));
@@ -42,8 +40,14 @@ public class XmlConfigTest {
public String apply(Object t) {
if (t == null)
return null;
- if (t instanceof Class)
- return ((Class<?>)t).getSimpleName();
+ if (t.getClass().isArray())
+ return apply(ArrayUtils.toList(t, Object.class));
+ if (t instanceof AA)
+ return "AA";
+ if (t instanceof AB)
+ return "AB";
+ if (t instanceof AC)
+ return "AC";
return t.toString();
}
};
@@ -106,37 +110,25 @@ public class XmlConfigTest {
@Test
public void basicSerializer() throws Exception {
AnnotationsMap m = a.getAnnotationsMap();
- XmlSerializer x = XmlSerializer.create().applyAnnotations(m, sr).build();
- check("true", x.getProperty(SERIALIZER_addBeanTypes));
- check("true", x.getProperty(XML_addNamespaceUrisToRoot));
- check("true", x.getProperty(XML_autoDetectNamespaces));
- check("foo", x.getProperty(XML_defaultNamespace));
- check("true", x.getProperty(XML_enableNamespaces));
- check(null, x.getProperty(XML_eventAllocator));
- check("[foo:null]", x.getProperty(XML_namespaces));
- check(null, x.getProperty(XML_preserveRootElement));
- check(null, x.getProperty(XML_reporter));
- check(null, x.getProperty(XML_resolver));
- check(null, x.getProperty(XML_validating));
- check("foo:null", x.getProperty(XML_xsNamespace));
+ XmlSerializerSession x = XmlSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("true", x.isAddBeanTypes());
+ check("true", x.isAddNamespaceUrisToRoot());
+ check("true", x.isAutoDetectNamespaces());
+ check("foo:null", x.getDefaultNamespace());
+ check("true", x.isEnableNamespaces());
+ check("[foo:null]", x.getNamespaces());
+ check("foo:null", x.getXsNamespace());
}
@Test
public void basicParser() throws Exception {
AnnotationsMap m = a.getAnnotationsMap();
- XmlParser x = XmlParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
- check(null, x.getProperty(XML_addNamespaceUrisToRoot));
- check(null, x.getProperty(XML_autoDetectNamespaces));
- check(null, x.getProperty(XML_defaultNamespace));
- check(null, x.getProperty(XML_enableNamespaces));
- check("AA", x.getProperty(XML_eventAllocator));
- check(null, x.getProperty(XML_namespaces));
- check("true", x.getProperty(XML_preserveRootElement));
- check("AB", x.getProperty(XML_reporter));
- check("AC", x.getProperty(XML_resolver));
- check("true", x.getProperty(XML_validating));
- check(null, x.getProperty(XML_xsNamespace));
+ XmlParserSession x = XmlParser.create().applyAnnotations(m, sr).build().createSession();
+ check("AA", x.getEventAllocator());
+ check("true", x.isPreserveRootElement());
+ check("AB", x.getReporter());
+ check("AC", x.getResolver());
+ check("true", x.isValidating());
}
//-----------------------------------------------------------------------------------------------------------------
@@ -150,15 +142,25 @@ public class XmlConfigTest {
@Test
public void noValuesSerializer() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- XmlSerializer x = XmlSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
+ XmlSerializerSession x = XmlSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isAddBeanTypes());
+ check("false", x.isAddNamespaceUrisToRoot());
+ check("true", x.isAutoDetectNamespaces());
+ check("juneau:http://www.apache.org/2013/Juneau", x.getDefaultNamespace());
+ check("false", x.isEnableNamespaces());
+ check("[]", x.getNamespaces());
+ check("xs:http://www.w3.org/2001/XMLSchema", x.getXsNamespace());
}
@Test
public void noValuesParser() throws Exception {
AnnotationsMap m = b.getAnnotationsMap();
- XmlParser x = XmlParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
+ XmlParserSession x = XmlParser.create().applyAnnotations(m, sr).build().createSession();
+ check(null, x.getEventAllocator());
+ check("false", x.isPreserveRootElement());
+ check(null, x.getReporter());
+ check(null, x.getResolver());
+ check("false", x.isValidating());
}
//-----------------------------------------------------------------------------------------------------------------
@@ -171,14 +173,24 @@ public class XmlConfigTest {
@Test
public void noAnnotationSerializer() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- XmlSerializer x = XmlSerializer.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
+ XmlSerializerSession x = XmlSerializer.create().applyAnnotations(m, sr).build().createSession();
+ check("false", x.isAddBeanTypes());
+ check("false", x.isAddNamespaceUrisToRoot());
+ check("true", x.isAutoDetectNamespaces());
+ check("juneau:http://www.apache.org/2013/Juneau", x.getDefaultNamespace());
+ check("false", x.isEnableNamespaces());
+ check("[]", x.getNamespaces());
+ check("xs:http://www.w3.org/2001/XMLSchema", x.getXsNamespace());
}
@Test
public void noAnnotationParser() throws Exception {
AnnotationsMap m = c.getAnnotationsMap();
- XmlParser x = XmlParser.create().applyAnnotations(m, sr).build();
- check(null, x.getProperty(SERIALIZER_addBeanTypes));
+ XmlParserSession x = XmlParser.create().applyAnnotations(m, sr).build().createSession();
+ check(null, x.getEventAllocator());
+ check("false", x.isPreserveRootElement());
+ check(null, x.getReporter());
+ check(null, x.getResolver());
+ check("false", x.isValidating());
}
}
diff --git a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfCommon.java b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfCommon.java
index 9c42ed4..66c7445 100644
--- a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfCommon.java
+++ b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfCommon.java
@@ -17,7 +17,6 @@ import java.util.*;
import org.apache.juneau.jena.annotation.*;
import org.apache.juneau.utils.*;
import org.apache.juneau.xml.*;
-import org.apache.juneau.xml.annotation.*;
/**
* Configurable properties common to both the {@link RdfSerializer} and {@link RdfParser} classes.
@@ -136,28 +135,6 @@ public interface RdfCommon {
public static final String RDF_juneauBpNs = PREFIX + "juneauBpNs.s";
/**
- * Configuration property: Reuse XML namespaces when RDF namespaces not specified.
- *
- * <h5 class='section'>Property:</h5>
- * <ul>
- * <li><b>Name:</b> <js>"Rdf.useXmlNamespaces.b"</js>
- * <li><b>Data type:</b> <code>Boolean</code>
- * <li><b>Default:</b> <jk>true</jk>
- * <li><b>Methods:</b>
- * <ul>
- * <li class='jm'>{@link RdfSerializerBuilder#useXmlNamespaces(boolean)}
- * <li class='jm'>{@link RdfParserBuilder#useXmlNamespaces(boolean)}
- * </ul>
- * </ul>
- *
- * <h5 class='section'>Description:</h5>
- * <p>
- * When specified, namespaces defined using {@link XmlNs @XmlNs} and {@link Xml @Xml} will be inherited by the RDF serializers.
- * <br>Otherwise, namespaces will be defined using {@link RdfNs @RdfNs} and {@link Rdf @Rdf}.
- */
- public static final String RDF_useXmlNamespaces = PREFIX + "useXmlNamespaces.b";
-
- /**
* Configuration property: RDF/XML property: <code>iri_rules</code>.
*
* <h5 class='section'>Property:</h5>
diff --git a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParser.java b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParser.java
index 96584bb..4f3f67e 100644
--- a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParser.java
+++ b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParser.java
@@ -12,6 +12,8 @@
// ***************************************************************************************************************************
package org.apache.juneau.jena;
+import static org.apache.juneau.internal.CollectionUtils.*;
+
import java.util.*;
import org.apache.juneau.*;
@@ -100,7 +102,7 @@ public class RdfParser extends ReaderParser implements RdfCommon {
private final Namespace juneauNs, juneauBpNs;
private final RdfCollectionFormat collectionFormat;
- final Map<String,Object> jenaSettings = new HashMap<>();
+ final Map<String,Object> jenaProperties;
/**
* Constructor.
@@ -116,6 +118,12 @@ public class RdfParser extends ReaderParser implements RdfCommon {
juneauNs = getInstanceProperty(RDF_juneauNs, Namespace.class, DEFAULT_JUNEAU_NS);
juneauBpNs = getInstanceProperty(RDF_juneauBpNs, Namespace.class, DEFAULT_JUNEAUBP_NS);
collectionFormat = getProperty(RDF_collectionFormat, RdfCollectionFormat.class, RdfCollectionFormat.DEFAULT);
+
+ Map<String,Object> m = new TreeMap<>();
+ for (String k : getPropertyKeys("RdfCommon"))
+ if (k.startsWith("jena."))
+ m.put(k.substring(5), getProperty("RdfCommon." + k));
+ jenaProperties = unmodifiableMap(m);
}
/**
@@ -149,35 +157,50 @@ public class RdfParser extends ReaderParser implements RdfCommon {
}
@Override /* Parser */
- public ReaderParserSession createSession(ParserSessionArgs args) {
+ public RdfParserSession createSession() {
+ return createSession(createDefaultSessionArgs());
+ }
+
+ @Override /* Parser */
+ public RdfParserSession createSession(ParserSessionArgs args) {
return new RdfParserSession(this, args);
}
//-----------------------------------------------------------------------------------------------------------------
- // Properties
+ // Common properties
//-----------------------------------------------------------------------------------------------------------------
/**
- * Configuration property: Trim whitespace from text elements.
+ * Configuration property: RDF format for representing collections and arrays.
*
- * @see #RDF_trimWhitespace
+ * @see #RDF_collectionFormat
* @return
- * <jk>true</jk> if whitespace in text elements will be automatically trimmed.
+ * RDF format for representing collections and arrays.
*/
- protected final boolean isTrimWhitespace() {
- return trimWhitespace;
+ protected final RdfCollectionFormat getCollectionFormat() {
+ return collectionFormat;
}
/**
- * Configuration property: Collections should be serialized and parsed as loose collections.
+ * Configuration property: Default XML namespace for bean properties.
*
- * @see #RDF_looseCollections
+ * @see #RDF_juneauBpNs
* @return
- * <jk>true</jk> if collections of resources are handled as loose collections of resources in RDF instead of
- * resources that are children of an RDF collection (e.g. Sequence, Bag).
+ * Default XML namespace for bean properties.
*/
- protected final boolean isLooseCollections() {
- return looseCollections;
+ protected final Namespace getJuneauBpNs() {
+ return juneauBpNs;
+ }
+
+ /**
+ * Configuration property: XML namespace for Juneau properties.
+ *
+ * @see #RDF_juneauNs
+ * @return
+ * XML namespace for Juneau properties.
+ */
+ protected final Namespace getJuneauNs() {
+ return juneauNs;
}
/**
@@ -187,43 +210,55 @@ public class RdfParser extends ReaderParser implements RdfCommon {
* @return
* The RDF language to use.
*/
- protected final String getRdfLanguage() {
+ protected final String getLanguage() {
return rdfLanguage;
}
/**
- * Configuration property: XML namespace for Juneau properties.
+ * Configuration property: Collections should be serialized and parsed as loose collections.
*
- * @see #RDF_juneauNs
+ * @see #RDF_looseCollections
* @return
- * XML namespace for Juneau properties.
+ * <jk>true</jk> if collections of resources are handled as loose collections of resources in RDF instead of
+ * resources that are children of an RDF collection (e.g. Sequence, Bag).
*/
- protected final Namespace getJuneauNs() {
- return juneauNs;
+ protected final boolean isLooseCollections() {
+ return looseCollections;
}
+ //-----------------------------------------------------------------------------------------------------------------
+ // Jena properties
+ //-----------------------------------------------------------------------------------------------------------------
+
/**
- * Configuration property: Default XML namespace for bean properties.
+ * Configuration property: All Jena-related configuration properties.
*
- * @see #RDF_juneauBpNs
* @return
- * Default XML namespace for bean properties.
+ * A map of all Jena-related configuration properties.
*/
- protected final Namespace getJuneauBpNs() {
- return juneauBpNs;
+ protected final Map<String,Object> getJenaProperties() {
+ return jenaProperties;
}
+ //-----------------------------------------------------------------------------------------------------------------
+ // Properties
+ //-----------------------------------------------------------------------------------------------------------------
+
/**
- * Configuration property: RDF format for representing collections and arrays.
+ * Configuration property: Trim whitespace from text elements.
*
- * @see #RDF_collectionFormat
+ * @see #RDF_trimWhitespace
* @return
- * RDF format for representing collections and arrays.
+ * <jk>true</jk> if whitespace in text elements will be automatically trimmed.
*/
- protected final RdfCollectionFormat getCollectionFormat() {
- return collectionFormat;
+ protected final boolean isTrimWhitespace() {
+ return trimWhitespace;
}
+ //-----------------------------------------------------------------------------------------------------------------
+ // Other methods
+ //-----------------------------------------------------------------------------------------------------------------
+
@Override /* Context */
public ObjectMap asMap() {
return super.asMap()
diff --git a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserBuilder.java b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserBuilder.java
index f16c14b..1e5d26a 100644
--- a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserBuilder.java
+++ b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserBuilder.java
@@ -19,13 +19,10 @@ import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.http.*;
-import org.apache.juneau.internal.*;
-import org.apache.juneau.jena.annotation.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.utils.*;
import org.apache.juneau.xml.*;
-import org.apache.juneau.xml.annotation.*;
/**
* Builder class for building instances of RDF parsers.
@@ -54,79 +51,6 @@ public class RdfParserBuilder extends ReaderParserBuilder {
}
//-----------------------------------------------------------------------------------------------------------------
- // Annotations
- //-----------------------------------------------------------------------------------------------------------------
-
- @Override
- public RdfParserBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) throws ParseException {
- super.applyAnnotations(m, sr);
- if (! m.containsKey(RdfConfig.class))
- return this;
- ObjectResolver r = new ObjectResolver(sr);
- for (RdfConfig a : m.get(RdfConfig.class)) {
- if (! a.language().isEmpty())
- language(r.string(a.language()));
- if (! a.juneauNs().isEmpty())
- juneauNs(r.string(a.juneauNs()));
- if (! a.juneauBpNs().isEmpty())
- juneauBpNs(r.string(a.juneauBpNs()));
- if (! a.useXmlNamespaces().isEmpty())
- useXmlNamespaces(r.bool(a.useXmlNamespaces()));
- if (! a.arp_iriRules().isEmpty())
- arp_iriRules(r.string(a.arp_iriRules()));
- if (! a.arp_errorMode().isEmpty())
- arp_errorMode(r.string(a.arp_errorMode()));
- if (! a.arp_embedding().isEmpty())
- arp_embedding(r.bool(a.arp_embedding()));
- if (! a.rdfxml_xmlBase().isEmpty())
- rdfxml_xmlBase(r.string(a.rdfxml_xmlBase()));
- if (! a.rdfxml_longId().isEmpty())
- rdfxml_longId(r.bool(a.rdfxml_longId()));
- if (! a.rdfxml_allowBadUris().isEmpty())
- rdfxml_allowBadUris(r.bool(a.rdfxml_allowBadUris()));
- if (! a.rdfxml_relativeUris().isEmpty())
- rdfxml_relativeUris(r.string(a.rdfxml_relativeUris()));
- if (! a.rdfxml_showXmlDeclaration().isEmpty())
- rdfxml_showXmlDeclaration(r.string(a.rdfxml_showXmlDeclaration()));
- if (! a.rdfxml_showDoctypeDeclaration().isEmpty())
- rdfxml_showDoctypeDeclaration(r.bool(a.rdfxml_showDoctypeDeclaration()));
- if (! a.rdfxml_tab().isEmpty())
- rdfxml_tab(r.integer(a.rdfxml_tab()));
- if (! a.rdfxml_attributeQuoteChar().isEmpty())
- rdfxml_attributeQuoteChar(r.string(a.rdfxml_attributeQuoteChar()));
- if (! a.rdfxml_blockRules().isEmpty())
- rdfxml_blockRules(r.string(a.rdfxml_blockRules()));
- if (! a.n3_minGap().isEmpty())
- n3_minGap(r.integer(a.n3_minGap()));
- if (! a.n3_objectLists().isEmpty())
- n3_objectLists(r.bool(a.n3_objectLists()));
- if (! a.n3_subjectColumn().isEmpty())
- n3_subjectColumn(r.integer(a.n3_subjectColumn()));
- if (! a.n3_propertyColumn().isEmpty())
- n3_propertyColumn(r.integer(a.n3_propertyColumn()));
- if (! a.n3_indentProperty().isEmpty())
- n3_indentProperty(r.integer(a.n3_indentProperty()));
- if (! a.n3_widePropertyLen().isEmpty())
- n3_widePropertyLen(r.integer(a.n3_widePropertyLen()));
- if (! a.n3_abbrevBaseUri().isEmpty())
- n3_abbrevBaseUri(r.bool(a.n3_abbrevBaseUri()));
- if (! a.n3_usePropertySymbols().isEmpty())
- n3_usePropertySymbols(r.bool(a.n3_usePropertySymbols()));
- if (! a.n3_useTripleQuotedStrings().isEmpty())
- n3_useTripleQuotedStrings(r.bool(a.n3_useTripleQuotedStrings()));
- if (! a.n3_useDoubles().isEmpty())
- n3_useDoubles(r.bool(a.n3_useDoubles()));
- if (! a.collectionFormat().isEmpty())
- collectionFormat(r.string(a.collectionFormat()));
- if (! a.looseCollections().isEmpty())
- looseCollections(r.bool(a.looseCollections()));
- if (! a.trimWhitespace().isEmpty())
- trimWhitespace(r.bool(a.trimWhitespace()));
- }
- return this;
- }
-
- //-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
@@ -173,7 +97,7 @@ public class RdfParserBuilder extends ReaderParserBuilder {
* {@doc http://www.ietf.org/rfc/rfc3987.txt RFC 3987}).
*
* </ul>
- *
+ *
* @param value
* The new value for this property.
* @return This object (for method chaining).
@@ -793,28 +717,6 @@ public class RdfParserBuilder extends ReaderParserBuilder {
}
/**
- * Configuration property: Reuse XML namespaces when RDF namespaces not specified.
- *
- * <p>
- * When specified, namespaces defined using {@link XmlNs @XmlNs} and {@link org.apache.juneau.xml.annotation.Xml @Xml} will be
- * inherited by the RDF parsers.
- * Otherwise, namespaces will be defined using {@link RdfNs @RdfNs} and {@link Rdf @Rdf}.
- *
- * <h5 class='section'>See Also:</h5>
- * <ul>
- * <li class='jf'>{@link RdfParser#RDF_useXmlNamespaces}
- * </ul>
- *
- * @param value
- * The new value for this property.
- * <br>The default is <jk>true</jk>.
- * @return This object (for method chaining).
- */
- public RdfParserBuilder useXmlNamespaces(boolean value) {
- return set(RDF_useXmlNamespaces, value);
- }
-
- /**
* Shortcut for calling <code>language(<jsf>LANG_RDF_XML</jsf>)</code>.
*
* <h5 class='section'>See Also:</h5>
@@ -1323,12 +1225,6 @@ public class RdfParserBuilder extends ReaderParserBuilder {
}
@Override /* ContextBuilder */
- public RdfParserBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public RdfParserBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
@@ -1363,4 +1259,10 @@ public class RdfParserBuilder extends ReaderParserBuilder {
super.apply(copyFrom);
return this;
}
+
+ @Override
+ public RdfParserBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) {
+ super.applyAnnotations(m, sr);
+ return this;
+ }
}
diff --git a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserSession.java b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserSession.java
index 5d55f19..91658e0 100644
--- a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserSession.java
+++ b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserSession.java
@@ -59,11 +59,11 @@ public class RdfParserSession extends ReaderParserSession {
pValue = model.createProperty(ctx.getJuneauNs().getUri(), RDF_juneauNs_VALUE);
pType = model.createProperty(ctx.getJuneauBpNs().getUri(), RDF_juneauNs_TYPE);
pRdfType = model.createProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
- rdfReader = model.getReader(ctx.getRdfLanguage());
+ rdfReader = model.getReader(ctx.getLanguage());
// Note: NTripleReader throws an exception if you try to set any properties on it.
- if (! ctx.getRdfLanguage().equals(LANG_NTRIPLE)) {
- for (Map.Entry<String,Object> e : ctx.jenaSettings.entrySet())
+ if (! ctx.getLanguage().equals(LANG_NTRIPLE)) {
+ for (Map.Entry<String,Object> e : ctx.jenaProperties.entrySet())
rdfReader.setProperty(e.getKey(), e.getValue());
}
}
@@ -430,30 +430,40 @@ public class RdfParserSession extends ReaderParserSession {
}
//-----------------------------------------------------------------------------------------------------------------
- // Properties
+ // Common properties
//-----------------------------------------------------------------------------------------------------------------
/**
- * Configuration property: Trim whitespace from text elements.
+ * Configuration property: RDF format for representing collections and arrays.
*
- * @see RdfParser#RDF_trimWhitespace
+ * @see RdfParser#RDF_collectionFormat
* @return
- * <jk>true</jk> if whitespace in text elements will be automatically trimmed.
+ * RDF format for representing collections and arrays.
*/
- protected final boolean isTrimWhitespace() {
- return ctx.isTrimWhitespace();
+ protected final RdfCollectionFormat getCollectionFormat() {
+ return ctx.getCollectionFormat();
}
/**
- * Configuration property: Collections should be serialized and parsed as loose collections.
+ * Configuration property: Default XML namespace for bean properties.
*
- * @see RdfParser#RDF_looseCollections
+ * @see RdfParser#RDF_juneauBpNs
* @return
- * <jk>true</jk> if collections of resources are handled as loose collections of resources in RDF instead of
- * resources that are children of an RDF collection (e.g. Sequence, Bag).
+ * Default XML namespace for bean properties.
*/
- protected final boolean isLooseCollections() {
- return ctx.isLooseCollections();
+ protected final Namespace getJuneauBpNs() {
+ return ctx.getJuneauBpNs();
+ }
+
+ /**
+ * Configuration property: XML namespace for Juneau properties.
+ *
+ * @see RdfParser#RDF_juneauNs
+ * @return
+ * XML namespace for Juneau properties.
+ */
+ protected final Namespace getJuneauNs() {
+ return ctx.getJuneauNs();
}
/**
@@ -463,40 +473,48 @@ public class RdfParserSession extends ReaderParserSession {
* @return
* The RDF language to use.
*/
- protected final String getRdfLanguage() {
- return ctx.getRdfLanguage();
+ protected final String getLanguage() {
+ return ctx.getLanguage();
}
/**
- * Configuration property: XML namespace for Juneau properties.
+ * Configuration property: Collections should be serialized and parsed as loose collections.
*
- * @see RdfParser#RDF_juneauNs
+ * @see RdfParser#RDF_looseCollections
* @return
- * XML namespace for Juneau properties.
+ * <jk>true</jk> if collections of resources are handled as loose collections of resources in RDF instead of
+ * resources that are children of an RDF collection (e.g. Sequence, Bag).
*/
- protected final Namespace getJuneauNs() {
- return ctx.getJuneauNs();
+ protected final boolean isLooseCollections() {
+ return ctx.isLooseCollections();
}
+ //-----------------------------------------------------------------------------------------------------------------
+ // Jena properties
+ //-----------------------------------------------------------------------------------------------------------------
+
/**
- * Configuration property: Default XML namespace for bean properties.
+ * Configuration property: All Jena-related configuration properties.
*
- * @see RdfParser#RDF_juneauBpNs
* @return
- * Default XML namespace for bean properties.
+ * A map of all Jena-related configuration properties.
*/
- protected final Namespace getJuneauBpNs() {
- return ctx.getJuneauBpNs();
+ protected final Map<String,Object> getJenaProperties() {
+ return ctx.getJenaProperties();
}
+ //-----------------------------------------------------------------------------------------------------------------
+ // Properties
+ //-----------------------------------------------------------------------------------------------------------------
+
/**
- * Configuration property: RDF format for representing collections and arrays.
+ * Configuration property: Trim whitespace from text elements.
*
- * @see RdfParser#RDF_collectionFormat
+ * @see RdfParser#RDF_trimWhitespace
* @return
- * RDF format for representing collections and arrays.
+ * <jk>true</jk> if whitespace in text elements will be automatically trimmed.
*/
- protected final RdfCollectionFormat getCollectionFormat() {
- return ctx.getCollectionFormat();
+ protected final boolean isTrimWhitespace() {
+ return ctx.isTrimWhitespace();
}
}
diff --git a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializer.java b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializer.java
index fb6da27..38ef48d 100644
--- a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializer.java
+++ b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializer.java
@@ -175,6 +175,27 @@ public class RdfSerializer extends WriterSerializer implements RdfCommon {
*/
public static final String RDF_namespaces = PREFIX + "namespaces.ls";
+ /**
+ * Configuration property: Reuse XML namespaces when RDF namespaces not specified.
+ *
+ * <h5 class='section'>Property:</h5>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.useXmlNamespaces.b"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * <li><b>Methods:</b>
+ * <ul>
+ * <li class='jm'>{@link RdfSerializerBuilder#useXmlNamespaces(boolean)}
+ * </ul>
+ * </ul>
+ *
+ * <h5 class='section'>Description:</h5>
+ * <p>
+ * When specified, namespaces defined using {@link XmlNs @XmlNs} and {@link Xml @Xml} will be inherited by the RDF serializers.
+ * <br>Otherwise, namespaces will be defined using {@link RdfNs @RdfNs} and {@link Rdf @Rdf}.
+ */
+ public static final String RDF_useXmlNamespaces = PREFIX + "useXmlNamespaces.b";
+
//-------------------------------------------------------------------------------------------------------------------
// Instance
//-------------------------------------------------------------------------------------------------------------------
@@ -190,7 +211,7 @@ public class RdfSerializer extends WriterSerializer implements RdfCommon {
private final Namespace juneauNs;
private final Namespace juneauBpNs;
private final RdfCollectionFormat collectionFormat;
- final Map<String,Object> jenaSettings;
+ final Map<String,Object> jenaProperties;
final Namespace[] namespaces;
/**
@@ -233,11 +254,11 @@ public class RdfSerializer extends WriterSerializer implements RdfCommon {
namespaces = getProperty(RDF_namespaces, Namespace[].class, new Namespace[0]);
addBeanTypes = getBooleanProperty(RDF_addBeanTypes, getBooleanProperty(SERIALIZER_addBeanTypes, false));
- Map<String,Object> m = new LinkedHashMap<>();
+ Map<String,Object> m = new TreeMap<>();
for (String k : getPropertyKeys("RdfCommon"))
if (k.startsWith("jena."))
- m.put(k.substring(5), getProperty(k));
- jenaSettings = unmodifiableMap(m);
+ m.put(k.substring(5), getProperty("RdfCommon." + k));
+ jenaProperties = unmodifiableMap(m);
}
/**
@@ -272,48 +293,62 @@ public class RdfSerializer extends WriterSerializer implements RdfCommon {
return new RdfSerializerBuilder();
}
+ @Override /* Context */
+ public RdfSerializerSession createSession() {
+ return createSession(createDefaultSessionArgs());
+ }
+
@Override /* Serializer */
- public WriterSerializerSession createSession(SerializerSessionArgs args) {
+ public RdfSerializerSession createSession(SerializerSessionArgs args) {
return new RdfSerializerSession(this, args);
}
//-----------------------------------------------------------------------------------------------------------------
- // Properties
+ // Common properties
//-----------------------------------------------------------------------------------------------------------------
/**
- * Configuration property: Add XSI data types to non-<code>String</code> literals.
+ * Configuration property: RDF format for representing collections and arrays.
*
- * @see #RDF_addLiteralTypes
+ * @see #RDF_collectionFormat
* @return
- * <jk>true</jk> if XSI data types should be added to string literals.
+ * RDF format for representing collections and arrays.
*/
- protected final boolean isAddLiteralTypes() {
- return addLiteralTypes;
+ protected final RdfCollectionFormat getCollectionFormat() {
+ return collectionFormat;
}
/**
- * Configuration property: Add RDF root identifier property to root node.
+ * Configuration property: Default XML namespace for bean properties.
*
- * @see #RDF_addRootProperty
+ * @see #RDF_juneauBpNs
* @return
- * <jk>true</jk> if RDF property <code>http://www.apache.org/juneau/root</code> is added with a value of <js>"true"</js>
- * to identify the root node in the graph.
+ * The XML namespace to use for bean properties.
*/
- protected final boolean isAddRootProp() {
- return addRootProperty;
+ protected final Namespace getJuneauBpNs() {
+ return juneauBpNs;
}
/**
- * Configuration property: Reuse XML namespaces when RDF namespaces not specified.
+ * Configuration property: XML namespace for Juneau properties.
*
- * @see #RDF_useXmlNamespaces
+ * @see #RDF_juneauNs
* @return
- * <jk>true</jk> if namespaces defined using {@link XmlNs @XmlNs} and {@link Xml @Xml} will be inherited by the RDF serializers.
- * <br>Otherwise, namespaces will be defined using {@link RdfNs @RdfNs} and {@link Rdf @Rdf}.
+ * The XML namespace to use for Juneau properties.
*/
- protected final boolean isUseXmlNamespaces() {
- return useXmlNamespaces;
+ protected final Namespace getJuneauNs() {
+ return juneauNs;
+ }
+
+ /**
+ * Configuration property: RDF language.
+ *
+ * @see #RDF_language
+ * @return
+ * The RDF language to use.
+ */
+ protected final String getLanguage() {
+ return rdfLanguage;
}
/**
@@ -328,17 +363,24 @@ public class RdfSerializer extends WriterSerializer implements RdfCommon {
return looseCollections;
}
+ //-----------------------------------------------------------------------------------------------------------------
+ // Jena properties
+ //-----------------------------------------------------------------------------------------------------------------
+
/**
- * Configuration property: Auto-detect namespace usage.
+ * Configuration property: All Jena-related configuration properties.
*
- * @see #RDF_autoDetectNamespaces
* @return
- * <jk>true</jk> if namespaces usage should be detected before serialization.
+ * A map of all Jena-related configuration properties.
*/
- protected final boolean isAutoDetectNamespaces() {
- return autoDetectNamespaces;
+ protected final Map<String,Object> getJenaProperties() {
+ return jenaProperties;
}
+ //-----------------------------------------------------------------------------------------------------------------
+ // Properties
+ //-----------------------------------------------------------------------------------------------------------------
+
/**
* Configuration property: Add <js>"_type"</js> properties when needed.
*
@@ -353,49 +395,66 @@ public class RdfSerializer extends WriterSerializer implements RdfCommon {
}
/**
- * Configuration property: RDF language.
+ * Configuration property: Add XSI data types to non-<code>String</code> literals.
*
- * @see #RDF_language
+ * @see #RDF_addLiteralTypes
* @return
- * The RDF language to use.
+ * <jk>true</jk> if XSI data types should be added to string literals.
*/
- protected final String getRdfLanguage() {
- return rdfLanguage;
+ protected final boolean isAddLiteralTypes() {
+ return addLiteralTypes;
}
/**
- * Configuration property: XML namespace for Juneau properties.
+ * Configuration property: Add RDF root identifier property to root node.
*
- * @see #RDF_juneauNs
+ * @see #RDF_addRootProperty
* @return
- * The XML namespace to use for Juneau properties.
+ * <jk>true</jk> if RDF property <code>http://www.apache.org/juneau/root</code> is added with a value of <js>"true"</js>
+ * to identify the root node in the graph.
*/
- protected final Namespace getJuneauNs() {
- return juneauNs;
+ protected final boolean isAddRootProperty() {
+ return addRootProperty;
}
/**
- * Configuration property: Default XML namespace for bean properties.
+ * Configuration property: Auto-detect namespace usage.
*
- * @see #RDF_juneauBpNs
+ * @see #RDF_autoDetectNamespaces
* @return
- * The XML namespace to use for bean properties.
+ * <jk>true</jk> if namespaces usage should be detected before serialization.
*/
- protected final Namespace getJuneauBpNs() {
- return juneauBpNs;
+ protected final boolean isAutoDetectNamespaces() {
+ return autoDetectNamespaces;
}
/**
- * Configuration property: RDF format for representing collections and arrays.
+ * Configuration property: Default namespaces.
*
- * @see #RDF_collectionFormat
+ * @see #RDF_namespaces
* @return
- * RDF format for representing collections and arrays.
+ * The default list of namespaces associated with this serializer.
*/
- protected final RdfCollectionFormat getCollectionFormat() {
- return collectionFormat;
+ public Namespace[] getNamespaces() {
+ return namespaces;
}
+ /**
+ * Configuration property: Reuse XML namespaces when RDF namespaces not specified.
+ *
+ * @see #RDF_useXmlNamespaces
+ * @return
+ * <jk>true</jk> if namespaces defined using {@link XmlNs @XmlNs} and {@link Xml @Xml} will be inherited by the RDF serializers.
+ * <br>Otherwise, namespaces will be defined using {@link RdfNs @RdfNs} and {@link Rdf @Rdf}.
+ */
+ protected final boolean isUseXmlNamespaces() {
+ return useXmlNamespaces;
+ }
+
+ //-----------------------------------------------------------------------------------------------------------------
+ // Other methods
+ //-----------------------------------------------------------------------------------------------------------------
+
@Override /* Context */
public ObjectMap asMap() {
return super.asMap()
diff --git a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerBuilder.java b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerBuilder.java
index 8cb7062..32fed99 100644
--- a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerBuilder.java
+++ b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerBuilder.java
@@ -19,9 +19,7 @@ import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.http.*;
-import org.apache.juneau.internal.*;
import org.apache.juneau.jena.annotation.*;
-import org.apache.juneau.parser.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.utils.*;
@@ -55,87 +53,6 @@ public class RdfSerializerBuilder extends WriterSerializerBuilder {
}
//-----------------------------------------------------------------------------------------------------------------
- // Annotations
- //-----------------------------------------------------------------------------------------------------------------
-
- @Override
- public RdfSerializerBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) throws ParseException {
- super.applyAnnotations(m, sr);
- if (! m.containsKey(RdfConfig.class))
- return this;
- ObjectResolver r = new ObjectResolver(sr);
- for (RdfConfig a : m.get(RdfConfig.class)) {
- if (! a.language().isEmpty())
- language(r.string(a.language()));
- if (! a.juneauNs().isEmpty())
- juneauNs(r.string(a.juneauNs()));
- if (! a.juneauBpNs().isEmpty())
- juneauBpNs(r.string(a.juneauBpNs()));
- if (! a.useXmlNamespaces().isEmpty())
- useXmlNamespaces(r.bool(a.useXmlNamespaces()));
- if (! a.arp_iriRules().isEmpty())
- arp_iriRules(r.string(a.arp_iriRules()));
- if (! a.arp_errorMode().isEmpty())
- arp_errorMode(r.string(a.arp_errorMode()));
- if (! a.arp_embedding().isEmpty())
- arp_embedding(r.bool(a.arp_embedding()));
- if (! a.rdfxml_xmlBase().isEmpty())
- rdfxml_xmlBase(r.string(a.rdfxml_xmlBase()));
- if (! a.rdfxml_longId().isEmpty())
- rdfxml_longId(r.bool(a.rdfxml_longId()));
- if (! a.rdfxml_allowBadUris().isEmpty())
- rdfxml_allowBadUris(r.bool(a.rdfxml_allowBadUris()));
- if (! a.rdfxml_relativeUris().isEmpty())
- rdfxml_relativeUris(r.string(a.rdfxml_relativeUris()));
- if (! a.rdfxml_showXmlDeclaration().isEmpty())
- rdfxml_showXmlDeclaration(r.string(a.rdfxml_showXmlDeclaration()));
- if (! a.rdfxml_showDoctypeDeclaration().isEmpty())
- rdfxml_showDoctypeDeclaration(r.bool(a.rdfxml_showDoctypeDeclaration()));
- if (! a.rdfxml_tab().isEmpty())
- rdfxml_tab(r.integer(a.rdfxml_tab()));
- if (! a.rdfxml_attributeQuoteChar().isEmpty())
- rdfxml_attributeQuoteChar(r.string(a.rdfxml_attributeQuoteChar()));
- if (! a.rdfxml_blockRules().isEmpty())
- rdfxml_blockRules(r.string(a.rdfxml_blockRules()));
- if (! a.n3_minGap().isEmpty())
- n3_minGap(r.integer(a.n3_minGap()));
- if (! a.n3_objectLists().isEmpty())
- n3_objectLists(r.bool(a.n3_objectLists()));
- if (! a.n3_subjectColumn().isEmpty())
- n3_subjectColumn(r.integer(a.n3_subjectColumn()));
- if (! a.n3_propertyColumn().isEmpty())
- n3_propertyColumn(r.integer(a.n3_propertyColumn()));
- if (! a.n3_indentProperty().isEmpty())
- n3_indentProperty(r.integer(a.n3_indentProperty()));
- if (! a.n3_widePropertyLen().isEmpty())
- n3_widePropertyLen(r.integer(a.n3_widePropertyLen()));
- if (! a.n3_abbrevBaseUri().isEmpty())
- n3_abbrevBaseUri(r.bool(a.n3_abbrevBaseUri()));
- if (! a.n3_usePropertySymbols().isEmpty())
- n3_usePropertySymbols(r.bool(a.n3_usePropertySymbols()));
- if (! a.n3_useTripleQuotedStrings().isEmpty())
- n3_useTripleQuotedStrings(r.bool(a.n3_useTripleQuotedStrings()));
- if (! a.n3_useDoubles().isEmpty())
- n3_useDoubles(r.bool(a.n3_useDoubles()));
- if (! a.collectionFormat().isEmpty())
- collectionFormat(r.string(a.collectionFormat()));
- if (! a.looseCollections().isEmpty())
- looseCollections(r.bool(a.looseCollections()));
- if (! a.addBeanTypes().isEmpty())
- addBeanTypes(r.bool(a.addBeanTypes()));
- if (! a.addLiteralTypes().isEmpty())
- addLiteralTypes(r.bool(a.addLiteralTypes()));
- if (! a.addRootProperty().isEmpty())
- addRootProperty(r.bool(a.addRootProperty()));
- if (! a.autoDetectNamespaces().isEmpty())
- autoDetectNamespaces(r.bool(a.autoDetectNamespaces()));
- if (a.namespaces().length > 0)
- namespaces(r.strings(a.namespaces()));
- }
- return this;
- }
-
- //-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
@@ -1544,12 +1461,6 @@ public class RdfSerializerBuilder extends WriterSerializerBuilder {
}
@Override /* ContextBuilder */
- public RdfSerializerBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public RdfSerializerBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
@@ -1584,4 +1495,10 @@ public class RdfSerializerBuilder extends WriterSerializerBuilder {
super.apply(copyFrom);
return this;
}
+
+ @Override
+ public RdfSerializerBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) {
+ super.applyAnnotations(m, sr);
+ return this;
+ }
}
diff --git a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
index 98aca28..0610a85 100644
--- a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
+++ b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
@@ -66,12 +66,12 @@ public final class RdfSerializerSession extends WriterSerializerSession {
addModelPrefix(ns);
pRoot = model.createProperty(ctx.getJuneauNs().getUri(), RDF_juneauNs_ROOT);
pValue = model.createProperty(ctx.getJuneauNs().getUri(), RDF_juneauNs_VALUE);
- writer = model.getWriter(ctx.getRdfLanguage());
+ writer = model.getWriter(ctx.getLanguage());
// Only apply properties with this prefix!
- String propPrefix = RdfCommon.LANG_PROP_MAP.get(ctx.getRdfLanguage());
+ String propPrefix = RdfCommon.LANG_PROP_MAP.get(ctx.getLanguage());
if (propPrefix == null)
- throw new FormattedRuntimeException("Unknown RDF language encountered: ''{0}''", ctx.getRdfLanguage());
+ throw new FormattedRuntimeException("Unknown RDF language encountered: ''{0}''", ctx.getLanguage());
// RDF/XML specific properties.
if (propPrefix.equals("rdfXml.")) {
@@ -79,7 +79,7 @@ public final class RdfSerializerSession extends WriterSerializerSession {
writer.setProperty("attributeQuoteChar", Character.toString(getQuoteChar()));
}
- for (Map.Entry<String,Object> e : ctx.jenaSettings.entrySet())
+ for (Map.Entry<String,Object> e : ctx.jenaProperties.entrySet())
if (e.getKey().startsWith(propPrefix, 5))
writer.setProperty(e.getKey().substring(5 + propPrefix.length()), e.getValue());
@@ -138,7 +138,7 @@ public final class RdfSerializerSession extends WriterSerializerSession {
r = n.asResource();
}
- if (isAddRootProp())
+ if (isAddRootProperty())
r.addProperty(pRoot, "true");
}
@@ -402,42 +402,51 @@ public final class RdfSerializerSession extends WriterSerializerSession {
}
//-----------------------------------------------------------------------------------------------------------------
- // Properties
+ // Common properties
//-----------------------------------------------------------------------------------------------------------------
/**
- * Configuration property: Add XSI data types to non-<code>String</code> literals.
+ * Configuration property: RDF format for representing collections and arrays.
*
- * @see RdfSerializer#RDF_addLiteralTypes
+ * @see RdfSerializer#RDF_collectionFormat
* @return
- * <jk>true</jk> if XSI data types should be added to string literals.
+ * RDF format for representing collections and arrays.
*/
- protected final boolean isAddLiteralTypes() {
- return ctx.isAddLiteralTypes();
+ protected final RdfCollectionFormat getCollectionFormat() {
+ return ctx.getCollectionFormat();
}
/**
- * Configuration property: Add RDF root identifier property to root node.
+ * Configuration property: Default XML namespace for bean properties.
*
- * @see RdfSerializer#RDF_addRootProperty
+ * @see RdfSerializer#RDF_juneauBpNs
* @return
- * <jk>true</jk> if RDF property <code>http://www.apache.org/juneau/root</code> is added with a value of <js>"true"</js>
- * to identify the root node in the graph.
+ * The XML namespace to use for bean properties.
*/
- protected final boolean isAddRootProp() {
- return ctx.isAddRootProp();
+ protected final Namespace getJuneauBpNs() {
+ return ctx.getJuneauBpNs();
}
/**
- * Configuration property: Reuse XML namespaces when RDF namespaces not specified.
+ * Configuration property: XML namespace for Juneau properties.
*
- * @see RdfSerializer#RDF_useXmlNamespaces
+ * @see RdfSerializer#RDF_juneauNs
* @return
- * <jk>true</jk> if namespaces defined using {@link XmlNs @XmlNs} and {@link org.apache.juneau.xml.annotation.Xml @Xml} will be inherited by the RDF serializers.
- * <br>Otherwise, namespaces will be defined using {@link RdfNs @RdfNs} and {@link Rdf @Rdf}.
+ * The XML namespace to use for Juneau properties.
*/
- protected final boolean isUseXmlNamespaces() {
- return ctx.isUseXmlNamespaces();
+ protected final Namespace getJuneauNs() {
+ return ctx.getJuneauNs();
+ }
+
+ /**
+ * Configuration property: RDF language.
+ *
+ * @see RdfSerializer#RDF_language
+ * @return
+ * The RDF language to use.
+ */
+ protected final String getLanguage() {
+ return ctx.getLanguage();
}
/**
@@ -452,17 +461,24 @@ public final class RdfSerializerSession extends WriterSerializerSession {
return ctx.isLooseCollections();
}
+ //-----------------------------------------------------------------------------------------------------------------
+ // Jena properties
+ //-----------------------------------------------------------------------------------------------------------------
+
/**
- * Configuration property: Auto-detect namespace usage.
+ * Configuration property: All Jena-related configuration properties.
*
- * @see RdfSerializer#RDF_autoDetectNamespaces
* @return
- * <jk>true</jk> if namespaces usage should be detected before serialization.
+ * A map of all Jena-related configuration properties.
*/
- protected final boolean isAutoDetectNamespaces() {
- return ctx.isAutoDetectNamespaces();
+ protected final Map<String,Object> getJenaProperties() {
+ return ctx.getJenaProperties();
}
+ //-----------------------------------------------------------------------------------------------------------------
+ // Properties
+ //-----------------------------------------------------------------------------------------------------------------
+
/**
* Configuration property: Add <js>"_type"</js> properties when needed.
*
@@ -477,46 +493,59 @@ public final class RdfSerializerSession extends WriterSerializerSession {
}
/**
- * Configuration property: RDF language.
+ * Configuration property: Add XSI data types to non-<code>String</code> literals.
*
- * @see RdfSerializer#RDF_language
+ * @see RdfSerializer#RDF_addLiteralTypes
* @return
- * The RDF language to use.
+ * <jk>true</jk> if XSI data types should be added to string literals.
*/
- protected final String getRdfLanguage() {
- return ctx.getRdfLanguage();
+ protected final boolean isAddLiteralTypes() {
+ return ctx.isAddLiteralTypes();
}
/**
- * Configuration property: XML namespace for Juneau properties.
+ * Configuration property: Add RDF root identifier property to root node.
*
- * @see RdfSerializer#RDF_juneauNs
+ * @see RdfSerializer#RDF_addRootProperty
* @return
- * The XML namespace to use for Juneau properties.
+ * <jk>true</jk> if RDF property <code>http://www.apache.org/juneau/root</code> is added with a value of <js>"true"</js>
+ * to identify the root node in the graph.
*/
- protected final Namespace getJuneauNs() {
- return ctx.getJuneauNs();
+ protected final boolean isAddRootProperty() {
+ return ctx.isAddRootProperty();
}
/**
- * Configuration property: Default XML namespace for bean properties.
+ * Configuration property: Auto-detect namespace usage.
*
- * @see RdfSerializer#RDF_juneauBpNs
+ * @see RdfSerializer#RDF_autoDetectNamespaces
* @return
- * The XML namespace to use for bean properties.
+ * <jk>true</jk> if namespaces usage should be detected before serialization.
*/
- protected final Namespace getJuneauBpNs() {
- return ctx.getJuneauBpNs();
+ protected final boolean isAutoDetectNamespaces() {
+ return ctx.isAutoDetectNamespaces();
}
/**
- * Configuration property: RDF format for representing collections and arrays.
+ * Configuration property: Default namespaces.
*
- * @see RdfSerializer#RDF_collectionFormat
+ * @see #RDF_namespaces
* @return
- * RDF format for representing collections and arrays.
+ * The default list of namespaces associated with this serializer.
*/
- protected final RdfCollectionFormat getCollectionFormat() {
- return ctx.getCollectionFormat();
+ protected final Namespace[] getNamespaces() {
+ return ctx.getNamespaces();
+ }
+
+ /**
+ * Configuration property: Reuse XML namespaces when RDF namespaces not specified.
+ *
+ * @see RdfSerializer#RDF_useXmlNamespaces
+ * @return
+ * <jk>true</jk> if namespaces defined using {@link XmlNs @XmlNs} and {@link org.apache.juneau.xml.annotation.Xml @Xml} will be inherited by the RDF serializers.
+ * <br>Otherwise, namespaces will be defined using {@link RdfNs @RdfNs} and {@link Rdf @Rdf}.
+ */
+ protected final boolean isUseXmlNamespaces() {
+ return ctx.isUseXmlNamespaces();
}
}
diff --git a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfConfig.java b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfConfig.java
index 9887745..b076631 100644
--- a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfConfig.java
+++ b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfConfig.java
@@ -17,6 +17,7 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
+import org.apache.juneau.annotation.*;
import org.apache.juneau.jena.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.xml.*;
@@ -29,9 +30,10 @@ import org.apache.juneau.xml.annotation.*;
* Used primarily for specifying bean configuration properties on REST classes and methods.
*/
@Documented
-@Target(TYPE)
+@Target({TYPE,METHOD})
@Retention(RUNTIME)
@Inherited
+@PropertyStoreApply(RdfConfigApply.class)
public @interface RdfConfig {
//-------------------------------------------------------------------------------------------------------------------
@@ -43,7 +45,7 @@ public @interface RdfConfig {
*
* <p>
* The RDF language to use.
- *
+ *
* <p>
* Can be any of the following:
* <ul class='spaced-list'>
@@ -102,27 +104,6 @@ public @interface RdfConfig {
String juneauBpNs() default "";
/**
- * Configuration property: Reuse XML namespaces when RDF namespaces not specified.
- *
- * <p>
- * When specified, namespaces defined using {@link XmlNs @XmlNs} and {@link Xml @Xml} will be inherited by the RDF serializers.
- * <br>Otherwise, namespaces will be defined using {@link RdfNs @RdfNs} and {@link Rdf @Rdf}.
- *
- * <p>
- * Possible values:
- * <ul>
- * <li><js>"true"</js> (default)
- * <li><js>"false"</js>
- * </ul>
- *
- * <h5 class='section'>See Also:</h5>
- * <ul>
- * <li class='jf'>{@link RdfCommon#RDF_useXmlNamespaces}
- * </ul>
- */
- String useXmlNamespaces() default "";
-
- /**
* Configuration property: RDF/XML property: <code>iri_rules</code>.
*
* <p>
@@ -635,4 +616,25 @@ public @interface RdfConfig {
* </ul>
*/
String[] namespaces() default {};
+
+ /**
+ * Configuration property: Reuse XML namespaces when RDF namespaces not specified.
+ *
+ * <p>
+ * When specified, namespaces defined using {@link XmlNs @XmlNs} and {@link Xml @Xml} will be inherited by the RDF serializers.
+ * <br>Otherwise, namespaces will be defined using {@link RdfNs @RdfNs} and {@link Rdf @Rdf}.
+ *
+ * <p>
+ * Possible values:
+ * <ul>
+ * <li><js>"true"</js> (default)
+ * <li><js>"false"</js>
+ * </ul>
+ *
+ * <h5 class='section'>See Also:</h5>
+ * <ul>
+ * <li class='jf'>{@link RdfSerializer#RDF_useXmlNamespaces}
+ * </ul>
+ */
+ String useXmlNamespaces() default "";
}
diff --git a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfConfigApply.java b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfConfigApply.java
new file mode 100644
index 0000000..c44ba5d
--- /dev/null
+++ b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfConfigApply.java
@@ -0,0 +1,110 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.jena.annotation;
+
+import static org.apache.juneau.jena.RdfCommon.*;
+import static org.apache.juneau.jena.RdfSerializer.*;
+import static org.apache.juneau.jena.RdfParser.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.utils.*;
+
+/**
+ * Applies {@link RdfConfig} annotations to a {@link PropertyStoreBuilder}.
+ */
+public class RdfConfigApply extends ConfigApply<RdfConfig> {
+
+ /**
+ * Constructor.
+ *
+ * @param c The annotation class.
+ * @param r The resolver for resolving values in annotations.
+ */
+ public RdfConfigApply(Class<RdfConfig> c, StringResolver r) {
+ super(c, r);
+ }
+
+ @Override
+ public void apply(RdfConfig a, PropertyStoreBuilder psb) {
+ if (! a.language().isEmpty())
+ psb.set(RDF_language, string(a.language()));
+ if (! a.juneauNs().isEmpty())
+ psb.set(RDF_juneauNs, string(a.juneauNs()));
+ if (! a.juneauBpNs().isEmpty())
+ psb.set(RDF_juneauBpNs, string(a.juneauBpNs()));
+ if (! a.useXmlNamespaces().isEmpty())
+ psb.set(RDF_useXmlNamespaces, bool(a.useXmlNamespaces()));
+ if (! a.arp_iriRules().isEmpty())
+ psb.set(RDF_arp_iriRules, string(a.arp_iriRules()));
+ if (! a.arp_errorMode().isEmpty())
+ psb.set(RDF_arp_errorMode, string(a.arp_errorMode()));
+ if (! a.arp_embedding().isEmpty())
+ psb.set(RDF_arp_embedding, bool(a.arp_embedding()));
+ if (! a.rdfxml_xmlBase().isEmpty())
+ psb.set(RDF_rdfxml_xmlBase, string(a.rdfxml_xmlBase()));
+ if (! a.rdfxml_longId().isEmpty())
+ psb.set(RDF_rdfxml_longId, bool(a.rdfxml_longId()));
+ if (! a.rdfxml_allowBadUris().isEmpty())
+ psb.set(RDF_rdfxml_allowBadUris, bool(a.rdfxml_allowBadUris()));
+ if (! a.rdfxml_relativeUris().isEmpty())
+ psb.set(RDF_rdfxml_relativeUris, string(a.rdfxml_relativeUris()));
+ if (! a.rdfxml_showXmlDeclaration().isEmpty())
+ psb.set(RDF_rdfxml_showXmlDeclaration, string(a.rdfxml_showXmlDeclaration()));
+ if (! a.rdfxml_showDoctypeDeclaration().isEmpty())
+ psb.set(RDF_rdfxml_showDoctypeDeclaration, bool(a.rdfxml_showDoctypeDeclaration()));
+ if (! a.rdfxml_tab().isEmpty())
+ psb.set(RDF_rdfxml_tab, integer(a.rdfxml_tab(), "rdfxml_tab"));
+ if (! a.rdfxml_attributeQuoteChar().isEmpty())
+ psb.set(RDF_rdfxml_attributeQuoteChar, string(a.rdfxml_attributeQuoteChar()));
+ if (! a.rdfxml_blockRules().isEmpty())
+ psb.set(RDF_rdfxml_blockRules, string(a.rdfxml_blockRules()));
+ if (! a.n3_minGap().isEmpty())
+ psb.set(RDF_n3_minGap, integer(a.n3_minGap(), "n3_minGap"));
+ if (! a.n3_objectLists().isEmpty())
+ psb.set(RDF_n3_objectLists, bool(a.n3_objectLists()));
+ if (! a.n3_subjectColumn().isEmpty())
+ psb.set(RDF_n3_subjectColumn, integer(a.n3_subjectColumn(), "n3_subjectColumn"));
+ if (! a.n3_propertyColumn().isEmpty())
+ psb.set(RDF_n3_propertyColumn, integer(a.n3_propertyColumn(), "n3_propertyColumn"));
+ if (! a.n3_indentProperty().isEmpty())
+ psb.set(RDF_n3_indentProperty, integer(a.n3_indentProperty(), "n3_indentProperty"));
+ if (! a.n3_widePropertyLen().isEmpty())
+ psb.set(RDF_n3_widePropertyLen, integer(a.n3_widePropertyLen(), "n3_widePropertyLen"));
+ if (! a.n3_abbrevBaseUri().isEmpty())
+ psb.set(RDF_n3_abbrevBaseUri, bool(a.n3_abbrevBaseUri()));
+ if (! a.n3_usePropertySymbols().isEmpty())
+ psb.set(RDF_n3_usePropertySymbols, bool(a.n3_usePropertySymbols()));
+ if (! a.n3_useTripleQuotedStrings().isEmpty())
+ psb.set(RDF_n3_useTripleQuotedStrings, bool(a.n3_useTripleQuotedStrings()));
+ if (! a.n3_useDoubles().isEmpty())
+ psb.set(RDF_n3_useDoubles, bool(a.n3_useDoubles()));
+ if (! a.collectionFormat().isEmpty())
+ psb.set(RDF_collectionFormat, string(a.collectionFormat()));
+ if (! a.looseCollections().isEmpty())
+ psb.set(RDF_looseCollections, bool(a.looseCollections()));
+
+ if (! a.addBeanTypes().isEmpty())
+ psb.set(RDF_addBeanTypes, bool(a.addBeanTypes()));
+ if (! a.addLiteralTypes().isEmpty())
+ psb.set(RDF_addLiteralTypes, bool(a.addLiteralTypes()));
+ if (! a.addRootProperty().isEmpty())
+ psb.set(RDF_addRootProperty, bool(a.addRootProperty()));
+ if (! a.autoDetectNamespaces().isEmpty())
+ psb.set(RDF_autoDetectNamespaces, bool(a.autoDetectNamespaces()));
+ if (a.namespaces().length > 0)
+ psb.set(RDF_namespaces, strings(a.namespaces()));
+
+ if (! a.trimWhitespace().isEmpty())
+ psb.set(RDF_trimWhitespace, bool(a.trimWhitespace()));
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
index 23617be..852ea72 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
@@ -2607,10 +2607,17 @@ public class BeanContext extends Context {
Object o = examples.get(c.getName());
if (o != null)
return o;
+ o = examples.get(c.getSimpleName());
+ if (o != null)
+ return o;
Class<?> c2 = findImplClass(c);
if (c2 == null)
return null;
- return examples.get(c2.getName());
+ o = examples.get(c2.getName());
+ if (o != null)
+ return o;
+ o = examples.get(c2.getSimpleName());
+ return o;
}
return null;
}
@@ -2801,6 +2808,86 @@ public class BeanContext extends Context {
//-----------------------------------------------------------------------------------------------------------------
/**
+ * Configuration property: Minimum bean class visibility.
+ *
+ * @see #BEAN_beanClassVisibility
+ * @return
+ * Classes are not considered beans unless they meet the minimum visibility requirements.
+ */
+ protected final Visibility getBeanClassVisibility() {
+ return beanClassVisibility;
+ }
+
+ /**
+ * Configuration property: Minimum bean constructor visibility.
+ *
+ * @see #BEAN_beanConstructorVisibility
+ * @return
+ * Only look for constructors with this specified minimum visibility.
+ */
+ protected final Visibility getBeanConstructorVisibility() {
+ return beanConstructorVisibility;
+ }
+
+ /**
+ * Configuration property: Bean dictionary.
+ *
+ * @see #BEAN_beanDictionary
+ * @return
+ * The list of classes that make up the bean dictionary in this bean context.
+ */
+ protected final List<Class<?>> getBeanDictionaryClasses() {
+ return beanDictionaryClasses;
+ }
+
+ /**
+ * Configuration property: Minimum bean field visibility.
+ *
+ *
+ * @see #BEAN_beanFieldVisibility
+ * @return
+ * Only look for bean fields with this specified minimum visibility.
+ */
+ protected final Visibility getBeanFieldVisibility() {
+ return beanFieldVisibility;
+ }
+
+ /**
+ * Configuration property: Bean filters.
+ *
+ *
+ * @see BeanContext#BEAN_beanFilters
+ * @return
+ * Only look for bean fields with this specified minimum visibility.
+ */
+ protected final BeanFilter[] getBeanFilters() {
+ return beanFilters;
+ }
+
+ /**
+ * Configuration property: BeanMap.put() returns old property value.
+ *
+ * @see #BEAN_beanMapPutReturnsOldValue
+ * @return
+ * <jk>true</jk> if the {@link BeanMap#put(String,Object) BeanMap.put()} method will return old property values.
+ * <br>Otherwise, it returns <jk>null</jk>.
+ */
+ protected final boolean isBeanMapPutReturnsOldValue() {
+ return beanMapPutReturnsOldValue;
+ }
+
+ /**
+ * Configuration property: Minimum bean method visibility.
+ *
+ * @see #BEAN_beanMethodVisibility
+ * @return
+ * Only look for bean methods with this specified minimum visibility.
+ */
+ protected final Visibility getBeanMethodVisibility() {
+ return beanMethodVisibility;
+ }
+
+ /**
* Configuration property: Beans require no-arg constructors.
*
* @see #BEAN_beansRequireDefaultConstructor
@@ -2849,63 +2936,61 @@ public class BeanContext extends Context {
}
/**
- * Configuration property: BeanMap.put() returns old property value.
+ * Configuration property: Bean type property name.
*
- * @see #BEAN_beanMapPutReturnsOldValue
+ * @see #BEAN_beanTypePropertyName
* @return
- * <jk>true</jk> if the {@link BeanMap#put(String,Object) BeanMap.put()} method will return old property values.
- * <br>Otherwise, it returns <jk>null</jk>.
+ * The name of the bean property used to store the dictionary name of a bean type so that the parser knows the data type to reconstruct.
*/
- protected final boolean isBeanMapPutReturnsOldValue() {
- return beanMapPutReturnsOldValue;
+ protected final String getBeanTypePropertyName() {
+ return beanTypePropertyName;
}
/**
- * Configuration property: Use interface proxies.
+ * Configuration property: Debug mode.
*
- * @see #BEAN_useInterfaceProxies
+ * @see #BEAN_debug
* @return
- * <jk>true</jk> if interfaces will be instantiated as proxy classes through the use of an
- * {@link InvocationHandler} if there is no other way of instantiating them.
+ * <jk>true</jk> if debug mode is enabled.
*/
- protected final boolean isUseInterfaceProxies() {
- return useInterfaceProxies;
+ protected boolean isDebug() {
+ return debug;
}
/**
- * Configuration property: Ignore unknown properties.
+ * Configuration property: POJO examples.
*
- * @see #BEAN_ignoreUnknownBeanProperties
+ * @see #BEAN_examples
* @return
- * <jk>true</jk> if trying to set a value on a non-existent bean property is silently ignored.
- * <br>Otherwise, a {@code RuntimeException} is thrown.
+ * A map of POJO examples keyed by class name.
*/
- protected final boolean isIgnoreUnknownBeanProperties() {
- return ignoreUnknownBeanProperties;
+ protected final Map<String,?> getExamples() {
+ return examples;
}
/**
- * Configuration property: Ignore unknown properties with null values.
+ * Configuration property: Bean property excludes.
*
- * @see #BEAN_ignoreUnknownNullBeanProperties
+ * @see #BEAN_excludeProperties
* @return
- * <jk>true</jk> if trying to set a <jk>null</jk> value on a non-existent bean property is silently ignored.
+ * The list of property names to exclude keyed by class name.
*/
- protected final boolean isIgnoreUnknownNullBeanProperties() {
- return ignoreUnknownNullBeanProperties;
+ protected final Map<String,String[]> getExcludeProperties() {
+ return excludeProperties;
}
/**
- * Configuration property: Ignore properties without setters.
+ * Configuration property: Find fluent setters.
*
- * <br>Otherwise, a {@code RuntimeException} is thrown.
+ * <h5 class='section'>Description:</h5>
+ * <p>
*
- * @see #BEAN_ignorePropertiesWithoutSetters
+ * @see #BEAN_fluentSetters
* @return
- * <jk>true</jk> if trying to set a value on a bean property without a setter is silently ignored.
+ * <jk>true</jk> if fluent setters are detected on beans.
*/
- protected final boolean isIgnorePropertiesWithoutSetters() {
- return ignorePropertiesWithoutSetters;
+ protected final boolean isFluentSetters() {
+ return fluentSetters;
}
/**
@@ -2931,128 +3016,149 @@ public class BeanContext extends Context {
}
/**
- * Configuration property: Use Java Introspector.
+ * Configuration property: Ignore properties without setters.
*
- * @see #BEAN_useJavaBeanIntrospector
+ * <br>Otherwise, a {@code RuntimeException} is thrown.
+ *
+ * @see #BEAN_ignorePropertiesWithoutSetters
* @return
- * <jk>true</jk> if the built-in Java bean introspector should be used for bean introspection.
+ * <jk>true</jk> if trying to set a value on a bean property without a setter is silently ignored.
*/
- protected final boolean isUseJavaBeanIntrospector() {
- return useJavaBeanIntrospector;
+ protected final boolean isIgnorePropertiesWithoutSetters() {
+ return ignorePropertiesWithoutSetters;
}
/**
- * Configuration property: Use enum names.
+ * Configuration property: Ignore unknown properties.
*
- * @see #BEAN_useEnumNames
+ * @see #BEAN_ignoreUnknownBeanProperties
* @return
- * <jk>true</jk> if enums are always serialized by name, not using {@link Object#toString()}.
+ * <jk>true</jk> if trying to set a value on a non-existent bean property is silently ignored.
+ * <br>Otherwise, a {@code RuntimeException} is thrown.
*/
- protected final boolean isUseEnumNames() {
- return useEnumNames;
+ protected final boolean isIgnoreUnknownBeanProperties() {
+ return ignoreUnknownBeanProperties;
}
/**
- * Configuration property: Sort bean properties.
+ * Configuration property: Ignore unknown properties with null values.
*
- * @see #BEAN_sortProperties
+ * @see #BEAN_ignoreUnknownNullBeanProperties
* @return
- * <jk>true</jk> if all bean properties will be serialized and access in alphabetical order.
+ * <jk>true</jk> if trying to set a <jk>null</jk> value on a non-existent bean property is silently ignored.
*/
- protected final boolean isSortProperties() {
- return sortProperties;
+ protected final boolean isIgnoreUnknownNullBeanProperties() {
+ return ignoreUnknownNullBeanProperties;
}
/**
- * Configuration property: Find fluent setters.
+ * Configuration property: Implementation classes.
*
- * <h5 class='section'>Description:</h5>
- * <p>
+ * @see #BEAN_implClasses
+ * @return
+ * Implementation classes keyed by interface class names.
+ */
+ protected final Map<String,ClassInfo> getImplClasses() {
+ return implClasses;
+ }
+
+ /**
+ * Configuration property: Bean property includes.
*
- * @see #BEAN_fluentSetters
+ * @see #BEAN_includeProperties
* @return
- * <jk>true</jk> if fluent setters are detected on beans.
+ * Include properties keyed by class name.
*/
- protected final boolean isFluentSetters() {
- return fluentSetters;
+ protected final Map<String,String[]> getIncludeProperties() {
+ return includeProperties;
}
/**
- * Configuration property: Debug mode.
+ * Configuration property: Locale.
*
- * @see #BEAN_debug
+ * @see #BEAN_locale
* @return
- * <jk>true</jk> if debug mode is enabled.
+ * The default locale for serializer and parser sessions.
*/
- protected boolean isDebug() {
- return debug;
+ protected final Locale getLocale() {
+ return locale;
}
/**
- * Configuration property: Minimum bean constructor visibility.
+ * Configuration property: Media type.
*
- * @see #BEAN_beanConstructorVisibility
+ * @see #BEAN_mediaType
* @return
- * Only look for constructors with this specified minimum visibility.
+ * The default media type value for serializer and parser sessions.
*/
- protected final Visibility getBeanConstructorVisibility() {
- return beanConstructorVisibility;
+ protected final MediaType getMediaType() {
+ return mediaType;
}
/**
- * Configuration property: Minimum bean class visibility.
+ * Configuration property: Bean class exclusions.
*
- * @see #BEAN_beanClassVisibility
+ * @see #BEAN_notBeanClasses
* @return
- * Classes are not considered beans unless they meet the minimum visibility requirements.
+ * The list of classes that are explicitly not beans.
*/
- protected final Visibility getBeanClassVisibility() {
- return beanClassVisibility;
+ protected final Class<?>[] getNotBeanClasses() {
+ return notBeanClasses;
}
/**
- * Configuration property: Minimum bean method visibility.
+ * Configuration property: Bean package exclusions.
*
- * @see #BEAN_beanMethodVisibility
+ * @see #BEAN_notBeanPackages
* @return
- * Only look for bean methods with this specified minimum visibility.
+ * The list of fully-qualified package names to exclude from being classified as beans.
*/
- protected final Visibility getBeanMethodVisibility() {
- return beanMethodVisibility;
+ protected final String[] getNotBeanPackagesNames() {
+ return notBeanPackageNames;
}
/**
- * Configuration property: Minimum bean field visibility.
+ * Configuration property: Bean package exclusions.
*
+ * @see #BEAN_notBeanPackages
+ * @return
+ * The list of package name prefixes to exclude from being classified as beans.
+ */
+ protected final String[] getNotBeanPackagesPrefixes() {
+ return notBeanPackagePrefixes;
+ }
+
+ /**
+ * Configuration property: POJO swaps.
*
- * @see #BEAN_beanFieldVisibility
+ * @see #BEAN_pojoSwaps
* @return
- * Only look for bean fields with this specified minimum visibility.
+ * The list POJO swaps defined.
*/
- protected final Visibility getBeanFieldVisibility() {
- return beanFieldVisibility;
+ protected final PojoSwap<?,?>[] getPojoSwaps() {
+ return pojoSwaps;
}
/**
- * Configuration property: Bean dictionary.
+ * Configuration property: Bean property namer.
*
- * @see #BEAN_beanDictionary
+ * @see #BEAN_propertyNamer
* @return
- * The list of classes that make up the bean dictionary in this bean context.
+ * The interface used to calculate bean property names.
*/
- protected final List<Class<?>> getBeanDictionaryClasses() {
- return beanDictionaryClasses;
+ protected final PropertyNamer getPropertyNamer() {
+ return propertyNamer;
}
/**
- * Configuration property: Locale.
+ * Configuration property: Sort bean properties.
*
- * @see #BEAN_locale
+ * @see #BEAN_sortProperties
* @return
- * The default locale for serializer and parser sessions.
+ * <jk>true</jk> if all bean properties will be serialized and access in alphabetical order.
*/
- protected final Locale getLocale() {
- return locale;
+ protected final boolean isSortProperties() {
+ return sortProperties;
}
/**
@@ -3067,38 +3173,43 @@ public class BeanContext extends Context {
}
/**
- * Configuration property: Media type.
+ * Configuration property: Use enum names.
*
- * @see #BEAN_mediaType
+ * @see #BEAN_useEnumNames
* @return
- * The default media type value for serializer and parser sessions.
+ * <jk>true</jk> if enums are always serialized by name, not using {@link Object#toString()}.
*/
- protected final MediaType getMediaType() {
- return mediaType;
+ protected final boolean isUseEnumNames() {
+ return useEnumNames;
}
/**
- * Configuration property: Bean property namer.
+ * Configuration property: Use interface proxies.
*
- * @see #BEAN_propertyNamer
+ * @see #BEAN_useInterfaceProxies
* @return
- * The interface used to calculate bean property names.
+ * <jk>true</jk> if interfaces will be instantiated as proxy classes through the use of an
+ * {@link InvocationHandler} if there is no other way of instantiating them.
*/
- protected final PropertyNamer getPropertyNamer() {
- return propertyNamer;
+ protected final boolean isUseInterfaceProxies() {
+ return useInterfaceProxies;
}
/**
- * Configuration property: Bean type property name.
+ * Configuration property: Use Java Introspector.
*
- * @see #BEAN_beanTypePropertyName
+ * @see #BEAN_useJavaBeanIntrospector
* @return
- * The name of the bean property used to store the dictionary name of a bean type so that the parser knows the data type to reconstruct.
+ * <jk>true</jk> if the built-in Java bean introspector should be used for bean introspection.
*/
- protected final String getBeanTypePropertyName() {
- return beanTypePropertyName;
+ protected final boolean isUseJavaBeanIntrospector() {
+ return useJavaBeanIntrospector;
}
+ //-----------------------------------------------------------------------------------------------------------------
+ // Other methods
+ //-----------------------------------------------------------------------------------------------------------------
+
@Override /* Context */
public ObjectMap asMap() {
return super.asMap()
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextBuilder.java
index 6cdacb5..70ac369 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextBuilder.java
@@ -13,6 +13,7 @@
package org.apache.juneau;
import static org.apache.juneau.BeanContext.*;
+import static org.apache.juneau.internal.StringUtils.*;
import java.io.*;
import java.lang.reflect.*;
@@ -20,7 +21,6 @@ import java.util.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.http.*;
-import org.apache.juneau.internal.*;
import org.apache.juneau.marshall.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.reflect.*;
@@ -89,117 +89,6 @@ public class BeanContextBuilder extends ContextBuilder {
}
//-----------------------------------------------------------------------------------------------------------------
- // Annotations
- //-----------------------------------------------------------------------------------------------------------------
-
- /**
- * Apply annotations to this builder.
- *
- * @param m
- * Annotations map.
- * <br>Must not be <jk>null</jk>.
- * @param sr The string resolver to use for resolving variables in the annotations.
- * @return This object (for method chaining).
- * @throws ParseException
- */
- public BeanContextBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) throws ParseException {
- if (! m.containsKey(BeanConfig.class))
- return this;
- ObjectResolver r = new ObjectResolver(sr);
- for (BeanConfig a : m.get(BeanConfig.class)) {
- if (! a.beanClassVisibility().isEmpty())
- beanClassVisibility(r.visibility(a.beanClassVisibility()));
- if (! a.beanConstructorVisibility().isEmpty())
- beanConstructorVisibility(r.visibility(a.beanConstructorVisibility()));
- if (a.beanDictionary().length != 0)
- beanDictionary(a.beanDictionary());
- if (a.beanDictionary_replace().length != 0)
- beanDictionaryReplace(a.beanDictionary_replace());
- if (a.beanDictionary_remove().length != 0)
- beanDictionaryRemove(a.beanDictionary_remove());
- if (! a.beanFieldVisibility().isEmpty())
- beanFieldVisibility(r.visibility(a.beanFieldVisibility()));
- if (a.beanFilters().length != 0)
- beanFilters(a.beanFilters());
- if (a.beanFilters_replace().length != 0)
- beanFiltersReplace(a.beanFilters_replace());
- if (a.beanFilters_remove().length != 0)
- beanFiltersRemove(a.beanFilters_remove());
- if (! a.beanMapPutReturnsOldValue().isEmpty())
- beanMapPutReturnsOldValue(r.bool(a.beanMapPutReturnsOldValue()));
- if (! a.beanMethodVisibility().isEmpty())
- beanMethodVisibility(r.visibility(a.beanMethodVisibility()));
- if (! a.beansRequireDefaultConstructor().isEmpty())
- beansRequireDefaultConstructor(r.bool(a.beansRequireDefaultConstructor()));
- if (! a.beansRequireSerializable().isEmpty())
- beansRequireSerializable(r.bool(a.beansRequireSerializable()));
- if (! a.beansRequireSettersForGetters().isEmpty())
- beansRequireSettersForGetters(r.bool(a.beansRequireSettersForGetters()));
- if (! a.beansRequireSomeProperties().isEmpty())
- beansRequireSomeProperties(r.bool(a.beansRequireSomeProperties()));
- if (! a.beanTypePropertyName().isEmpty())
- beanTypePropertyName(r.string(a.beanTypePropertyName()));
- if (! a.debug().isEmpty())
- debug(r.bool(a.debug()));
- for (CSEntry e : a.examples())
- exampleJson(e.key(), r.string(e.value()));
- for (CSEntry e : a.excludeProperties())
- excludeProperties(e.key(), r.string(e.value()));
- if (! a.fluentSetters().isEmpty())
- fluentSetters(r.bool(a.fluentSetters()));
- if (! a.ignoreInvocationExceptionsOnGetters().isEmpty())
- ignoreInvocationExceptionsOnGetters(r.bool(a.ignoreInvocationExceptionsOnGetters()));
- if (! a.ignoreInvocationExceptionsOnSetters().isEmpty())
- ignoreInvocationExceptionsOnSetters(r.bool(a.ignoreInvocationExceptionsOnSetters()));
- if (! a.ignorePropertiesWithoutSetters().isEmpty())
- ignorePropertiesWithoutSetters(r.bool(a.ignorePropertiesWithoutSetters()));
- if (! a.ignoreUnknownBeanProperties().isEmpty())
- ignoreUnknownBeanProperties(r.bool(a.ignoreUnknownBeanProperties()));
- if (! a.ignoreUnknownNullBeanProperties().isEmpty())
- ignoreUnknownNullBeanProperties(r.bool(a.ignoreUnknownNullBeanProperties()));
- for (CCEntry e : a.implClasses())
- implClass(e.key(), e.value());
- for (CSEntry e : a.includeProperties())
- includeProperties(e.key(), r.string(e.value()));
- if (! a.locale().isEmpty())
- locale(r.locale(a.locale()));
- if (! a.mediaType().isEmpty())
- mediaType(r.mediaType(a.mediaType()));
- if (a.notBeanClasses().length != 0)
- notBeanClasses(a.notBeanClasses());
- if (a.notBeanClasses_replace().length != 0)
- notBeanClassesReplace(a.notBeanClasses_replace());
- if (a.notBeanClasses_remove().length != 0)
- notBeanClassesRemove(a.notBeanClasses_remove());
- if (a.notBeanPackages().length != 0)
- notBeanPackages(r.strings(a.notBeanPackages()));
- if (a.notBeanPackages_replace().length != 0)
- notBeanPackagesReplace(r.strings(a.notBeanPackages_replace()));
- if (a.notBeanPackages_remove().length != 0)
- notBeanPackagesRemove(r.strings(a.notBeanPackages_remove()));
- if (a.pojoSwaps().length != 0)
- pojoSwaps(a.pojoSwaps());
- if (a.pojoSwaps_replace().length != 0)
- pojoSwapsReplace(a.pojoSwaps_replace());
- if (a.pojoSwaps_remove().length != 0)
- pojoSwapsRemove(a.pojoSwaps_remove());
- if (a.propertyNamer() != PropertyNamer.Null.class)
- propertyNamer(a.propertyNamer());
- if (! a.sortProperties().isEmpty())
- sortProperties(r.bool(a.sortProperties()));
- if (! a.timeZone().isEmpty())
- timeZone(r.timeZone(a.timeZone()));
- if (! a.useEnumNames().isEmpty())
- useEnumNames(r.bool(a.useEnumNames()));
- if (! a.useInterfaceProxies().isEmpty())
- useInterfaceProxies(r.bool(a.useInterfaceProxies()));
- if (! a.useJavaBeanIntrospector().isEmpty())
- useJavaBeanIntrospector(r.bool(a.useJavaBeanIntrospector()));
- }
- return this;
- }
-
- //-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
@@ -301,7 +190,7 @@ public class BeanContextBuilder extends ContextBuilder {
* @return This object (for method chaining).
*/
public BeanContextBuilder beanDictionaryReplace(Class<?>...values) {
- return set(false, BEAN_beanDictionary, values);
+ return set(BEAN_beanDictionary, values);
}
/**
@@ -320,7 +209,7 @@ public class BeanContextBuilder extends ContextBuilder {
* @return This object (for method chaining).
*/
public BeanContextBuilder beanDictionaryReplace(Object...values) {
- return set(false, BEAN_beanDictionary, values);
+ return set(BEAN_beanDictionary, values);
}
/**
@@ -450,7 +339,7 @@ public class BeanContextBuilder extends ContextBuilder {
* @return This object (for method chaining).
*/
public BeanContextBuilder beanFiltersReplace(Class<?>...values) {
- return set(false, BEAN_beanFilters, values);
+ return set(BEAN_beanFilters, values);
}
/**
@@ -476,7 +365,7 @@ public class BeanContextBuilder extends ContextBuilder {
* @return This object (for method chaining).
*/
public BeanContextBuilder beanFiltersReplace(Object...values) {
- return set(false, BEAN_beanFilters, values);
+ return set(BEAN_beanFilters, values);
}
/**
@@ -833,6 +722,30 @@ public class BeanContextBuilder extends ContextBuilder {
}
/**
+ * Configuration property: POJO examples.
+ *
+ * <p>
+ * Specifies an example of the specified class.
+ *
+ * <h5 class='section'>See Also:</h5>
+ * <ul>
+ * <li class='jf'>{@link BeanContext#BEAN_examples}
+ * </ul>
+ *
+ * @param json The simple JSON representation of the example.
+ * @return This object (for method chaining).
+ * @throws ParseException If parameter is not valid Simple-JSON.
+ */
+ public BeanContextBuilder examples(String json) throws ParseException {
+ if (! isObjectMap(json, true))
+ json = "{" + json + "}";
+ ObjectMap m = new ObjectMap(json);
+ for (Map.Entry<String,Object> e : m.entrySet())
+ addTo(BEAN_examples, e.getKey(), e.getValue());
+ return this;
+ }
+
+ /**
* Configuration property: Bean property excludes.
*
* <p>
@@ -1281,7 +1194,7 @@ public class BeanContextBuilder extends ContextBuilder {
* @return This object (for method chaining).
*/
public BeanContextBuilder notBeanClassesReplace(Class<?>...values) {
- return set(false, BEAN_notBeanClasses, values);
+ return set(BEAN_notBeanClasses, values);
}
/**
@@ -1306,7 +1219,7 @@ public class BeanContextBuilder extends ContextBuilder {
* @return This object (for method chaining).
*/
public BeanContextBuilder notBeanClassesReplace(Object...values) {
- return set(false, BEAN_notBeanClasses, values);
+ return set(BEAN_notBeanClasses, values);
}
/**
@@ -1396,7 +1309,7 @@ public class BeanContextBuilder extends ContextBuilder {
* @return This object (for method chaining).
*/
public BeanContextBuilder notBeanPackagesReplace(String...values) {
- return set(false, BEAN_notBeanPackages, values);
+ return set(BEAN_notBeanPackages, values);
}
/**
@@ -1417,7 +1330,7 @@ public class BeanContextBuilder extends ContextBuilder {
* @return This object (for method chaining).
*/
public BeanContextBuilder notBeanPackagesReplace(Object...values) {
- return set(false, BEAN_notBeanPackages, values);
+ return set(BEAN_notBeanPackages, values);
}
/**
@@ -1512,7 +1425,7 @@ public class BeanContextBuilder extends ContextBuilder {
* @return This object (for method chaining).
*/
public BeanContextBuilder pojoSwapsReplace(Class<?>...values) {
- return set(false, BEAN_pojoSwaps, values);
+ return set(BEAN_pojoSwaps, values);
}
/**
@@ -1534,7 +1447,7 @@ public class BeanContextBuilder extends ContextBuilder {
* @return This object (for method chaining).
*/
public BeanContextBuilder pojoSwapsReplace(Object...values) {
- return set(false, BEAN_pojoSwaps, values);
+ return set(BEAN_pojoSwaps, values);
}
/**
@@ -1758,12 +1671,6 @@ public class BeanContextBuilder extends ContextBuilder {
}
@Override /* ContextBuilder */
- public BeanContextBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public BeanContextBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
@@ -1798,4 +1705,10 @@ public class BeanContextBuilder extends ContextBuilder {
super.apply(copyFrom);
return this;
}
+
+ @Override
+ public BeanContextBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) {
+ super.applyAnnotations(m, sr);
+ return this;
+ }
}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
index baaa697..4cd0bd4 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
@@ -1131,6 +1131,87 @@ public class BeanSession extends Session {
//-----------------------------------------------------------------------------------------------------------------
/**
+ * Configuration property: Minimum bean class visibility.
+ *
+ * @see BeanContext#BEAN_beanClassVisibility
+ * @return
+ * Classes are not considered beans unless they meet the minimum visibility requirements.
+ */
+ protected final Visibility getBeanClassVisibility() {
+ return ctx.getBeanClassVisibility();
+ }
+
+ /**
+ * Configuration property: Minimum bean constructor visibility.
+ *
+ * @see BeanContext#BEAN_beanConstructorVisibility
+ * @return
+ * Only look for constructors with this specified minimum visibility.
+ */
+ protected final Visibility getBeanConstructorVisibility() {
+ return ctx.getBeanConstructorVisibility();
+ }
+
+ /**
+ * Configuration property: Bean dictionary.
+ *
+ * @see BeanContext#BEAN_beanDictionary
+ * @return
+ * The list of classes that make up the bean dictionary in this bean context.
+ */
+ // TODO - Rename to getBeanDictionary()
+ protected final List<Class<?>> getBeanDictionaryClasses() {
+ return ctx.getBeanDictionaryClasses();
+ }
+
+ /**
+ * Configuration property: Minimum bean field visibility.
+ *
+ *
+ * @see BeanContext#BEAN_beanFieldVisibility
+ * @return
+ * Only look for bean fields with this specified minimum visibility.
+ */
+ protected final Visibility getBeanFieldVisibility() {
+ return ctx.getBeanFieldVisibility();
+ }
+
+ /**
+ * Configuration property: Bean filters.
+ *
+ *
+ * @see BeanContext#BEAN_beanFilters
+ * @return
+ * Only look for bean fields with this specified minimum visibility.
+ */
+ protected BeanFilter[] getBeanFilters() {
+ return ctx.getBeanFilters();
+ }
+
+ /**
+ * Configuration property: BeanMap.put() returns old property value.
+ *
+ * @see BeanContext#BEAN_beanMapPutReturnsOldValue
+ * @return
+ * <jk>true</jk> if the {@link BeanMap#put(String,Object) BeanMap.put()} method will return old property values.
+ * <br>Otherwise, it returns <jk>null</jk>.
+ */
+ protected final boolean isBeanMapPutReturnsOldValue() {
+ return ctx.isBeanMapPutReturnsOldValue();
+ }
+
+ /**
+ * Configuration property: Minimum bean method visibility.
+ *
+ * @see BeanContext#BEAN_beanMethodVisibility
+ * @return
+ * Only look for bean methods with this specified minimum visibility.
+ */
+ protected final Visibility getBeanMethodVisibility() {
+ return ctx.getBeanMethodVisibility();
+ }
+
+ /**
* Configuration property: Beans require no-arg constructors.
*
* @see BeanContext#BEAN_beansRequireDefaultConstructor
@@ -1179,63 +1260,63 @@ public class BeanSession extends Session {
}
/**
- * Configuration property: BeanMap.put() returns old property value.
+ * Configuration property: Bean type property name.
*
- * @see BeanContext#BEAN_beanMapPutReturnsOldValue
+ * @see BeanContext#BEAN_beanTypePropertyName
* @return
- * <jk>true</jk> if the {@link BeanMap#put(String,Object) BeanMap.put()} method will return old property values.
- * <br>Otherwise, it returns <jk>null</jk>.
+ * The name of the bean property used to store the dictionary name of a bean type so that the parser knows the data type to reconstruct.
*/
- protected final boolean isBeanMapPutReturnsOldValue() {
- return ctx.isBeanMapPutReturnsOldValue();
+ protected final String getBeanTypePropertyName() {
+ return ctx.getBeanTypePropertyName();
}
/**
- * Configuration property: Use interface proxies.
+ * Configuration property: Debug mode.
*
- * @see BeanContext#BEAN_useInterfaceProxies
+ * @see BeanContext#BEAN_debug
* @return
- * <jk>true</jk> if interfaces will be instantiated as proxy classes through the use of an
- * {@link InvocationHandler} if there is no other way of instantiating them.
+ * <jk>true</jk> if debug mode is enabled.
*/
- protected final boolean isUseInterfaceProxies() {
- return ctx.isUseInterfaceProxies();
+ protected final boolean isDebug() {
+ return debug;
}
/**
- * Configuration property: Ignore unknown properties.
+ * Configuration property: POJO examples.
*
- * @see BeanContext#BEAN_ignoreUnknownBeanProperties
+ * @see BeanContext#BEAN_examples
* @return
- * <jk>true</jk> if trying to set a value on a non-existent bean property is silently ignored.
- * <br>Otherwise, a {@code RuntimeException} is thrown.
+ * A map of POJO examples keyed by class name.
*/
- protected final boolean isIgnoreUnknownBeanProperties() {
- return ctx.isIgnoreUnknownBeanProperties();
+ protected final Map<String,?> getExamples() {
+ return ctx.getExamples();
}
+
/**
- * Configuration property: Ignore unknown properties with null values.
+ * Configuration property: Bean property excludes.
*
- * @see BeanContext#BEAN_ignoreUnknownNullBeanProperties
+ * @see BeanContext#BEAN_excludeProperties
* @return
- * <jk>true</jk> if trying to set a <jk>null</jk> value on a non-existent bean property is silently ignored.
+ * The list of property names to exclude keyed by class name.
*/
- protected final boolean isIgnoreUnknownNullBeanProperties() {
- return ctx.isIgnoreUnknownNullBeanProperties();
+ protected final Map<String,String[]> getExcludeProperties() {
+ return ctx.getExcludeProperties();
}
+
/**
- * Configuration property: Ignore properties without setters.
+ * Configuration property: Find fluent setters.
*
- * <br>Otherwise, a {@code RuntimeException} is thrown.
+ * <h5 class='section'>Description:</h5>
+ * <p>
*
- * @see BeanContext#BEAN_ignorePropertiesWithoutSetters
+ * @see BeanContext#BEAN_fluentSetters
* @return
- * <jk>true</jk> if trying to set a value on a bean property without a setter is silently ignored.
+ * <jk>true</jk> if fluent setters are detected on beans.
*/
- protected final boolean isIgnorePropertiesWithoutSetters() {
- return ctx.isIgnorePropertiesWithoutSetters();
+ protected final boolean isFluentSetters() {
+ return ctx.isFluentSetters();
}
/**
@@ -1261,158 +1342,158 @@ public class BeanSession extends Session {
}
/**
- * Configuration property: Use Java Introspector.
+ * Configuration property: Ignore properties without setters.
*
- * @see BeanContext#BEAN_useJavaBeanIntrospector
+ * <br>Otherwise, a {@code RuntimeException} is thrown.
+ *
+ * @see BeanContext#BEAN_ignorePropertiesWithoutSetters
* @return
- * <jk>true</jk> if the built-in Java bean introspector should be used for bean introspection.
+ * <jk>true</jk> if trying to set a value on a bean property without a setter is silently ignored.
*/
- protected final boolean isUseJavaBeanIntrospector() {
- return ctx.isUseJavaBeanIntrospector();
+ protected final boolean isIgnorePropertiesWithoutSetters() {
+ return ctx.isIgnorePropertiesWithoutSetters();
}
/**
- * Configuration property: Use enum names.
+ * Configuration property: Ignore unknown properties.
*
- * @see BeanContext#BEAN_useEnumNames
+ * @see BeanContext#BEAN_ignoreUnknownBeanProperties
* @return
- * <jk>true</jk> if enums are always serialized by name, not using {@link Object#toString()}.
+ * <jk>true</jk> if trying to set a value on a non-existent bean property is silently ignored.
+ * <br>Otherwise, a {@code RuntimeException} is thrown.
*/
- protected final boolean isUseEnumNames() {
- return ctx.isUseEnumNames();
+ protected final boolean isIgnoreUnknownBeanProperties() {
+ return ctx.isIgnoreUnknownBeanProperties();
}
/**
- * Configuration property: Sort bean properties.
+ * Configuration property: Ignore unknown properties with null values.
*
- * @see BeanContext#BEAN_sortProperties
+ * @see BeanContext#BEAN_ignoreUnknownNullBeanProperties
* @return
- * <jk>true</jk> if all bean properties will be serialized and access in alphabetical order.
+ * <jk>true</jk> if trying to set a <jk>null</jk> value on a non-existent bean property is silently ignored.
*/
- protected final boolean isSortProperties() {
- return ctx.isSortProperties();
+ protected final boolean isIgnoreUnknownNullBeanProperties() {
+ return ctx.isIgnoreUnknownNullBeanProperties();
}
/**
- * Configuration property: Find fluent setters.
+ * Configuration property: Implementation classes.
*
- * <h5 class='section'>Description:</h5>
- * <p>
- *
- * @see BeanContext#BEAN_fluentSetters
+ * @see BeanContext#BEAN_implClasses
* @return
- * <jk>true</jk> if fluent setters are detected on beans.
+ * Implementation classes keyed by interface class names.
*/
- protected final boolean isFluentSetters() {
- return ctx.isFluentSetters();
+ protected final Map<String,ClassInfo> getImplClasses() {
+ return ctx.getImplClasses();
}
/**
- * Configuration property: Minimum bean constructor visibility.
+ * Configuration property: Bean property includes.
*
- * @see BeanContext#BEAN_beanConstructorVisibility
+ * @see BeanContext#BEAN_includeProperties
* @return
- * Only look for constructors with this specified minimum visibility.
+ * Include properties keyed by class name.
*/
- protected final Visibility getBeanConstructorVisibility() {
- return ctx.getBeanConstructorVisibility();
+ protected final Map<String,String[]> getIncludeProperties() {
+ return ctx.getIncludeProperties();
}
/**
- * Configuration property: Minimum bean class visibility.
+ * Configuration property: Locale.
*
- * @see BeanContext#BEAN_beanClassVisibility
- * @return
- * Classes are not considered beans unless they meet the minimum visibility requirements.
+ * <p>
+ * The locale is determined in the following order:
+ * <ol>
+ * <li><code>locale</code> parameter passed in through constructor.
+ * <li>{@link BeanContext#BEAN_locale} entry in parameter passed in through constructor.
+ * <li>{@link BeanContext#BEAN_locale} setting on bean context.
+ * <li>Locale returned by {@link Locale#getDefault()}.
+ * </ol>
+ *
+ * @see BeanContext#BEAN_locale
+ * @return The session locale.
*/
- protected final Visibility getBeanClassVisibility() {
- return ctx.getBeanClassVisibility();
+ public final Locale getLocale() {
+ return locale;
}
/**
- * Configuration property: Minimum bean method visibility.
+ * Configuration property: Media type.
*
- * @see BeanContext#BEAN_beanMethodVisibility
- * @return
- * Only look for bean methods with this specified minimum visibility.
+ * <p>
+ * For example, <js>"application/json"</js>.
+ *
+ * @see BeanContext#BEAN_mediaType
+ * @return The media type for this session, or <jk>null</jk> if not specified.
*/
- protected final Visibility getBeanMethodVisibility() {
- return ctx.getBeanMethodVisibility();
+ public final MediaType getMediaType() {
+ return mediaType;
}
/**
- * Configuration property: Minimum bean field visibility.
- *
+ * Configuration property: Bean class exclusions.
*
- * @see BeanContext#BEAN_beanFieldVisibility
+ * @see BeanContext#BEAN_notBeanClasses
* @return
- * Only look for bean fields with this specified minimum visibility.
+ * The list of classes that are explicitly not beans.
*/
- protected final Visibility getBeanFieldVisibility() {
- return ctx.getBeanFieldVisibility();
+ protected final Class<?>[] getNotBeanClasses() {
+ return ctx.getNotBeanClasses();
}
/**
- * Configuration property: Bean dictionary.
+ * Configuration property: Bean package exclusions.
*
- * @see BeanContext#BEAN_beanDictionary
+ * @see BeanContext#BEAN_notBeanPackages
* @return
- * The list of classes that make up the bean dictionary in this bean context.
+ * The list of fully-qualified package names to exclude from being classified as beans.
*/
- protected final List<Class<?>> getBeanDictionaryClasses() {
- return ctx.getBeanDictionaryClasses();
+ protected final String[] getNotBeanPackagesNames() {
+ return ctx.getNotBeanPackagesNames();
}
/**
- * Configuration property: Bean property namer.
+ * Configuration property: Bean package exclusions.
*
- * @see BeanContext#BEAN_propertyNamer
+ * @see BeanContext#BEAN_notBeanPackages
* @return
- * The interface used to calculate bean property names.
+ * The list of package name prefixes to exclude from being classified as beans.
*/
- protected final PropertyNamer getPropertyNamer() {
- return ctx.getPropertyNamer();
+ protected final String[] getNotBeanPackagesPrefixes() {
+ return ctx.getNotBeanPackagesPrefixes();
}
/**
- * Configuration property: Bean type property name.
+ * Configuration property: POJO swaps.
*
- * @see BeanContext#BEAN_beanTypePropertyName
+ * @see BeanContext#BEAN_pojoSwaps
* @return
- * The name of the bean property used to store the dictionary name of a bean type so that the parser knows the data type to reconstruct.
+ * The list POJO swaps defined.
*/
- protected final String getBeanTypePropertyName() {
- return ctx.getBeanTypePropertyName();
+ protected final PojoSwap<?,?>[] getPojoSwaps() {
+ return ctx.getPojoSwaps();
}
-
/**
- * Configuration property: Debug mode.
+ * Configuration property: Bean property namer.
*
- * @see BeanContext#BEAN_debug
+ * @see BeanContext#BEAN_propertyNamer
* @return
- * <jk>true</jk> if debug mode is enabled.
+ * The interface used to calculate bean property names.
*/
- protected final boolean isDebug() {
- return debug;
+ protected final PropertyNamer getPropertyNamer() {
+ return ctx.getPropertyNamer();
}
/**
- * Configuration property: Locale.
- *
- * <p>
- * The locale is determined in the following order:
- * <ol>
- * <li><code>locale</code> parameter passed in through constructor.
- * <li>{@link BeanContext#BEAN_locale} entry in parameter passed in through constructor.
- * <li>{@link BeanContext#BEAN_locale} setting on bean context.
- * <li>Locale returned by {@link Locale#getDefault()}.
- * </ol>
+ * Configuration property: Sort bean properties.
*
- * @see BeanContext#BEAN_locale
- * @return The session locale.
+ * @see BeanContext#BEAN_sortProperties
+ * @return
+ * <jk>true</jk> if all bean properties will be serialized and access in alphabetical order.
*/
- public final Locale getLocale() {
- return locale;
+ protected final boolean isSortProperties() {
+ return ctx.isSortProperties();
}
/**
@@ -1434,18 +1515,43 @@ public class BeanSession extends Session {
}
/**
- * Configuration property: Media type.
+ * Configuration property: Use enum names.
*
- * <p>
- * For example, <js>"application/json"</js>.
+ * @see BeanContext#BEAN_useEnumNames
+ * @return
+ * <jk>true</jk> if enums are always serialized by name, not using {@link Object#toString()}.
+ */
+ protected final boolean isUseEnumNames() {
+ return ctx.isUseEnumNames();
+ }
+
+ /**
+ * Configuration property: Use interface proxies.
*
- * @see BeanContext#BEAN_mediaType
- * @return The media type for this session, or <jk>null</jk> if not specified.
+ * @see BeanContext#BEAN_useInterfaceProxies
+ * @return
+ * <jk>true</jk> if interfaces will be instantiated as proxy classes through the use of an
+ * {@link InvocationHandler} if there is no other way of instantiating them.
*/
- public final MediaType getMediaType() {
- return mediaType;
+ protected final boolean isUseInterfaceProxies() {
+ return ctx.isUseInterfaceProxies();
+ }
+
+ /**
+ * Configuration property: Use Java Introspector.
+ *
+ * @see BeanContext#BEAN_useJavaBeanIntrospector
+ * @return
+ * <jk>true</jk> if the built-in Java bean introspector should be used for bean introspection.
+ */
+ protected final boolean isUseJavaBeanIntrospector() {
+ return ctx.isUseJavaBeanIntrospector();
}
+ //-----------------------------------------------------------------------------------------------------------------
+ // Other methods
+ //-----------------------------------------------------------------------------------------------------------------
+
/**
* HTTP part schema of object being serialized or parsed.
*
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseBuilder.java
index 737a328..fcab304 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseBuilder.java
@@ -16,10 +16,7 @@ import static org.apache.juneau.BeanTraverseContext.*;
import java.util.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.http.*;
-import org.apache.juneau.internal.*;
-import org.apache.juneau.parser.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.utils.*;
@@ -45,29 +42,6 @@ public class BeanTraverseBuilder extends BeanContextBuilder {
}
//-----------------------------------------------------------------------------------------------------------------
- // Annotations
- //-----------------------------------------------------------------------------------------------------------------
-
- @Override
- public BeanTraverseBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) throws ParseException {
- super.applyAnnotations(m, sr);
- if (! m.containsKey(BeanConfig.class))
- return this;
- ObjectResolver r = new ObjectResolver(sr);
- for (BeanConfig a : m.get(BeanConfig.class)) {
- if (! a.detectRecursions().isEmpty())
- detectRecursions(r.bool(a.detectRecursions()));
- if (! a.ignoreRecursions().isEmpty())
- ignoreRecursions(r.bool(a.ignoreRecursions()));
- if (! a.initialDepth().isEmpty())
- initialDepth(r.integer(a.initialDepth()));
- if (! a.maxDepth().isEmpty())
- maxDepth(r.integer(a.maxDepth()));
- }
- return this;
- }
-
- //-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
@@ -610,12 +584,6 @@ public class BeanTraverseBuilder extends BeanContextBuilder {
}
@Override /* ContextBuilder */
- public BeanTraverseBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public BeanTraverseBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
@@ -651,6 +619,12 @@ public class BeanTraverseBuilder extends BeanContextBuilder {
return this;
}
+ @Override
+ public BeanTraverseBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) {
+ super.applyAnnotations(m, sr);
+ return this;
+ }
+
@Override /* Context */
public BeanTraverseContext build() {
return null;
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseContext.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseContext.java
index f69ee5a..74edcdc 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseContext.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseContext.java
@@ -237,6 +237,11 @@ public abstract class BeanTraverseContext extends BeanContext {
}
@Override /* Context */
+ public BeanTraverseSession createSession() {
+ return new BeanTraverseSession(this, createDefaultSessionArgs());
+ }
+
+ @Override /* Context */
public BeanTraverseSession createSession(BeanSessionArgs args) {
return new BeanTraverseSession(this, args);
}
@@ -247,6 +252,29 @@ public abstract class BeanTraverseContext extends BeanContext {
//-----------------------------------------------------------------------------------------------------------------
/**
+ * Configuration property: Automatically detect POJO recursions.
+ *
+ * @see #BEANTRAVERSE_detectRecursions
+ * @return
+ * <jk>true</jk> if recursions should be checked for during traversal.
+ */
+ protected final boolean isDetectRecursions() {
+ return detectRecursions;
+ }
+
+ /**
+ * Configuration property: Ignore recursion errors.
+ *
+ * @see #BEANTRAVERSE_ignoreRecursions
+ * @return
+ * <jk>true</jk> if when we encounter the same object when traversing a tree, we set the value to <jk>null</jk>.
+ * <br>Otherwise, an exception is thrown with the message <js>"Recursion occurred, stack=..."</js>.
+ */
+ protected final boolean isIgnoreRecursions() {
+ return ignoreRecursions;
+ }
+
+ /**
* Configuration property: Initial depth.
*
* @see #BEANTRAVERSE_initialDepth
@@ -269,27 +297,9 @@ public abstract class BeanTraverseContext extends BeanContext {
return maxDepth;
}
- /**
- * Configuration property: Automatically detect POJO recursions.
- * @see #BEANTRAVERSE_detectRecursions
- * @return
- * <jk>true</jk> if recursions should be checked for during traversal.
- */
- protected final boolean isDetectRecursions() {
- return detectRecursions;
- }
-
- /**
- * Configuration property: Ignore recursion errors.
- *
- * @see #BEANTRAVERSE_ignoreRecursions
- * @return
- * <jk>true</jk> if when we encounter the same object when traversing a tree, we set the value to <jk>null</jk>.
- * <br>Otherwise, an exception is thrown with the message <js>"Recursion occurred, stack=..."</js>.
- */
- protected final boolean isIgnoreRecursions() {
- return ignoreRecursions;
- }
+ //-----------------------------------------------------------------------------------------------------------------
+ // Other methods
+ //-----------------------------------------------------------------------------------------------------------------
@Override /* Context */
public ObjectMap asMap() {
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseSession.java
index e5d0a8c..ef82929 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseSession.java
@@ -243,48 +243,48 @@ public class BeanTraverseSession extends BeanSession {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Configuration property: Initial depth.
+ * Configuration property: Automatically detect POJO recursions.
*
- * @see BeanTraverseContext#BEANTRAVERSE_initialDepth
+ * @see BeanTraverseContext#BEANTRAVERSE_detectRecursions
* @return
- * The initial indentation level at the root.
+ * <jk>true</jk> if recursions should be checked for during traversal.
*/
- protected final int getInitialDepth() {
- return ctx.getInitialDepth();
+ protected final boolean isDetectRecursions() {
+ return ctx.isDetectRecursions();
}
/**
- * Configuration property: Max traversal depth.
+ * Configuration property: Ignore recursion errors.
*
- * @see BeanTraverseContext#BEANTRAVERSE_maxDepth
+ * @see BeanTraverseContext#BEANTRAVERSE_ignoreRecursions
* @return
- * The depth at which traversal is aborted if depth is reached in the POJO tree.
- * <br>If this depth is exceeded, an exception is thrown.
+ * <jk>true</jk> if when we encounter the same object when traversing a tree, we set the value to <jk>null</jk>.
+ * <br>Otherwise, a {@link BeanRecursionException} is thrown with the message <js>"Recursion occurred, stack=..."</js>.
*/
- protected final int getMaxDepth() {
- return ctx.getMaxDepth();
+ protected final boolean isIgnoreRecursions() {
+ return ctx.isIgnoreRecursions();
}
/**
- * Configuration property: Automatically detect POJO recursions.
+ * Configuration property: Initial depth.
*
- * @see BeanTraverseContext#BEANTRAVERSE_detectRecursions
+ * @see BeanTraverseContext#BEANTRAVERSE_initialDepth
* @return
- * <jk>true</jk> if recursions should be checked for during traversal.
+ * The initial indentation level at the root.
*/
- protected final boolean isDetectRecursions() {
- return ctx.isDetectRecursions();
+ protected final int getInitialDepth() {
+ return ctx.getInitialDepth();
}
/**
- * Configuration property: Ignore recursion errors.
+ * Configuration property: Max traversal depth.
*
- * @see BeanTraverseContext#BEANTRAVERSE_ignoreRecursions
+ * @see BeanTraverseContext#BEANTRAVERSE_maxDepth
* @return
- * <jk>true</jk> if when we encounter the same object when traversing a tree, we set the value to <jk>null</jk>.
- * <br>Otherwise, a {@link BeanRecursionException} is thrown with the message <js>"Recursion occurred, stack=..."</js>.
+ * The depth at which traversal is aborted if depth is reached in the POJO tree.
+ * <br>If this depth is exceeded, an exception is thrown.
*/
- protected final boolean isIgnoreRecursions() {
- return ctx.isIgnoreRecursions();
+ protected final int getMaxDepth() {
+ return ctx.getMaxDepth();
}
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ConfigApply.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ConfigApply.java
new file mode 100644
index 0000000..0dfc337
--- /dev/null
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ConfigApply.java
@@ -0,0 +1,163 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau;
+
+import static org.apache.juneau.internal.StringUtils.*;
+
+import java.lang.annotation.*;
+import java.util.*;
+
+import org.apache.juneau.annotation.*;
+import org.apache.juneau.utils.*;
+
+/**
+ * Class used to add properties to a {@link PropertyStore} from an annotation (e.g. {@link BeanConfig}).
+ *
+ * @param <T> The annotation that this <code>ConfigApply</code> reads from.
+ */
+public abstract class ConfigApply<T extends Annotation> {
+
+ private final StringResolver r;
+ private final Class<T> c;
+
+ /**
+ * Constructor.
+ *
+ * @param c The annotation class.
+ * @param r The string resolver to use for resolving strings.
+ */
+ protected ConfigApply(Class<T> c, StringResolver r) {
+ this.r = r == null ? StringResolver.NOOP : r;
+ this.c = c;
+ }
+
+ /**
+ * Apply the specified annotation to the specified property store builder.
+ *
+ * @param a The annotation.
+ * @param ps The property store builder.
+ */
+ public abstract void apply(T a, PropertyStoreBuilder ps);
+
+
+ /**
+ * Resolves the specified string.
+ *
+ * @param in The string containing variables to resolve.
+ * @return The resolved string.
+ */
+ protected String string(String in) {
+ return r.resolve(in);
+ }
+
+ /**
+ * Resolves the specified strings in the string array.
+ *
+ * @param in The string array containing variables to resolve.
+ * @return An array with resolved strings.
+ */
+ protected String[] strings(String[] in) {
+ String[] out = new String[in.length];
+ for (int i = 0; i < in.length; i++)
+ out[i] = r.resolve(in[i]);
+ return out;
+ }
+
+ /**
+ * Resolves the specified strings as a maps of strings-to-strings.
+ *
+ * @param in The string array containing variables to resolve.
+ * @param loc The annotation field name.
+ * @return A map of strings-to-strings.
+ */
+ protected Map<String,String> stringsMap(String[] in, String loc) {
+ Map<String,String> m = new LinkedHashMap<>();
+ for (String s : strings(in)) {
+ for (String s2 : split(s, ';')) {
+ int i = s2.indexOf(':');
+ if (i == -1)
+ throw new ConfigException("Invalid syntax for key/value pair on annotation @{0}({1}): {2}", c.getSimpleName(), loc, s2);
+ m.put(s2.substring(0, i).trim(), s2.substring(i+1).trim());
+ }
+ }
+ return m;
+ }
+
+ /**
+ * Resolves the specified string and converts it to a boolean.
+ *
+ * @param in The string containing variables to resolve.
+ * @return The resolved boolean.
+ */
+ public boolean bool(String in) {
+ return Boolean.parseBoolean(r.resolve(in));
+ }
+
+ /**
+ * Resolves the specified string and converts it to an int.
+ *
+ * @param in The string containing variables to resolve.
+ * @param loc The annotation field name.
+ * @return The resolved int.
+ */
+ protected int integer(String in, String loc) {
+ try {
+ return Integer.parseInt(r.resolve(in));
+ } catch (NumberFormatException e) {
+ throw new ConfigException("Invalid syntax for integer on annotation @{0}({1}): {2}", c.getSimpleName(), loc, in);
+ }
+ }
+
+ /**
+ * Resolves the specified string and converts it to a Visibility.
+ *
+ * @param in The string containing variables to resolve.
+ * @param loc The annotation field name.
+ * @return The resolved Visibility.
+ */
+ protected Visibility visibility(String in, String loc) {
+ try {
+ return Visibility.valueOf(r.resolve(in));
+ } catch (IllegalArgumentException e) {
+ throw new ConfigException("Invalid syntax for visibility on annotation @{0}({1}): {2}", c.getSimpleName(), loc, in);
+ }
+ }
+
+ /**
+ * Resolves the specified strings and converts it to an ObjectMap.
+ *
+ * @param in The strings to be concatenated and parsed into an ObjectMapl.
+ * @param loc The annotation field name.
+ * @return The resolved ObjectMap.
+ */
+ protected ObjectMap objectMap(String[] in, String loc) {
+ return objectMap(joinnl(strings(in)), loc);
+ }
+
+ /**
+ * Resolves the specified string and converts it to an ObjectMap.
+ *
+ * @param in The string to be parsed into an ObjectMapl.
+ * @param loc The annotation field name.
+ * @return The resolved ObjectMap.
+ */
+ protected ObjectMap objectMap(String in, String loc) {
+ try {
+ if (! isObjectMap(in, true))
+ in = "{" + in + "}";
+ return new ObjectMap(in);
+ } catch (Exception e) {
+ throw new ConfigException("Invalid syntax for Simple-JSON on annotation @{0}({1}): {2}", c.getSimpleName(), loc, in);
+ }
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBuilder.java
index 34a5250..dfd990a 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBuilder.java
@@ -14,6 +14,9 @@ package org.apache.juneau;
import java.util.*;
+import org.apache.juneau.reflect.*;
+import org.apache.juneau.utils.*;
+
/**
* Builder class for building instances of serializers and parsers.
*/
@@ -86,6 +89,18 @@ public abstract class ContextBuilder {
}
/**
+ * Applies a set of annotations to this property store.
+ *
+ * @param annotationsMap The annotations map.
+ * @param r The string resolver for resolving variables in annotation values.
+ * @return This object (for method chaining).
+ */
+ public ContextBuilder applyAnnotations(AnnotationsMap annotationsMap, StringResolver r) {
+ this.psb.applyAnnotations(annotationsMap, r);
+ return this;
+ }
+
+ /**
* Build a new instance of the specified object.
*
* @param c The subclass of {@link Context} to instantiate.
@@ -123,24 +138,6 @@ public abstract class ContextBuilder {
}
/**
- * Sets or adds to a SET or LIST property.
- *
- * @param append
- * If <jk>true</jk>, the previous value is appended to. Otherwise, the previous value is replaced.
- * @param name The property name.
- * @param value The property value.
- * @return This object (for method chaining).
- * @see PropertyStoreBuilder#set(String, Object)
- */
- public ContextBuilder set(boolean append, String name, Object value) {
- if (append)
- psb.addTo(name, value);
- else
- psb.set(name, value);
- return this;
- }
-
- /**
* Sets multiple configuration properties on this object.
*
* @param properties The properties to set on this class.
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/PropertyStoreBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/PropertyStoreBuilder.java
index c9c0b24..301ff64 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/PropertyStoreBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/PropertyStoreBuilder.java
@@ -14,14 +14,18 @@ package org.apache.juneau;
import static java.util.Collections.*;
+import java.lang.annotation.*;
import java.lang.reflect.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
import org.apache.juneau.PropertyStore.*;
+import org.apache.juneau.annotation.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.json.*;
+import org.apache.juneau.reflect.*;
+import org.apache.juneau.utils.*;
/**
* A builder for {@link PropertyStore} objects.
@@ -97,6 +101,33 @@ public class PropertyStoreBuilder {
}
/**
+ * Applies the settings in the specified annotations to this property store.
+ *
+ * @param annotationsMap The map of annotations to apply.
+ * @param r The string resolver used to resolve any variables in the annotations.
+ * @return This object (for method chaining).
+ */
+ public PropertyStoreBuilder applyAnnotations(AnnotationsMap annotationsMap, StringResolver r) {
+ for (Map.Entry<Class<? extends Annotation>,List<Annotation>> e : annotationsMap.entrySet()) {
+ Class<? extends Annotation> ac = e.getKey();
+ PropertyStoreApply apply = ac.getAnnotation(PropertyStoreApply.class);
+ if (apply != null) {
+ try {
+ ConfigApply<Annotation> ca = apply.value().getConstructor(Class.class, StringResolver.class).newInstance(ac, r);
+ for (Annotation a : e.getValue()) {
+ ca.apply(a, this);
+ }
+ } catch (ConfigException ex) {
+ throw ex;
+ } catch (Exception ex) {
+ throw new ConfigException(ex, "Could not instantiate ConfigApply class {0}", apply.value());
+ }
+ }
+ }
+ return this;
+ }
+
+ /**
* Sets a configuration property value on this object.
*
* @param key
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfig.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfig.java
index 0c61cf4..1a8c454 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfig.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfig.java
@@ -32,9 +32,10 @@ import org.apache.juneau.transform.*;
* Used primarily for specifying bean configuration properties on REST classes and methods.
*/
@Documented
-@Target(TYPE)
+@Target({TYPE,METHOD})
@Retention(RUNTIME)
@Inherited
+@PropertyStoreApply(BeanConfigApply.class)
public @interface BeanConfig {
//-----------------------------------------------------------------------------------------------------------------
@@ -374,6 +375,126 @@ public @interface BeanConfig {
String beanTypePropertyName() default "";
/**
+ * Configuration property: Bean property includes.
+ *
+ * Shortcut for specifying the {@link BeanContext#BEAN_includeProperties} property on all serializers.
+ *
+ * <p>
+ * The typical use case is when you're rendering summary and details views of the same bean in a resource and
+ * you want to expose or hide specific properties depending on the level of detail you want.
+ *
+ * <p>
+ * In the example below, our 'summary' view is a list of beans where we only want to show the ID property,
+ * and our detail view is a single bean where we want to expose different fields:
+ * <p class='bcode w800'>
+ * <jc>// Our bean</jc>
+ * <jk>public class</jk> MyBean {
+ *
+ * <jc>// Summary properties</jc>
+ * <ja>@Html</ja>(link=<js>"servlet:/mybeans/{id}"</js>)
+ * <jk>public</jk> String <jf>id</jf>;
+ *
+ * <jc>// Detail properties</jc>
+ * <jk>public</jk> String <jf>a</jf>, <jf>b</jf>;
+ * }
+ *
+ * <jc>// Only render "id" property.</jc>
+ * <ja>@RestMethod</ja>(name=<jsf>GET</jsf>, path=<js>"/mybeans"</js>)
+ * <ja>@BeanConfig</ja>(bpi=<js>"MyBean: id"</js>)
+ * <jk>public</jk> List<MyBean> getBeanSummary() {...}
+ *
+ * <jc>// Only render "a" and "b" properties.</jc>
+ * <ja>@RestMethod</ja>(name=<jsf>GET</jsf>, path=<js>"/mybeans/{id}"</js>)
+ * <ja>@BeanConfig</ja>(bpi=<js>"MyBean: a,b"</js>)
+ * <jk>public</jk> MyBean getBeanDetails(<ja>@Path</ja> String id) {...}
+ * </p>
+ *
+ * <h5 class='section'>Notes:</h5>
+ * <ul class='spaced-list'>
+ * <li>
+ * The format of each value is: <js>"Key: comma-delimited-tokens"</js>.
+ * <li>
+ * Keys can be fully-qualified or short class names or <js>"*"</js> to represent all classes.
+ * <li>
+ * Values are comma-delimited lists of bean property names.
+ * <li>
+ * Properties apply to specified class and all subclasses.
+ * <li>
+ * Semicolons can be used as an additional separator for multiple values:
+ * <p class='bcode w800'>
+ * <jc>// Equivalent</jc>
+ * bpi={<js>"Bean1: foo"</js>,<js>"Bean2: bar,baz"</js>}
+ * bpi=<js>"Bean1: foo; Bean2: bar,baz"</js>
+ * </p>
+ * </ul>
+ *
+ * <h5 class='section'>See Also:</h5>
+ * <ul>
+ * <li class='jf'>{@link BeanContext#BEAN_includeProperties}
+ * </ul>
+ */
+ String[] bpi() default {};
+
+ /**
+ * Configuration property: Bean property excludes.
+ *
+ * Shortcut for specifying the {@link BeanContext#BEAN_excludeProperties} property on all serializers.
+ *
+ * <p>
+ * Same as {@link #bpi()} except you specify a list of bean property names that you want to exclude from
+ * serialization.
+ *
+ * <p>
+ * In the example below, our 'summary' view is a list of beans where we want to exclude some properties:
+ * <p class='bcode w800'>
+ * <jc>// Our bean</jc>
+ * <jk>public class</jk> MyBean {
+ *
+ * <jc>// Summary properties</jc>
+ * <ja>@Html</ja>(link=<js>"servlet:/mybeans/{id}"</js>)
+ * <jk>public</jk> String <jf>id</jf>;
+ *
+ * <jc>// Detail properties</jc>
+ * <jk>public</jk> String <jf>a</jf>, <jf>b</jf>;
+ * }
+ *
+ * <jc>// Don't show "a" and "b" properties.</jc>
+ * <ja>@RestMethod</ja>(name=<jsf>GET</jsf>, path=<js>"/mybeans"</js>)
+ * <ja>@BeanConfig</ja>(bpx=<js>"MyBean: a,b"</js>)
+ * <jk>public</jk> List<MyBean> getBeanSummary() {...}
+ *
+ * <jc>// Render all properties.</jc>
+ * <ja>@RestMethod</ja>(name=<jsf>GET</jsf>, path=<js>"/mybeans/{id}"</js>)
+ * <jk>public</jk> MyBean getBeanDetails(<ja>@Path</ja> String id) {...}
+ * </p>
+ *
+ * <h5 class='section'>Notes:</h5>
+ * <ul class='spaced-list'>
+ * <li>
+ * The format of each value is: <js>"Key: comma-delimited-tokens"</js>.
+ * <li>
+ * Keys can be fully-qualified or short class names or <js>"*"</js> to represent all classes.
+ * <li>
+ * Values are comma-delimited lists of bean property names.
+ * <li>
+ * Properties apply to specified class and all subclasses.
+ * <li>
+ * Semicolons can be used as an additional separator for multiple values:
+ * <p class='bcode w800'>
+ * <jc>// Equivalent</jc>
+ * bpx={<js>"Bean1: foo"</js>,<js>"Bean2: bar,baz"</js>}
+ * bpx=<js>"Bean1: foo; Bean2: bar,baz"</js>
+ * </p>
+ * </ul>
+ *
+ * <h5 class='section'>See Also:</h5>
+ * <ul>
+ * <li class='jf'>{@link BeanContext#BEAN_excludeProperties}
+ * </ul>
+ */
+ String[] bpx() default {};
+
+ /**
* Configuration property: Debug mode.
*
* <p>
@@ -445,7 +566,37 @@ public @interface BeanConfig {
* <li class='jf'>{@link BeanContext#BEAN_examples}
* </ul>
*/
- CSEntry[] examples() default {};
+ CS[] example() default {};
+
+ /**
+ * Configuration property: POJO examples.
+ *
+ * <p>
+ * Same as {@link #example()} but allows you to define examples as a Simple-JSON string.
+ *
+ * <p>
+ * Keys are the class of the example and can be the fully-qualified name or simple name.
+ * <br>Values are Simple-JSON representation of that class.
+ *
+ * <p>
+ * The individual strings are concatenated together and the whole string is treated as a JSON Object.
+ * <br>The leading and trailing <js>'{'</js> and <js>'}'</js> characters are optional.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <ja>@BeanConfig</ja>(
+ * examples={
+ * <js>"MyBean: {foo:'bar'}"</js> <jc>// Could also be "{MyBean: {foo:'bar'}}"</jc>
+ * }
+ * )
+ * <p>
+ *
+ * <h5 class='section'>See Also:</h5>
+ * <ul>
+ * <li class='jf'>{@link BeanContext#BEAN_examples}
+ * </ul>
+ */
+ String[] examples() default {};
/**
* Configuration property: Bean property excludes.
@@ -474,7 +625,7 @@ public @interface BeanConfig {
* <li class='jf'>{@link BeanContext#BEAN_excludeProperties}
* </ul>
*/
- CSEntry[] excludeProperties() default {};
+ CS[] excludeProperties() default {};
/**
* Configuration property: Find fluent setters.
@@ -632,7 +783,7 @@ public @interface BeanConfig {
* <li class='jf'>{@link BeanContext#BEAN_implClasses}
* </ul>
*/
- CCEntry[] implClasses() default {};
+ CC[] implClasses() default {};
/**
* Configuration property: Bean property includes.
@@ -661,7 +812,7 @@ public @interface BeanConfig {
* <li class='jf'>{@link BeanContext#BEAN_includeProperties}
* </ul>
*/
- CSEntry[] includeProperties() default {};
+ CS[] includeProperties() default {};
/**
* Configuration property: Locale.
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfigApply.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfigApply.java
new file mode 100644
index 0000000..4670a52
--- /dev/null
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfigApply.java
@@ -0,0 +1,166 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.annotation;
+
+import static org.apache.juneau.BeanContext.*;
+import static org.apache.juneau.BeanTraverseContext.*;
+
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.http.*;
+import org.apache.juneau.marshall.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.utils.*;
+
+/**
+ * Applies {@link BeanConfig} annotations to a {@link PropertyStoreBuilder}.
+ */
+public class BeanConfigApply extends ConfigApply<BeanConfig> {
+
+ /**
+ * Constructor.
+ *
+ * @param c The annotation class.
+ * @param r The resolver for resolving values in annotations.
+ */
+ public BeanConfigApply(Class<BeanConfig> c, StringResolver r) {
+ super(c, r);
+ }
+
+ @Override
+ public void apply(BeanConfig a, PropertyStoreBuilder psb) {
+ if (! a.beanClassVisibility().isEmpty())
+ psb.set(BEAN_beanClassVisibility, visibility(a.beanClassVisibility(), "beanClassVisibility"));
+ if (! a.beanConstructorVisibility().isEmpty())
+ psb.set(BEAN_beanConstructorVisibility, visibility(a.beanConstructorVisibility(), "beanConstructorVisibility"));
+ if (a.beanDictionary().length != 0)
+ psb.addTo(BEAN_beanDictionary, a.beanDictionary());
+ if (a.beanDictionary_replace().length != 0)
+ psb.set(BEAN_beanDictionary, a.beanDictionary_replace());
+ if (a.beanDictionary_remove().length != 0)
+ psb.removeFrom(BEAN_beanDictionary, a.beanDictionary_remove());
+ if (! a.beanFieldVisibility().isEmpty())
+ psb.set(BEAN_beanFieldVisibility, visibility(a.beanFieldVisibility(), "beanFieldVisibility"));
+ if (a.beanFilters().length != 0)
+ psb.addTo(BEAN_beanFilters, a.beanFilters());
+ if (a.beanFilters_replace().length != 0)
+ psb.set(BEAN_beanFilters, a.beanFilters_replace());
+ if (a.beanFilters_remove().length != 0)
+ psb.removeFrom(BEAN_beanFilters, a.beanFilters_remove());
+ if (! a.beanMapPutReturnsOldValue().isEmpty())
+ psb.set(BEAN_beanMapPutReturnsOldValue, bool(a.beanMapPutReturnsOldValue()));
+ if (! a.beanMethodVisibility().isEmpty())
+ psb.set(BEAN_beanMethodVisibility, visibility(a.beanMethodVisibility(), "beanMethodVisibility"));
+ if (! a.beansRequireDefaultConstructor().isEmpty())
+ psb.set(BEAN_beansRequireDefaultConstructor, bool(a.beansRequireDefaultConstructor()));
+ if (! a.beansRequireSerializable().isEmpty())
+ psb.set(BEAN_beansRequireSerializable, bool(a.beansRequireSerializable()));
+ if (! a.beansRequireSettersForGetters().isEmpty())
+ psb.set(BEAN_beansRequireSettersForGetters, bool(a.beansRequireSettersForGetters()));
+ if (! a.beansRequireSomeProperties().isEmpty())
+ psb.set(BEAN_beansRequireSomeProperties, bool(a.beansRequireSomeProperties()));
+ if (! a.beanTypePropertyName().isEmpty())
+ psb.set(BEAN_beanTypePropertyName, string(a.beanTypePropertyName()));
+ if (a.bpi().length > 0)
+ psb.addTo(BEAN_includeProperties, stringsMap(a.bpi(), "bpi"));
+ if (a.bpx().length > 0)
+ psb.addTo(BEAN_excludeProperties, stringsMap(a.bpi(), "bpx"));
+ if (! a.debug().isEmpty())
+ psb.set(BEAN_debug, bool(a.debug()));
+ for (CS e : a.example())
+ psb.addTo(BEAN_examples, e.k().getName(), parse(e.k(), e.v(), "example"));
+ if (a.examples().length > 0)
+ psb.addTo(BEAN_examples, objectMap(a.examples(), "examples"));
+ for (CS e : a.excludeProperties())
+ psb.addTo(BEAN_excludeProperties, e.k().getName(), string(e.v()));
+ if (! a.fluentSetters().isEmpty())
+ psb.set(BEAN_fluentSetters, bool(a.fluentSetters()));
+ if (! a.ignoreInvocationExceptionsOnGetters().isEmpty())
+ psb.set(BEAN_ignoreInvocationExceptionsOnGetters, bool(a.ignoreInvocationExceptionsOnGetters()));
+ if (! a.ignoreInvocationExceptionsOnSetters().isEmpty())
+ psb.set(BEAN_ignoreInvocationExceptionsOnSetters, bool(a.ignoreInvocationExceptionsOnSetters()));
+ if (! a.ignorePropertiesWithoutSetters().isEmpty())
+ psb.set(BEAN_ignorePropertiesWithoutSetters, bool(a.ignorePropertiesWithoutSetters()));
+ if (! a.ignoreUnknownBeanProperties().isEmpty())
+ psb.set(BEAN_ignoreUnknownBeanProperties, bool(a.ignoreUnknownBeanProperties()));
+ if (! a.ignoreUnknownNullBeanProperties().isEmpty())
+ psb.set(BEAN_ignoreUnknownNullBeanProperties, bool(a.ignoreUnknownNullBeanProperties()));
+ for (CC e : a.implClasses())
+ psb.addTo(BEAN_implClasses, e.k().getName(), e.v());
+ for (CS e : a.includeProperties())
+ psb.addTo(BEAN_includeProperties, e.k().getName(), string(e.v()));
+ if (! a.locale().isEmpty())
+ psb.set(BEAN_locale, locale(a.locale()));
+ if (! a.mediaType().isEmpty())
+ psb.set(BEAN_mediaType, mediaType(a.mediaType()));
+ if (a.notBeanClasses().length != 0)
+ psb.addTo(BEAN_notBeanClasses, a.notBeanClasses());
+ if (a.notBeanClasses_replace().length != 0)
+ psb.set(BEAN_notBeanClasses, a.notBeanClasses_replace());
+ if (a.notBeanClasses_remove().length != 0)
+ psb.removeFrom(BEAN_notBeanClasses, a.notBeanClasses_remove());
+ if (a.notBeanPackages().length != 0)
+ psb.addTo(BEAN_notBeanPackages, strings(a.notBeanPackages()));
+ if (a.notBeanPackages_replace().length != 0)
+ psb.set(BEAN_notBeanPackages, strings(a.notBeanPackages_replace()));
+ if (a.notBeanPackages_remove().length != 0)
+ psb.removeFrom(BEAN_notBeanPackages, strings(a.notBeanPackages_remove()));
+ if (a.pojoSwaps().length != 0)
+ psb.addTo(BEAN_pojoSwaps, a.pojoSwaps());
+ if (a.pojoSwaps_replace().length != 0)
+ psb.set(BEAN_pojoSwaps, a.pojoSwaps_replace());
+ if (a.pojoSwaps_remove().length != 0)
+ psb.removeFrom(BEAN_pojoSwaps, a.pojoSwaps_remove());
+ if (a.propertyNamer() != PropertyNamer.Null.class)
+ psb.set(BEAN_propertyNamer, a.propertyNamer());
+ if (! a.sortProperties().isEmpty())
+ psb.set(BEAN_sortProperties, bool(a.sortProperties()));
+ if (! a.timeZone().isEmpty())
+ psb.set(BEAN_timeZone, timeZone(a.timeZone()));
+ if (! a.useEnumNames().isEmpty())
+ psb.set(BEAN_useEnumNames, bool(a.useEnumNames()));
+ if (! a.useInterfaceProxies().isEmpty())
+ psb.set(BEAN_useInterfaceProxies, bool(a.useInterfaceProxies()));
+ if (! a.useJavaBeanIntrospector().isEmpty())
+ psb.set(BEAN_useJavaBeanIntrospector, bool(a.useJavaBeanIntrospector()));
+ if (! a.detectRecursions().isEmpty())
+ psb.set(BEANTRAVERSE_detectRecursions, bool(a.detectRecursions()));
+ if (! a.ignoreRecursions().isEmpty())
+ psb.set(BEANTRAVERSE_ignoreRecursions, bool(a.ignoreRecursions()));
+ if (! a.initialDepth().isEmpty())
+ psb.set(BEANTRAVERSE_initialDepth, integer(a.initialDepth(), "initialDepth"));
+ if (! a.maxDepth().isEmpty())
+ psb.set(BEANTRAVERSE_maxDepth, integer(a.maxDepth(), "maxDepth"));
+ }
+
+ private Locale locale(String in) {
+ return Locale.forLanguageTag(string(in));
+ }
+
+ private MediaType mediaType(String in) {
+ return MediaType.forString(string(in));
+ }
+
+ private TimeZone timeZone(String in) {
+ return TimeZone.getTimeZone(string(in));
+ }
+
+ private <T> T parse(Class<T> c, String in, String loc) {
+ try {
+ return SimpleJson.DEFAULT.read(string(in), c);
+ } catch (ParseException e) {
+ throw new ConfigException("Invalid syntax for visibility on annotation @BeanConfig({0}): {1}", loc, in);
+ }
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/CCEntry.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/CC.java
similarity index 95%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/CCEntry.java
rename to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/CC.java
index 1639f98..533396a 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/CCEntry.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/CC.java
@@ -15,11 +15,11 @@ package org.apache.juneau.annotation;
/**
* Represents a Class-to-Class mapping.
*/
-public @interface CCEntry {
+public @interface CC {
/** The Class key */
- public Class<?> key();
+ public Class<?> k();
/** The Class value */
- public Class<?> value();
+ public Class<?> v();
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/CSEntry.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/CS.java
similarity index 95%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/CSEntry.java
rename to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/CS.java
index 9e8ee71..8e5a16b 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/CSEntry.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/CS.java
@@ -15,11 +15,11 @@ package org.apache.juneau.annotation;
/**
* Represents a Class-to-String mapping.
*/
-public @interface CSEntry {
+public @interface CS {
/** The Class key */
- public Class<?> key();
+ public Class<?> k();
/** The String value */
- public String value();
+ public String v();
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvConfig.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/PropertyStoreApply.java
similarity index 80%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvConfig.java
copy to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/PropertyStoreApply.java
index a76304d..28d9bff 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvConfig.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/PropertyStoreApply.java
@@ -10,23 +10,27 @@
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
-package org.apache.juneau.csv.annotation;
+package org.apache.juneau.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
-import org.apache.juneau.csv.*;
+import org.apache.juneau.*;
/**
- * Annotation for specifying config properties defined in {@link CsvSerializer} and {@link CsvParser}.
- *
- * <p>
- * Used primarily for specifying bean configuration properties on REST classes and methods.
+ * Applied to Config annotations to identify the class used to push the values into a property store.
*/
@Documented
-@Target(TYPE)
+@Target({ANNOTATION_TYPE})
@Retention(RUNTIME)
@Inherited
-public @interface CsvConfig {}
+public @interface PropertyStoreApply {
+
+ /**
+ * Identifies the class used to push values from an annotation into a property store.
+ */
+ @SuppressWarnings("rawtypes")
+ public Class<? extends ConfigApply> value();
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SCEntry.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SC.java
similarity index 95%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SCEntry.java
copy to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SC.java
index f4e1a9c..0401ab8 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SCEntry.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SC.java
@@ -15,11 +15,11 @@ package org.apache.juneau.annotation;
/**
* Represents a String-to-Class mapping.
*/
-public @interface SCEntry {
+public @interface SC {
/** The String key */
- public String key();
+ public String k();
/** The Class value */
- public Class<?> value();
+ public Class<?> v();
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SSEntry.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SS.java
similarity index 95%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SSEntry.java
rename to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SS.java
index 478d42a..a55c1ab 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SSEntry.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SS.java
@@ -15,11 +15,11 @@ package org.apache.juneau.annotation;
/**
* Represents a String-to-String mapping.
*/
-public @interface SSEntry {
+public @interface SS {
/** The String key */
- public String key();
+ public String k();
/** The String value */
- public String value();
+ public String v();
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvParser.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvParser.java
index de14995..b7946e1 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvParser.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvParser.java
@@ -60,7 +60,12 @@ public class CsvParser extends ReaderParser {
}
@Override /* Parser */
- public ReaderParserSession createSession(ParserSessionArgs args) {
+ public CsvParserSession createSession() {
+ return createSession(createDefaultSessionArgs());
+ }
+
+ @Override /* Parser */
+ public CsvParserSession createSession(ParserSessionArgs args) {
return new CsvParserSession(this, args);
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvParserBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvParserBuilder.java
index 5dc6867..c7b0bc4 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvParserBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvParserBuilder.java
@@ -47,16 +47,6 @@ public class CsvParserBuilder extends ReaderParserBuilder {
}
//-----------------------------------------------------------------------------------------------------------------
- // Annotations
- //-----------------------------------------------------------------------------------------------------------------
-
- @Override
- public CsvParserBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) throws ParseException {
- super.applyAnnotations(m, sr);
- return this;
- }
-
- //-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
@@ -541,12 +531,6 @@ public class CsvParserBuilder extends ReaderParserBuilder {
}
@Override /* ContextBuilder */
- public CsvParserBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public CsvParserBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
@@ -581,4 +565,10 @@ public class CsvParserBuilder extends ReaderParserBuilder {
super.apply(copyFrom);
return this;
}
+
+ @Override
+ public CsvParserBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) {
+ super.applyAnnotations(m, sr);
+ return this;
+ }
}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvSerializer.java
index 2a97a11..19477c7 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvSerializer.java
@@ -62,8 +62,13 @@ public final class CsvSerializer extends WriterSerializer {
return new CsvSerializerBuilder();
}
+ @Override /* Context */
+ public CsvSerializerSession createSession() {
+ return createSession(createDefaultSessionArgs());
+ }
+
@Override /* Serializer */
- public WriterSerializerSession createSession(SerializerSessionArgs args) {
+ public CsvSerializerSession createSession(SerializerSessionArgs args) {
return new CsvSerializerSession(this, args);
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvSerializerBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvSerializerBuilder.java
index e96bd39..a31d2e7 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvSerializerBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/CsvSerializerBuilder.java
@@ -16,7 +16,6 @@ import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.http.*;
-import org.apache.juneau.parser.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.utils.*;
@@ -48,16 +47,6 @@ public class CsvSerializerBuilder extends WriterSerializerBuilder {
}
//-----------------------------------------------------------------------------------------------------------------
- // Annotations
- //-----------------------------------------------------------------------------------------------------------------
-
- @Override
- public CsvSerializerBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) throws ParseException {
- super.applyAnnotations(m, sr);
- return this;
- }
-
- //-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
@@ -655,12 +644,6 @@ public class CsvSerializerBuilder extends WriterSerializerBuilder {
}
@Override /* ContextBuilder */
- public CsvSerializerBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public CsvSerializerBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
@@ -695,4 +678,10 @@ public class CsvSerializerBuilder extends WriterSerializerBuilder {
super.apply(copyFrom);
return this;
}
+
+ @Override
+ public CsvSerializerBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) {
+ super.applyAnnotations(m, sr);
+ return this;
+ }
}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvConfig.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvConfig.java
index a76304d..4b78b63 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvConfig.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvConfig.java
@@ -17,6 +17,7 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
+import org.apache.juneau.annotation.*;
import org.apache.juneau.csv.*;
/**
@@ -26,7 +27,8 @@ import org.apache.juneau.csv.*;
* Used primarily for specifying bean configuration properties on REST classes and methods.
*/
@Documented
-@Target(TYPE)
+@Target({TYPE,METHOD})
@Retention(RUNTIME)
@Inherited
+@PropertyStoreApply(CsvConfigApply.class)
public @interface CsvConfig {}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvConfig.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvConfigApply.java
similarity index 76%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvConfig.java
copy to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvConfigApply.java
index a76304d..f2ccaac 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvConfig.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvConfigApply.java
@@ -12,21 +12,25 @@
// ***************************************************************************************************************************
package org.apache.juneau.csv.annotation;
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-import java.lang.annotation.*;
-
-import org.apache.juneau.csv.*;
+import org.apache.juneau.*;
+import org.apache.juneau.utils.*;
/**
- * Annotation for specifying config properties defined in {@link CsvSerializer} and {@link CsvParser}.
- *
- * <p>
- * Used primarily for specifying bean configuration properties on REST classes and methods.
+ * Applies {@link CsvConfig} annotations to a {@link PropertyStoreBuilder}.
*/
-@Documented
-@Target(TYPE)
-@Retention(RUNTIME)
-@Inherited
-public @interface CsvConfig {}
+public class CsvConfigApply extends ConfigApply<CsvConfig> {
+
+ /**
+ * Constructor.
+ *
+ * @param c The annotation class.
+ * @param r The resolver for resolving values in annotations.
+ */
+ public CsvConfigApply(Class<CsvConfig> c, StringResolver r) {
+ super(c, r);
+ }
+
+ @Override
+ public void apply(CsvConfig a, PropertyStoreBuilder psb) {
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializer.java
index 140ba96..b32b36e 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializer.java
@@ -596,6 +596,11 @@ public class HtmlDocSerializer extends HtmlStrippedDocSerializer {
}
@Override /* Serializer */
+ public HtmlDocSerializerSession createSession() {
+ return createSession(createDefaultSessionArgs());
+ }
+
+ @Override /* Serializer */
public HtmlDocSerializerSession createSession(SerializerSessionArgs args) {
return new HtmlDocSerializerSession(this, args);
}
@@ -607,53 +612,30 @@ public class HtmlDocSerializer extends HtmlStrippedDocSerializer {
return schemaSerializer;
}
-
//-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
/**
- * Configuration property: CSS style code.
- *
- * @see #HTMLDOC_style
- * @return
- * The CSS instructions to add to the HTML page.
- */
- protected final String[] getStyle() {
- return style;
- }
-
- /**
- * Configuration property: Stylesheet import URLs.
- *
- * @see #HTMLDOC_stylesheet
- * @return
- * The link to the stylesheet of the HTML page.
- */
- protected final String[] getStylesheet() {
- return stylesheet;
- }
-
- /**
- * Configuration property: Javascript code.
+ * Configuration property: Aside section contents.
*
- * @see #HTMLDOC_script
+ * @see #HTMLDOC_aside
* @return
- * Arbitrary Javascript to add to the HTML page.
+ * The overridden contents of the aside section on the HTML page.
*/
- protected final String[] getScript() {
- return script;
+ protected final String[] getAside() {
+ return aside;
}
/**
- * Configuration property: Page navigation links.
+ * Configuration property: Footer section contents.
*
- * @see #HTMLDOC_navlinks
+ * @see #HTMLDOC_footer
* @return
- * Navigation links to add to the HTML page.
+ * The overridden contents of the footer section on the HTML page.
*/
- protected final String[] getNavlinks() {
- return navlinks;
+ protected final String[] getFooter() {
+ return footer;
}
/**
@@ -690,25 +672,14 @@ public class HtmlDocSerializer extends HtmlStrippedDocSerializer {
}
/**
- * Configuration property: Aside section contents.
- *
- * @see #HTMLDOC_aside
- * @return
- * The overridden contents of the aside section on the HTML page.
- */
- protected final String[] getAside() {
- return aside;
- }
-
- /**
- * Configuration property: Footer section contents.
+ * Configuration property: Page navigation links.
*
- * @see #HTMLDOC_footer
+ * @see #HTMLDOC_navlinks
* @return
- * The overridden contents of the footer section on the HTML page.
+ * Navigation links to add to the HTML page.
*/
- protected final String[] getFooter() {
- return footer;
+ protected final String[] getNavlinks() {
+ return navlinks;
}
/**
@@ -734,6 +705,39 @@ public class HtmlDocSerializer extends HtmlStrippedDocSerializer {
}
/**
+ * Configuration property: Javascript code.
+ *
+ * @see #HTMLDOC_script
+ * @return
+ * Arbitrary Javascript to add to the HTML page.
+ */
+ protected final String[] getScript() {
+ return script;
+ }
+
+ /**
+ * Configuration property: CSS style code.
+ *
+ * @see #HTMLDOC_style
+ * @return
+ * The CSS instructions to add to the HTML page.
+ */
+ protected final String[] getStyle() {
+ return style;
+ }
+
+ /**
+ * Configuration property: Stylesheet import URLs.
+ *
+ * @see #HTMLDOC_stylesheet
+ * @return
+ * The link to the stylesheet of the HTML page.
+ */
+ protected final String[] getStylesheet() {
+ return stylesheet;
+ }
+
+ /**
* Configuration property: HTML document template.
*
* @see #HTMLDOC_template
@@ -744,6 +748,10 @@ public class HtmlDocSerializer extends HtmlStrippedDocSerializer {
return template;
}
+ //-----------------------------------------------------------------------------------------------------------------
+ // Other methods
+ //-----------------------------------------------------------------------------------------------------------------
+
@Override /* Context */
public ObjectMap asMap() {
return super.asMap()
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerBuilder.java
index 53266a1..f569d60 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerBuilder.java
@@ -17,10 +17,7 @@ import static org.apache.juneau.html.HtmlDocSerializer.*;
import java.util.*;
import org.apache.juneau.*;
-import org.apache.juneau.html.annotation.*;
import org.apache.juneau.http.*;
-import org.apache.juneau.internal.*;
-import org.apache.juneau.parser.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.utils.*;
@@ -53,54 +50,6 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
}
//-----------------------------------------------------------------------------------------------------------------
- // Annotations
- //-----------------------------------------------------------------------------------------------------------------
-
- @Override
- public HtmlDocSerializerBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) throws ParseException {
- super.applyAnnotations(m, sr);
- if (! m.containsKey(HtmlDocConfig.class))
- return this;
- ObjectResolver r = new ObjectResolver(sr);
- for (HtmlDocConfig a : m.get(HtmlDocConfig.class)) {
- if (a.aside().length > 0)
- aside(r.strings(a.aside()));
- if (a.footer().length > 0)
- footer(r.strings(a.footer()));
- if (a.head().length > 0)
- head(r.strings(a.head()));
- if (a.header().length > 0)
- header(r.strings(a.header()));
- if (a.nav().length > 0)
- nav(r.strings(a.nav()));
- if (a.navlinks().length > 0)
- navlinks(r.strings(a.navlinks()));
- if (a.navlinks_replace().length > 0)
- navlinks_replace(r.strings(a.navlinks_replace()));
- if (! a.noResultsMessage().isEmpty())
- noResultsMessage(r.string(a.noResultsMessage()));
- if (! a.nowrap().isEmpty())
- nowrap(r.bool(a.nowrap()));
- if (a.script().length > 0)
- script(r.strings(a.script()));
- if (a.script_replace().length > 0)
- script_replace(r.strings(a.script_replace()));
- if (a.style().length > 0)
- style(r.strings(a.style()));
- if (a.style_replace().length > 0)
- style_replace(r.strings(a.style_replace()));
- if (a.stylesheet().length > 0)
- stylesheet(r.strings(a.stylesheet()));
- if (a.stylesheet_replace().length > 0)
- stylesheet_replace
- (r.strings(a.stylesheet_replace()));
- if (a.template() != HtmlDocTemplate.Null.class)
- template(a.template());
- }
- return this;
- }
-
- //-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
@@ -130,8 +79,9 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
*
* @param value
* The new value for this property.
+ * @return This object (for method chaining).
*/
- private HtmlDocSerializerBuilder aside(String[] value) {
+ public HtmlDocSerializerBuilder aside(String[] value) {
set(HTMLDOC_aside, value);
return this;
}
@@ -156,8 +106,9 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
*
* @param value
* The new value for this property.
+ * @return This object (for method chaining).
*/
- private HtmlDocSerializerBuilder footer(String[] value) {
+ public HtmlDocSerializerBuilder footer(String[] value) {
set(HTMLDOC_footer, value);
return this;
}
@@ -179,8 +130,9 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
*
* @param value
* The new value for this property.
+ * @return This object (for method chaining).
*/
- private HtmlDocSerializerBuilder head(String[] value) {
+ public HtmlDocSerializerBuilder head(String[] value) {
set(HTMLDOC_head, value);
return this;
}
@@ -203,8 +155,9 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
*
* @param value
* The new value for this property.
+ * @return This object (for method chaining).
*/
- private HtmlDocSerializerBuilder header(String[] value) {
+ public HtmlDocSerializerBuilder header(String[] value) {
set(HTMLDOC_header, value);
return this;
}
@@ -230,8 +183,9 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
*
* @param value
* The new value for this property.
+ * @return This object (for method chaining).
*/
- private HtmlDocSerializerBuilder nav(String[] value) {
+ public HtmlDocSerializerBuilder nav(String[] value) {
set(HTMLDOC_nav, value);
return this;
}
@@ -274,8 +228,9 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
*
* @param value
* The new value for this property.
+ * @return This object (for method chaining).
*/
- private HtmlDocSerializerBuilder navlinks_replace(String[] value) {
+ public HtmlDocSerializerBuilder navlinks_replace(String[] value) {
set(HTMLDOC_navlinks, value);
return this;
}
@@ -285,8 +240,9 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
*
* @param value
* The value to add to this property.
+ * @return This object (for method chaining).
*/
- private HtmlDocSerializerBuilder navlinks(String[] value) {
+ public HtmlDocSerializerBuilder navlinks(String[] value) {
set(HTMLDOC_navlinks_add, value);
return this;
}
@@ -309,8 +265,9 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
*
* @param value
* The new value for this property.
+ * @return This object (for method chaining).
*/
- private HtmlDocSerializerBuilder noResultsMessage(String value) {
+ public HtmlDocSerializerBuilder noResultsMessage(String value) {
set(HTMLDOC_noResultsMessage, value);
return this;
}
@@ -323,8 +280,9 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
*
* @param value
* The new value for this property.
+ * @return This object (for method chaining).
*/
- private HtmlDocSerializerBuilder nowrap(boolean value) {
+ public HtmlDocSerializerBuilder nowrap(boolean value) {
set(HTMLDOC_nowrap, value);
return this;
}
@@ -346,8 +304,9 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
*
* @param value
* The new value for this property.
+ * @return This object (for method chaining).
*/
- private HtmlDocSerializerBuilder script_replace(String[] value) {
+ public HtmlDocSerializerBuilder script_replace(String[] value) {
set(HTMLDOC_script, value);
return this;
}
@@ -357,8 +316,9 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
*
* @param value
* The value to add to this property.
+ * @return This object (for method chaining).
*/
- private HtmlDocSerializerBuilder script(String[] value) {
+ public HtmlDocSerializerBuilder script(String[] value) {
set(HTMLDOC_script_add, value);
return this;
}
@@ -381,8 +341,9 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
*
* @param value
* The new value for this property.
+ * @return This object (for method chaining).
*/
- private HtmlDocSerializerBuilder style_replace(String[] value) {
+ public HtmlDocSerializerBuilder style_replace(String[] value) {
set(HTMLDOC_style, value);
return this;
}
@@ -392,8 +353,9 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
*
* @param value
* The value to add to this property.
+ * @return This object (for method chaining).
*/
- private HtmlDocSerializerBuilder style(String[] value) {
+ public HtmlDocSerializerBuilder style(String[] value) {
set(HTMLDOC_style_add, value);
return this;
}
@@ -409,8 +371,9 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
*
* @param value
* The new value for this property.
+ * @return This object (for method chaining).
*/
- private HtmlDocSerializerBuilder stylesheet_replace(String[] value) {
+ public HtmlDocSerializerBuilder stylesheet_replace(String[] value) {
set(HTMLDOC_stylesheet, value);
return this;
}
@@ -420,8 +383,9 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
*
* @param value
* The value to add to this property.
+ * @return This object (for method chaining).
*/
- private HtmlDocSerializerBuilder stylesheet(String[] value) {
+ public HtmlDocSerializerBuilder stylesheet(String[] value) {
set(HTMLDOC_stylesheet_add, value);
return this;
}
@@ -445,8 +409,9 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
*
* @param value
* The new value for this property.
+ * @return This object (for method chaining).
*/
- private HtmlDocSerializerBuilder template(Class<?> value) {
+ public HtmlDocSerializerBuilder template(Class<?> value) {
set(HTMLDOC_template, value);
return this;
}
@@ -1129,12 +1094,6 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
}
@Override /* ContextBuilder */
- public HtmlDocSerializerBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public HtmlDocSerializerBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
@@ -1169,4 +1128,10 @@ public class HtmlDocSerializerBuilder extends HtmlStrippedDocSerializerBuilder {
super.apply(copyFrom);
return this;
}
+
+ @Override
+ public HtmlDocSerializerBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) {
+ super.applyAnnotations(m, sr);
+ return this;
+ }
}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java
index 9598e43..8834998 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java
@@ -115,47 +115,25 @@ public class HtmlDocSerializerSession extends HtmlStrippedDocSerializerSession {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Configuration property: CSS style code.
- *
- * @see HtmlDocSerializer#HTMLDOC_style
- * @return
- * The CSS instructions to add to the HTML page.
- */
- protected final Set<String> getStyle() {
- return style;
- }
-
- /**
- * Configuration property: Stylesheet import URLs.
- *
- * @see HtmlDocSerializer#HTMLDOC_stylesheet
- * @return
- * The link to the stylesheet of the HTML page.
- */
- protected final Set<String> getStylesheet() {
- return stylesheet;
- }
-
- /**
- * Configuration property: Javascript code.
+ * Configuration property: Aside section contents.
*
- * @see HtmlDocSerializer#HTMLDOC_script
+ * @see HtmlDocSerializer#HTMLDOC_aside
* @return
- * Arbitrary Javascript to add to the HTML page.
+ * The overridden contents of the aside section on the HTML page.
*/
- protected final Set<String> getScript() {
- return script;
+ protected final String[] getAside() {
+ return aside;
}
/**
- * Configuration property: Page navigation links.
+ * Configuration property: Footer section contents.
*
- * @see HtmlDocSerializer#HTMLDOC_navlinks
+ * @see HtmlDocSerializer#HTMLDOC_footer
* @return
- * Navigation links to add to the HTML page.
+ * The overridden contents of the footer section on the HTML page.
*/
- protected final String[] getNavlinks() {
- return navlinks;
+ protected final String[] getFooter() {
+ return footer;
}
/**
@@ -192,25 +170,14 @@ public class HtmlDocSerializerSession extends HtmlStrippedDocSerializerSession {
}
/**
- * Configuration property: Aside section contents.
- *
- * @see HtmlDocSerializer#HTMLDOC_aside
- * @return
- * The overridden contents of the aside section on the HTML page.
- */
- protected final String[] getAside() {
- return aside;
- }
-
- /**
- * Configuration property: Footer section contents.
+ * Configuration property: Page navigation links.
*
- * @see HtmlDocSerializer#HTMLDOC_footer
+ * @see HtmlDocSerializer#HTMLDOC_navlinks
* @return
- * The overridden contents of the footer section on the HTML page.
+ * Navigation links to add to the HTML page.
*/
- protected final String[] getFooter() {
- return footer;
+ protected final String[] getNavlinks() {
+ return navlinks;
}
/**
@@ -236,6 +203,39 @@ public class HtmlDocSerializerSession extends HtmlStrippedDocSerializerSession {
}
/**
+ * Configuration property: Javascript code.
+ *
+ * @see HtmlDocSerializer#HTMLDOC_script
+ * @return
+ * Arbitrary Javascript to add to the HTML page.
+ */
+ protected final Set<String> getScript() {
+ return script;
+ }
+
+ /**
+ * Configuration property: CSS style code.
+ *
+ * @see HtmlDocSerializer#HTMLDOC_style
+ * @return
+ * The CSS instructions to add to the HTML page.
+ */
+ protected final Set<String> getStyle() {
+ return style;
+ }
+
+ /**
+ * Configuration property: Stylesheet import URLs.
+ *
+ * @see HtmlDocSerializer#HTMLDOC_stylesheet
+ * @return
+ * The link to the stylesheet of the HTML page.
+ */
+ protected final Set<String> getStylesheet() {
+ return stylesheet;
+ }
+
+ /**
* Configuration property: HTML document template.
*
* @see HtmlDocSerializer#HTMLDOC_template
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParser.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParser.java
index 1174989..9f3bcb3 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParser.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParser.java
@@ -74,6 +74,11 @@ public class HtmlParser extends XmlParser {
}
@Override /* Parser */
+ public HtmlParserSession createSession() {
+ return createSession(createDefaultSessionArgs());
+ }
+
+ @Override /* Parser */
public HtmlParserSession createSession(ParserSessionArgs args) {
return new HtmlParserSession(this, args);
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserBuilder.java
index f4a26dd..6df038b 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserBuilder.java
@@ -51,16 +51,6 @@ public class HtmlParserBuilder extends XmlParserBuilder {
}
//-----------------------------------------------------------------------------------------------------------------
- // Annotations
- //-----------------------------------------------------------------------------------------------------------------
-
- @Override
- public HtmlParserBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) throws ParseException {
- super.applyAnnotations(m, sr);
- return this;
- }
-
- //-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
@@ -563,12 +553,6 @@ public class HtmlParserBuilder extends XmlParserBuilder {
}
@Override /* ContextBuilder */
- public HtmlParserBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public HtmlParserBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
@@ -603,4 +587,10 @@ public class HtmlParserBuilder extends XmlParserBuilder {
super.apply(copyFrom);
return this;
}
+
+ @Override
+ public HtmlParserBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) {
+ super.applyAnnotations(m, sr);
+ return this;
+ }
}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java
index d8b7879..f7ad845 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java
@@ -91,6 +91,11 @@ public final class HtmlSchemaDocSerializer extends HtmlDocSerializer {
}
@Override /* Serializer */
+ public HtmlSchemaDocSerializerSession createSession() {
+ return createSession(createDefaultSessionArgs());
+ }
+
+ @Override /* Serializer */
public HtmlSchemaDocSerializerSession createSession(SerializerSessionArgs args) {
return new HtmlSchemaDocSerializerSession(this, args);
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaSerializer.java
index 1a4ff99..a15f1a8 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaSerializer.java
@@ -133,16 +133,16 @@ public class HtmlSchemaSerializer extends HtmlSerializer {
return new HtmlSchemaSerializerBuilder(getPropertyStore());
}
- @Override /* Serializer */
- public HtmlSchemaSerializerSession createSession(SerializerSessionArgs args) {
- return new HtmlSchemaSerializerSession(this, args);
- }
-
@Override /* Context */
public HtmlSchemaSerializerSession createSession() {
return createSession(createDefaultSessionArgs());
}
+ @Override /* Serializer */
+ public HtmlSchemaSerializerSession createSession(SerializerSessionArgs args) {
+ return new HtmlSchemaSerializerSession(this, args);
+ }
+
JsonSchemaGenerator getGenerator() {
return generator;
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaSerializerBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaSerializerBuilder.java
index 4ae3995..282f34b 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaSerializerBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaSerializerBuilder.java
@@ -20,7 +20,6 @@ import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.http.*;
import org.apache.juneau.jsonschema.*;
-import org.apache.juneau.parser.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.utils.*;
@@ -52,16 +51,6 @@ public class HtmlSchemaSerializerBuilder extends HtmlSerializerBuilder {
}
//-----------------------------------------------------------------------------------------------------------------
- // Annotations
- //-----------------------------------------------------------------------------------------------------------------
-
- @Override
- public HtmlSchemaSerializerBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) throws ParseException {
- super.applyAnnotations(m, sr);
- return this;
- }
-
- //-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
@@ -795,12 +784,6 @@ public class HtmlSchemaSerializerBuilder extends HtmlSerializerBuilder {
}
@Override /* ContextBuilder */
- public HtmlSchemaSerializerBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public HtmlSchemaSerializerBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
@@ -835,4 +818,10 @@ public class HtmlSchemaSerializerBuilder extends HtmlSerializerBuilder {
super.apply(copyFrom);
return this;
}
+
+ @Override
+ public HtmlSchemaSerializerBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) {
+ super.applyAnnotations(m, sr);
+ return this;
+ }
}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializer.java
index 8b33cbb..0f336d3 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializer.java
@@ -629,7 +629,7 @@ public class HtmlSerializer extends XmlSerializer {
private final AnchorText uriAnchorText;
private final boolean
- lookForLabelParameters,
+ detectLabelParameters,
detectLinksInStrings,
addKeyValueTableHeaders,
addBeanTypes;
@@ -677,7 +677,7 @@ public class HtmlSerializer extends XmlSerializer {
public HtmlSerializer(PropertyStore ps, String produces, String accept) {
super(ps, produces, accept);
uriAnchorText = getProperty(HTML_uriAnchorText, AnchorText.class, AnchorText.TO_STRING);
- lookForLabelParameters = getBooleanProperty(HTML_detectLabelParameters, true);
+ detectLabelParameters = getBooleanProperty(HTML_detectLabelParameters, true);
detectLinksInStrings = getBooleanProperty(HTML_detectLinksInStrings, true);
labelParameter = getStringProperty(HTML_labelParameter, "label");
addKeyValueTableHeaders = getBooleanProperty(HTML_addKeyValueTableHeaders, false);
@@ -706,7 +706,12 @@ public class HtmlSerializer extends XmlSerializer {
}
@Override /* Serializer */
- public WriterSerializerSession createSession(SerializerSessionArgs args) {
+ public HtmlSerializerSession createSession() {
+ return createSession(createDefaultSessionArgs());
+ }
+
+ @Override /* Serializer */
+ public HtmlSerializerSession createSession(SerializerSessionArgs args) {
return new HtmlSerializerSession(this, args);
}
@@ -722,49 +727,49 @@ public class HtmlSerializer extends XmlSerializer {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Configuration property: Look for link labels in URIs.
+ * Configuration property: Add <js>"_type"</js> properties when needed.
*
- * @see #HTML_detectLabelParameters
+ * @see #HTML_addBeanTypes
* @return
- * <jk>true</jk> if we should look for URL label parameters (e.g. <js>"?label=foobar"</js>).
+ * <jk>true</jk> if <js>"_type"</js> properties will be added to beans if their type cannot be inferred
+ * through reflection.
*/
- protected final boolean isLookForLabelParameters() {
- return lookForLabelParameters;
+ @Override
+ protected final boolean isAddBeanTypes() {
+ return addBeanTypes;
}
/**
- * Configuration property: Look for URLs in {@link String Strings}.
+ * Configuration property: Add key/value headers on bean/map tables.
*
- * @see #HTML_detectLinksInStrings
+ * @see #HTML_addKeyValueTableHeaders
* @return
- * <jk>true</jk> if we should automatically convert strings to URLs if they look like a URL.
+ * <jk>true</jk> if <code><b>key</b></code> and <code><b>value</b></code> column headers are added to tables.
*/
- protected final boolean isDetectLinksInStrings() {
- return detectLinksInStrings;
+ protected final boolean isAddKeyValueTableHeaders() {
+ return addKeyValueTableHeaders;
}
/**
- * Configuration property: Add key/value headers on bean/map tables.
+ * Configuration property: Look for link labels in URIs.
*
- * @see #HTML_addKeyValueTableHeaders
+ * @see #HTML_detectLabelParameters
* @return
- * <jk>true</jk> if <code><b>key</b></code> and <code><b>value</b></code> column headers are added to tables.
+ * <jk>true</jk> if we should look for URL label parameters (e.g. <js>"?label=foobar"</js>).
*/
- protected final boolean isAddKeyValueTableHeaders() {
- return addKeyValueTableHeaders;
+ protected final boolean isDetectLabelParameters() {
+ return detectLabelParameters;
}
/**
- * Configuration property: Add <js>"_type"</js> properties when needed.
+ * Configuration property: Look for URLs in {@link String Strings}.
*
- * @see #HTML_addBeanTypes
+ * @see #HTML_detectLinksInStrings
* @return
- * <jk>true</jk> if <js>"_type"</js> properties will be added to beans if their type cannot be inferred
- * through reflection.
+ * <jk>true</jk> if we should automatically convert strings to URLs if they look like a URL.
*/
- @Override
- protected final boolean isAddBeanTypes() {
- return addBeanTypes;
+ protected final boolean isDetectLinksInStrings() {
+ return detectLinksInStrings;
}
/**
@@ -790,12 +795,16 @@ public class HtmlSerializer extends XmlSerializer {
return uriAnchorText;
}
+ //-----------------------------------------------------------------------------------------------------------------
+ // Other methods
+ //-----------------------------------------------------------------------------------------------------------------
+
@Override /* Context */
public ObjectMap asMap() {
return super.asMap()
.append("HtmlSerializer", new ObjectMap()
.append("uriAnchorText", uriAnchorText)
- .append("lookForLabelParameters", lookForLabelParameters)
+ .append("detectLabelParameters", detectLabelParameters)
.append("detectLinksInStrings", detectLinksInStrings)
.append("labelParameter", labelParameter)
.append("addKeyValueTableHeaders", addKeyValueTableHeaders)
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerBuilder.java
index 71abf80..9548019 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerBuilder.java
@@ -17,10 +17,7 @@ import static org.apache.juneau.html.HtmlSerializer.*;
import java.util.*;
import org.apache.juneau.*;
-import org.apache.juneau.html.annotation.*;
import org.apache.juneau.http.*;
-import org.apache.juneau.internal.*;
-import org.apache.juneau.parser.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.utils.*;
@@ -53,33 +50,6 @@ public class HtmlSerializerBuilder extends XmlSerializerBuilder {
}
//-----------------------------------------------------------------------------------------------------------------
- // Annotations
- //-----------------------------------------------------------------------------------------------------------------
-
- @Override
- public HtmlSerializerBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) throws ParseException {
- super.applyAnnotations(m, sr);
- if (! m.containsKey(HtmlConfig.class))
- return this;
- ObjectResolver r = new ObjectResolver(sr);
- for (HtmlConfig a : m.get(HtmlConfig.class)) {
- if (! a.addBeanTypes().isEmpty())
- addBeanTypes(r.bool(a.addBeanTypes()));
- if (! a.addKeyValueTableHeaders().isEmpty())
- addKeyValueTableHeaders(r.bool(a.addKeyValueTableHeaders()));
- if (! a.detectLabelParameters().isEmpty())
- detectLabelParameters(r.bool(a.detectLabelParameters()));
- if (! a.detectLinksInStrings().isEmpty())
- detectLinksInStrings(r.bool(a.detectLinksInStrings()));
- if (! a.labelParameter().isEmpty())
- labelParameter(r.string(a.labelParameter()));
- if (! a.uriAnchorText().isEmpty())
- uriAnchorText(r.string(a.uriAnchorText()));
- }
- return this;
- }
-
- //-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
@@ -855,12 +825,6 @@ public class HtmlSerializerBuilder extends XmlSerializerBuilder {
}
@Override /* ContextBuilder */
- public HtmlSerializerBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public HtmlSerializerBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
@@ -895,4 +859,10 @@ public class HtmlSerializerBuilder extends XmlSerializerBuilder {
super.apply(copyFrom);
return this;
}
+
+ @Override
+ public HtmlSerializerBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) {
+ super.applyAnnotations(m, sr);
+ return this;
+ }
}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java
index cd53fa0..5745a01 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java
@@ -115,7 +115,7 @@ public class HtmlSerializerSession extends XmlSerializerSession {
*/
public String getAnchorText(BeanPropertyMeta pMeta, Object o) {
String s = o.toString();
- if (isLookForLabelParameters()) {
+ if (isDetectLabelParameters()) {
Matcher m = labelPattern.matcher(s);
if (m.find())
return urlDecode(m.group(1));
@@ -818,54 +818,55 @@ public class HtmlSerializerSession extends XmlSerializerSession {
}
return th;
}
+
//-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
/**
- * Configuration property: Look for link labels in URIs.
+ * Configuration property: Add <js>"_type"</js> properties when needed.
*
- * @see HtmlSerializer#HTML_detectLabelParameters
+ * @see HtmlSerializer#HTML_addBeanTypes
* @return
- * <jk>true</jk> if we should look for URL label parameters (e.g. <js>"?label=foobar"</js>).
+ * <jk>true</jk> if <js>"_type"</js> properties will be added to beans if their type cannot be inferred
+ * through reflection.
*/
- protected final boolean isLookForLabelParameters() {
- return ctx.isLookForLabelParameters();
+ @Override
+ protected final boolean isAddBeanTypes() {
+ return ctx.isAddBeanTypes();
}
/**
- * Configuration property: Look for URLs in {@link String Strings}.
+ * Configuration property: Add key/value headers on bean/map tables.
*
- * @see HtmlSerializer#HTML_detectLinksInStrings
+ * @see HtmlSerializer#HTML_addKeyValueTableHeaders
* @return
- * <jk>true</jk> if we should automatically convert strings to URLs if they look like a URL.
+ * <jk>true</jk> if <code><b>key</b></code> and <code><b>value</b></code> column headers are added to tables.
*/
- protected final boolean isDetectLinksInStrings() {
- return ctx.isDetectLinksInStrings();
+ protected final boolean isAddKeyValueTableHeaders() {
+ return ctx.isAddKeyValueTableHeaders();
}
/**
- * Configuration property: Add key/value headers on bean/map tables.
+ * Configuration property: Look for link labels in URIs.
*
- * @see HtmlSerializer#HTML_addKeyValueTableHeaders
+ * @see HtmlSerializer#HTML_detectLabelParameters
* @return
- * <jk>true</jk> if <code><b>key</b></code> and <code><b>value</b></code> column headers are added to tables.
+ * <jk>true</jk> if we should look for URL label parameters (e.g. <js>"?label=foobar"</js>).
*/
- protected final boolean isAddKeyValueTableHeaders() {
- return ctx.isAddKeyValueTableHeaders();
+ protected final boolean isDetectLabelParameters() {
+ return ctx.isDetectLabelParameters();
}
/**
- * Configuration property: Add <js>"_type"</js> properties when needed.
+ * Configuration property: Look for URLs in {@link String Strings}.
*
- * @see HtmlSerializer#HTML_addBeanTypes
+ * @see HtmlSerializer#HTML_detectLinksInStrings
* @return
- * <jk>true</jk> if <js>"_type"</js> properties will be added to beans if their type cannot be inferred
- * through reflection.
+ * <jk>true</jk> if we should automatically convert strings to URLs if they look like a URL.
*/
- @Override
- protected final boolean isAddBeanTypes() {
- return ctx.isAddBeanTypes();
+ protected final boolean isDetectLinksInStrings() {
+ return ctx.isDetectLinksInStrings();
}
/**
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializer.java
index 66a3a2a..79e5f4b 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializer.java
@@ -94,7 +94,12 @@ public class HtmlStrippedDocSerializer extends HtmlSerializer {
}
@Override /* Serializer */
- public WriterSerializerSession createSession(SerializerSessionArgs args) {
+ public HtmlSerializerSession createSession() {
+ return createSession(createDefaultSessionArgs());
+ }
+
+ @Override /* Serializer */
+ public HtmlSerializerSession createSession(SerializerSessionArgs args) {
return new HtmlStrippedDocSerializerSession(this, args);
}
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializerBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializerBuilder.java
index ec43e67..1e25303 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializerBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlStrippedDocSerializerBuilder.java
@@ -16,7 +16,6 @@ import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.http.*;
-import org.apache.juneau.parser.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.utils.*;
@@ -49,16 +48,6 @@ public class HtmlStrippedDocSerializerBuilder extends HtmlSerializerBuilder {
}
//-----------------------------------------------------------------------------------------------------------------
- // Annotations
- //-----------------------------------------------------------------------------------------------------------------
-
- @Override
- public HtmlStrippedDocSerializerBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) throws ParseException {
- super.applyAnnotations(m, sr);
- return this;
- }
-
- //-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
@@ -740,12 +729,6 @@ public class HtmlStrippedDocSerializerBuilder extends HtmlSerializerBuilder {
}
@Override /* ContextBuilder */
- public HtmlStrippedDocSerializerBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public HtmlStrippedDocSerializerBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
@@ -780,4 +763,10 @@ public class HtmlStrippedDocSerializerBuilder extends HtmlSerializerBuilder {
super.apply(copyFrom);
return this;
}
+
+ @Override
+ public HtmlStrippedDocSerializerBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) {
+ super.applyAnnotations(m, sr);
+ return this;
+ }
}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlConfig.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlConfig.java
index 62efeae..a2c7c07 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlConfig.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlConfig.java
@@ -19,6 +19,7 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
+import org.apache.juneau.annotation.*;
import org.apache.juneau.html.*;
import org.apache.juneau.serializer.*;
@@ -29,9 +30,10 @@ import org.apache.juneau.serializer.*;
* Used primarily for specifying bean configuration properties on REST classes and methods.
*/
@Documented
-@Target(TYPE)
+@Target({TYPE,METHOD})
@Retention(RUNTIME)
@Inherited
+@PropertyStoreApply(HtmlConfigApply.class)
public @interface HtmlConfig {
//-------------------------------------------------------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xmlschema/XmlSchemaSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlConfigApply.java
similarity index 57%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xmlschema/XmlSchemaSerializer.java
copy to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlConfigApply.java
index de912d0..099e640 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xmlschema/XmlSchemaSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlConfigApply.java
@@ -1,53 +1,49 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.xmlschema;
-
-import org.apache.juneau.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.xml.*;
-
-/**
- * Serializes POJO metadata to HTTP responses as XML.
- *
- * <h5 class='topic'>Media types</h5>
- *
- * Handles <code>Accept</code> types: <code><b>text/xml+schema</b></code>
- * <p>
- * Produces <code>Content-Type</code> types: <code><b>text/xml</b></code>
- *
- * <h5 class='topic'>Description</h5>
- *
- * Produces the XML-schema representation of the XML produced by the {@link XmlSerializer} class with the same properties.
- */
-public class XmlSchemaSerializer extends XmlSerializer {
-
- /**
- * Constructor.
- *
- * @param ps Initialize with the specified config property store.
- */
- public XmlSchemaSerializer(PropertyStore ps) {
- super(
- ps.builder()
- .set(XML_enableNamespaces, true)
- .build(),
- "text/xml",
- "text/xml+schema"
- );
- }
-
- @Override /* Serializer */
- public WriterSerializerSession createSession(SerializerSessionArgs args) {
- return new XmlSchemaSerializerSession(this, args);
- }
-}
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.html.annotation;
+
+import static org.apache.juneau.html.HtmlSerializer.*;
+import org.apache.juneau.*;
+import org.apache.juneau.utils.*;
+
+/**
+ * Applies {@link HtmlConfig} annotations to a {@link PropertyStoreBuilder}.
+ */
+public class HtmlConfigApply extends ConfigApply<HtmlConfig> {
+
+ /**
+ * Constructor.
+ *
+ * @param c The annotation class.
+ * @param r The resolver for resolving values in annotations.
+ */
+ public HtmlConfigApply(Class<HtmlConfig> c, StringResolver r) {
+ super(c, r);
+ }
+
+ @Override
+ public void apply(HtmlConfig a, PropertyStoreBuilder psb) {
+ if (! a.addBeanTypes().isEmpty())
+ psb.set(HTML_addBeanTypes, bool(a.addBeanTypes()));
+ if (! a.addKeyValueTableHeaders().isEmpty())
+ psb.set(HTML_addKeyValueTableHeaders, bool(a.addKeyValueTableHeaders()));
+ if (! a.detectLabelParameters().isEmpty())
+ psb.set(HTML_detectLabelParameters, bool(a.detectLabelParameters()));
+ if (! a.detectLinksInStrings().isEmpty())
+ psb.set(HTML_detectLinksInStrings, bool(a.detectLinksInStrings()));
+ if (! a.labelParameter().isEmpty())
+ psb.set(HTML_labelParameter, string(a.labelParameter()));
+ if (! a.uriAnchorText().isEmpty())
+ psb.set(HTML_uriAnchorText, string(a.uriAnchorText()));
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlDocConfig.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlDocConfig.java
index 2046433..eb4b6bc 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlDocConfig.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlDocConfig.java
@@ -20,6 +20,7 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
import org.apache.juneau.*;
+import org.apache.juneau.annotation.*;
import org.apache.juneau.html.*;
/**
@@ -29,9 +30,10 @@ import org.apache.juneau.html.*;
* Used primarily for specifying bean configuration properties on REST classes and methods.
*/
@Documented
-@Target(TYPE)
+@Target({TYPE,METHOD})
@Retention(RUNTIME)
@Inherited
+@PropertyStoreApply(HtmlDocConfigApply.class)
public @interface HtmlDocConfig {
//-------------------------------------------------------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlDocConfigApply.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlDocConfigApply.java
new file mode 100644
index 0000000..33ffc2a
--- /dev/null
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlDocConfigApply.java
@@ -0,0 +1,70 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.html.annotation;
+
+import static org.apache.juneau.html.HtmlDocSerializer.*;
+import org.apache.juneau.*;
+import org.apache.juneau.html.*;
+import org.apache.juneau.utils.*;
+
+/**
+ * Applies {@link HtmlDocConfig} annotations to a {@link PropertyStoreBuilder}.
+ */
+public class HtmlDocConfigApply extends ConfigApply<HtmlDocConfig> {
+
+ /**
+ * Constructor.
+ *
+ * @param c The annotation class.
+ * @param r The resolver for resolving values in annotations.
+ */
+ public HtmlDocConfigApply(Class<HtmlDocConfig> c, StringResolver r) {
+ super(c, r);
+ }
+
+ @Override
+ public void apply(HtmlDocConfig a, PropertyStoreBuilder psb) {
+ if (a.aside().length > 0)
+ psb.set(HTMLDOC_aside, strings(a.aside()));
+ if (a.footer().length > 0)
+ psb.set(HTMLDOC_footer, strings(a.footer()));
+ if (a.head().length > 0)
+ psb.set(HTMLDOC_head, strings(a.head()));
+ if (a.header().length > 0)
+ psb.set(HTMLDOC_header, strings(a.header()));
+ if (a.nav().length > 0)
+ psb.set(HTMLDOC_nav, strings(a.nav()));
+ if (a.navlinks().length > 0)
+ psb.addTo(HTMLDOC_navlinks, strings(a.navlinks()));
+ if (a.navlinks_replace().length > 0)
+ psb.set(HTMLDOC_navlinks, strings(a.navlinks_replace()));
+ if (! a.noResultsMessage().isEmpty())
+ psb.set(HTMLDOC_noResultsMessage, string(a.noResultsMessage()));
+ if (! a.nowrap().isEmpty())
+ psb.set(HTMLDOC_nowrap, bool(a.nowrap()));
+ if (a.script().length > 0)
+ psb.addTo(HTMLDOC_script, strings(a.script()));
+ if (a.script_replace().length > 0)
+ psb.set(HTMLDOC_script, strings(a.script_replace()));
+ if (a.style().length > 0)
+ psb.addTo(HTMLDOC_style, strings(a.style()));
+ if (a.style_replace().length > 0)
+ psb.set(HTMLDOC_style, strings(a.style_replace()));
+ if (a.stylesheet().length > 0)
+ psb.addTo(HTMLDOC_stylesheet, strings(a.stylesheet()));
+ if (a.stylesheet_replace().length > 0)
+ psb.set(HTMLDOC_stylesheet, strings(a.stylesheet_replace()));
+ if (a.template() != HtmlDocTemplate.Null.class)
+ psb.set(HTMLDOC_template, a.template());
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ObjectResolver.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ObjectResolver.java
deleted file mode 100644
index ec7d4b2..0000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ObjectResolver.java
+++ /dev/null
@@ -1,120 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.internal;
-
-import java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.http.*;
-import org.apache.juneau.utils.*;
-
-/**
- * Convenience wrapper around a {@link StringResolver} that also constructs string-based objects.
- *
- */
-public class ObjectResolver {
-
- private final StringResolver r;
-
- /**
- * Constructor.
- *
- * @param r
- */
- public ObjectResolver(StringResolver r) {
- this.r = r == null ? StringResolver.NOOP : r;
- }
-
- /**
- * Resolves the specified string.
- *
- * @param in The string containing variables to resolve.
- * @return The resolved string.
- */
- public String string(String in) {
- return r.resolve(in);
- }
-
- /**
- * Resolves the specified strings in the string array.
- *
- * @param in The string array containing variables to resolve.
- * @return An array with resolved strings.
- */
- public String[] strings(String[] in) {
- String[] out = new String[in.length];
- for (int i = 0; i < in.length; i++)
- out[i] = r.resolve(in[i]);
- return out;
- }
-
- /**
- * Resolves the specified string and converts it to a boolean.
- *
- * @param in The string containing variables to resolve.
- * @return The resolved boolean.
- */
- public boolean bool(String in) {
- return Boolean.parseBoolean(r.resolve(in));
- }
-
- /**
- * Resolves the specified string and converts it to an int.
- *
- * @param in The string containing variables to resolve.
- * @return The resolved int.
- */
- public int integer(String in) {
- return Integer.parseInt(r.resolve(in));
- }
-
- /**
- * Resolves the specified string and converts it to a Locale.
- *
- * @param in The string containing variables to resolve.
- * @return The resolved Locale.
- */
- public Locale locale(String in) {
- return Locale.forLanguageTag(r.resolve(in));
- }
-
- /**
- * Resolves the specified string and converts it to a MediaType.
- *
- * @param in The string containing variables to resolve.
- * @return The resolved MediaType.
- */
- public MediaType mediaType(String in) {
- return MediaType.forString(r.resolve(in));
- }
-
- /**
- * Resolves the specified string and converts it to a TimeZone.
- *
- * @param in The string containing variables to resolve.
- * @return The resolved TimeZone.
- */
- public TimeZone timeZone(String in) {
- return TimeZone.getTimeZone(r.resolve(in));
- }
-
- /**
- * Resolves the specified string and converts it to a Visibility.
- *
- * @param in The string containing variables to resolve.
- * @return The resolved Visibility.
- */
- public Visibility visibility(String in) {
- return Visibility.valueOf(r.resolve(in));
- }
-}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoParser.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoParser.java
index 92e15de..99768a0 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoParser.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoParser.java
@@ -69,7 +69,12 @@ public final class JsoParser extends InputStreamParser {
}
@Override /* Parser */
- public InputStreamParserSession createSession(ParserSessionArgs args) {
+ public JsoParserSession createSession() {
+ return createSession(createDefaultSessionArgs());
+ }
+
+ @Override /* Parser */
+ public JsoParserSession createSession(ParserSessionArgs args) {
return new JsoParserSession(args);
}
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoParserBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoParserBuilder.java
index 6df18fa..46b7e5b 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoParserBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoParserBuilder.java
@@ -47,16 +47,6 @@ public class JsoParserBuilder extends InputStreamParserBuilder {
}
//-----------------------------------------------------------------------------------------------------------------
- // Annotations
- //-----------------------------------------------------------------------------------------------------------------
-
- @Override
- public JsoParserBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) throws ParseException {
- super.applyAnnotations(m, sr);
- return this;
- }
-
- //-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
@@ -535,12 +525,6 @@ public class JsoParserBuilder extends InputStreamParserBuilder {
}
@Override /* ContextBuilder */
- public JsoParserBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public JsoParserBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
@@ -575,4 +559,10 @@ public class JsoParserBuilder extends InputStreamParserBuilder {
super.apply(copyFrom);
return this;
}
+
+ @Override
+ public JsoParserBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) {
+ super.applyAnnotations(m, sr);
+ return this;
+ }
}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoSerializer.java
index 55338aa..4cfb8fc 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoSerializer.java
@@ -70,8 +70,13 @@ public class JsoSerializer extends OutputStreamSerializer {
return new JsoSerializerBuilder();
}
+ @Override /* Context */
+ public JsoSerializerSession createSession() {
+ return createSession(createDefaultSessionArgs());
+ }
+
@Override /* Serializer */
- public OutputStreamSerializerSession createSession(SerializerSessionArgs args) {
+ public JsoSerializerSession createSession(SerializerSessionArgs args) {
return new JsoSerializerSession(this, args);
}
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoSerializerBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoSerializerBuilder.java
index 3b20513..6e4148e 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoSerializerBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoSerializerBuilder.java
@@ -16,7 +16,6 @@ import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.http.*;
-import org.apache.juneau.parser.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.utils.*;
@@ -48,16 +47,6 @@ public class JsoSerializerBuilder extends OutputStreamSerializerBuilder {
}
//-----------------------------------------------------------------------------------------------------------------
- // Annotations
- //-----------------------------------------------------------------------------------------------------------------
-
- @Override
- public JsoSerializerBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) throws ParseException {
- super.applyAnnotations(m, sr);
- return this;
- }
-
- //-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
@@ -625,12 +614,6 @@ public class JsoSerializerBuilder extends OutputStreamSerializerBuilder {
}
@Override /* ContextBuilder */
- public JsoSerializerBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public JsoSerializerBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
@@ -665,4 +648,10 @@ public class JsoSerializerBuilder extends OutputStreamSerializerBuilder {
super.apply(copyFrom);
return this;
}
+
+ @Override
+ public JsoSerializerBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) {
+ super.applyAnnotations(m, sr);
+ return this;
+ }
}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/JsoConfig.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/JsoConfig.java
index 6b507b0..e011d35 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/JsoConfig.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/JsoConfig.java
@@ -17,6 +17,7 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
+import org.apache.juneau.annotation.*;
import org.apache.juneau.jso.*;
/**
@@ -26,7 +27,8 @@ import org.apache.juneau.jso.*;
* Used primarily for specifying bean configuration properties on REST classes and methods.
*/
@Documented
-@Target(TYPE)
+@Target({TYPE,METHOD})
@Retention(RUNTIME)
@Inherited
+@PropertyStoreApply(JsoConfigApply.class)
public @interface JsoConfig {}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/JsoConfig.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/JsoConfigApply.java
similarity index 76%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/JsoConfig.java
copy to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/JsoConfigApply.java
index 6b507b0..12b5233 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/JsoConfig.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/JsoConfigApply.java
@@ -12,21 +12,25 @@
// ***************************************************************************************************************************
package org.apache.juneau.jso.annotation;
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-import java.lang.annotation.*;
-
-import org.apache.juneau.jso.*;
+import org.apache.juneau.*;
+import org.apache.juneau.utils.*;
/**
- * Annotation for specifying config properties defined in {@link JsoSerializer} and {@link JsoParser}.
- *
- * <p>
- * Used primarily for specifying bean configuration properties on REST classes and methods.
+ * Applies {@link JsoConfig} annotations to a {@link PropertyStoreBuilder}.
*/
-@Documented
-@Target(TYPE)
-@Retention(RUNTIME)
-@Inherited
-public @interface JsoConfig {}
+public class JsoConfigApply extends ConfigApply<JsoConfig> {
+
+ /**
+ * Constructor.
+ *
+ * @param c The annotation class.
+ * @param r The resolver for resolving values in annotations.
+ */
+ public JsoConfigApply(Class<JsoConfig> c, StringResolver r) {
+ super(c, r);
+ }
+
+ @Override
+ public void apply(JsoConfig a, PropertyStoreBuilder psb) {
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParser.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParser.java
index edc9e8d..55fd19f 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParser.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParser.java
@@ -237,7 +237,12 @@ public class JsonParser extends ReaderParser {
}
@Override /* Parser */
- public ReaderParserSession createSession(ParserSessionArgs args) {
+ public JsonParserSession createSession() {
+ return createSession(createDefaultSessionArgs());
+ }
+
+ @Override /* Parser */
+ public JsonParserSession createSession(ParserSessionArgs args) {
return new JsonParserSession(this, args);
}
@@ -257,6 +262,10 @@ public class JsonParser extends ReaderParser {
return validateEnd;
}
+ //-----------------------------------------------------------------------------------------------------------------
+ // Other methods
+ //-----------------------------------------------------------------------------------------------------------------
+
@Override /* Context */
public ObjectMap asMap() {
return super.asMap()
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserBuilder.java
index dea173b..d848454 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserBuilder.java
@@ -18,8 +18,6 @@ import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.http.*;
-import org.apache.juneau.internal.*;
-import org.apache.juneau.json.annotation.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.utils.*;
@@ -51,23 +49,6 @@ public class JsonParserBuilder extends ReaderParserBuilder {
}
//-----------------------------------------------------------------------------------------------------------------
- // Annotations
- //-----------------------------------------------------------------------------------------------------------------
-
- @Override
- public JsonParserBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) throws ParseException {
- super.applyAnnotations(m, sr);
- if (! m.containsKey(JsonConfig.class))
- return this;
- ObjectResolver r = new ObjectResolver(sr);
- for (JsonConfig a : m.get(JsonConfig.class)) {
- if (! a.validateEnd().isEmpty())
- validateEnd(r.bool(a.validateEnd()));
- }
- return this;
- }
-
- //-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
@@ -590,12 +571,6 @@ public class JsonParserBuilder extends ReaderParserBuilder {
}
@Override /* ContextBuilder */
- public JsonParserBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public JsonParserBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
@@ -630,4 +605,10 @@ public class JsonParserBuilder extends ReaderParserBuilder {
super.apply(copyFrom);
return this;
}
+
+ @Override
+ public JsonParserBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) {
+ super.applyAnnotations(m, sr);
+ return this;
+ }
}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSchemaSerializerBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSchemaSerializerBuilder.java
index cf2f1ac..38dc36c 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSchemaSerializerBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSchemaSerializerBuilder.java
@@ -20,7 +20,6 @@ import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.http.*;
import org.apache.juneau.jsonschema.*;
-import org.apache.juneau.parser.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.utils.*;
@@ -52,16 +51,6 @@ public class JsonSchemaSerializerBuilder extends JsonSerializerBuilder {
}
//-----------------------------------------------------------------------------------------------------------------
- // Annotations
- //-----------------------------------------------------------------------------------------------------------------
-
- @Override
- public JsonSchemaSerializerBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) throws ParseException {
- super.applyAnnotations(m, sr);
- return this;
- }
-
- //-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
@@ -861,12 +850,6 @@ public class JsonSchemaSerializerBuilder extends JsonSerializerBuilder {
}
@Override /* ContextBuilder */
- public JsonSchemaSerializerBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public JsonSchemaSerializerBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
@@ -901,4 +884,10 @@ public class JsonSchemaSerializerBuilder extends JsonSerializerBuilder {
super.apply(copyFrom);
return this;
}
+
+ @Override
+ public JsonSchemaSerializerBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) {
+ super.applyAnnotations(m, sr);
+ return this;
+ }
}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializer.java
index b51350c..2f17781 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializer.java
@@ -393,6 +393,11 @@ public class JsonSerializer extends WriterSerializer {
// Entry point methods
//-----------------------------------------------------------------------------------------------------------------
+ @Override /* Context */
+ public JsonSerializerSession createSession() {
+ return createSession(createDefaultSessionArgs());
+ }
+
@Override /* Serializer */
public JsonSerializerSession createSession(SerializerSessionArgs args) {
return new JsonSerializerSession(this, args);
@@ -403,15 +408,16 @@ public class JsonSerializer extends WriterSerializer {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Configuration property: Simple JSON mode.
+ * Configuration property: Add <js>"_type"</js> properties when needed.
*
- * @see #JSON_simpleMode
+ * @see #JSON_addBeanTypes
* @return
- * <jk>true</jk> if JSON attribute names will only be quoted when necessary.
- * <br>Otherwise, they are always quoted.
+ * <jk>true</jk> if <js>"_type"</js> properties will be added to beans if their type cannot be inferred
+ * through reflection.
*/
- protected final boolean isSimpleMode() {
- return simpleMode;
+ @Override
+ protected final boolean isAddBeanTypes() {
+ return addBeanTypes;
}
/**
@@ -426,18 +432,21 @@ public class JsonSerializer extends WriterSerializer {
}
/**
- * Configuration property: Add <js>"_type"</js> properties when needed.
+ * Configuration property: Simple JSON mode.
*
- * @see #JSON_addBeanTypes
+ * @see #JSON_simpleMode
* @return
- * <jk>true</jk> if <js>"_type"</js> properties will be added to beans if their type cannot be inferred
- * through reflection.
+ * <jk>true</jk> if JSON attribute names will only be quoted when necessary.
+ * <br>Otherwise, they are always quoted.
*/
- @Override
- protected final boolean isAddBeanTypes() {
- return addBeanTypes;
+ protected final boolean isSimpleMode() {
+ return simpleMode;
}
+ //-----------------------------------------------------------------------------------------------------------------
+ // Other methods
+ //-----------------------------------------------------------------------------------------------------------------
+
@Override /* Context */
public ObjectMap asMap() {
return super.asMap()
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerBuilder.java
index 6147781..7804599 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerBuilder.java
@@ -18,9 +18,6 @@ import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.http.*;
-import org.apache.juneau.internal.*;
-import org.apache.juneau.json.annotation.*;
-import org.apache.juneau.parser.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.utils.*;
@@ -52,27 +49,6 @@ public class JsonSerializerBuilder extends WriterSerializerBuilder {
}
//-----------------------------------------------------------------------------------------------------------------
- // Annotations
- //-----------------------------------------------------------------------------------------------------------------
-
- @Override
- public JsonSerializerBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) throws ParseException {
- super.applyAnnotations(m, sr);
- if (! m.containsKey(JsonConfig.class))
- return this;
- ObjectResolver r = new ObjectResolver(sr);
- for (JsonConfig a : m.get(JsonConfig.class)) {
- if (! a.addBeanTypes().isEmpty())
- addBeanTypes(r.bool(a.addBeanTypes()));
- if (! a.escapeSolidus().isEmpty())
- escapeSolidus(r.bool(a.escapeSolidus()));
- if (! a.simpleMode().isEmpty())
- simple(r.bool(a.simpleMode()));
- }
- return this;
- }
-
- //-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
@@ -763,12 +739,6 @@ public class JsonSerializerBuilder extends WriterSerializerBuilder {
}
@Override /* ContextBuilder */
- public JsonSerializerBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public JsonSerializerBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
@@ -803,4 +773,10 @@ public class JsonSerializerBuilder extends WriterSerializerBuilder {
super.apply(copyFrom);
return this;
}
+
+ @Override
+ public JsonSerializerBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) {
+ super.applyAnnotations(m, sr);
+ return this;
+ }
}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerSession.java
index 7c3a3e3..f1b8838 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerSession.java
@@ -271,15 +271,16 @@ public class JsonSerializerSession extends WriterSerializerSession {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Configuration property: Simple JSON mode.
+ * Configuration property: Add <js>"_type"</js> properties when needed.
*
- * @see JsonSerializer#JSON_simpleMode
+ * @see JsonSerializer#JSON_addBeanTypes
* @return
- * <jk>true</jk> if JSON attribute names will only be quoted when necessary.
- * <br>Otherwise, they are always quoted.
+ * <jk>true</jk> if <js>"_type"</js> properties will be added to beans if their type cannot be inferred
+ * through reflection.
*/
- protected final boolean isSimpleMode() {
- return ctx.isSimpleMode();
+ @Override
+ protected final boolean isAddBeanTypes() {
+ return ctx.isAddBeanTypes();
}
/**
@@ -294,15 +295,14 @@ public class JsonSerializerSession extends WriterSerializerSession {
}
/**
- * Configuration property: Add <js>"_type"</js> properties when needed.
+ * Configuration property: Simple JSON mode.
*
- * @see JsonSerializer#JSON_addBeanTypes
+ * @see JsonSerializer#JSON_simpleMode
* @return
- * <jk>true</jk> if <js>"_type"</js> properties will be added to beans if their type cannot be inferred
- * through reflection.
+ * <jk>true</jk> if JSON attribute names will only be quoted when necessary.
+ * <br>Otherwise, they are always quoted.
*/
- @Override
- protected final boolean isAddBeanTypes() {
- return ctx.isAddBeanTypes();
+ protected final boolean isSimpleMode() {
+ return ctx.isSimpleMode();
}
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonConfig.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonConfig.java
index 53a4228..d999d82 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonConfig.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonConfig.java
@@ -19,6 +19,7 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
+import org.apache.juneau.annotation.*;
import org.apache.juneau.json.*;
import org.apache.juneau.serializer.*;
@@ -29,9 +30,10 @@ import org.apache.juneau.serializer.*;
* Used primarily for specifying bean configuration properties on REST classes and methods.
*/
@Documented
-@Target(TYPE)
+@Target({TYPE,METHOD})
@Retention(RUNTIME)
@Inherited
+@PropertyStoreApply(JsonConfigApply.class)
public @interface JsonConfig {
//-------------------------------------------------------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xmlschema/XmlSchemaSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonConfigApply.java
similarity index 60%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xmlschema/XmlSchemaSerializer.java
copy to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonConfigApply.java
index de912d0..dee4363 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xmlschema/XmlSchemaSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonConfigApply.java
@@ -1,53 +1,47 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.xmlschema;
-
-import org.apache.juneau.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.xml.*;
-
-/**
- * Serializes POJO metadata to HTTP responses as XML.
- *
- * <h5 class='topic'>Media types</h5>
- *
- * Handles <code>Accept</code> types: <code><b>text/xml+schema</b></code>
- * <p>
- * Produces <code>Content-Type</code> types: <code><b>text/xml</b></code>
- *
- * <h5 class='topic'>Description</h5>
- *
- * Produces the XML-schema representation of the XML produced by the {@link XmlSerializer} class with the same properties.
- */
-public class XmlSchemaSerializer extends XmlSerializer {
-
- /**
- * Constructor.
- *
- * @param ps Initialize with the specified config property store.
- */
- public XmlSchemaSerializer(PropertyStore ps) {
- super(
- ps.builder()
- .set(XML_enableNamespaces, true)
- .build(),
- "text/xml",
- "text/xml+schema"
- );
- }
-
- @Override /* Serializer */
- public WriterSerializerSession createSession(SerializerSessionArgs args) {
- return new XmlSchemaSerializerSession(this, args);
- }
-}
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.json.annotation;
+
+import static org.apache.juneau.json.JsonSerializer.*;
+import static org.apache.juneau.json.JsonParser.*;
+import org.apache.juneau.*;
+import org.apache.juneau.utils.*;
+
+/**
+ * Applies {@link JsonConfig} annotations to a {@link PropertyStoreBuilder}.
+ */
+public class JsonConfigApply extends ConfigApply<JsonConfig> {
+
+ /**
+ * Constructor.
+ *
+ * @param c The annotation class.
+ * @param r The resolver for resolving values in annotations.
+ */
+ public JsonConfigApply(Class<JsonConfig> c, StringResolver r) {
+ super(c, r);
+ }
+
+ @Override
+ public void apply(JsonConfig a, PropertyStoreBuilder psb) {
+ if (! a.addBeanTypes().isEmpty())
+ psb.set(JSON_addBeanTypes, bool(a.addBeanTypes()));
+ if (! a.escapeSolidus().isEmpty())
+ psb.set(JSON_escapeSolidus, bool(a.escapeSolidus()));
+ if (! a.simpleMode().isEmpty())
+ psb.set(JSON_simpleMode, bool(a.simpleMode()));
+
+ if (! a.validateEnd().isEmpty())
+ psb.set(JSON_validateEnd, bool(a.validateEnd()));
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGenerator.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGenerator.java
index 7db8aad..88ade07 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGenerator.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGenerator.java
@@ -323,14 +323,14 @@ public class JsonSchemaGenerator extends BeanTraverseContext {
return new JsonSchemaGeneratorBuilder();
}
- @Override
- public JsonSchemaGeneratorSession createSession(BeanSessionArgs args) {
- return new JsonSchemaGeneratorSession(this, args);
+ @Override /* Context */
+ public JsonSchemaGeneratorSession createSession() {
+ return createSession(createDefaultSessionArgs());
}
@Override
- public JsonSchemaGeneratorSession createSession() {
- return new JsonSchemaGeneratorSession(this, null);
+ public JsonSchemaGeneratorSession createSession(BeanSessionArgs args) {
+ return new JsonSchemaGeneratorSession(this, args);
}
JsonSerializer getJsonSerializer() {
@@ -342,25 +342,25 @@ public class JsonSchemaGenerator extends BeanTraverseContext {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Configuration property: Use bean definitions.
+ * Configuration property: Add descriptions to types.
*
- * @see #JSONSCHEMA_useBeanDefs
+ * @see #JSONSCHEMA_addDescriptionsTo
* @return
- * <jk>true</jk> if schemas on beans will be serialized with <js>'$ref'</js> tags.
+ * Set of categories of types that descriptions should be automatically added to generated schemas.
*/
- protected final boolean isUseBeanDefs() {
- return useBeanDefs;
+ protected final Set<TypeCategory> getAddDescriptionsTo() {
+ return addDescriptionsTo;
}
/**
- * Configuration property: Allow nested examples.
+ * Configuration property: Add examples.
*
- * @see #JSONSCHEMA_allowNestedExamples
+ * @see #JSONSCHEMA_addExamplesTo
* @return
- * <jk>true</jk> if nested examples are allowed in schema definitions.
+ * Set of categories of types that examples should be automatically added to generated schemas.
*/
- protected final boolean isAllowNestedExamples() {
- return allowNestedExamples;
+ protected final Set<TypeCategory> getAddExamplesTo() {
+ return addExamplesTo;
}
/**
@@ -375,6 +375,17 @@ public class JsonSchemaGenerator extends BeanTraverseContext {
}
/**
+ * Configuration property: Allow nested examples.
+ *
+ * @see #JSONSCHEMA_allowNestedExamples
+ * @return
+ * <jk>true</jk> if nested examples are allowed in schema definitions.
+ */
+ protected final boolean isAllowNestedExamples() {
+ return allowNestedExamples;
+ }
+
+ /**
* Configuration property: Bean schema definition mapper.
*
* @see #JSONSCHEMA_beanDefMapper
@@ -386,38 +397,42 @@ public class JsonSchemaGenerator extends BeanTraverseContext {
}
/**
- * Configuration property: Add examples.
+ * Configuration property: Default schemas.
*
- * @see #JSONSCHEMA_addExamplesTo
+ * @see #JSONSCHEMA_defaultSchemas
* @return
- * Set of categories of types that examples should be automatically added to generated schemas.
+ * Custom schema information for particular class types.
*/
- protected final Set<TypeCategory> getAddExamplesTo() {
- return addExamplesTo;
+ protected final Map<String,ObjectMap> getDefaultSchemas() {
+ return defaultSchemas;
}
/**
- * Configuration property: Add descriptions to types.
+ * Configuration property: Ignore types from schema definitions.
*
- * @see #JSONSCHEMA_addDescriptionsTo
+ * @see JsonSchemaGenerator#JSONSCHEMA_ignoreTypes
* @return
- * Set of categories of types that descriptions should be automatically added to generated schemas.
+ * Custom schema information for particular class types.
*/
- protected final Set<TypeCategory> getAddDescriptionsTo() {
- return addDescriptionsTo;
+ public Set<Pattern> getIgnoreTypes() {
+ return ignoreTypes;
}
/**
- * Configuration property: Default schemas.
+ * Configuration property: Use bean definitions.
*
- * @see #JSONSCHEMA_defaultSchemas
+ * @see #JSONSCHEMA_useBeanDefs
* @return
- * Custom schema information for particular class types.
+ * <jk>true</jk> if schemas on beans will be serialized with <js>'$ref'</js> tags.
*/
- protected final Map<String,ObjectMap> getDefaultSchemas() {
- return defaultSchemas;
+ protected final boolean isUseBeanDefs() {
+ return useBeanDefs;
}
+ //-----------------------------------------------------------------------------------------------------------------
+ // Other methods
+ //-----------------------------------------------------------------------------------------------------------------
+
/**
* Returns <jk>true</jk> if the specified type is ignored.
*
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGeneratorBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGeneratorBuilder.java
index 80064c4..871e374 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGeneratorBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGeneratorBuilder.java
@@ -19,9 +19,6 @@ import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.http.*;
-import org.apache.juneau.internal.*;
-import org.apache.juneau.jsonschema.annotation.*;
-import org.apache.juneau.parser.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.utils.*;
@@ -52,37 +49,6 @@ public class JsonSchemaGeneratorBuilder extends BeanTraverseBuilder {
}
//-----------------------------------------------------------------------------------------------------------------
- // Annotations
- //-----------------------------------------------------------------------------------------------------------------
-
- @Override
- public JsonSchemaGeneratorBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) throws ParseException {
- super.applyAnnotations(m, sr);
- if (! m.containsKey(JsonSchemaConfig.class))
- return this;
- ObjectResolver r = new ObjectResolver(sr);
- for (JsonSchemaConfig a : m.get(JsonSchemaConfig.class)) {
- if (! a.addDescriptionsTo().isEmpty())
- addDescriptionsTo(r.string(a.addDescriptionsTo()));
- if (! a.addExamplesTo().isEmpty())
- addExamplesTo(r.string(a.addExamplesTo()));
- if (! a.allowNestedDescriptions().isEmpty())
- allowNestedDescriptions(r.bool(a.allowNestedDescriptions()));
- if (! a.allowNestedExamples().isEmpty())
- allowNestedExamples(r.bool(a.allowNestedExamples()));
- if (a.beanDefMapper() != BeanDefMapper.Null.class)
- beanDefMapper(a.beanDefMapper());
- for (CSEntry e : a.defaultSchemas())
- defaultSchema(e.key(), new ObjectMap(r.string(e.value())));
- if (! a.ignoreTypes().isEmpty())
- ignoreTypes(r.string(a.ignoreTypes()));
- if (! a.useBeanDefs().isEmpty())
- useBeanDefs(r.bool(a.useBeanDefs()));
- }
- return this;
- }
-
- //-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
@@ -761,12 +727,6 @@ public class JsonSchemaGeneratorBuilder extends BeanTraverseBuilder {
}
@Override /* ContextBuilder */
- public JsonSchemaGeneratorBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public JsonSchemaGeneratorBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
@@ -802,4 +762,9 @@ public class JsonSchemaGeneratorBuilder extends BeanTraverseBuilder {
return this;
}
+ @Override
+ public JsonSchemaGeneratorBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) {
+ super.applyAnnotations(m, sr);
+ return this;
+ }
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGeneratorSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGeneratorSession.java
index d5fab1b..d8fc9bf 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGeneratorSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGeneratorSession.java
@@ -17,6 +17,7 @@ import static org.apache.juneau.jsonschema.TypeCategory.*;
import java.lang.reflect.*;
import java.util.*;
+import java.util.regex.*;
import org.apache.juneau.*;
import org.apache.juneau.json.*;
@@ -351,25 +352,25 @@ public class JsonSchemaGeneratorSession extends BeanTraverseSession {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Configuration property: Use bean definitions.
+ * Configuration property: Add descriptions to types.
*
- * @see JsonSchemaGenerator#JSONSCHEMA_useBeanDefs
+ * @see JsonSchemaGenerator#JSONSCHEMA_addDescriptionsTo
* @return
- * <jk>true</jk> if schemas on beans will be serialized with <js>'$ref'</js> tags.
+ * Set of categories of types that descriptions should be automatically added to generated schemas.
*/
- protected final boolean isUseBeanDefs() {
- return ctx.isUseBeanDefs();
+ protected final Set<TypeCategory> getAddDescriptionsTo() {
+ return ctx.getAddDescriptionsTo();
}
/**
- * Configuration property: Allow nested examples.
+ * Configuration property: Add examples.
*
- * @see JsonSchemaGenerator#JSONSCHEMA_allowNestedExamples
+ * @see JsonSchemaGenerator#JSONSCHEMA_addExamplesTo
* @return
- * <jk>true</jk> if nested examples are allowed in schema definitions.
+ * Set of categories of types that examples should be automatically added to generated schemas.
*/
- protected final boolean isAllowNestedExamples() {
- return ctx.isAllowNestedExamples();
+ protected final Set<TypeCategory> getAddExamplesTo() {
+ return ctx.getAddExamplesTo();
}
/**
@@ -384,6 +385,17 @@ public class JsonSchemaGeneratorSession extends BeanTraverseSession {
}
/**
+ * Configuration property: Allow nested examples.
+ *
+ * @see JsonSchemaGenerator#JSONSCHEMA_allowNestedExamples
+ * @return
+ * <jk>true</jk> if nested examples are allowed in schema definitions.
+ */
+ protected final boolean isAllowNestedExamples() {
+ return ctx.isAllowNestedExamples();
+ }
+
+ /**
* Configuration property: Bean schema definition mapper.
*
* @see JsonSchemaGenerator#JSONSCHEMA_beanDefMapper
@@ -395,36 +407,36 @@ public class JsonSchemaGeneratorSession extends BeanTraverseSession {
}
/**
- * Configuration property: Add examples.
+ * Configuration property: Default schemas.
*
- * @see JsonSchemaGenerator#JSONSCHEMA_addExamplesTo
+ * @see JsonSchemaGenerator#JSONSCHEMA_defaultSchemas
* @return
- * Set of categories of types that examples should be automatically added to generated schemas.
+ * Custom schema information for particular class types.
*/
- protected final Set<TypeCategory> getAddExamplesTo() {
- return ctx.getAddExamplesTo();
+ protected final Map<String,ObjectMap> getDefaultSchemas() {
+ return ctx.getDefaultSchemas();
}
/**
- * Configuration property: Add descriptions to types.
+ * Configuration property: Ignore types from schema definitions.
*
- * @see JsonSchemaGenerator#JSONSCHEMA_addDescriptionsTo
+ * @see JsonSchemaGenerator#JSONSCHEMA_ignoreTypes
* @return
- * Set of categories of types that descriptions should be automatically added to generated schemas.
+ * Custom schema information for particular class types.
*/
- protected final Set<TypeCategory> getAddDescriptionsTo() {
- return ctx.getAddDescriptionsTo();
+ protected final Set<Pattern> getIgnoreTypes() {
+ return ctx.getIgnoreTypes();
}
/**
- * Configuration property: Default schemas.
+ * Configuration property: Use bean definitions.
*
- * @see JsonSchemaGenerator#JSONSCHEMA_defaultSchemas
+ * @see JsonSchemaGenerator#JSONSCHEMA_useBeanDefs
* @return
- * Custom schema information for particular class types.
+ * <jk>true</jk> if schemas on beans will be serialized with <js>'$ref'</js> tags.
*/
- protected final Map<String,ObjectMap> getDefaultSchemas() {
- return ctx.getDefaultSchemas();
+ protected final boolean isUseBeanDefs() {
+ return ctx.isUseBeanDefs();
}
//-----------------------------------------------------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfig.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfig.java
index 2cc9dcb..caff6f5 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfig.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfig.java
@@ -30,9 +30,10 @@ import org.apache.juneau.jsonschema.*;
* Used primarily for specifying bean configuration properties on REST classes and methods.
*/
@Documented
-@Target(TYPE)
+@Target({TYPE,METHOD})
@Retention(RUNTIME)
@Inherited
+@PropertyStoreApply(JsonSchemaConfigApply.class)
public @interface JsonSchemaConfig {
//-------------------------------------------------------------------------------------------------------------------
@@ -179,7 +180,7 @@ public @interface JsonSchemaConfig {
* <li class='jf'>{@link JsonSchemaGenerator#JSONSCHEMA_defaultSchemas}
* </ul>
*/
- CSEntry[] defaultSchemas() default {};
+ CS[] defaultSchemas() default {};
/**
* Configuration property: Ignore types from schema definitions.
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xmlschema/XmlSchemaDocSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfigApply.java
similarity index 50%
copy from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xmlschema/XmlSchemaDocSerializer.java
copy to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfigApply.java
index 61098a7..b273724 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xmlschema/XmlSchemaDocSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfigApply.java
@@ -1,51 +1,55 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.xmlschema;
-
-import org.apache.juneau.*;
-import org.apache.juneau.serializer.*;
-
-/**
- * Serializes POJO metadata to HTTP responses as XML.
- *
- * <h5 class='topic'>Media types</h5>
- *
- * Handles <code>Accept</code> types: <code><b>text/xml+schema</b></code>
- * <p>
- * Produces <code>Content-Type</code> types: <code><b>text/xml</b></code>
- *
- * <h5 class='topic'>Description</h5>
- *
- * Same as {@link XmlSchemaSerializer}, except prepends <code><xt><?xml</xt> <xa>version</xa>=<xs>'1.0'</xs>
- * <xa>encoding</xa>=<xs>'UTF-8'</xs><xt>?></xt></code> to the response to make it a valid XML document.
- */
-public class XmlSchemaDocSerializer extends XmlSchemaSerializer {
-
- //-----------------------------------------------------------------------------------------------------------------
- // Overridden methods
- //-----------------------------------------------------------------------------------------------------------------
-
- /**
- * Constructor.
- *
- * @param ps The property store containing all the settings for this object.
- */
- public XmlSchemaDocSerializer(PropertyStore ps) {
- super(ps);
- }
-
- @Override /* Serializer */
- public WriterSerializerSession createSession(SerializerSessionArgs args) {
- return new XmlSchemaSerializerSession(this, args);
- }
-}
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.jsonschema.annotation;
+
+import static org.apache.juneau.jsonschema.JsonSchemaGenerator.*;
+import org.apache.juneau.*;
+import org.apache.juneau.annotation.*;
+import org.apache.juneau.jsonschema.*;
+import org.apache.juneau.utils.*;
+
+/**
+ * Applies {@link JsonSchemaConfig} annotations to a {@link PropertyStoreBuilder}.
+ */
+public class JsonSchemaConfigApply extends ConfigApply<JsonSchemaConfig> {
+
+ /**
+ * Constructor.
+ *
+ * @param c The annotation class.
+ * @param r The resolver for resolving values in annotations.
+ */
+ public JsonSchemaConfigApply(Class<JsonSchemaConfig> c, StringResolver r) {
+ super(c, r);
+ }
+
+ @Override
+ public void apply(JsonSchemaConfig a, PropertyStoreBuilder psb) {
+ if (! a.addDescriptionsTo().isEmpty())
+ psb.set(JSONSCHEMA_addDescriptionsTo, string(a.addDescriptionsTo()));
+ if (! a.addExamplesTo().isEmpty())
+ psb.set(JSONSCHEMA_addExamplesTo, string(a.addExamplesTo()));
+ if (! a.allowNestedDescriptions().isEmpty())
+ psb.set(JSONSCHEMA_allowNestedDescriptions, bool(a.allowNestedDescriptions()));
+ if (! a.allowNestedExamples().isEmpty())
+ psb.set(JSONSCHEMA_allowNestedExamples, bool(a.allowNestedExamples()));
+ if (a.beanDefMapper() != BeanDefMapper.Null.class)
+ psb.set(JSONSCHEMA_beanDefMapper, a.beanDefMapper());
+ for (CS e : a.defaultSchemas())
+ psb.addTo(JSONSCHEMA_defaultSchemas, e.k().getName(), objectMap(e.v(), "defaultSchemas"));
+ if (! a.ignoreTypes().isEmpty())
+ psb.set(JSONSCHEMA_ignoreTypes, string(a.ignoreTypes()));
+ if (! a.useBeanDefs().isEmpty())
+ psb.set(JSONSCHEMA_useBeanDefs, bool(a.useBeanDefs()));
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
index 58c1bcd..71b21f7 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackParser.java
@@ -106,6 +106,11 @@ public class MsgPackParser extends InputStreamParser {
}
@Override /* Parser */
+ public MsgPackParserSession createSession() {
+ return createSession(createDefaultSessionArgs());
+ }
+
+ @Override /* Parser */
public MsgPackParserSession createSession(ParserSessionArgs args) {
return new MsgPackParserSession(this, args);
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackParserBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackParserBuilder.java
index 091ec2c..1340a92 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackParserBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackParserBuilder.java
@@ -47,16 +47,6 @@ public class MsgPackParserBuilder extends InputStreamParserBuilder {
}
//-----------------------------------------------------------------------------------------------------------------
- // Annotations
- //-----------------------------------------------------------------------------------------------------------------
-
- @Override
- public MsgPackParserBuilder applyAnnotations(AnnotationsMap m, StringResolver sr) throws ParseException {
- super.applyAnnotations(m, sr);
- return this;
- }
-
- //-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
@@ -535,12 +525,6 @@ public class MsgPackParserBuilder extends InputStreamParserBuilder {
}
@Override /* ContextBuilder */
- public MsgPackParserBuilder set(boolean append, String name, Object value) {
- super.set(append, name, value);
- return this;
- }
-
- @Override /* ContextBuilder */
public MsgPackParserBuilder set(Map<String,Object> properties) {
super.set(properties);
return this;
@@ -575,4 +559,10 @@ public class MsgPackParserBuilder extends InputStreamParserBuilder {
super.apply(copyFrom);
return this;
... 4962 lines suppressed ...