Java Doc for LazyDynaBean.java in  » Library » Apache-commons-beanutils-1.8.0-BETA-src » org » apache » commons » beanutils » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache commons beanutils 1.8.0 BETA src » org.apache.commons.beanutils 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.beanutils.LazyDynaBean

All known Subclasses:   org.apache.commons.beanutils.LazyDynaMap,
LazyDynaBean
public class LazyDynaBean implements DynaBean,Serializable(Code)

DynaBean which automatically adds properties to the DynaClass and provides Lazy List and Lazy Map features.

DynaBeans deal with three types of properties - simple, indexed and mapped and have the following get() and set() methods for each of these types:

  • Simple property methods - get(name) and set(name, value)
  • Indexed property methods - get(name, index) and set(name, index, value)
  • Mapped property methods - get(name, key) and set(name, key, value)

Getting Property Values

Calling any of the get() methods, for a property which doesn't exist, returns null in this implementation.

Setting Simple Properties

The LazyDynaBean will automatically add a property to the DynaClass if it doesn't exist when the set(name, value) method is called.

DynaBean myBean = new LazyDynaBean();
myBean.set("myProperty", "myValue");

Setting Indexed Properties

If the property doesn't exist, the LazyDynaBean will automatically add a property with an ArrayList type to the DynaClass when the set(name, index, value) method is called. It will also instantiate a new ArrayList and automatically grow the List so that it is big enough to accomodate the index being set. ArrayList is the default indexed property that LazyDynaBean uses but this can be easily changed by overriding the defaultIndexedProperty(name) method.

DynaBean myBean = new LazyDynaBean();
myBean.set("myIndexedProperty", 0, "myValue1");
myBean.set("myIndexedProperty", 1, "myValue2");

If the indexed property does exist in the DynaClass but is set to null in the LazyDynaBean, then it will instantiate a new List or Array as specified by the property's type in the DynaClass and automatically grow the List or Array so that it is big enough to accomodate the index being set.

DynaBean myBean = new LazyDynaBean();
MutableDynaClass myClass = (MutableDynaClass)myBean.getDynaClass();
myClass.add("myIndexedProperty", int[].class);
myBean.set("myIndexedProperty", 0, new Integer(10));
myBean.set("myIndexedProperty", 1, new Integer(20));

Setting Mapped Properties

If the property doesn't exist, the LazyDynaBean will automatically add a property with a HashMap type to the DynaClass and instantiate a new HashMap in the DynaBean when the set(name, key, value) method is called. HashMap is the default mapped property that LazyDynaBean uses but this can be easily changed by overriding the defaultMappedProperty(name) method.

DynaBean myBean = new LazyDynaBean();
myBean.set("myMappedProperty", "myKey", "myValue");

If the mapped property does exist in the DynaClass but is set to null in the LazyDynaBean, then it will instantiate a new Map as specified by the property's type in the DynaClass.

DynaBean myBean = new LazyDynaBean();
MutableDynaClass myClass = (MutableDynaClass)myBean.getDynaClass();
myClass.add("myMappedProperty", TreeMap.class);
myBean.set("myMappedProperty", "myKey", "myValue");

Restricted DynaClass

MutableDynaClass have a facility to restrict the DynaClass so that its properties cannot be modified. If the MutableDynaClass is restricted then calling any of the set() methods for a property which doesn't exist will result in a IllegalArgumentException being thrown.


See Also:   LazyDynaClass
author:
   Niall Pemberton


Field Summary
final protected static  BigDecimalBigDecimal_ZERO
    
final protected static  BigIntegerBigInteger_ZERO
    
final protected static  ByteByte_ZERO
    
final protected static  CharacterCharacter_SPACE
    
final protected static  DoubleDouble_ZERO
    
final protected static  FloatFloat_ZERO
    
final protected static  IntegerInteger_ZERO
    
final protected static  LongLong_ZERO
    
