Top Description Inners Fields Constructors Methods
org.glassfish.pfl.basic.algorithm

public final Class ObjectUtility

extends Object
Class Inheritance
Imports
java.lang.reflect.Field, .Method, .Modifier, java.math.BigDecimal, .BigInteger, java.util.ArrayList, .Arrays, .Collection, .Date, .Enumeration, .IdentityHashMap, .Iterator, .List, .Map, .Map.Entry, .Properties, java.util.concurrent.atomic.AtomicBoolean, .AtomicInteger, .AtomicLong, javax.management.ObjectName, javax.management.openmbean.ArrayType, .CompositeData, .CompositeType, .TabularData, .TabularType, org.glassfish.pfl.basic.contain.Pair, org.glassfish.pfl.basic.reflection.FieldValueHelper

General object related utilities.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
pack-priv static interface

Field Summary

Modifier and TypeField and Description
private ObjectUtility.ObjectPrinter
private final Object[][]
private ObjectUtility.ClassMap
private ObjectUtility.ObjectPrinter
private static ObjectUtility
private ObjectUtility.ObjectPrinter
private int
private int
private boolean
private ObjectUtility.ObjectPrinter
private static ObjectUtility.ObjectPrinter
private static ObjectUtility
private static ObjectUtility.ObjectPrinter

Constructor Summary

AccessConstructor and Description
public
ObjectUtility(boolean isIndenting, int initialLevel, int increment)

Method Summary

Modifier and TypeMethod and Description
private void
pack-priv ObjectUtility.ObjectPrinter
classify(Class<T> cls)

public static String

Returns:

the String representation of obj.
compactObjectToString
(Object
Object to print.
object
)

A convenience method that gives the default behavior: do not use indenting to display the object's structure.

public static String

Returns:

the String representation of obj.
defaultObjectToString
(Object
Object to print.
object
)

A convenience method that gives the default behavior: use indenting to display the object's structure and do not use built-in toString methods.

private Field[]
private void
handleArray(IdentityHashMap<K, V> printed, ObjectWriter result, Object obj)

private void
handleObject(IdentityHashMap<K, V> printed, ObjectWriter result, Object obj)

public String
objectToString(Object obj)

objectToString handles display of arbitrary objects.

private void
public ObjectUtility
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

arrayPrinterback to summary
private ObjectUtility.ObjectPrinter arrayPrinter
CLASS_MAP_DATAback to summary
private final Object[][] CLASS_MAP_DATA
classMapback to summary
private ObjectUtility.ClassMap classMap
collectionPrinterback to summary
private ObjectUtility.ObjectPrinter collectionPrinter
compactback to summary
private static ObjectUtility compact
generalObjectPrinterback to summary
private ObjectUtility.ObjectPrinter generalObjectPrinter
incrementback to summary
private int increment
initialLevelback to summary
private int initialLevel
isIndentingback to summary
private boolean isIndenting
mapPrinterback to summary
private ObjectUtility.ObjectPrinter mapPrinter
propertiesPrinterback to summary
private static ObjectUtility.ObjectPrinter propertiesPrinter
standardback to summary
private static ObjectUtility standard
toStringPrinterback to summary
private static ObjectUtility.ObjectPrinter toStringPrinter

Constructor Detail

ObjectUtilityback to summary
public ObjectUtility(boolean isIndenting, int initialLevel, int increment)

Method Detail

checkPackageAccessback to summary
private void checkPackageAccess(Class<T> cls)
classifyback to summary
pack-priv ObjectUtility.ObjectPrinter classify(Class<T> cls)
compactObjectToStringback to summary
public static String compactObjectToString(Object object)

A convenience method that gives the default behavior: do not use indenting to display the object's structure.

Parameters
object:Object

Object to print.

Returns:String

the String representation of obj.

defaultObjectToStringback to summary
public static String defaultObjectToString(Object object)

A convenience method that gives the default behavior: use indenting to display the object's structure and do not use built-in toString methods.

Parameters
object:Object

Object to print.

Returns:String

the String representation of obj.

getDeclaredFieldsback to summary
private Field[] getDeclaredFields(Class<T> cls)
handleArrayback to summary
private void handleArray(IdentityHashMap<K, V> printed, ObjectWriter result, Object obj)
handleObjectback to summary
private void handleObject(IdentityHashMap<K, V> printed, ObjectWriter result, Object obj)
Annotations
@SuppressWarnings:unchecked
objectToStringback to summary
public String objectToString(Object obj)

objectToString handles display of arbitrary objects. It correctly handles objects whose elements form an arbitrary graph. It uses reflection to display the contents of any kind of object. An object's toString() method may optionally be used, but the default is to ignore all toString() methods except for those defined for primitive types, primitive type wrappers, and strings.

objectToStringHelperback to summary
private void objectToStringHelper(IdentityHashMap<K, V> printed, ObjectWriter result, Object obj)
Annotations
@SuppressWarnings:unchecked
useToStringback to summary
public ObjectUtility useToString(Class<T> cls)
org.glassfish.pfl.basic.algorithm back to summary

private Class ObjectUtility.ClassMap

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv List<Pair<Class<?>, ObjectUtility.ObjectPrinter>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ObjectUtility.ObjectPrinter
get(Class<T> cls)

Return the first element of the ClassMap that is assignable to cls.

public void
put(Class<T> cls, ObjectUtility.ObjectPrinter obj)

Add obj to the map with key cls.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

databack to summary
pack-priv List<Pair<Class<?>, ObjectUtility.ObjectPrinter>> data

Constructor Detail

ClassMapback to summary
public ClassMap()

Method Detail

getback to summary
public ObjectUtility.ObjectPrinter get(Class<T> cls)

Return the first element of the ClassMap that is assignable to cls. The order is determined by the order in which the put method was called. Returns null if there is no match.

putback to summary
public void put(Class<T> cls, ObjectUtility.ObjectPrinter obj)

Add obj to the map with key cls. Note that order matters, as the first match is returned.

org.glassfish.pfl.basic.algorithm back to summary

pack-priv Interface ObjectUtility.ObjectPrinter


Method Summary

Modifier and TypeMethod and Description
public boolean
public void
print(IdentityHashMap<K, V> printed, ObjectWriter buff, Object obj)

Method Detail

alwaysPrintback to summary
public boolean alwaysPrint()
printback to summary
public void print(IdentityHashMap<K, V> printed, ObjectWriter buff, Object obj)