[lsc-changes] r493 - lsc/trunk/src/main/java/org/lsc/beans

jclarke at lsc-project.org jclarke at lsc-project.org
Sun Nov 29 22:26:03 CET 2009


Author: jclarke
Date: 2009-11-29 22:26:02 +0100 (Sun, 29 Nov 2009)
New Revision: 493

Added:
   lsc/trunk/src/main/java/org/lsc/beans/LscBean.java
Modified:
   lsc/trunk/src/main/java/org/lsc/beans/AbstractBean.java
   lsc/trunk/src/main/java/org/lsc/beans/IBean.java
   lsc/trunk/src/main/java/org/lsc/beans/SimpleBean.java
Log:
References #22. Seperate AbstractBean into LscBean (new class to be kept) and AbstractBean (deprecated class to be removed in LSC 1.3). Update the IBean interface.

Modified: lsc/trunk/src/main/java/org/lsc/beans/AbstractBean.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/beans/AbstractBean.java	2009-11-29 21:19:20 UTC (rev 492)
+++ lsc/trunk/src/main/java/org/lsc/beans/AbstractBean.java	2009-11-29 21:26:02 UTC (rev 493)
@@ -47,10 +47,10 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.sql.ResultSetMetaData;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -62,12 +62,10 @@
 import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.SearchResult;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.lsc.Configuration;
 import org.lsc.objects.top;
-import org.lsc.service.DataSchemaProvider;
 import org.lsc.utils.DateUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Abstract bean used to centralize methods across all beans
@@ -78,8 +76,13 @@
  * The bean is also able to map a bean from SearchResult LDAP object.
  *
  * @author Sebastien Bahloul <seb at lsc-project.org>
+ * @deprecated
+ * 		This class was used in LSC 1.1 projects, and is no longer
+ * 		necessary, but kept for reverse compatibility. It will be
+ * 		removed in LSC 1.3.
+ * 
  */
