Jerome,

> Agreed, let's reuse the safer "getValue() : String" method introduced in
> StringRepresentation and deprecate toString(). 

Thanks for making the change.

Why not go one steo further and have getValue cache the value?

   private boolean cached = false;
   private value = null;

   public String getValue()
        {
                if (!cached) 
                {
                    try
                    {
                        value = ByteUtils.toString(getStream());
                        cached = true;
                    }
                    catch (IOException ioe)
                    {
                    }
                }

                return value;
        } 


This way getValue, Request.getEntityAsString, etc. would always return the same
result. Which is what you expect from a method with a getter-like name, and
would prevent some hard-to-pinpoint bugs.


-Vincent.

Reply via email to