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.getStoreElement();
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()
Opening the show() method causes all return values of the subsequent methods to be automatically output in the console. Renewed invocation of show() ends automatic output. Example:
bsh % show();
bsh % e = context.getStoreElement();
<<SECTION editor="833847" id="835469" lastchange="1168967507480" name="Text/Bild" notdisplayed="" position="2" revision="1739" sectiontemplate="10">
<LANG language="DE"/>
</SECTION>
>
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.