org.lsc.beans
Class LscBean

java.lang.Object
  extended by org.lsc.beans.LscBean
All Implemented Interfaces:
Serializable, Cloneable, IBean
Direct Known Subclasses:
AbstractBean, SimpleBean

public abstract class LscBean
extends Object
implements IBean

Basic bean used to centralize methods across all beans

This object mainly provides methods to store and access "attributes", i.e. named fields and their values.

This implementation ignores the case of attribute names, and uses Java Sets to store lists of values, so values must be unique and are unordered.

Author:
Sebastien Bahloul <seb@lsc-project.org>, Jonathan Clarke <jonathan@phillipoux.net>
See Also:
Serialized Form

Constructor Summary
LscBean()
           
 
Method Summary
 LscBean clone()
          Clone this Bean object.
 void generateDn()
          Generate the distinguish name according to the information on the bean.
 Set<Object> getAttributeAsSetById(String id)
          Get an attribute from its name as a Set.
 Attribute getAttributeById(String id)
          Get an attribute from its name.
 String getAttributeFirstValueById(String id)
          Get the first value of an attribute from its name
 Set<String> getAttributesNames()
          Get the attributes name list.
 String getAttributeValueById(String id)
          Deprecated.  
 List<String> getAttributeValuesById(String id)
          Get all values of an attribute from its name
 DataSchemaProvider getDataSchema()
           
 String getDistinguishedName()
          Default distinguished name getter.
 String getDistinguishName()
          Deprecated. Use getDistinguishedName()
 String getDN()
          Default distinguished name getter.
 String getFullDistinguishedName()
          Distinguish name getter that makes sure to return the FULL DN (including suffix).
static LscBean getInstance(SearchResult entry, String baseDn, Class<?> c)
          Set a bean from an LDAP entry
 void setAttribute(Attribute attr)
          Set an attribute.
 void setAttribute(String attrName, Set<Object> attrValues)
          Set an attribute.
 void setDataSchema(DataSchemaProvider dataSchema)
           
 void setDistinguishedName(String dn)
          Default distinguishedName setter.
 void setDistinguishName(String dn)
          Deprecated. Use setDistinguishedName(String)
static void setMetadata(ResultSetMetaData metaData)
          Manage something there !
 String toString()
          Bean pretty printer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LscBean

public LscBean()
Method Detail

getAttributeById

public final Attribute getAttributeById(String id)
Get an attribute from its name.

Specified by:
getAttributeById in interface IBean
Parameters:
id - the name
Returns:
the LDAP attribute

getAttributeAsSetById

public final Set<Object> getAttributeAsSetById(String id)
Get an attribute from its name as a Set.

Specified by:
getAttributeAsSetById in interface IBean
Parameters:
id - the name
Returns:
the LDAP attribute

getAttributeValueById

public final String getAttributeValueById(String id)
                                   throws NamingException
Deprecated. 

Get the first value of an attribute from its name

Specified by:
getAttributeValueById in interface IBean
Parameters:
id - The attribute name (case insensitive)
Returns:
String The first value of the attribute, or the empty string ("")
Throws:
NamingException

getAttributeFirstValueById

public final String getAttributeFirstValueById(String id)
                                        throws NamingException
Get the first value of an attribute from its name

Specified by:
getAttributeFirstValueById in interface IBean
Parameters:
id - The attribute name (case insensitive)
Returns:
String The first value of the attribute, or the empty string ("")
Throws:
NamingException

getAttributeValuesById

public final List<String> getAttributeValuesById(String id)
                                          throws NamingException
Get all values of an attribute from its name

Specified by:
getAttributeValuesById in interface IBean
Parameters:
id - The attribute name (case insensitive)
Returns:
List List of attribute values, or an empty list
Throws:
NamingException

getAttributesNames

public final Set<String> getAttributesNames()
Get the attributes name list.

Specified by:
getAttributesNames in interface IBean
Returns:
the attributes list

setAttribute

public final void setAttribute(Attribute attr)
Set an attribute. API CHANGE: Do nothing if attribute is empty

Specified by:
setAttribute in interface IBean
Parameters:
attr - the attribute to set

setAttribute

public final void setAttribute(String attrName,
                               Set<Object> attrValues)
Set an attribute.

Specified by:
setAttribute in interface IBean
Parameters:
attrName - The attribute name.
attrValues - A set of values for the attribute.

getDistinguishName

public final String getDistinguishName()
Deprecated. Use getDistinguishedName()

Default distinguished name getter.

Specified by:
getDistinguishName in interface IBean
Returns:
the distinguishedName

getDistinguishedName

public final String getDistinguishedName()
Default distinguished name getter.

Specified by:
getDistinguishedName in interface IBean
Returns:
the distinguishedName

getDN

public final String getDN()
Default distinguished name getter.

Returns:
the distinguishedName

getFullDistinguishedName

public final String getFullDistinguishedName()
Distinguish name getter that makes sure to return the FULL DN (including suffix).

Returns:
the distinguishedName

setDistinguishName

public final void setDistinguishName(String dn)
Deprecated. Use setDistinguishedName(String)

Default distinguishedName setter.

Specified by:
setDistinguishName in interface IBean
Parameters:
dn - The distinguishedName to set

setDistinguishedName

public final void setDistinguishedName(String dn)
Default distinguishedName setter.

Specified by:
setDistinguishedName in interface IBean
Parameters:
dn - The distinguishedName to set

generateDn

public void generateDn()
                throws NamingException
Description copied from interface: IBean
Generate the distinguish name according to the information on the bean.

Specified by:
generateDn in interface IBean
Throws:
NamingException - thrown is a directory exception is encountered while generating the new distinguish name

toString

public final String toString()
Bean pretty printer.

Overrides:
toString in class Object
Returns:
the pretty formatted string to display

clone

public LscBean clone()
              throws CloneNotSupportedException
Clone this Bean object.

Specified by:
clone in interface IBean
Overrides:
clone in class Object
Returns:
Object
Throws:
CloneNotSupportedException

setDataSchema

public void setDataSchema(DataSchemaProvider dataSchema)

getDataSchema

public DataSchemaProvider getDataSchema()

setMetadata

public static void setMetadata(ResultSetMetaData metaData)
Manage something there !

Parameters:
metaData -

getInstance

public static LscBean getInstance(SearchResult entry,
                                  String baseDn,
                                  Class<?> c)
                           throws NamingException
Set a bean from an LDAP entry

Parameters:
entry - the LDAP entry
baseDn - the base Dn used to set the right Dn
c - class to instantiate
Returns:
the bean
Throws:
NamingException - thrown if a directory exception is encountered while looking at the entry


Copyright © 2005-2010 LSC project. All Rights Reserved.