org.schmant.support.util
Interface FlatteningListDecorator

All Known Implementing Classes:
JRubyExecutor, JythonExecutor, MozillaRhinoExecutor, SunJavaScriptExecutor

public interface FlatteningListDecorator

This adapter is used by different script language implementations to teach FlatteningList about their own strange array and collection implementations.

When Schmant starts, a ScriptExecutor may register an implementation of this interface with the FlatteningList class.

Since:
1.0
Author:
Karl Gustafsson

Method Summary
<T> int
tryAdd(FlatteningList<T> list, int index, Object o, ObjectTransformer<T> transformer)
          If o is an object that this decorator handles, add it to the list.
<T> int
tryAdd(FlatteningList<T> list, int index, T o)
          If o is an object that this decorator handles, add it to the list.
 

Method Detail

tryAdd

<T> int tryAdd(FlatteningList<T> list,
               int index,
               T o)
If o is an object that this decorator handles, add it to the list.

Type Parameters:
T - The type of objects in the list.
Parameters:
list - The list to add the object to.
index - The index for the new object in the list. If this argument is -1, add the object to the end of the list.
o - The object to add.
Returns:
The total number of objects added to the list. If this decorator does not handle the supplied object, this method should return -1.

tryAdd

<T> int tryAdd(FlatteningList<T> list,
               int index,
               Object o,
               ObjectTransformer<T> transformer)
If o is an object that this decorator handles, add it to the list.

Type Parameters:
T - The type of objects in the list.
Parameters:
index - The index for the new object in the list. If this argument is -1, add the object to the end of the list.
list - The list to add the object to.
o - The object to add.
transformer - The transformer used to transform the object into the list's type before it is added.
Returns:
The total number of objects added to the list. If this decorator does not handle the supplied object, this method should return -1.