Hi:

Can someone provide an example of "dumping"
out the ECS HTML Elements to a PrintWriter or an
OutputStream?

Wouldn't using a StringBuffer be just as efficient?

Thanks:

Alex

-----Original Message-----
From: Stephan Nagy [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 21, 2001 9:41 AM
To: [EMAIL PROTECTED]
Subject: Re: AW: Returning an object containing various HTML objects


"Comba-Riepenhausen Enrique (CO)" wrote:

> I would return them in following format:
>
> public String create questionPanel()
> {
>     String returnString = "";
>     Table firstTable  = new Table();
>     Table secondTable = new Table();
>     Table thirdTable  = new Table();
>        .
>        .
>        .
>      Other Objects.....
>
>       ....add all objects together
>     StringBuffer returnString = new StringBuffer();
>     returnString.append( firstTable.toString() );
>     returnString.append( secondTable.toString() );
>     returnString.append( thirdTable.toString() );
>     returnString.append( otherObjects.toString() );
>      return (returnString.toString() );
> }
>
> This is an performance issue. if you concatenate the String with +=
> you spend a lot of time in the creation of a new Object every time.
>
> -----Ursprüngliche Nachricht-----
> Von: David Ethell [mailto:[EMAIL PROTECTED]]
> Gesendet: Mittwoch, 21. März 2001 12:38
> An: [EMAIL PROTECTED]
> Betreff: RE: Returning an object containing various HTML objects
>
> Or, write them all as Strings and return a string:
>
> public String create questionPanel()
> {
>     String returnString = "";
>     Table firstTable  = new Table();
>     Table secondTable = new Table();
>     Table thirdTable  = new Table();
>        .
>        .
>        .
>      Other Objects.....
>
>       ....add all objects together
>     returnString += firstTable.toString();
>     returnString += secondTable.toString();
>     returnString += thirdTable.toString();
>     returnString += otherObjects.toString();
>      return (returnString);
> }

It is way more efficient to just dump them out to a PrintWriter or an
OutputStream directly then calling toString on them as that is an
incredibly expensive operation.  I can't actually think of a good reason
to ever call toString on an element in order to output it.

-stephan


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to