On 9/26/10 11:30 PM, Stefan Seelmann wrote:
Hi Emmanuel,
On Sun, Sep 26, 2010 at 8:07 PM, Emmanuel Lecharny<[email protected]> wrote:
Hi guys,
while investigating the NPE Stefan pointed out today, I found that the DN,
RDN and AVA are not completely immutable.
AVA has two methods that can modify it :
getNormValue(),
getUpValue()
Fixed.
RDN has many methods modifying it contents :
clear(),
This should be removed completele.
Not necessarily. I will make it package protected, as it's used by the
RdnParser. In other words, the user won't be able to use it.
getAtav(),
getAttributeTypeAndValue( String type ),
getNormValue(),
getUpValue(),
getValue( String type ),
iterator(),
normalize( ... ) (all the methods),
readExternal( ObjectInput in )
There are also two addAttributeTypeAndValue() and a setUpName() method.
The addAttributeTypeAndValue should renamed to addAVA() IMO.
DN has some too :
DN( RDN )
add( RDN )
addAll( int posn, DN )
addAllNormalized()
getRdn()
getRdn( int pos )
normalize(...)
Isn't that a paradox? The DN/RDN/AVA should be immutable. but we need
to modify them later in order to normalize them. IMO the only solution
is to have a constructor (or factory method) with a SchemaManager or
OID-Map parameter that normalizes the DN at construction time.
Yes. I think that the normalize() methods are still there because we
injected the schemaManager later in the design. We could get rid of it
now, maybe.
The
normalize() methods should then be renamed to "getNormalized()", and
they don't modify the actual object, but create a new object by
calling the constructor (or factory method) with the schema manager.
+1
Alternatively, if the DN/RDN/AVA is already normalized, the
getNormalized() method can just return the actual object.
yep.
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com