org.xulux.dataprovider.bean
Class BeanDataProvider

java.lang.Object
  extended by org.xulux.dataprovider.bean.BeanDataProvider
All Implemented Interfaces:
org.xulux.api.dataprovider.IDataProvider

public final class BeanDataProvider
extends java.lang.Object
implements org.xulux.api.dataprovider.IDataProvider

The BeanDataProvider is the main entry point for the dataprovider. It is the datasource

Version:
$Id: BeanDataProvider.java,v 1.1 2005/12/18 12:58:23 mvdb Exp $
Author:
Martin van den Bemt

Constructor Summary
BeanDataProvider()
          Constructor for BeanDataProvider.
 
Method Summary
 void addConverter(java.lang.Class clazz)
           
 void addConverter(java.lang.String clazz)
          Convenience method.
 void addMapping(org.xulux.api.dataprovider.IMapping mapping)
           
 void clearMappings()
          Clears all the mappings currently available
 org.xulux.api.dataprovider.IMapping createMapping(java.lang.Object object)
           
 java.lang.Class getBaseClass()
          Returns the baseClass.
 java.util.List getCache()
           
 org.xulux.api.dataprovider.IConverter getConverter(java.lang.Class clazz)
           
 org.xulux.api.dataprovider.IConverter getConverter(java.lang.Object object)
           
 java.util.Map getConverters()
           
 org.xulux.api.dataprovider.IMapping getMapping(java.lang.Class clazz)
           
 BeanMapping getMapping(java.lang.Class clazz, boolean newMapping)
           
 BeanMapping getMapping(java.lang.Class clazz, java.lang.String preferredName)
          Tries to get a mapping based on the specified bean
 org.xulux.api.dataprovider.IMapping getMapping(java.lang.Object object)
          Convenience method.
 org.xulux.api.dataprovider.IMapping getMapping(java.lang.String name)
           
 java.util.Map getMappings()
          Returns a clone of the original mapping map, so alteration doesn't effect the registry..
 java.lang.String getPlainBeanName(java.lang.Class clazz)
           
 java.lang.String getPossibleMappingName(java.lang.Class clazz)
          Tries to find a possible name for the mapping
 java.lang.Object getValue(java.lang.Object mapping, java.lang.String field, java.lang.Object object)
           
 void initialize()
           
 void initialize(java.io.InputStream stream)
          Initializes the dictionary from a stream The stream will be closed.
 void initialize(java.lang.Object object)
           
 boolean isInCache(java.lang.Class clazz)
          Checks to see if this class is currently being discovered.
 boolean needsPartValue()
           
 void reset()
          Reset all dictionary settings..
 void setBaseClass(java.lang.Class baseClass)
          Sets the baseClass.
 void setProperty(java.lang.String name, java.lang.String value)
           
 java.lang.Object setValue(java.lang.Object mapping, java.lang.String field, java.lang.Object object, java.lang.Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanDataProvider

public BeanDataProvider()
Constructor for BeanDataProvider.

Method Detail

getMapping

public org.xulux.api.dataprovider.IMapping getMapping(java.lang.String name)
Parameters:
name - the name of the mapping
Returns:
the mapping

getMappings

public java.util.Map getMappings()
Returns a clone of the original mapping map, so alteration doesn't effect the registry..

Specified by:
getMappings in interface org.xulux.api.dataprovider.IDataProvider
Returns:
the mappings in a Map

addMapping

public void addMapping(org.xulux.api.dataprovider.IMapping mapping)
Specified by:
addMapping in interface org.xulux.api.dataprovider.IDataProvider
See Also:
org.xulux.dataprovider.IDataProvider#addMapping(org.xulux.dataprovider.IMapping)

getMapping

public org.xulux.api.dataprovider.IMapping getMapping(java.lang.Class clazz)
Parameters:
clazz - the class
Returns:
the mapping of the specified clazz

getMapping

public org.xulux.api.dataprovider.IMapping getMapping(java.lang.Object object)
Convenience method. This calls the getMapping(Class)

Specified by:
getMapping in interface org.xulux.api.dataprovider.IDataProvider
Parameters:
object - the object to get the mapping for
Returns:
the beanmapping that is connected to the class of the specified instance or null when the object is null.

getMapping

public BeanMapping getMapping(java.lang.Class clazz,
                              boolean newMapping)
Parameters:
clazz - the class to get the mapping for
newMapping - if true it creates the mapping and adds it to the dictionary, if the name is not yet known.
Returns:
the beanmapping or null when no mapping could be created

getMapping

public BeanMapping getMapping(java.lang.Class clazz,
                              java.lang.String preferredName)
Tries to get a mapping based on the specified bean

Parameters:
clazz - the class
preferredName - the name to use for the mapping if it needs to be created
Returns:
the beanmapping found

getPlainBeanName

public java.lang.String getPlainBeanName(java.lang.Class clazz)
Parameters:
clazz - the class
Returns:
the plaing bean name for the specified class

getPossibleMappingName

public java.lang.String getPossibleMappingName(java.lang.Class clazz)
Tries to find a possible name for the mapping

Parameters:
clazz - the class to investigate
Returns:
the possible mapping name

initialize

public void initialize(java.lang.Object object)
See Also:
org.xulux.dataprovider.IDictionary#initialize(java.lang.Object)

initialize

public void initialize(java.io.InputStream stream)
Initializes the dictionary from a stream The stream will be closed.

Parameters:
stream - - a stream with the dictionary.xml

getBaseClass

public java.lang.Class getBaseClass()
Returns the baseClass.

Returns:
Class

setBaseClass

public void setBaseClass(java.lang.Class baseClass)
Sets the baseClass.

Parameters:
baseClass - The baseClass to set

clearMappings

public void clearMappings()
Clears all the mappings currently available


reset

public void reset()
Reset all dictionary settings..


isInCache

public boolean isInCache(java.lang.Class clazz)
Checks to see if this class is currently being discovered. This is a nice way to prevent infinite loops.

Parameters:
clazz - the class to look for
Returns:
boolean if the class is already in the cache

getCache

public java.util.List getCache()
Returns:
a clone of the current cache.

addConverter

public void addConverter(java.lang.Class clazz)
Parameters:
clazz - - the class of the converter.

addConverter

public void addConverter(java.lang.String clazz)
Convenience method. see addConverter(Class) for more details.

Parameters:
clazz - the clazz to add the converter for

getConverter

public org.xulux.api.dataprovider.IConverter getConverter(java.lang.Object object)
Specified by:
getConverter in interface org.xulux.api.dataprovider.IDataProvider
Parameters:
object - the object to get the convert for
Returns:
the converter for the object specified or null when no converter is present

getConverters

public java.util.Map getConverters()
Returns:
all registered converters

getConverter

public org.xulux.api.dataprovider.IConverter getConverter(java.lang.Class clazz)
Parameters:
clazz - the class to get the convert for
Returns:
the coverter for the clazz specified or null when no converter is present

initialize

public void initialize()
Specified by:
initialize in interface org.xulux.api.dataprovider.IDataProvider
See Also:
IDataProvider.initialize()

setValue

public java.lang.Object setValue(java.lang.Object mapping,
                                 java.lang.String field,
                                 java.lang.Object object,
                                 java.lang.Object value)
Specified by:
setValue in interface org.xulux.api.dataprovider.IDataProvider
See Also:
IDataProvider.setValue(java.lang.Object, java.lang.String, java.lang.Object, java.lang.Object)

getValue

public java.lang.Object getValue(java.lang.Object mapping,
                                 java.lang.String field,
                                 java.lang.Object object)
Specified by:
getValue in interface org.xulux.api.dataprovider.IDataProvider
See Also:
IDataProvider.getValue(java.lang.Object, java.lang.String, java.lang.Object)

needsPartValue

public boolean needsPartValue()
Specified by:
needsPartValue in interface org.xulux.api.dataprovider.IDataProvider
See Also:
IDataProvider.needsPartValue()

setProperty

public void setProperty(java.lang.String name,
                        java.lang.String value)
Specified by:
setProperty in interface org.xulux.api.dataprovider.IDataProvider
See Also:
IDataProvider.setProperty(java.lang.String, java.lang.String)

createMapping

public org.xulux.api.dataprovider.IMapping createMapping(java.lang.Object object)
Specified by:
createMapping in interface org.xulux.api.dataprovider.IDataProvider
See Also:
IDataProvider.createMapping(java.lang.Object)


Copyright © 2006-2007 Martin van den Bemt. All Rights Reserved.