final protected static  ShortShort_ZERO
    
protected  MutableDynaClassdynaClass
     The MutableDynaClass "base class" that this DynaBean is associated with.
protected  Mapvalues
     The MutableDynaClass "base class" that this DynaBean is associated with.

Constructor Summary
public  LazyDynaBean()
     Construct a new LazyDynaBean with a LazyDynaClass instance.
public  LazyDynaBean(String name)
     Construct a new LazyDynaBean with a LazyDynaClass instance.
public  LazyDynaBean(DynaClass dynaClass)
     Construct a new DynaBean associated with the specified DynaClass instance - if its not a MutableDynaClass then a new LazyDynaClass is created and the properties copied.

Method Summary
public  booleancontains(String name, String key)
    
protected  ObjectcreateDynaBeanProperty(String name, Class type)
     Create a new Instance of a 'DynaBean' Property.
protected  ObjectcreateIndexedProperty(String name, Class type)
    
protected  ObjectcreateMappedProperty(String name, Class type)
    
protected  ObjectcreateNumberProperty(String name, Class type)
     Create a new Instance of a java.lang.Number Property.
protected  ObjectcreateOtherProperty(String name, Class type)
    
protected  ObjectcreatePrimitiveProperty(String name, Class type)
     Create a new Instance of a 'Primitive' Property.
protected  ObjectcreateProperty(String name, Class type)
    
protected  ObjectdefaultIndexedProperty(String name)
    

Creates a new ArrayList for an 'indexed' property which doesn't exist.

This method shouls be overriden if an alternative List or Array implementation is required for 'indexed' properties.


Parameters:
  name - Name of the 'indexed property.
protected  MapdefaultMappedProperty(String name)
    

Creates a new HashMap for a 'mapped' property which doesn't exist.

This method can be overriden if an alternative Map implementation is required for 'mapped' properties.


Parameters:
  name - Name of the 'mapped property.
public  Objectget(String name)
    

Return the value of a simple property with the specified name.

N.B. Returns null if there is no property of the specified name.


Parameters:
  name - Name of the property whose value is to be retrieved.
public  Objectget(String name, int index)
    
public  Objectget(String name, String key)
    
public  DynaClassgetDynaClass()
     Return the DynaClass instance that describes the set of properties available for this DynaBean.
public  MapgetMap()
     Return a Map representation of this DynaBean.
protected  ObjectgrowIndexedProperty(String name, Object indexedProperty, int index)
     Grow the size of an indexed property
Parameters:
  name - The name of the property
Parameters:
  indexedProperty - The current property value
