public class FormattingOptions extends Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
FormattingOptions.SubtypeField
A structure that defines the tag name and attribute name for a field
that sould be formatted as a field with a subtype.
|
(package private) static class |
FormattingOptions.SubtypeFieldWithPrefix |
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_TYPE_ATTRIBUTE_NAME |
private Map<String,String> |
fieldsAsAttributes |
private Set<String> |
fieldsNotRendered |
private Set<String> |
fieldsRendered |
private Map<String,FormattingOptions.SubtypeField> |
fieldsWithSubtypes |
private Map<String,FormattingOptions.SubtypeFieldWithPrefix> |
prefixedFieldsWithSubtypes |
Constructor and Description |
---|
FormattingOptions() |
Modifier and Type | Method and Description |
---|---|
Set<Map.Entry<String,String>> |
fieldsAsAttributes() |
void |
formatFieldAsAttribute(String fieldName,
String attributeName)
Tells to format a field as an attribute of the hit's tag.
|
void |
formatFieldWithSubtype(String fieldNamePrefix,
String tagName,
String typeAttributeName)
Same as
formatFieldWithSubtype(String, String, String, String) except that fields
are selected based on the beginning of their name and the type attribute value is deduced
from the rest of their name. |
void |
formatFieldWithSubtype(String fieldName,
String tagName,
String typeAttributeName,
String typeAttributeValue)
Tells to format a field using a subtype.
|
String |
getAttributeName(String fieldName) |
FormattingOptions.SubtypeField |
getSubtype(String fieldName) |
FormattingOptions.SubtypeFieldWithPrefix |
getSubtypeWithPrefix(String fieldName) |
void |
setFieldNotToRender(String fieldName)
Tells a field should not be rendered.
|
void |
setFieldToRender(String fieldName)
Tells a field should be rendered.
|
boolean |
shouldRenderField(String fieldName)
Tells whether a field should be rendered.
|
public static final String DEFAULT_TYPE_ATTRIBUTE_NAME
private Map<String,FormattingOptions.SubtypeField> fieldsWithSubtypes
private Map<String,FormattingOptions.SubtypeFieldWithPrefix> prefixedFieldsWithSubtypes
public void formatFieldAsAttribute(String fieldName, String attributeName)
formatFieldAsAttribute("query-latency", "latency")
.
Output would be:
<hit latency="100"></hit>instead of:
<hit><latency>100</latency></hit>
public void formatFieldWithSubtype(String fieldName, String tagName, String typeAttributeName, String typeAttributeValue)
formatFieldWithSubtype("latency-connect", "latency", "type", "connect"
,
formatFieldWithSubtype("latency-finish", "latency", "type", "connect"
and so on,
allows to have a common 'latency' tag name for all fields of the same kind.
Note that it does no collapsing on tags.
Output would be:
<latency type="connect">50</latency> <latency type="finish">250</latency>Instead of:
<hit> <latency-connect>50</latency-connect> <latency-finish>50</latency-finish>
public FormattingOptions.SubtypeField getSubtype(String fieldName)
public void formatFieldWithSubtype(String fieldNamePrefix, String tagName, String typeAttributeName)
formatFieldWithSubtype(String, String, String, String)
except that fields
are selected based on the beginning of their name and the type attribute value is deduced
from the rest of their name. So this may select many fields instead of only one.
Invoking formatFieldWithSubtype("latency-", "latency", "type")
only once allows to have a common 'latency'
tag name for all fields that start with 'latency-'. Type attribute value will be 'start' for field 'latency-start'.
Note that it does no collapsing on tags.
This is mostly used when you don't know all field names ahead.
Output would be:
<latency type="connect">50</latency> <latency type="finish">250</latency>Instead of:
<hit> <latency-connect>50</latency-connect> <latency-finish>50</latency-finish>Note: don't use this with prefixes that start with a common substring (e.g. 'http', 'http_proxy'), I can tell you it just won't work.
public FormattingOptions.SubtypeFieldWithPrefix getSubtypeWithPrefix(String fieldName)
public boolean shouldRenderField(String fieldName)
public void setFieldToRender(String fieldName)
Note: if at least one field is set to render, then only
these fields should be rendered. Use setFieldNotToRender(String)
to only exclude specific fields.
public void setFieldNotToRender(String fieldName)
Note: all other fields should be rendered. Use setFieldToRender(String)
to only include specific fields.
Copyright © 2017. All rights reserved.