Michael Ströder wrote:
Emmanuel Lecharny wrote:
Hallvard B Furuseth wrote:
Michael Ströder writes:
It really depends on what you want to express. Note that "" represents
the rootDSE or root naming context. So "" would reference something
existing or well-defined. IMHO NULL (or None in Python) would better
signal something undefined or none-existing.
Yes. There is one case in the LDAP ASN.1 grammar (in rfc 4511) where
you need to distinguish between an absent DN and an empty DN: The LDAPDN
field ModifyDNRequest.newSuperior, which is 'OPTIONAL'. There may be
others in LDAP extensions defined elsewhere.
This is starting to be confusing. The initial question was :
"Should the toString() method of a class that represents a DN return
null or an empty string?"
This can't be answered consistently without knowing what this returned
value is used for. But I'll try: If you just created an object instance
of the DN class without assigning any real DN to it method toString()
should return NULL instead of "".
In this very case (ie, you do a new LdapDN(), which is an empty DN), I
would suggest you return "", not null. But if the DN is optional and not
used (as in a ModifyDN with no newSuperior), then you should return NULL
=> no newSuperior DN.
Do we agree ?
But if the question is :
"How do I represent a DN in a structure when I do a toString() on this
structure", then the answer would be :
- null if the DN member is null
I guess with "DN member" you're referring to the class' attribute for
storing the DN. So I guess this is the case I described above.
yep. Like the 'name' element in a LdapResult (which is a mandatory
value, though should resolve to "" )
- "" if the DN does not hold any value.
I doubt that this is right or maybe I misunderstood "does not hold any
value".
A LDAPDN is a translation of the X500 structure. It contains RDNs, and
when you don't have any RDN, then the DN does not contain any value.
This is what I wanted to express...
Again: "" refers to the rootDSE or is the root naming context in search
requests with scope!=base. If you pass "" to any other method (e.g. for
a modify request) then it has a specific meaning (e.g. modifying the
rootDSE).
correct.
Well, not being a Java programmer I will stay out of further discussion
because I don't know what's common in the Java world.
Oh, I don't think it's a Java problem, unless we consider it to be a
question on how to handle Null vs "" in Java.
I'm pretty sure that we are on the same page, to some extent, and that
Marc have the answers he was expecting, thanks to your mails !
--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org