Parameters:
  index - The indexed value to grow the property to (i.e.
protected  booleanisAssignable(Class dest, Class source)
    
protected  booleanisDynaProperty(String name)
     Indicates if there is a property with the specified name.
protected  MapnewMap()
    
public  voidremove(String name, String key)
     Remove any existing value for the specified key on the specified mapped property.
public  voidset(String name, Object value)
     Set the value of a simple property with the specified name.
public  voidset(String name, int index, Object value)
     Set the value of an indexed property with the specified name.
public  voidset(String name, String key, Object value)
     Set the value of a mapped property with the specified name.
public  intsize(String name)
    

Field Detail
BigDecimal_ZERO
final protected static BigDecimal BigDecimal_ZERO(Code)
BigDecimal Zero



BigInteger_ZERO
final protected static BigInteger BigInteger_ZERO(Code)
BigInteger Zero



Byte_ZERO
final protected static Byte Byte_ZERO(Code)
Byte Zero



Character_SPACE
final protected static Character Character_SPACE(Code)
Character Space



Double_ZERO
final protected static Double Double_ZERO(Code)
Double Zero



Float_ZERO
final protected static Float Float_ZERO(Code)
Float Zero



Integer_ZERO
final protected static Integer Integer_ZERO(Code)
Integer Zero



Long_ZERO
final protected static Long Long_ZERO(Code)
Long Zero



Short_ZERO
final protected static Short Short_ZERO(Code)
Short Zero



dynaClass
protected MutableDynaClass dynaClass(Code)
The MutableDynaClass "base class" that this DynaBean is associated with.



values
protected Map values(Code)
The MutableDynaClass "base class" that this DynaBean is associated with.




Constructor Detail
LazyDynaBean
public LazyDynaBean()(Code)
Construct a new LazyDynaBean with a LazyDynaClass instance.



LazyDynaBean
public LazyDynaBean(String name)(Code)
Construct a new LazyDynaBean with a LazyDynaClass instance.
Parameters:
  name - Name of this DynaBean class



LazyDynaBean
public LazyDynaBean(DynaClass dynaClass)(Code)
Construct a new DynaBean associated with the specified DynaClass instance - if its not a MutableDynaClass then a new LazyDynaClass is created and the properties copied.
Parameters:
  dynaClass - The DynaClass we are associated with




Method Detail
contains
public boolean contains(String name, String key)(Code)
Does the specified mapped property contain a value for the specified key value?
Parameters:
  name - Name of the property to check
Parameters:
  key - Name of the key to check true if the mapped property contains a value forthe specified key, otherwise false
exception:
  IllegalArgumentException - if no property name is specified



createDynaBeanProperty
protected Object createDynaBeanProperty(String name, Class type)(Code)
Create a new Instance of a 'DynaBean' Property.
Parameters:
  name - The name of the property
Parameters:
  type - The class of the property The new value



createIndexedProperty
protected Object createIndexedProperty(String name, Class type)(Code)
Create a new Instance of an 'Indexed' Property
Parameters:
  name - The name of the property
Parameters:
  type - The class of the property The new value



createMappedProperty
protected Object createMappedProperty(String name, Class type)(Code)
Create a new Instance of a 'Mapped' Property
Parameters:
  name - The name of the property
Parameters:
  type - The class of the property The new value



createNumberProperty
protected Object createNumberProperty(String name, Class type)(Code)
Create a new Instance of a java.lang.Number Property.
Parameters:
  name - The name of the property
Parameters:
  type - The class of the property The new value



createOtherProperty
protected Object createOtherProperty(String name, Class type)(Code)
Create a new Instance of other Property types
Parameters:
  name - The name of the property
Parameters:
  type - The class of the property The new value



createPrimitiveProperty
protected Object createPrimitiveProperty(String name, Class type)(Code)
Create a new Instance of a 'Primitive' Property.
Parameters:
  name - The name of the property
Parameters:
  type - The class of the property The new value



createProperty
protected Object createProperty(String name, Class type)(Code)
Create a new Instance of a Property
Parameters:
  name - The name of the property
Parameters:
  type - The class of the property The new value



defaultIndexedProperty
protected Object defaultIndexedProperty(String name)(Code)

Creates a new ArrayList for an 'indexed' property which doesn't exist.

This method shouls be overriden if an alternative List or Array implementation is required for 'indexed' properties.


Parameters:
  name - Name of the 'indexed property. The default value for an indexed property (java.util.ArrayList)



defaultMappedProperty
protected Map defaultMappedProperty(String name)(Code)

Creates a new HashMap for a 'mapped' property which doesn't exist.

This method can be overriden if an alternative Map implementation is required for 'mapped' properties.


Parameters:
  name - Name of the 'mapped property. The default value for a mapped property (java.util.HashMap)



get
public Object get(String name)(Code)

Return the value of a simple property with the specified name.

N.B. Returns null if there is no property of the specified name.


Parameters:
  name - Name of the property whose value is to be retrieved. The property's value
exception:
  IllegalArgumentException - if no property name is specified



get
public Object get(String name, int index)(Code)

Return the value of an indexed property with the specified name.

N.B. Returns null if there is no 'indexed' property of the specified name.


Parameters:
  name - Name of the property whose value is to be retrieved
Parameters:
  index - Index of the value to be retrieved The indexed property's value
exception:
  IllegalArgumentException - if the specified propertyexists, but is not indexed
exception:
  IndexOutOfBoundsException - if the specified indexis outside the range of the underlying property



get
public Object get(String name, String key)(Code)

Return the value of a mapped property with the specified name.

N.B. Returns null if there is no 'mapped' property of the specified name.


Parameters:
  name - Name of the property whose value is to be retrieved
Parameters:
  key - Key of the value to be retrieved The mapped property's value
exception:
  IllegalArgumentException - if the specified propertyexists, but is not mapped



getDynaClass
public DynaClass getDynaClass()(Code)
Return the DynaClass instance that describes the set of properties available for this DynaBean. The associated DynaClass



getMap
public Map getMap()(Code)
Return a Map representation of this DynaBean.

This, for example, could be used in JSTL in the following way to access a DynaBean's fooProperty:
  • ${myDynaBean.map.fooProperty}
a Map representation of this DynaBean



growIndexedProperty
protected Object growIndexedProperty(String name, Object indexedProperty, int index)(Code)
Grow the size of an indexed property
Parameters:
  name - The name of the property
Parameters:
  indexedProperty - The current property value
Parameters:
  index - The indexed value to grow the property to (i.e. one less thanthe required size) The new property value (grown to the appropriate size)



isAssignable
protected boolean isAssignable(Class dest, Class source)(Code)
Is an object of the source class assignable to the destination class?
Parameters:
  dest - Destination class
Parameters:
  source - Source class true if the source class is assignable to thedestination class, otherwise false



isDynaProperty
protected boolean isDynaProperty(String name)(Code)
Indicates if there is a property with the specified name.
Parameters:
  name - The name of the property to check true if there is a property of thespecified name, otherwise false



newMap
protected Map newMap()(Code)

Creates a new instance of the Map.

a new Map instance



remove
public void remove(String name, String key)(Code)
Remove any existing value for the specified key on the specified mapped property.
Parameters:
  name - Name of the property for which a value is tobe removed
Parameters:
  key - Key of the value to be removed
exception:
  IllegalArgumentException - if there is no propertyof the specified name



set
public void set(String name, Object value)(Code)
Set the value of a simple property with the specified name.
Parameters:
  name - Name of the property whose value is to be set
Parameters:
  value - Value to which this property is to be set
exception:
  IllegalArgumentException - if this is not an existing propertyname for our DynaClass and the MutableDynaClass is restricted
exception:
  ConversionException - if the specified value cannot beconverted to the type required for this property
exception:
  NullPointerException - if an attempt is made to set aprimitive property to null



set
public void set(String name, int index, Object value)(Code)
Set the value of an indexed property with the specified name.
Parameters:
  name - Name of the property whose value is to be set
Parameters:
  index - Index of the property to be set
Parameters:
  value - Value to which this property is to be set
exception:
  ConversionException - if the specified value cannot beconverted to the type required for this property
exception:
  IllegalArgumentException - if there is no propertyof the specified name
exception:
  IllegalArgumentException - if the specified propertyexists, but is not indexed
exception:
  IndexOutOfBoundsException - if the specified indexis outside the range of the underlying property



set
public void set(String name, String key, Object value)(Code)
Set the value of a mapped property with the specified name.
Parameters:
  name - Name of the property whose value is to be set
Parameters:
  key - Key of the property to be set
Parameters:
  value - Value to which this property is to be set
exception:
  ConversionException - if the specified value cannot beconverted to the type required for this property
exception:
  IllegalArgumentException - if there is no propertyof the specified name
exception:
  IllegalArgumentException - if the specified propertyexists, but is not mapped



size
public int size(String name)(Code)

Return the size of an indexed or mapped property.


Parameters:
  name - Name of the property The indexed or mapped property size
exception:
  IllegalArgumentException - if no property name is specified



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.