[jdom-interest] Auto-normalizing attribute values

Hallvard Tratteberg hal at idi.ntnu.no
Mon May 6 01:06:14 PDT 2002


> -----Original Message-----
> Subject: Re: [jdom-interest] Auto-normalizing attribute values
>
> Elliotte Rusty Harold wrote:
> > Should the various setAttributeValue() methods in Element and Attribute
> > check the attribute type and normalize the string according to the
attribute type?
> >
> That would also mean updating the attribute value when the attribute type
is changed.
> But if the type is then switched back to the previous one, the original
attribute value is lost.
>
> Why not just change the getAttributeValue methods to only normalize the
> returned value according to the current type without changing the
> inner storage?

As long as the default attribute type (when there is no DTD) does not imply
changing the value, we should not require the original to be kept. When the
attribute type later is set, the programmer should be aware of the
"destructive" behavior.

I propose we add a method e.g. String normalizeValue() (note not
normalizeAttributeValue :-) that is called whenever the attribute value or
type is changed. This method is responsible for changing the value according
to the normalization rules for the type. This method is also a hook for
potential subclasses of Attribute that want to compute the String value
based on an object or property.

Hallvard




More information about the jdom-interest mailing list