Please browse the categories below to previous answers to questions like yours. If you do not find the answer for your particular situation, ask for help on the appropriate mailing list.
(Answer) (Category) Java Apache Project : (Category) Element Construction Set : (Category) Examples :
A great idea about filter usage...
----------
From: "Doug Ahmann" douga@zoapworks.com
To: "ECS" ecs@list.working-dogs.com
Subject: ECS usage idea
Date: Wed, Jul 21, 1999, 9:46 AM


I've been thinking over the whole filter issue and wanted some opinions on
the following suggestion.

I'm turning filtering off by default in the properties. This allows me to do
the more common cases that I do such as:

something.addElement("Some text" + Entities.NBSP + "some more text");

without having to setFilterState(false).

Then, if I have a document I'm generating where I need to filter stuff I
simply create a filter object locally:

CharacterFilter filter = new CharacterFilter();

...

something
        .addElement(new BR())
        .addElement("Some text" + Entities.NBSP + filter.process("This & that"))
        .addElement(new Font("Times")
                .addElement(...

I could even have a few instances of custom filters in some globally
available place and reuse them.

The upside is that it avoids the problem of not being able to chain together
the .setFilterState() calls with addElement calls. It also removes the
overhead of ALWAYS filtering "just in case".

The downside is that it requires you to "manually" remember to filter items
that need filtering.

Can anyone think of any reason why this practice will bite me later on?

Thanks,
Doug

------------------------------------------------------------
Doug Ahmann
Zoapworks Inc.
(651) 762-1226 x203
[Append to This Answer]
Previous: (Answer) A couple of questions...
This document is: http://java.apache.org/faq/?file=256
[Search] [Appearance] [Show Expert Edit Commands]
This is a Faq-O-Matic 2.709.
Please browse the categories below to previous answers to questions like yours. If you do not find the answer for your particular situation, ask for help on the appropriate mailing list.