Class HtmlSerializer.Builder<SELF extends HtmlSerializer.Builder<SELF>>
- Direct Known Subclasses:
HtmlSchemaSerializer.Builder,HtmlSerializer.DefaultBuilder,HtmlStrippedDocSerializer.Builder
- Enclosing class:
- HtmlSerializer
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBuilder()Constructor, default settings.protectedBuilder(HtmlSerializer copyFrom) Copy constructor.protectedBuilder(HtmlSerializer.Builder<?> copyFrom) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionAdd"_type" properties when needed.addBeanTypesHtml(boolean value) Same asaddBeanTypesHtml()but allows you to explicitly specify the value.HtmlSerializer configuration property: Add key/value headers on bean/map tables.addKeyValueTableHeaders(boolean value) Same asaddKeyValueTableHeaders()but allows you to explicitly specify the value.build()Build the object.abstract SELFcopy()Copy creator.HtmlSerializer configuration property: Dont look for link labels in URIs.disableDetectLabelParameters(boolean value) Same asdisableDetectLabelParameters()but allows you to explicitly specify the value.HtmlSerializer configuration property: Don't look for URLs inStrings.disableDetectLinksInStrings(boolean value) Same asdisableDetectLinksInStrings()but allows you to explicitly specify the value.hashKey()Returns the hashkey of this builder.labelParameter(String value) HtmlSerializer configuration property: Link label parameter name.uriAnchorText(AnchorText value) HtmlSerializer configuration property: Anchor text source.Methods inherited from class org.apache.juneau.marshall.xml.XmlSerializer.Builder
addBeanTypesXml, addBeanTypesXml, addNamespaceUrisToRoot, addNamespaceUrisToRoot, defaultNamespace, disableAutoDetectNamespaces, disableAutoDetectNamespaces, disableJsonTags, disableJsonTags, enableNamespaces, enableNamespaces, namespaces, ns, textNodeDelimiterMethods inherited from class org.apache.juneau.marshall.serializer.WriterSerializer.Builder
maxIndent, quoteChar, quoteCharOverride, sq, streamCharset, useWhitespace, useWhitespace, wsMethods inherited from class org.apache.juneau.marshall.serializer.Serializer.Builder
accept, addBeanTypes, addBeanTypes, addRootType, addRootType, getAccept, getProduces, keepNullProperties, keepNullProperties, listener, nonDefault, nonDefault, produces, sortCollections, sortCollections, sortMaps, sortMaps, trimEmptyCollections, trimEmptyCollections, trimEmptyMaps, trimEmptyMaps, trimStrings, trimStrings, uriContext, uriRelativity, uriResolutionMethods inherited from class org.apache.juneau.marshall.MarshallingTraverseContext.Builder
detectRecursions, detectRecursions, ignoreRecursions, ignoreRecursions, initialDepth, maxDepthMethods inherited from class org.apache.juneau.marshall.MarshallingContextable.Builder
activeView, annotations, beanClassVisibility, beanConstructorVisibility, beanDictionary, beanFieldVisibility, beanInterceptor, beanMapPutReturnsOldValue, beanMethodVisibility, beanProperties, beanProperties, beanProperties, beanPropertiesExcludes, beanPropertiesExcludes, beanPropertiesExcludes, beanPropertiesReadOnly, beanPropertiesReadOnly, beanPropertiesReadOnly, beanPropertiesWriteOnly, beanPropertiesWriteOnly, beanPropertiesWriteOnly, beansRequireDefaultConstructor, beansRequireSerializable, beansRequireSettersForGetters, bigNumberFormat, binaryFormat, bitSetFormat, booleanFormat, calendarFormat, classFormat, classLoader, currencyFormat, dateFormat, debug, dictionaryOn, disableBeansRequireSomeProperties, disableDefaultViewInclusion, disableIgnoreMissingSetters, disableIgnoreTransientFields, disableIgnoreUnknownNullBeanProperties, disableInterfaceProxies, durationFormat, enumFormat, example, example, findFluentSetters, findFluentSetters, floatFormat, ignoreInvocationExceptionsOnGetters, ignoreInvocationExceptionsOnSetters, ignoreUnknownBeanProperties, ignoreUnknownEnumValues, implClass, implClasses, interfaceClass, interfaces, locale, localeFormat, marshallingContext, marshallingContext, marshallingContext, marshallingContext, mediaType, notBeanClasses, notBeanPackages, periodFormat, propertyNamer, propertyNamer, recordComponentOrder, stopClass, swap, swap, swaps, swaps, temporalFormat, timeZone, timeZoneFormat, typeName, typePropertyName, typePropertyName, unsortedProperties, unsortedProperties, useJavaBeanIntrospector, uuidFormat, validateSchema, validateSchemaMethods inherited from class org.apache.juneau.marshall.Context.Builder
annotations, apply, applyAnnotations, applyAnnotations, asSubtype, build, cache, canApply, copyOrNull, debug, getApplied, getType, impl, isDebug, registerBuilders, self, type
-
Constructor Details
-
Builder
protected Builder()Constructor, default settings. -
Builder
Copy constructor.- Parameters:
copyFrom- The builder to copy from.
Cannot benull .
-
Builder
Copy constructor.- Parameters:
copyFrom- The bean to copy from.
Cannot benull .
-
-
Method Details
-
addBeanTypesHtml
Add"_type" properties when needed.If
true , then"_type" properties will be added to beans if their type cannot be inferred through reflection.When present, this value overrides the
Serializer.Builder#addBeanTypes()setting and is provided to customize the behavior of specific serializers in aSerializerSet.- Returns:
- This object.
-
addBeanTypesHtml
Same asaddBeanTypesHtml()but allows you to explicitly specify the value.- Parameters:
value- The value for this setting.- Returns:
- This object.
-
addKeyValueTableHeaders
HtmlSerializer configuration property: Add key/value headers on bean/map tables.When enabled,
key andvalue column headers are added to tables.Example:
// Our bean class. public class MyBean {public Stringf1 ="foo" ;public Stringf2 ="bar" ; }// Serializer without headers. WriterSerializerserializer1 = HtmlSerializer.DEFAULT ;// Serializer with headers. WriterSerializerserializer2 = HtmlSerializer .create () .addKeyValueTableHeaders() .build(); StringwithoutHeaders =serializer1 .write(new MyBean()); StringwithHeaders =serializer2 .write(new MyBean());The following shows the difference between the two generated outputs:
withoutHeaders withHeaders f1 foo f2 bar key value f1 foo f2 bar - Returns:
- This object.
-
addKeyValueTableHeaders
Same asaddKeyValueTableHeaders()but allows you to explicitly specify the value.- Parameters:
value- The value for this setting.- Returns:
- This object.
-
build
Description copied from class:Context.BuilderBuild the object.- Overrides:
buildin classXmlSerializer.Builder<SELF extends HtmlSerializer.Builder<SELF>>- Returns:
- The built object.
-
copy
Description copied from class:Context.BuilderCopy creator.- Specified by:
copyin classXmlSerializer.Builder<SELF extends HtmlSerializer.Builder<SELF>>- Returns:
- A new mutable copy of this builder.
-
disableDetectLabelParameters
HtmlSerializer configuration property: Dont look for link labels in URIs.Disables the feature where if the URL has a label parameter (e.g.
"?label=foobar" ), then use that as the anchor text of the link.The parameter name can be changed via the
labelParameter(String)property.Example:
// Our bean class with a property containing what looks like a URL. public class MyBean {public URIf1 = URI.create ("http://www.apache.org?label=Apache%20Foundation" ); }// Serializer with label detection. WriterSerializerserializer1 = HtmlSerializer .create () .addKeyValueTableHeaders() .build();// Serializer without label detection. WriterSerializerserializer2 = HtmlSerializer .create () .addKeyValueTableHeaders() .disableDetectLabelParameters() .build(); StringwithLabels =serializer1 .write(new MyBean()); StringwithoutLabels =serializer2 .write(new MyBean());The following shows the difference between the two generated outputs.
Note that they're both hyperlinks, but the anchor text differs:withLabels withoutLabels key value f1 Apache Foundation key value f1 http://www.apache.org?label=Apache%20Foundation - Returns:
- This object.
-
disableDetectLabelParameters
Same asdisableDetectLabelParameters()but allows you to explicitly specify the value.- Parameters:
value- The value for this setting.- Returns:
- This object.
-
disableDetectLinksInStrings
HtmlSerializer configuration property: Don't look for URLs inStrings.Disables the feature where if a string looks like a URL (i.e. starts with
"http://" or"https://" , then treat it like a URL and make it into a hyperlink based on the rules specified byuriAnchorText(AnchorText).Example:
// Our bean class with a property containing what looks like a URL. public class MyBean {public Stringf1 ="http://www.apache.org" ; }// Serializer with link detection. WriterSerializerserializer1 = HtmlSerializer .create () .addKeyValueTableHeaders() .build();// Serializer without link detection. WriterSerializerserializer2 = HtmlSerializer .create () .addKeyValueTableHeaders() .disableDetectLinksInStrings() .build(); StringwithLinks =serializer1 .write(new MyBean()); StringwithoutLinks =serializer2 .write(new MyBean());The following shows the difference between the two generated outputs:
withLinks withoutLinks key value f1 http://www.apache.org key value f1 http://www.apache.org - Returns:
- This object.
-
disableDetectLinksInStrings
Same asdisableDetectLinksInStrings()but allows you to explicitly specify the value.- Parameters:
value- The value for this setting.- Returns:
- This object.
-
hashKey
Description copied from class:Context.BuilderReturns the hashkey of this builder.Used to return previously instantiated context beans that have matching hashkeys. The
HashKeyobject is suitable for use as a hashmap key of a map of context beans. A context bean is considered equivalent if theHashKey.equals(Object)method is the same.- Overrides:
hashKeyin classXmlSerializer.Builder<SELF extends HtmlSerializer.Builder<SELF>>- Returns:
- The hashkey of this builder.
-
labelParameter
HtmlSerializer configuration property: Link label parameter name.The parameter name to look for when resolving link labels}.
- Parameters:
value- The new value for this property.
Cannot benull .
The default is"label" .- Returns:
- This object.
-
uriAnchorText
HtmlSerializer configuration property: Anchor text source.When creating anchor tags (e.g.
) in HTML, this setting defines what to set the inner text to.<a href ='...' > text</a> The possible values are:
AnchorTextTO_STRING(default) - Set to whatever is returned byObject.toString()on the object.
Example:
// Our bean class with a URI property. public class MyBean {public URIf1 = URI.create ("http://www.apache.org?foo=bar#myAnchor" ); }// Serializer with TO_STRING anchor text. WriterSerializerserializer1 = HtmlSerializer.create ().anchorText(TO_STRING ).build();// Produces: <a href='http://www.apache.org?foo=bar#myAnchor'>http://www.apache.org?foo=bar#myAnchor</a> Stringhtml =serializer1 .write(new MyBean());PROPERTY_NAME- Set to the bean property name.
Example:
// Our bean class with a URI property. public class MyBean {public URIf1 = URI.create ("http://www.apache.org?foo=bar#myAnchor" ); }// Serializer with PROPERTY_NAME anchor text. WriterSerializerserializer1 = HtmlSerializer.create ().anchorText(PROPERTY_NAME ).build();// Produces: <a href='http://www.apache.org?foo=bar#myAnchor'>f1</a> Stringhtml =serializer1 .write(new MyBean());URI- Set to the URI value.
Example:
// Our bean class with a URI property. public class MyBean {public URIf1 = URI.create ("http://www.apache.org?foo=bar#myAnchor" ); }// Serializer with URI anchor text. WriterSerializerserializer1 = HtmlSerializer.create ().anchorText(URI ).build();// Produces: <a href='http://www.apache.org?foo=bar#myAnchor'>http://www.apache.org?foo=bar</a> Stringhtml =serializer1 .write(new MyBean());LAST_TOKEN- Set to the last token of the URI value.
Example:
// Our bean class with a URI property. public class MyBean {public URIf1 = URI.create ("http://www.apache.org/foo/bar?baz=qux#myAnchor" ); }// Serializer with LAST_TOKEN anchor text. WriterSerializerserializer1 = HtmlSerializer.create ().anchorText(LAST_TOKEN ).build();// Produces: <a href='http://www.apache.org/foo/bar?baz=qux#myAnchor'>bar</a> Stringhtml =serializer1 .write(new MyBean());URI_ANCHOR- Set to the anchor of the URL.
Example:
// Our bean class with a URI property. public class MyBean {public URIf1 = URI.create ("http://www.apache.org/foo/bar?baz=qux#myAnchor" ); }// Serializer with URI_ANCHOR anchor text. WriterSerializerserializer1 = HtmlSerializer.create ().anchorText(URI_ANCHOR ).build();// Produces: <a href='http://www.apache.org/foo/bar?baz=qux#myAnchor'>myAnchor</a> Stringhtml =serializer1 .write(new MyBean());CONTEXT_RELATIVE- Same asTO_STRINGbut assumes it's a context-relative path.
Example:
// Our bean class with a URI property. public class MyBean {public URIf1 = URI.create ("bar/baz" ); }// Serializer with CONTEXT_RELATIVE anchor text. WriterSerializerserializer1 = HtmlSerializer .create () .anchorText(CONTEXT_RELATIVE ) .uriResolution(ROOT_RELATIVE ) .uriRelativity(RESOURCE ) .uriContext("{authority:'http://localhost:10000',contextRoot:'/myContext',servletPath:'/myServlet',pathInfo:'/foo'}" ) .build();// Produces: <a href='/myContext/myServlet/bar/baz'>myServlet/bar/baz</a> Stringhtml =serializer1 .write(new MyBean());SERVLET_RELATIVE- Same asTO_STRINGbut assumes it's a servlet-relative path.
Example:
// Our bean class with a URI property. public class MyBean {public URIf1 = URI.create ("bar/baz" ); }// Serializer with SERVLET_RELATIVE anchor text. WriterSerializerserializer1 = HtmlSerializer .create () .anchorText(SERVLET_RELATIVE ) .uriResolution(ROOT_RELATIVE ) .uriRelativity(RESOURCE ) .uriContext("{authority:'http://localhost:10000',contextRoot:'/myContext',servletPath:'/myServlet',pathInfo:'/foo'}" ) .build();// Produces: <a href='/myContext/myServlet/bar/baz'>bar/baz</a> Stringhtml =serializer1 .write(new MyBean());PATH_RELATIVE- Same asTO_STRINGbut assumes it's a path-relative path.
Example:
// Our bean class with a URI property. public class MyBean {public URIf1 = URI.create ("bar/baz" ); }// Serializer with PATH_RELATIVE anchor text. WriterSerializerserializer1 = HtmlSerializer .create () .anchorText(PATH_RELATIVE ) .uriResolution(ROOT_RELATIVE ) .uriRelativity(PATH_INFO ) .uriContext("{authority:'http://localhost:10000',contextRoot:'/myContext',servletPath:'/myServlet',pathInfo:'/foo'}" ) .build();// Produces: <a href='/myContext/myServlet/foo/bar/baz'>bar/baz</a> Stringhtml =serializer1 .write(new MyBean());
- Parameters:
value- The new value for this property.
Cannot benull .
The default isAnchorText.TO_STRING.- Returns:
- This object.
-