-public abstract class AbstractBean implements IBean {
+public abstract class AbstractBean extends LscBean {
 
 	/**
 	 * For eclipse
@@ -105,21 +108,13 @@
 	/** The list of local methods. */
 	private static Map<String, List<Method>> localMethods;
 
-	/** The attributes map. */
-	private Map<String, Attribute> attrs;
-
-	/** The distinguish name. */
-	private String distinguishName;
-
-	/** Data schema related to this bean - must always be set just after initiating the bean */
-	private DataSchemaProvider dataSchemaProvider;
-
 	/**
 	 * The default constructor.
 	 */
 	public AbstractBean() {
-		attrs = new HashMap<String, Attribute>();
 		localMethods = new HashMap<String, List<Method>>();
+
+		LOGGER.warn("Using deprecated class AbstractBean. Your setup will still work fine, but must be upgraded to use SimpleBean before upgrading to LSC 1.3.");
 	}
 
 	/**
@@ -262,17 +257,9 @@
 	 * @param values the values list
 	 */
 	protected static void mapList(IBean bean, String paramName, List<?> values) {
-		Attribute attr = new BasicAttribute(paramName);
-
 		if (values != null) {
-			Iterator<?> iter = values.iterator();
-
-			while (iter.hasNext()) {
-				attr.add(iter.next());
-			}
+			bean.setAttribute(paramName, new HashSet<Object>(values));
 		}
-
-		bean.setAttribute(attr);
 	}
 
 	/**
@@ -323,13 +310,11 @@
 	 *                the string value
 	 */
 	protected static void mapString(IBean bean, String paramName, String value) {
-		Attribute attr = new BasicAttribute(paramName);
-
 		if ((value != null) && (value.trim().length() > 0)) {
-			attr.add(value.trim());
+			Set<Object> set = new HashSet<Object>(1);
+			set.add(value);
+			bean.setAttribute(paramName, set);
 		}
-
-		bean.setAttribute(attr);
 	}
 
 	/**
@@ -405,166 +390,6 @@
 		return null;
 	}
 
-	/**
-	 * Get an attribute from its name.
-	 *
-	 * @param id the name
-	 * @return the LDAP attribute
-	 */
-	public final Attribute getAttributeById(final String id) {
-		// use lower case since attribute names are case-insensitive
-		return attrs.get(id.toLowerCase());
-	}
-
-	/**
-	 * Get the <b>first</b> value of an attribute from its name
-	 *
-	 * @param id The attribute name (case insensitive)
-	 * @return String The first value of the attribute, or the empty string ("")
-	 * @throws NamingException
-	 * @deprecated
-	 */
-	public final String getAttributeValueById(final String id)
-					throws NamingException {
-		return getAttributeFirstValueById(id);
-	}
-
-	/**
-	 * Get the <b>first</b> value of an attribute from its name
-	 * 
-	 * @param id
-	 *            The attribute name (case insensitive)
-	 * @return String The first value of the attribute, or the empty string ("")
-	 * @throws NamingException
-	 */
-	public final String getAttributeFirstValueById(final String id)
-					throws NamingException {
-		List<String> allValues = getAttributeValuesById(id);
-		return allValues.size() >= 1 ? allValues.get(0) : "";
-	}
-
-	/**
-	 * Get all values of an attribute from its name
-	 * 
-	 * @param id
-	 *            The attribute name (case insensitive)
-	 * @return List<String> List of attribute values, or an empty list
-	 * @throws NamingException
-	 */
-	public final List<String> getAttributeValuesById(final String id)
-					throws NamingException {
-		List<String> resultsArray = new ArrayList<String>();
-
-		Attribute attribute = getAttributeById(id);
-		for (int i = 0; attribute != null && i < attribute.size(); i++) {
-			Object value = attribute.get(i);
-			String stringValue;
-
-			// convert to String because this method only returns Strings
-			if (value instanceof byte[]) {
-				stringValue = new String((byte[]) value);
-			} else {
-				stringValue = value.toString();
-			}
-
-			resultsArray.add(stringValue);
-		}
-
-		return resultsArray;
-	}
-
-	/**
-	 * Get the attributes name list.
-	 *
-	 * @return the attributes list
-	 */
-	public final Set<String> getAttributesNames() {
-		return attrs.keySet();
-	}
-
-	/**
-	 * Set an attribute.
-	 * API CHANGE: Do nothing if attribute is empty
-	 *
-	 * @param attr
-	 *                the attribute to set
-	 */
-	public final void setAttribute(final Attribute attr) {
-		// use lower case since attribute names are case-insensitive
-		if (attr != null && attr.size() > 0) {
-			attrs.put(attr.getID().toLowerCase(), attr);
-		}
-	}
-
-	/**
-	 * Default distinguish name getter.
-	 *
-	 * @return the distinguishName
-	 */
-	public final String getDistinguishName() {
-		return distinguishName;
-	}
-
-	/**
-	 * Distinguish name getter that makes sure to return the FULL DN (including suffix).
-	 *
-	 * @return the distinguishName
-	 */
-	public final String getFullDistinguishedName() {
-		if (!distinguishName.endsWith("," + Configuration.DN_REAL_ROOT)) {
-			return distinguishName + "," + Configuration.DN_REAL_ROOT;
-		} else {
-			return distinguishName;
-		}
-	}
-
-	/**
-	 * Default distinguishName setter.
-	 *
-	 * @param dn
-	 *                the distinguishName to set
-	 */
-	public final void setDistinguishName(final String dn) {
-		distinguishName = dn;
-	}
-
-	public void generateDn() throws NamingException {
-	}
-
-	/**
-	 * Bean pretty printer.
-	 *
-	 * @return the pretty formatted string to display
-	 */
-	@Override
-	public final String toString() {
-		StringBuffer sb = new StringBuffer();
-		Iterator<String> keySetIter = attrs.keySet().iterator();
-		sb.append("dn: ").append(distinguishName).append('\n');
-
-		while (keySetIter.hasNext()) {
-			String key = keySetIter.next();
-
-			if (attrs.get(key) != null) {
-				sb.append("=> " + key);
-
-				Object values = attrs.get(key);
-
-				if (values instanceof List) {
-					Iterator<?> valuesIter = ((List<?>) values).iterator();
-
-					while (valuesIter.hasNext()) {
-						sb.append(" - ").append(valuesIter.next()).append("\n");
-					}
-				} else {
-					sb.append(" - ").append(values).append("\n");
-				}
-			}
-		}
-
-		return sb.toString();
-	}
-
 	public static final Map<String, List<Method>> getLocalMethods() {
 		return localMethods;
 	}
@@ -573,43 +398,4 @@
 		AbstractBean.localMethods = localMethods;
 	}
 
-	/**
-	 * Clone this AbstractBean object.
-	 * @return Object
-	 * @throws java.lang.CloneNotSupportedException
-	 */
-	@Override
-	public AbstractBean clone() throws CloneNotSupportedException {
-		try {
-			AbstractBean bean = (AbstractBean) this.getClass().newInstance();
-			bean.setDistinguishName(this.getDistinguishName());
-			Iterator<String> attributesIt = this.getAttributesNames().iterator();
-
-			while (attributesIt.hasNext()) {
-				String attributeName = attributesIt.next();
-				bean.setAttribute((Attribute) this.getAttributeById(attributeName).clone());
-			}
-			return bean;
-		} catch (InstantiationException ex) {
-			throw new CloneNotSupportedException(ex.getLocalizedMessage());
-		} catch (IllegalAccessException ex) {
-			throw new CloneNotSupportedException(ex.getLocalizedMessage());
-		}
-	}
-
-	public void setDataSchema(DataSchemaProvider dataSchema) {
-		this.dataSchemaProvider = dataSchema;
-	}
-
-	public DataSchemaProvider getDataSchema() {
-		return dataSchemaProvider;
-	}
-
-	/**
-	 * Manage something there !
-	 * @param metaData
-	 */
-	public static void setMetadata(ResultSetMetaData metaData) {
-		// TODO Auto-generated method stub
-	}
 }

