On Sun, Jan 28, 2001 at 11:48:43PM -0500, Jason van Zyl wrote:
> That's not really very meaningful. If we are going
> to go that route we should probably have an object
> that represents a set of transformations to be
> performed on the values to be set in the object.
>
> We can leave the signature of the standard method
> as is:
>
> data.getParameters().setProperties(user)
>
> and have another signature
>
> data.getParameters().setProperties(user, transformations)
-1 because this is setProperties specific.
How about:
data.getParameters()..setTransformations(transformations).setProperties(user)
That way transformations is used for all getXXX methods.
> Where transformations might be an ArrayList of
> Transformation objects that might look like something
> like the following:
>
> public interface Transformation
> {
> public Class getClass();
> public Object transform(Object objectToTransform);
> }
>
> public class Trim implements Transformation
> {
> public Class getClass()
> {
> return String.class;
> }
>
> public Object transform(Object objectToTransform)
> {
> return trim((String) objectToTransform);
> }
>
> private String trim(String s)
> {
> // trim the string.
> return trimmedString;
> }
> }
>
> Cycle through the transformations performing the
> desired transformations to the desired types.
>
> This would work for stripping bad HTML out of
> text, trimming strings, rounding floats, or
> whatever. We could leave the setProperties()
> and setProperty() in PP as they are and make
> two new methods that deal with the transformations.
> Then if you choose to take it raw you can, or you can apply
> whatever transforms you want and we won't
> make a big mess of the PP class I'm sure the above could be
> implemented better but that's the general
> idea.
Rather than getClass() in Transformation, how about transform checks
that the Object passed in is of a suitable type to transform itself.
Unfortunately for native types this means wrapping them on the way in
and unwrapping them on the way out. Which works, but involves
potentially unnecessary memory allocation. Perhaps this work should be
done in the Transformations class (which contains the ArrayList) and has
transformInt, transformLong methods etc. Then it need only do the
wrapping if there are actual transformations in the list.
Or maybe do have the getClass method in Transformation, then the
Transformations.transformXXX methods need only do wrapping if there
exists a transformation that applies to that type.
+1 on the idea definitely, needs implementing well however.
--
Sean Legassick
[EMAIL PROTECTED]
Czlowiekiem jestem i nic co ludzkie nie jest mi obce
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]