Start page / Template development / Scripting / Introduction to BeanShell / Methods

Convenience methods

BeanShell offers a clear, manageable number of convenience methods (useful auxiliary functions) which can provide support during scripting and debugging.

print()
The print(Object) method generates a string output of any object required. Exemplary script opened from the BeanShell console:

bsh % e = context.getElement();
bsh % print(e);
<SECTION editor="833847" id="835469" lastchange="1168967507480" name="Text/Bild" notdisplayed="" position="2" revision="1739" sectiontemplate="10">
<LANG language="DE"/>
</SECTION>

show()
A return values of methods which are called in the BeanShell console are automatically output in the console by default.
Invocating show() ends automatic output. Example:

bsh % show();
bsh % e = context.getElement();
<<SECTION editor="833847" id="835469" lastchange="1168967507480" name="Text/Bild" notdisplayed="" position="2" revision="1739" sectiontemplate="10">
<LANG language="DE"/>
</SECTION>
>

You can reactivate the output with another call of show().

getMethods()
Sometimes it is helpful to get an overview of the methods available for an object. The class names of an object can be used to display a list of all methods of this class (including the inherited methods) with getMethods().
Example:

bsh % print(e.getClass().getMethods());
java.lang.reflect.Method []: {
public void de.espirit.firstspirit.store.access.pagestore.SectionImpl.appendChildBefore(de.espirit.firstspirit.access.store.StoreElement,de.espirit.firstspirit.access.store.StoreElement),
public java.util.Set de.espirit.firstspirit.store.access.pagestore.SectionImpl.getReferences() throws java.io.IOException,
public final de.espirit.firstspirit.access.store.templatestore.Template de.espirit.firstspirit.store.access.pagestore.SectionImpl.getTemplate(),
public void de.espirit.firstspirit.store.access.pagestore.SectionImpl.clearCachedData(),
...
public final void java.lang.Object.wait() java.lang.InterruptedException,
public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException,
public final native void java.lang.Object.notify(),
public final native void java.lang.Object.notifyAll(),
}

javap()
The method javap(Object) shows an overview of all methods and fields of an object that are implemented or overwritten directly in the concrete class.

© 2005 - 2024 Crownpeak Technology GmbH | All rights reserved. | FirstSpirit 2024.12 | Data privacy