Modified: lsc/trunk/src/main/java/org/lsc/beans/IBean.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/beans/IBean.java	2009-11-29 21:19:20 UTC (rev 492)
+++ lsc/trunk/src/main/java/org/lsc/beans/IBean.java	2009-11-29 21:26:02 UTC (rev 493)
@@ -46,72 +46,135 @@
 package org.lsc.beans;
 
 import java.io.Serializable;
+import java.util.List;
 import java.util.Set;
 
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 
 /**
- * General interface of a bean.
+ * General interface of a bean. A bean in LSC describes an entry in a
+ * source or destination. It has nothing to do with Java beans (in fact,
+ * LSC beans do not have any get- or set- methods).
  * 
- * This bean has been designed to allow attribute modifications
+ * <p>
+ * An entry is described in this bean in a similar way to an LDAP entry.
+ * Each bean has a distinguishedName which can be set and get. Each bean
+ * also has a set of attributes, each of which has a set of values.
+ * </p>
  * 
+ * <p>
+ * Most methods are convenience methods to get the values of each attribute.
+ * </p>
+ * 
  * @author Sebastien Bahloul &lt;seb at lsc-project.org&gt;
+ * @author Jonathan Clarke &lt;jonathan at phillipoux.net&gt;
  */
-public interface IBean extends Cloneable, Serializable {
+public interface IBean extends Cloneable, Serializable
+{
 
-    /**
-         * Get an attribute from its name.
-         * 
-         * @param id
-         *                the name
-         * @return the attribute
-         */
-    Attribute getAttributeById(String id);
+	/**
+	 * Get an attribute from its name.
+	 * 
+	 * @param id
+	 *            the name
+	 * @return the LDAP attribute
+	 */
+	Attribute getAttributeById(final String id);
 
-    /**
-         * Get the attributes name.
-         * 
-         * @return a set containing all the attributes name
-         */
-    Set<String> getAttributesNames();
+	/**
+	 * Get an attribute from its name as a Set.
+	 *
+	 * @param id the name
+	 * @return the LDAP attribute
+	 */
+	Set<Object> getAttributeAsSetById(final String id);
+	
+	/**
+	 * Get the <b>first</b> value of an attribute from its name
+	 * 
+	 * @param id
+	 *            The attribute name (case insensitive)
+	 * @return String The first value of the attribute, or the empty string ("")
+	 * @throws NamingException
+	 * @deprecated
+	 */
+	public String getAttributeValueById(final String id) throws NamingException;
 
-    /**
-         * Set a attribute.
-         * 
-         * @param attr
-         *                the attribute to set
-         */
-    void setAttribute(Attribute attr);
+	/**
+	 * Get the <b>first</b> value of an attribute from its name
+	 * 
+	 * @param id
+	 *            The attribute name (case insensitive)
+	 * @return String The first value of the attribute, or the empty string ("")
+	 * @throws NamingException
+	 */
+	public String getAttributeFirstValueById(final String id)
+			throws NamingException;
 
-    /**
-         * Get the distinguish name.
-         * 
-         * @return the distinguish name
-         */
-    String getDistinguishName();
+	/**
+	 * Get all values of an attribute from its name
+	 * 
+	 * @param id
+	 *            The attribute name (case insensitive)
+	 * @return List<String> List of attribute values, or an empty list
+	 * @throws NamingException
+	 */
+	public List<String> getAttributeValuesById(final String id)
+			throws NamingException;
 
-    /**
-         * Set the distinguish name.
-         * 
-         * @param dn
-         *                the distinguish name
-         */
-    void setDistinguishName(String dn);
+	/**
+	 * Get the attributes name.
+	 * 
+	 * @return a set containing all the attributes name
+	 */
+	Set<String> getAttributesNames();
 
-    /**
-         * Generate the distinguish name according to the information on the
-         * bean.
-         * 
-         * @throws NamingException
-         *                 thrown is a directory exception is encountered while
-         *                 generating the new distinguish name
-         */
-    void generateDn() throws NamingException;
+	/**
+	 * Set an attribute.
+	 * 
+	 * @param attr
+	 *            the attribute to set
+	 */
+	void setAttribute(Attribute attr);
 
 	/**
+	 * Set an attribute.
+	 *
+	 * @param attrName The attribute name.
+	 * @param attrValues A set of values for the attribute.
+	 */
+	void setAttribute(String attrName, Set<Object> attrValues);
+	
+	/**
+	 * Get the distinguish name.
+	 * 
+	 * @return the distinguish name
+	 */
+	String getDistinguishName();
+
+	/**
+	 * Set the distinguish name.
+	 * 
+	 * @param dn
+	 *            the distinguish name
+	 */
+	void setDistinguishName(String dn);
+
+	/**
+	 * Generate the distinguish name according to the information on the bean.
+	 * 
+	 * @throws NamingException
+	 *             thrown is a directory exception is encountered while
+	 *             generating the new distinguish name
+	 */
+	void generateDn() throws NamingException;
+
+	/**
 	 * Clone this object.
+	 * 
 	 * @return Object
+	 * @throws CloneNotSupportedException 
 	 */
 	IBean clone() throws CloneNotSupportedException;
 

Added: lsc/trunk/src/main/java/org/lsc/beans/LscBean.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/beans/LscBean.java	                        (rev 0)
+++ lsc/trunk/src/main/java/org/lsc/beans/LscBean.java	2009-11-29 21:26:02 UTC (rev 493)
@@ -0,0 +1,333 @@
+/*
+ ****************************************************************************
+ * Ldap Synchronization Connector provides tools to synchronize
+ * electronic identities from a list of data sources including
+ * any database with a JDBC connector, another LDAP directory,
+ * flat files...
+ *
+ *                  ==LICENSE NOTICE==
+ * 
+ * Copyright (c) 2008, LSC Project 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+
+ *    * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *     * Neither the name of the LSC Project nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *                  ==LICENSE NOTICE==
+ *
+ *               (c) 2008 - 2009 LSC Project
+ *         Sebastien Bahloul <seb at lsc-project.org>
+ *         Thomas Chemineau <thomas at lsc-project.org>
+ *         Jonathan Clarke <jon at lsc-project.org>
+ *         Remy-Christophe Schermesser <rcs at lsc-project.org>
+ ****************************************************************************
+ */
+package org.lsc.beans;
+
+import java.sql.ResultSetMetaData;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+
+import org.lsc.Configuration;
+import org.lsc.service.DataSchemaProvider;
+import org.lsc.utils.SetUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Basic bean used to centralize methods across all beans
+ *
+ * <P>
+ * This object mainly provides methods to store and access "attributes",
+ * i.e. named fields and their values.
+ * </P>
+ * 
+ * <P>
+ * 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.
+ * </P>
+ * 
+ * @author Sebastien Bahloul &lt;seb at lsc-project.org&gt;
+ * @author Jonathan Clarke &lt;jonathan at phillipoux.net&gt;
+ */
+public abstract class LscBean implements IBean {
+
+	private static final long serialVersionUID = 5074469517356449901L;
+
+	private static final Logger LOGGER = LoggerFactory.getLogger(LscBean.class);
+
+	/** The distinguished name. */
+	private String distinguishedName;
+
+	/** The attributes map. */
+	private Map<String, Set<Object>> attrs;
+	
+	/** Data schema related to this bean - must always be set just after initiating the bean */
+	private DataSchemaProvider dataSchemaProvider;
+
+	public LscBean() {
+		attrs = new HashMap<String, Set<Object>>();
+	}
+	
+	/**
+	 * Get an attribute from its name.
+	 *
+	 * @param id the name
+	 * @return the LDAP attribute
+	 */
+	public final Attribute getAttributeById(final String id) {
+		// use lower case since attribute names are case-insensitive
+		return SetUtils.setToAttribute(id, attrs.get(id.toLowerCase()));
+	}
+	
+	
+	/**
+	 * Get an attribute from its name as a Set.
+	 *
+	 * @param id the name
+	 * @return the LDAP attribute
+	 */
+	public final Set<Object> getAttributeAsSetById(final String id) {
+		// use lower case since attribute names are case-insensitive
+		return attrs.get(id.toLowerCase());
+	}
+
+
+	/**
+	 * Get the <b>first</b> value of an attribute from its name
+	 *
+	 * @param id The attribute name (case insensitive)
+	 * @return String The first value of the attribute, or the empty string ("")
+	 * @throws NamingException
+	 * @deprecated
+	 */
+	public final String getAttributeValueById(final String id)
+					throws NamingException {
+		return getAttributeFirstValueById(id);
+	}
+
+	
+	/**
+	 * Get the <b>first</b> value of an attribute from its name
+	 * 
+	 * @param id
+	 *            The attribute name (case insensitive)
+	 * @return String The first value of the attribute, or the empty string ("")
+	 * @throws NamingException
+	 */
+	public final String getAttributeFirstValueById(final String id)
+					throws NamingException {
+		List<String> allValues = getAttributeValuesById(id);
+		return allValues.size() >= 1 ? allValues.get(0) : "";
+	}
+
+	
+	/**
+	 * Get all values of an attribute from its name
+	 * 
+	 * @param id
+	 *            The attribute name (case insensitive)
+	 * @return List<String> List of attribute values, or an empty list
+	 * @throws NamingException
+	 */
+	public final List<String> getAttributeValuesById(final String id)
+					throws NamingException {
+		List<String> resultsArray = new ArrayList<String>();
+
+		Set<Object> attributeValues = attrs.get(id.toLowerCase());
+		
+		if (attributeValues != null) {
+			for (Object value : attributeValues) {
+				String stringValue;
+	
+				// convert to String because this method only returns Strings
+				if (value instanceof byte[]) {
+					stringValue = new String((byte[]) value);
+				} else {
+					stringValue = value.toString();
+				}
+	
+				resultsArray.add(stringValue);
+			}
+		}
+
+		return resultsArray;
+	}
+
+	
+	/**
+	 * Get the attributes name list.
+	 *
+	 * @return the attributes list
+	 */
+	public final Set<String> getAttributesNames() {
+		return attrs.keySet();
+	}
+
+	
+	/**
+	 * Set an attribute.
+	 * API CHANGE: Do nothing if attribute is empty
+	 *
+	 * @param attr
+	 *                the attribute to set
+	 */
+	public final void setAttribute(final Attribute attr) {
+		if (attr != null && attr.size() > 0) {
+			// convert the Attribute into a Set of values
+			try {
+				setAttribute(attr.getID(), SetUtils.attributeToSet(attr));
+			}
+			catch (NamingException e) {
+				LOGGER.error("Error storing the attribute {}: {}", new Object[]{attr.getID(), e.toString()});
+				LOGGER.debug(e.toString(), e);
+			}
+		}
+	}
+
+	
+	/**
+	 * Set an attribute.
+	 *
+	 * @param attrName The attribute name.
+	 * @param attrValues A set of values for the attribute.
+	 */
+	public final void setAttribute(String attrName, Set<Object> attrValues)
+	{
+		// use lower case since attribute names are case-insensitive
+		attrs.put(attrName.toLowerCase(), attrValues);
+	}
+
+	
+	/**
+	 * Default distinguish name getter.
+	 *
+	 * @return the distinguishName
+	 */
+	public final String getDistinguishName() {
+		return distinguishedName;
+	}
+
+	
+	/**
+	 * Distinguish name getter that makes sure to return the FULL DN (including suffix).
+	 *
+	 * @return the distinguishName
+	 */
+	public final String getFullDistinguishedName() {
+		if (!distinguishedName.endsWith("," + Configuration.DN_REAL_ROOT)) {
+			return distinguishedName + "," + Configuration.DN_REAL_ROOT;
+		} else {
+			return distinguishedName;
+		}
+	}
+	
+
+	/**
+	 * Default distinguishName setter.
+	 *
+	 * @param dn
+	 *                the distinguishName to set
+	 */
+	public final void setDistinguishName(final String dn) {
+		distinguishedName = dn;
+	}
+
+	
+	public void generateDn() throws NamingException {
+	}
+
+	
+	/**
+	 * Bean pretty printer.
+	 *
+	 * @return the pretty formatted string to display
+	 */
+	@Override
+	public final String toString() {
+		StringBuffer sb = new StringBuffer();
+		sb.append("dn: ").append(distinguishedName).append('\n');
+
+		for (String key: attrs.keySet()) {
+			Set<Object> values = attrs.get(key);
+			if (values != null) {
+				sb.append("=> " + key);
+				for (Object value : values) {
+					sb.append(" - ").append(value).append('\n');
+				}
+			}
+		}
+
+		return sb.toString();
+	}
+
+	
+	/**
+	 * Clone this Bean object.
+	 * @return Object
+	 * @throws java.lang.CloneNotSupportedException
+	 */
+	@Override
+	public LscBean clone() throws CloneNotSupportedException {
+		try {
+			LscBean bean = (LscBean) this.getClass().newInstance();
+			bean.setDistinguishName(this.getDistinguishName());
+			
+			for (String attributeName : this.getAttributesNames()) {
+				bean.setAttribute(attributeName, this.getAttributeAsSetById(attributeName));
+			}
+			return bean;
+		} catch (InstantiationException ex) {
+			throw new CloneNotSupportedException(ex.getLocalizedMessage());
+		} catch (IllegalAccessException ex) {
+			throw new CloneNotSupportedException(ex.getLocalizedMessage());
+		}
+	}
+
+	
+	public void setDataSchema(DataSchemaProvider dataSchema) {
+		this.dataSchemaProvider = dataSchema;
+	}
+
+	
+	public DataSchemaProvider getDataSchema() {
+		return dataSchemaProvider;
+	}
+	
+	
+	/**
+	 * Manage something there !
+	 * @param metaData
+	 */
+	public static void setMetadata(ResultSetMetaData metaData) {
+		// TODO Auto-generated method stub
+	}
+
+}

Modified: lsc/trunk/src/main/java/org/lsc/beans/SimpleBean.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/beans/SimpleBean.java	2009-11-29 21:19:20 UTC (rev 492)
+++ lsc/trunk/src/main/java/org/lsc/beans/SimpleBean.java	2009-11-29 21:26:02 UTC (rev 493)
@@ -45,13 +45,18 @@
  */
 package org.lsc.beans;
 
+
 /**
  * Empty simple bean
  *
- * May be override by any subclass if neede
+ * May be overridden by any subclass if needed. Currently,
+ * the only purpose of this class is to have a non-abstract
+ * implementation of LscBean.
 
  * @author Sebastien Bahloul &lt;seb at lsc-project.org&gt;
  */
-public class SimpleBean extends AbstractBean {
+public class SimpleBean extends LscBean {
 
+	private static final long serialVersionUID = -4500840611218768461L;
+	
 }



More information about the lsc-changes mailing list