Class AttributeListWrapper
- All Implemented Interfaces:
AttributeListProvider
This class' toString() will either output in a default format unless provided
with a non-null, non-empty Formatter formatString, in which
case it will use it.
Supported API: true
Extendable: true
-
Method Summary
Modifier and TypeMethodDescriptionfinal voidClear attribute list and string rep caches.final voidClear string rep cache.protected abstract AttributeListMethod used by getAttributeList() to compute attribute list when needed, as governed by isCaching().protected StringMethod used by toString() to compute string representation when needed, as governed by isCaching().static StringRender the given object to a String using non-multi-line formatting.static StringdefaultRenderObjectAsString(Object obj, boolean multiLineFormat) Render the given object to a String.static StringgetActualSeparator(String separator) setSeparator() will not accept certain separators, e.g.final AttributeListMethod used by toString() [or a custom log4j renderer] to get attribute list when needed.static StringDefault value of separator property.final StringReturns format string specified for use withFormatter.static String[]getNamesOfReadableAttributes(MBeanInfo mbeanInfo) Get list of all of the readable attributes from an MBeanInfo.getReadableProperties(Object bean) Get names of readable properties and their values from regular Java beangetReadableProperties(Object bean, Class stopClass) Get names of readable properties and their values from regular Java bean.final StringReturns separator string used by default format (i.e.final booleanReturns whether first result of computeAttributeList() and computeStringRep() will be cached or be called again on each call of getAttributeList() and toString(), respectively.final booleanReturns whether multi-line format is used
Supported API: truefinal booleanReturns true if attribute names are included by default format (i.e.static AttributeListWrappernewInstance(Map<String, ?> attrMap, String[] attributeNames) Get instance wrapping which will produce an attribute list containing the attributes from attrMap specified by attributeNames -- or all attributes from attrMap if attributeNames is null.static AttributeListWrappernewInstance(AttributeList attributeList) Get instance wrapping given attribute list.static AttributeListWrappernewInstance(DynamicMBean mbean, String[] attributeNames) Shorthand for newInstance( mbean.getAttributes( attributeNames ) ).static AttributeListWrappernewInstance(MBeanServerConnection mbeanServer, ObjectName objectName) Get instance wrapping which will produce an attribute list from the given MBean as needed.final voidsetCaching(boolean caching) Sets whether first result of computeAttributeList() and computeStringRep() will be cached or be called again on each call of getAttributeList() and toString(), respectively.final voidsetFormatString(String formatString) final voidsetMultiLineFormat(boolean multiLineFormat) Sets whether multi-line format is used
Supported API: truefinal voidsetSeparator(String separator) Sets separator string used by default format (i.e.final voidsetShortFormat(boolean shortFormat) Sets whether attribute names are included by default format (i.e.toString()Renders the attribute list returned by getAttributeList() as a String.
-
Method Details
-
getDefaultSeparator
Default value of separator property.
Supported API: true -
newInstance
Get instance wrapping given attribute list.
Supported API: true -
newInstance
Get instance wrapping which will produce an attribute list containing the attributes from attrMap specified by attributeNames -- or all attributes from attrMap if attributeNames is null.
Supported API: true -
newInstance
Shorthand for newInstance( mbean.getAttributes( attributeNames ) ).
Supported API: true -
newInstance
public static AttributeListWrapper newInstance(MBeanServerConnection mbeanServer, ObjectName objectName) Get instance wrapping which will produce an attribute list from the given MBean as needed. This list will contain all readable attributes.
Supported API: true -
getAttributeList
Method used by toString() [or a custom log4j renderer] to get attribute list when needed.
Supported API: true- Specified by:
getAttributeListin interfaceAttributeListProvider
-
computeAttributeList
Method used by getAttributeList() to compute attribute list when needed, as governed by isCaching().Subclasses must override this method.
Supported API: true -
getFormatString
-
setFormatString
-
isShortFormat
public final boolean isShortFormat()Returns true if attribute names are included by default format (i.e. that used format string is not set)
Supported API: true -
setShortFormat
public final void setShortFormat(boolean shortFormat) Sets whether attribute names are included by default format (i.e. that used format string is not set)
Supported API: true -
isMultiLineFormat
public final boolean isMultiLineFormat()Returns whether multi-line format is used
Supported API: true -
setMultiLineFormat
public final void setMultiLineFormat(boolean multiLineFormat) Sets whether multi-line format is used
Supported API: true -
getSeparator
Returns separator string used by default format (i.e. that used format string is not set)
Supported API: true -
setSeparator
Sets separator string used by default format (i.e. that used format string is not set)
Supported API: true -
isCaching
public final boolean isCaching()Returns whether first result of computeAttributeList() and computeStringRep() will be cached or be called again on each call of getAttributeList() and toString(), respectively. This property is true by default as normal usage of this class is to capture one set of values into an instance which may be used multiple times.Note that the caching mechanism does not use synchronization, locking, or volatiles to absolutely ensure only one invocation of each method. Rather the caching strategy makes a best effort to avoid multiple calls while avoiding additional bottlenecks.
Supported API: true -
setCaching
public final void setCaching(boolean caching) Sets whether first result of computeAttributeList() and computeStringRep() will be cached or be called again on each call of getAttributeList() and toString(), respectively. This property is true by default as normal usage of this class is to capture one set of values into an instance which may be used multiple times.Note that the caching mechanism does not use synchronization, locking, or volatiles to absolutely ensure only one invocation of each method. Rather the caching strategy makes a best effort to avoid multiple calls while avoiding additional bottlenecks.
Supported API: true -
clearCaches
public final void clearCaches()Clear attribute list and string rep caches.
Supported API: true -
clearStringRepCache
public final void clearStringRepCache()Clear string rep cache.
Supported API: true -
getActualSeparator
setSeparator() will not accept certain separators, e.g. null or "", and will use the result of getDefaultSeparator() instead. This routine returns what setSeparator() will actually use.
Supported API: true -
toString
Renders the attribute list returned by getAttributeList() as a String.Subclasses can override this method, but should override computeStringRep() instead unless they wish to alter the caching behavior.
Supported API: true -
computeStringRep
Method used by toString() to compute string representation when needed, as governed by isCaching().Subclasses can override this method.
Supported API: true -
defaultRenderObjectAsString
Render the given object to a String using non-multi-line formatting.
Supported API: true -
defaultRenderObjectAsString
Render the given object to a String.
Supported API: true -
getNamesOfReadableAttributes
Get list of all of the readable attributes from an MBeanInfo.
Supported API: true -
getReadableProperties
Get names of readable properties and their values from regular Java bean- Parameters:
bean- Object to introspect for Java Beans properties
Supported API: true
-
getReadableProperties
Get names of readable properties and their values from regular Java bean.
Supported API: true- Parameters:
bean- Object to introspect for Java Beans propertiesstopClass- The base class at which to stop the analysis. Any methods/properties/events in the stopClass or in its base classes will be ignored in the analysis.
-