[jdom-interest] Still more Verification

Oliver Imbusch flabes at livis.de
Wed Aug 23 00:43:06 PDT 2000

>>>>> "jh" == Jason Hunter <jhunter at collab.net> writes:


    jh> Is it worth a 20% performance on all element construction to
    jh> sanity check the text content?

no, not in general IMHO.

    jh> But how would one differentiate between the two?

public void setValue (String value, boolean check) {
    if (check) {
        String reason = Verifier.checkCharacterData (value);
        if (reason != null) {
            throw new IllegalDataException (value, reason);
    this.value = value;

public void setValue (String value) {
    setValue (value, true);

So if you go for speed you'll choose the variant with the extra flag.
Check of a boolean every time a value is set should be OK. People who
don't care for 20% performance degradation can probably live with the
extra method call introduced by the convenience wrapper.

Or switch checking on/off on a per-object base using a
setCheck(boolen) method.

    jh> We haven't worried about it for things like checking tag names
    jh> because it's relatively fast

I have, and I was lucky to find the non-checking no-op protected
Element c'tor.

    jh> but when you have a document that could have large amounts of
    jh> text, do you really want to check every character one at a
    jh> time against a matrix of legal characters?

Again, no, *PLEASE*!


More information about the jdom-interest mailing list