Class InvokerHelper
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Object[]Shared zero-length array used as the argument list for a call that takes no arguments.protected static final Object[]The same array asEMPTY_ARGS.protected static final Class[]Shared zero-length array ofClassobjects.static final StringThe method name"main".static final MetaClassRegistry -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidappend(Appendable out, Object object) Deprecated.static Object[]Converts the given object into an array; if it's an array then just cast otherwise wrap it in an arrayasIterator(Object o) static ListAdaptsvalueto aList.static voidassertFailed(Object expression, Object message) static Object[]asUnwrappedArray(Object arguments) NormalizesargumentswithasArray(Object), then replaces eachPojoWrapperelement withPojoWrapper.unwrap().static ObjectbitwiseNegate(Object value) Bitwise-negatesvalue.static AssertionErrorcreateAssertError(Object expression, Object message) static ListcreateList(Object[] values) Returns a newArrayListsized tovalues.lengthand filled with those elements in order.static MapBuilds aLinkedHashMapfrom successive pairs invalues.static ListcreateRange(Object from, Object to, boolean inclusive) Creates a range fromfromtotowith the left end included.static ListcreateRange(Object from, Object to, boolean exclusiveLeft, boolean exclusiveRight) Creates the range fromfromtotoby delegating toScriptBytecodeAdapter.createRange.static ScriptcreateScript(Class scriptClass, Binding context) static TuplecreateTuple(Object[] array) Returns aTupleconstructed fromarray.static StringescapeBackslashes(String orig) Deprecated.useFormatHelper.escapeBackslashes(String)static MatcherFind the right hand regex within the left hand string and return a matcher.protected static StringDeprecated.useFormatHelper.format(Object, boolean)static StringDeprecated.useFormatHelper.format(Object, boolean, int)static StringDeprecated.useFormatHelper.format(Object, boolean, int, boolean)static ObjectgetAttribute(Object object, String attribute) Reads the attributeattributefromobject.static ObjectgetGroovyObjectProperty(GroovyObject object, String property) Readspropertyby callingGroovyObject.getProperty(String)onobject, with no null substitution and no registry lookup.static MetaClassgetMetaClass(Class cls) Returns the meta-class registered forcls.static MetaClassgetMetaClass(Object object) Returns the meta-class used forobject.static MetaClassRegistryReturnsmetaRegistry.static ClosuregetMethodPointer(Object object, String methodName) Returns a method closure for the given object and name.static ObjectgetProperty(Object object, String property) Reads the propertypropertyfromobject.static ObjectgetPropertySafe(Object object, String property) Readspropertyfromobjectwhenobjectis notnull.static intinitialCapacity(int initialEntryCnt) According to the initial entry count, calculate the initial capacity of hash map, which is power of 2 (SEE https://stackoverflow.com/questions/8352378/why-does-hashmap-require-that-the-initial-capacity-be-a-power-of-two)static StringDeprecated.useFormatHelper.inspect(Object)static ObjectinvokeClosure(Object closure, Object arguments) static ObjectinvokeConstructorOf(Class type, Object arguments) Invokes a constructor oftypethrough the meta-class registered for that class.static ObjectinvokeConstructorOf(String klass, Object arguments) LoadsklasswithClass.forName(String)and invokes a constructor of that class.static ObjectinvokeMethod(Object object, String methodName, Object arguments) Invokes the given method on the object.static ObjectinvokeMethodSafe(Object object, String methodName, Object arguments) InvokesmethodNameonobjectwhenobjectis notnull.static ObjectInvokes a constructor oftypewithEMPTY_ARGS.static ObjectinvokeStaticMethod(Class type, String method, Object arguments) Invokes the static methodmethodontypethrough the meta-class registered fortype.static ObjectinvokeStaticMethod(String klass, String methodName, Object arguments) LoadsklasswithClass.forName(String)and invokes the static methodmethodNameon that class.static ObjectinvokeStaticNoArgumentsMethod(Class type, String methodName) static ObjectinvokeSuperMethod(Object object, String methodName, Object arguments) InvokesmethodNamethrough the meta-class of the superclass ofobject's runtime class.static booleanmatchRegex(Object left, Object right) Find the right hand regex within the left hand string and return a matcher.static ScriptInstantiatesscriptClassand associatescontext.static voidremoveClass(Class clazz) static Objectstatic voidsetAttribute(Object object, String attribute, Object newValue) WritesnewValueto the attributeattributeonobject.static voidsetGroovyObjectProperty(Object newValue, GroovyObject object, String property) This is so we don't have to reorder the stack when we call this method.static voidsetProperties(Object object, Map map) Sets the properties on the given objectstatic voidsetProperty(Object object, String property, Object newValue) WritesnewValueto the propertypropertyonobject.static voidsetProperty2(Object newValue, Object object, String property) This is so we don't have to reorder the stack when we call this method.static voidsetPropertySafe2(Object newValue, Object object, String property) This is so we don't have to reorder the stack when we call this method.static SpreadMapstatic StringtoArrayString(Object[] arguments) Deprecated.useFormatHelper.toArrayString(Object[])static StringtoArrayString(Object[] arguments, int maxSize, boolean safe) Deprecated.useFormatHelper.toArrayString(Object[], int, boolean)static StringtoListString(Collection arg) Deprecated.useFormatHelper.toListString(Collection)static StringtoListString(Collection arg, int maxSize) Deprecated.useFormatHelper.toListString(Collection, int)static StringtoListString(Collection arg, int maxSize, boolean safe) Deprecated.useFormatHelper.toListString(Collection, int, boolean)static StringtoMapString(Map arg) Deprecated.useFormatHelper.toMapString(Map)static StringtoMapString(Map arg, int maxSize) Deprecated.useFormatHelper.toMapString(Map, int)static StringDeprecated.useFormatHelper.toString(Object)static StringtoTypeString(Object[] arguments) Deprecated.useFormatHelper.toTypeString(Object[])static StringtoTypeString(Object[] arguments, int maxSize) Deprecated.useFormatHelper.toTypeString(Object[], int)static ObjectunaryMinus(Object value) Negatesvalue.static ObjectApplies unary plus tovalue.static voidDeprecated.useFormatHelper.write(Writer, Object)
-
Field Details
-
EMPTY_ARGS
Shared zero-length array used as the argument list for a call that takes no arguments. -
EMPTY_ARGUMENTS
-
EMPTY_TYPES
Shared zero-length array ofClassobjects. -
metaRegistry
TheMetaClassRegistryfromGroovySystem.getMetaClassRegistry(). Meta-class lookups in this class go through this registry. -
MAIN_METHOD_NAME
The method name"main".createScript(Class, Binding)calls a static method of this name when a class cannot be constructed from aBinding.- See Also:
-
-
Constructor Details
-
InvokerHelper
public InvokerHelper()
-
-
Method Details
-
removeClass
- Parameters:
clazz- the class removed from those caches
-
invokeMethodSafe
InvokesmethodNameonobjectwhenobjectis notnull. Anullreceiver returnsnulland does not callinvokeMethod(Object, String, Object).- Parameters:
object- the receiver, ornullmethodName- the method to invokearguments- the arguments accepted byinvokeMethod(Object, String, Object)- Returns:
- the method result, or
nullwhenobjectisnull
-
invokeStaticMethod
public static Object invokeStaticMethod(String klass, String methodName, Object arguments) throws ClassNotFoundException LoadsklasswithClass.forName(String)and invokes the static methodmethodNameon that class.- Parameters:
klass- the class name passed toClass.forName(String)methodName- the static method to invokearguments- the arguments passed toinvokeStaticMethod(Class, String, Object)- Returns:
- the result of the static call
- Throws:
ClassNotFoundException- ifklasscannot be loaded
-
invokeStaticNoArgumentsMethod
- Parameters:
type- the class that receives the static callmethodName- the static method to invoke- Returns:
- the result of the static call
-
invokeConstructorOf
public static Object invokeConstructorOf(String klass, Object arguments) throws ClassNotFoundException LoadsklasswithClass.forName(String)and invokes a constructor of that class.- Parameters:
klass- the class name passed toClass.forName(String)arguments- the arguments passed toinvokeConstructorOf(Class, Object)- Returns:
- the new instance
- Throws:
ClassNotFoundException- ifklasscannot be loaded
-
invokeNoArgumentsConstructorOf
Invokes a constructor oftypewithEMPTY_ARGS.- Parameters:
type- the class to instantiate- Returns:
- the new instance
-
invokeClosure
- Parameters:
closure- the receiver ofdoCallarguments- the arguments passed to that invocation- Returns:
- the result of
doCall
-
asList
Adaptsvalueto aList.nullbecomesCollections.EMPTY_LIST. AListis returned as given. When the runtime class is an array, the value is cast toObject[]and passed toArrays.asList(T...); a primitive array fails that cast. AnEnumerationis copied, in iteration order, into a newArrayList. Any other value becomes a one-element list. ThrowsClassCastExceptionifvalueis a primitive array.- Parameters:
value- the value to adapt- Returns:
- a list for
value
-
getAttribute
Reads the attributeattributefromobject. Anullreceiver is replaced withNullObject.getNullObject()before the read. AClassreceiver is tested before aGroovyObjectand uses the meta-class registered for that class. AGroovyObjectuses the meta-class fromGroovyObject.getMetaClass(). Every other receiver uses the meta-class registered for its runtime class. The value is then read withgetAttributeon that meta-class.- Parameters:
object- the receiver, ornullattribute- the attribute name- Returns:
- the attribute value
-
setAttribute
WritesnewValueto the attributeattributeonobject. Anullreceiver is replaced withNullObject.getNullObject()before the write. AClassreceiver is tested before aGroovyObjectand uses the meta-class registered for that class. AGroovyObjectuses the meta-class fromGroovyObject.getMetaClass(). Every other receiver uses the meta-class registered for its runtime class. The value is then written withsetAttributeon that meta-class.- Parameters:
object- the receiver, ornullattribute- the attribute namenewValue- the value to assign
-
getProperty
Reads the propertypropertyfromobject. Anullreceiver is replaced withNullObject.getNullObject()before the read. AGroovyObjectis tested before aClassand is read throughGroovyObject.getProperty(String). AClassreceiver uses the meta-class registered for that class. Every other receiver usesMetaClassRegistryImpl.getMetaClass(Object)and thengetPropertyon that meta-class.- Parameters:
object- the receiver, ornullproperty- the property name- Returns:
- the property value
-
getPropertySafe
Readspropertyfromobjectwhenobjectis notnull. Anullreceiver returnsnulland is not replaced withNullObject.- Parameters:
object- the receiver, ornullproperty- the property name- Returns:
- the property value, or
nullwhenobjectisnull
-
setProperty
@GroovyABI(since="1.0.0") public static void setProperty(Object object, String property, Object newValue) WritesnewValueto the propertypropertyonobject. Anullreceiver is replaced withNullObject.getNullObject()before the write. AGroovyObjectis tested before aClassand is written throughGroovyObject.setProperty(String, Object). AClassreceiver uses the meta-class registered for that class. Every other receiver usesMetaClassRegistryImpl.getMetaClass(Object)and thensetPropertyon that meta-class.- Parameters:
object- the receiver, ornullproperty- the property namenewValue- the value to assign
-
setProperty2
@GroovyABI(since="1.0.0") public static void setProperty2(Object newValue, Object object, String property) This is so we don't have to reorder the stack when we call this method. At some point a better name might be in order. -
setGroovyObjectProperty
@GroovyABI(since="1.0.0") public static void setGroovyObjectProperty(Object newValue, GroovyObject object, String property) This is so we don't have to reorder the stack when we call this method. At some point a better name might be in order. -
getGroovyObjectProperty
@GroovyABI(since="1.0.0") public static Object getGroovyObjectProperty(GroovyObject object, String property) Readspropertyby callingGroovyObject.getProperty(String)onobject, with no null substitution and no registry lookup.- Parameters:
object- the Groovy receiverproperty- the property name- Returns:
- the property value
-
setPropertySafe2
@GroovyABI(since="1.0.0") public static void setPropertySafe2(Object newValue, Object object, String property) This is so we don't have to reorder the stack when we call this method. At some point a better name might be in order. -
getMethodPointer
Returns a method closure for the given object and name. -
unaryMinus
Negatesvalue.Integer,Long,Double, andFloatuse arithmetic negation.ShortandByteare negated and cast back toshortandbyte.BigIntegerandBigDecimalusenegate(). AnArrayListyields a new list of the element-wise results. Any other value is passed toinvokeMethod(Object, String, Object)as the no-argument methodnegative.- Parameters:
value- the value to negate- Returns:
- the negated value
-
unaryPlus
Applies unary plus tovalue.Integer,Long,BigInteger,BigDecimal,Double,Float,Short, andByteare returned unchanged. AnArrayListyields a new list of the element-wise results. Any other value is passed toinvokeMethod(Object, String, Object)as the no-argument methodpositive.- Parameters:
value- the value to which unary plus is applied- Returns:
- the numeric value unchanged, or the element-wise or method result
-
findRegex
Find the right hand regex within the left hand string and return a matcher.- Parameters:
left- string to compareright- regular expression to compare the string to
-
matchRegex
Find the right hand regex within the left hand string and return a matcher.- Parameters:
left- string to compareright- regular expression to compare the string to
-
createTuple
Returns aTupleconstructed fromarray.- Parameters:
array- the elements passed to the tuple constructor- Returns:
- the new tuple
-
spreadMap
Builds aSpreadMapfromvaluewhenvalueis aMap. Entries are flattened, in key-set iteration order, into an array that alternates key then value, and that array is passed to theSpreadMapconstructor. A non-map value throwsSpreadMapEvaluatingException.nulldoes not reach that throw: the message callsFormatHelper.typeName(value), which dereferencesvalue.- Parameters:
value- the map to spread- Returns:
- a spread map of the map's entries
-
createList
Returns a newArrayListsized tovalues.lengthand filled with those elements in order.- Parameters:
values- the elements to copy into the list- Returns:
- the new list
-
initialCapacity
public static int initialCapacity(int initialEntryCnt) According to the initial entry count, calculate the initial capacity of hash map, which is power of 2 (SEE https://stackoverflow.com/questions/8352378/why-does-hashmap-require-that-the-initial-capacity-be-a-power-of-two)- Parameters:
initialEntryCnt- the initial entry count- Returns:
- the initial capacity
-
createMap
Builds aLinkedHashMapfrom successive pairs invalues. The initial capacity isinitialCapacity(int)ofvalues.length / 2. A pair whose first element is aSpreadMapand whose second element is aMapcontributes that map's entries. Every other pair is stored as one key and value. A trailing element left without a pair is ignored.- Parameters:
values- alternating keys and values, with optional spread pairs- Returns:
- the collected entries in insertion order
-
assertFailed
- Parameters:
expression- the expression supplied to the errormessage- the message supplied to the error
-
createAssertError
- Since:
- 4.0.7
-
runScript
RunsscriptClassin aBindingwhoseargsvariable is the supplied array. The instance comes fromcreateScript(Class, Binding), andrunis invoked on it withEMPTY_ARGS.- Parameters:
scriptClass- the class passed tocreateScript(Class, Binding)args- the array stored as the binding variableargs- Returns:
- the result of
run
-
createScript
AdaptsscriptClassto aScriptassociated withcontext.A
nullclass produces aNullScriptbound tocontext; itsrunmethod returnsnull. A class assignable toScriptis instantiated withnewScript(Class, Binding).For any other class,
Binding.class.getName()is loaded fromscriptClass's class loader. A binding of that loaded type is constructed fromcontext.getVariables()through its declaredMapconstructor, andscriptClassis constructed with its declared constructor that takes that binding type. The instance is wrapped in aScriptcreated with the no-argument constructor, so the wrapper's own binding is a new emptyBinding. The wrapper'srunmethod invokesrunon the instance with no arguments.If that attempt throws
ClassNotFoundException,NoSuchMethodException, orSecurityException, the result is aScriptconstructed withcontext. Itsrunmethod calls the staticMAIN_METHOD_NAMEmethod with one argument: the binding propertyargswhen that value is aString[], otherwise a new emptyString[]. A missingargsproperty, reported asMissingPropertyException, also selects the empty array. Before the wrapper is returned, each entry ofcontext.getVariables()whose key'stoString()does not start with'_'is written as a property of thescriptClassclass object. AMissingPropertyExceptionfrom that write is ignored, and so is anIllegalArgumentExceptioncarried as the cause of anInvokerInvocationException.Any other
Exceptionis wrapped in aGroovyRuntimeExceptionthat namesscriptClass.- Parameters:
scriptClass- the class to adapt, ornullcontext- the binding supplied to the adapted script- Returns:
- the adapted
Script
-
newScript
public static Script newScript(Class<? extends Script> scriptClass, Binding context) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException InstantiatesscriptClassand associatescontext. Uses the public(Binding)constructor whenscriptClasshas one. When that constructor is absent, calls the declared no-argument constructor and thenScript.setBinding(Binding).- Parameters:
scriptClass- theScripttype to constructcontext- the binding passed to the constructor, or tosetBinding- Returns:
- the new script instance
- Throws:
NoSuchMethodException- if the no-argument constructor is absentInstantiationException- if the class that declares the chosen constructor is abstractIllegalAccessException- if the chosen constructor is inaccessibleInvocationTargetException- if the chosen constructor throws an exception
-
setProperties
Sets the properties on the given object -
createRange
public static List createRange(Object from, Object to, boolean exclusiveLeft, boolean exclusiveRight) Creates the range fromfromtotoby delegating toScriptBytecodeAdapter.createRange. ARuntimeExceptionorErroris rethrown unchanged. Any otherThrowableis wrapped in aRuntimeException.- Parameters:
from- the start value passed to the delegateto- the end value passed to the delegateexclusiveLeft- passed through as the left-exclusive flagexclusiveRight- passed through as the right-exclusive flag- Returns:
- the list returned by the delegate
-
createRange
Creates a range fromfromtotowith the left end included. The call iscreateRange(from, to, false, !inclusive), soinclusivecontrols whethertois included.- Parameters:
from- the start value; the left end is inclusiveto- the end valueinclusive-trueto includeto;falseto exclude it- Returns:
- the list from
createRange(Object, Object, boolean, boolean)
-
bitwiseNegate
Bitwise-negatesvalue.IntegerandLonguse the~operator.BigIntegerusesnot(). AStringorGStringis compiled as a regular expression byStringGroovyMethods.bitwiseNegateonvalue.toString(). AnArrayListyields a new list of the element-wise results. Any other value is passed toinvokeMethod(Object, String, Object)as the no-argument methodbitwiseNegate.- Parameters:
value- the value to negate- Returns:
- the negated number, the
Patterncompiled from a string or GString, a list of the element-wise results, or the value returned by the no-argumentbitwiseNegatemethod
-
getMetaRegistry
ReturnsmetaRegistry.- Returns:
- the registry from
GroovySystem.getMetaClassRegistry()
-
getMetaClass
Returns the meta-class used forobject. AGroovyObjectis tested before aClassand answers withGroovyObject.getMetaClass(). AClassanswers withMetaClassRegistry.getMetaClass(Class)onmetaRegistry. Any other object answers withMetaClassRegistryImpl.getMetaClass(Object).- Parameters:
object- the receiver whose meta-class is required- Returns:
- that meta-class
-
getMetaClass
Returns the meta-class registered forcls.- Parameters:
cls- the class to look up inmetaRegistry- Returns:
MetaClassRegistry.getMetaClass(Class)forcls
-
invokeMethod
@GroovyABI(since="5.0.0") public static Object invokeMethod(Object object, String methodName, Object arguments) Invokes the given method on the object. -
invokeSuperMethod
InvokesmethodNamethrough the meta-class of the superclass ofobject's runtime class. Arguments are normalized withasArray(Object). Anullreceiver throwsNullPointerExceptionwhose message namesmethodName.- Parameters:
object- the receiver; must not benullmethodName- the method to invokearguments- the argument list, a single argument, ornull- Returns:
- the result of the meta-class invocation
-
invokeStaticMethod
Invokes the static methodmethodontypethrough the meta-class registered fortype. Arguments are normalized withasArray(Object).- Parameters:
type- the class that receives the static callmethod- the method namearguments- the argument list, a single argument, ornull- Returns:
- the result of the static call
-
invokeConstructorOf
Invokes a constructor oftypethrough the meta-class registered for that class. Arguments are normalized withasArray(Object).- Parameters:
type- the class to instantiatearguments- the argument list, a single argument, ornull- Returns:
- the new instance
-
asArray
Converts the given object into an array; if it's an array then just cast otherwise wrap it in an array -
asUnwrappedArray
NormalizesargumentswithasArray(Object), then replaces eachPojoWrapperelement withPojoWrapper.unwrap(). Whenargumentsis already anObject[], that same array is updated and returned.- Parameters:
arguments- the argument list, a single argument, ornull- Returns:
- the normalized array, with wrappers removed
-
asIterator
- Parameters:
o- the receiver ofiterator- Returns:
- the iterator returned by that call
-
toString
Deprecated.useFormatHelper.toString(Object)Returns the string representation ofargumentsproduced byFormatHelper.toString(Object).- Parameters:
arguments- the object to render- Returns:
- that string representation
-
inspect
Deprecated.useFormatHelper.inspect(Object)Returns the inspect rendering ofselfproduced byFormatHelper.inspect(Object), which selects inspect mode with escaped backslashes.- Parameters:
self- the object to inspect- Returns:
- that rendering
-
write
Deprecated.useFormatHelper.write(Writer, Object)Writesobjecttooutby callingFormatHelper.write(Writer, Object).- Parameters:
out- the writer that receives the textobject- the object to write- Throws:
IOException- if writing fails
-
append
Deprecated.useFormatHelper.append(Appendable, Object)Appendsobjecttooutby callingFormatHelper.append(Appendable, Object).- Parameters:
out- the appendable that receives the textobject- the object to append- Throws:
IOException- if appending fails
-
format
Deprecated.useFormatHelper.format(Object, boolean)Rendersargumentsby callingFormatHelper.format(Object, boolean). Whenverboseistrue, the delegate uses inspect mode with escaped backslashes.- Parameters:
arguments- the object to renderverbose-trueto select inspect mode with escaped backslashes- Returns:
- the formatted text
-
format
Deprecated.useFormatHelper.format(Object, boolean, int)Rendersargumentsby callingFormatHelper.format(Object, boolean, int). Whenverboseistrue, the delegate uses inspect mode with escaped backslashes.maxSizeis an approximate character limit;-1means no limit.- Parameters:
arguments- the object to renderverbose-trueto select inspect mode with escaped backslashesmaxSize- the approximate character limit, or-1for no limit- Returns:
- the formatted text
-
format
@Deprecated public static String format(Object arguments, boolean verbose, int maxSize, boolean safe) Deprecated.useFormatHelper.format(Object, boolean, int, boolean)Rendersargumentsby callingFormatHelper.format(Object, boolean, int, boolean). Whenverboseistrue, the delegate uses inspect mode with escaped backslashes.maxSizeis an approximate character limit;-1means no limit. Whensafeistrue, anExceptionthrown while rendering is swallowed and a fallback representation is used.- Parameters:
arguments- the object to renderverbose-trueto select inspect mode with escaped backslashesmaxSize- the approximate character limit, or-1for no limitsafe-trueto swallow a renderingException- Returns:
- the formatted text
-
escapeBackslashes
Deprecated.useFormatHelper.escapeBackslashes(String)Returnsorigwith backslash, newline, carriage return, tab, and form feed written as escape sequences, by callingFormatHelper.escapeBackslashes(String).- Parameters:
orig- the text to escape- Returns:
- the escaped text
-
toTypeString
Deprecated.useFormatHelper.toTypeString(Object[])Returns a comma-separated list of the runtime type names inarguments, by callingFormatHelper.toTypeString(Object[]).- Parameters:
arguments- the values whose types are rendered- Returns:
- the type list, or
"null"whenargumentsisnull
-
toTypeString
Deprecated.useFormatHelper.toTypeString(Object[], int)Returns a comma-separated list of the runtime type names inarguments, by callingFormatHelper.toTypeString(Object[], int). Output stops after aboutmaxSizecharacters and then appends"...";-1means no limit.- Parameters:
arguments- the values whose types are renderedmaxSize- the approximate character limit, or-1for no limit- Returns:
- the type list
-
toMapString
Deprecated.useFormatHelper.toMapString(Map)Returns the bracketed rendering ofarg, using[and]boundaries, by callingFormatHelper.toMapString(Map).- Parameters:
arg- the map to render- Returns:
- the map text
-
toMapString
Deprecated.useFormatHelper.toMapString(Map, int)Returns the bracketed rendering ofarg, using[and]boundaries, by callingFormatHelper.toMapString(Map, int). Output stops after aboutmaxSizecharacters and then appends"...";-1means no limit.- Parameters:
arg- the map to rendermaxSize- the approximate character limit, or-1for no limit- Returns:
- the map text
-
toListString
Deprecated.useFormatHelper.toListString(Collection)Returns the bracketed rendering ofarg, using[and]boundaries, by callingFormatHelper.toListString(Collection).- Parameters:
arg- the collection to render- Returns:
- the collection text
-
toListString
Deprecated.useFormatHelper.toListString(Collection, int)Returns the bracketed rendering ofarg, using[and]boundaries, by callingFormatHelper.toListString(Collection, int). Output stops after aboutmaxSizecharacters and then appends"...";-1means no limit.- Parameters:
arg- the collection to rendermaxSize- the approximate character limit, or-1for no limit- Returns:
- the collection text
-
toListString
Deprecated.useFormatHelper.toListString(Collection, int, boolean)Returns the bracketed rendering ofarg, using[and]boundaries, by callingFormatHelper.toListString(Collection, int, boolean). Output stops after aboutmaxSizecharacters and then appends"...";-1means no limit. Whensafeistrue, an item whose rendering throws anExceptionuses a fallback representation.- Parameters:
arg- the collection to rendermaxSize- the approximate character limit, or-1for no limitsafe-trueto substitute a fallback for an item that fails to render- Returns:
- the collection text
-
toArrayString
Deprecated.useFormatHelper.toArrayString(Object[])Returns the bracketed rendering ofarguments, using[and]boundaries, by callingFormatHelper.toArrayString(Object[]).- Parameters:
arguments- the array to render- Returns:
- the array text
-
toArrayString
Deprecated.useFormatHelper.toArrayString(Object[], int, boolean)Returns the bracketed rendering ofarguments, using[and]boundaries, by callingFormatHelper.toArrayString(Object[], int, boolean). Output stops after aboutmaxSizecharacters and then appends"...";-1means no limit. Whensafeistrue, an element whose rendering throws anExceptionuses a fallback representation.- Parameters:
arguments- the array to rendermaxSize- the approximate character limit, or-1for no limitsafe-trueto substitute a fallback for an element that fails to render- Returns:
- the array text
-
FormatHelper.append(Appendable, Object)