Start page
Start page

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 useful to obtain an overview of the methods available for an object. A list of the methods can be displayed via the class name of an object using 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 javap(Object) method displays an overview of all an object's methods and fields.

© 2005 - 2015 e-Spirit AG | All rights reserved. | Last change: 2014-03-20