You are viewing a plain text version of this content. The canonical link for it is here.
Posted to api@directory.apache.org by Emmanuel Lecharny <el...@gmail.com> on 2010/04/19 18:52:24 UTC
Attribute object definition
Hi guys,
I'm back from two weeks of vacations, and it's hard to come back to code
... Anyway, coding is quite close to having vacations, so...
I have checked the existing APIs and how they implement the Attribute
object. here is what we have :
- JNDI :
o an Attribute interface, a BasicAttribute implementation
o Implements Cloneable and Serializable
o A few constructors :
BasicAttribute(String id)
BasicAttribute(String id, boolean ordered)
BasicAttribute(String id, Object value)
BasicAttribute(String id, Object value, boolean ordered)
- jLDAP :
o no interface, a LDAPAttribute class
o Implements Cloneable, Comparable and Serializable
o A few constructors :
LDAPAttribute()
LDAPAttribute(LDAPAttribute)
LDAPAttribute(String id)
LDAPAttribute(String id, byte[] value)
LDAPAttribute(String id, String value)
LDAPAttribute(String id, String[] value)
- OpenDS :
o One interface, Attribute
o Many classes implementing this interface : AbstractAttribute,
EmptyAttribute LinkedAttribute ( it seems that the ater is the one to
use when creating a new Attribute) plus some wrappers
(UnmodifiableAttribute, RenamedAttribute)
o Does not implement any extra interface
o Some constructors, none being schema aware :
LinkedAttribute(Attribute)
LinkedAttribute(AttributeDescription)
LinkedAttribute(AttributeDescription, ByteString)
LinkedAttribute(AttributeDescription, ByteString...)
LinkedAttribute(AttributeDescription, Collection<ByteString>)
LinkedAttribute(String)
LinkedAttribute(String, Object)
LinkedAttribute(String, Object...)
- UnboundID
o No interface, just one class : Attribute
o implements Serializable
o Many (too many) constructors :
Attribute(String name)
Attribute(String name, ASN1OctetString... values)
Attribute(String name, byte[] value)
Attribute(String name, byte[]... values)
Attribute(String name, Collection<String>)
Attribute(String name, MatchingRule)
Attribute(String name, MatchingRule, ASN1OctetString[])
Attribute(String name, MatchingRule, byte[])
Attribute(String name, MatchingRule, byte[]...)
Attribute(String name, MatchingRule, Collection<String>)
Attribute(String name, MatchingRule, String)
Attribute(String name, MatchingRule, String...)
Attribute(String name, Schema, ASN1OctetString... values)
Attribute(String name, Schema, byte[]...)
Attribute(String name, Schema, Collection<String>)
Attribute(String name, Schema, String...)
Attribute(String name, String value)
Attribute(String name, String... values)
Suggestions :
- We want to define an Interface and an Implementation. The selected
name could be :
* Attribute for the interface
* DefaultAttribute for the implementation
The reason why it's named DefaultAttribute is that it's quite a common
practice (probably better than BaseAttribute, BasicAttribute or
AttributeImpl).
- We may define an AbstractAttribute class if needed
- We should also implement Comparable, Iterable (over values), Cloneable
and externalizable
- We may have a ImmutableAttribute class, a wrapper around a mutable
Attribute instance
- The class might be schema aware, assuming that we inject the schema
into it (either via a constructor or via an apply(Schema) method)
- The constructors could be :
DefaultAttribute()
DefaultAttribute(String id)
DefaultAttribute(String id, byte[]... values)
DefaultAttribute(String id, String... values)
DefaultAttribute(String id, Value<?>... values)
DefaultAttribute(AttributeType at)
DefaultAttribute(AttributeType at, byte[]... values)
DefaultAttribute(AttributeType at, String... values)
DefaultAttribute(AttributeType at, Value<?>... values))
DefaultAttribute(String id, SchemaManager schema)
DefaultAttribute(String id, SchemaManager schema, byte[]... values)
DefaultAttribute(String id, SchemaManager schema, String... values)
DefaultAttribute(String id, SchemaManager schema, Value<?>... values)
Thoughts ?
--
Regards,
Cordialement,
Emmanuel Lécharny
www.nextury.com
Re: Attribute object definition
Posted by Kiran Ayyagari <ay...@gmail.com>.
On Mon, Apr 19, 2010 at 7:52 PM, Emmanuel Lecharny <el...@gmail.com> wrote:
>
> Suggestions :
> - We want to define an Interface and an Implementation. The selected name
> could be :
> * Attribute for the interface
> * DefaultAttribute for the implementation
+1
> The reason why it's named DefaultAttribute is that it's quite a common
> practice (probably better than BaseAttribute, BasicAttribute or
> AttributeImpl).
> - We may define an AbstractAttribute class if needed
hmm not sure if we really need this, users can extend the above
DefaultAttribute if required, wdyt?
> - We should also implement Comparable, Iterable (over values), Cloneable and
> externalizable
> - We may have a ImmutableAttribute class, a wrapper around a mutable
> Attribute instance
> - The class might be schema aware, assuming that we inject the schema into
> it (either via a constructor or via an apply(Schema) method)
> - The constructors could be :
> DefaultAttribute()
> DefaultAttribute(String id)
> DefaultAttribute(String id, byte[]... values)
> DefaultAttribute(String id, String... values)
> DefaultAttribute(String id, Value<?>... values)
that we gonna get rid of these Value classes sooner or later right so,
hmm not sure if we need a
constructor with it
> DefaultAttribute(String id, SchemaManager schema)
> DefaultAttribute(String id, SchemaManager schema, byte[]... values)
> DefaultAttribute(String id, SchemaManager schema, String... values)
> DefaultAttribute(String id, SchemaManager schema, Value<?>... values)
I would suggest to merge the above SchemaManager based constructors to just one
DefaultAttribute(String id, SchemaManager schema)
and let the users add the attributes with separate calls
thanks Emmanuel
Kiran Ayyagari