Java Doc for BeanMap.java in  » Library » Apache-common-Collections » org » apache » commons » collections » 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 common Collections » org.apache.commons.collections 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.util.AbstractMap
      org.apache.commons.collections.BeanMap

BeanMap
public class BeanMap extends AbstractMap implements Cloneable(Code)
An implementation of Map for JavaBeans which uses introspection to get and put properties in the bean.

If an exception occurs during attempts to get or set a property then the property is considered non existent in the Map
since:
   Commons Collections 1.0
version:
   $Revision: 158697 $ $Date: 2005-03-22 23:47:45 +0000 (Tue, 22 Mar 2005) $
author:
   James Strachan
author:
   Stephen Colebourne
author:
   Dimiter Dimitrov


Inner Class :protected static class MyMapEntry extends AbstractMapEntry

Field Summary
final public static  Object[]NULL_ARGUMENTS
     An empty array.
public static  HashMapdefaultTransformers
     Maps primitive Class types to transformers.

Constructor Summary
public  BeanMap()
     Constructs a new empty BeanMap.
public  BeanMap(Object bean)
     Constructs a new BeanMap that operates on the specified bean.

Method Summary
public  voidclear()
     This method reinitializes the bean map to have default values for the bean's properties.
public  Objectclone()
     Clone this bean map using the following process:
  • If there is no underlying bean, return a cloned BeanMap without a bean.
  • Since there is an underlying bean, try to instantiate a new bean of the same type using Class.newInstance().
  • If the instantiation fails, throw a CloneNotSupportedException
  • Clone the bean map and set the newly instantiated bean as the underlying bean for the bean map.
  • Copy each property that is both readable and writable from the existing object to a cloned bean map.
public  booleancontainsKey(Object name)
     Returns true if the bean defines a property with the given name.

The given name must be a String; if not, this method returns false.

public  booleancontainsValue(Object value)
     Returns true if the bean defines a property whose current value is the given object.
protected  ObjectconvertType(Class newType, Object value)
     Converts the given value to the given type.
protected  Object[]createWriteMethodArguments(Method method, Object value)
     Creates an array of parameters to pass to the given mutator method.
public  IteratorentryIterator()
     Convenience method for getting an iterator over the entries.
public  SetentrySet()
     Gets a Set of MapEntry objects that are the mappings for this BeanMap.
protected  voidfirePropertyChange(Object key, Object oldValue, Object newValue)
     Called during a successful BeanMap.put(Object,Object) operation. Default implementation does nothing.
public  Objectget(Object name)
     Returns the value of the bean's property with the given name.

The given name must be a String and must not be null; otherwise, this method returns null. If the bean defines a property with the given name, the value of that property is returned.

public  ObjectgetBean()
     Returns the bean currently being operated on.
public  MethodgetReadMethod(String name)
     Returns the accessor for the property with the given name.
protected  MethodgetReadMethod(Object name)
     Returns the accessor for the property with the given name.
public  ClassgetType(String name)
     Returns the type of the property with the given name.
protected  TransformergetTypeTransformer(Class aType)
     Returns a transformer for the given primitive type.
public  MethodgetWriteMethod(String name)
     Returns the mutator for the property with the given name.
protected  MethodgetWriteMethod(Object name)
     Returns the mutator for the property with the given name.
public  IteratorkeyIterator()
     Convenience method for getting an iterator over the keys.
public  SetkeySet()
     Get the keys for this BeanMap.

Write-only properties are not included in the returned set of property names, although it is possible to set their value and to get their type. BeanMap keys.

protected  voidlogInfo(Exception ex)
     Logs the given exception to System.out.
protected  voidlogWarn(Exception ex)
     Logs the given exception to System.err.
public  Objectput(Object name, Object value)
     Sets the bean property with the given name to the given value.
public  voidputAllWriteable(BeanMap map)
     Puts all of the writable properties from the given BeanMap into this BeanMap.
protected  voidreinitialise()
     Reinitializes this bean.
public  voidsetBean(Object newBean)
     Sets the bean to be operated on by this map.
public  intsize()
     Returns the number of properties defined by the bean.
public  StringtoString()
    
public  IteratorvalueIterator()
     Convenience method for getting an iterator over the values.
public  Collectionvalues()
     Returns the values for the BeanMap. values for the BeanMap.

Field Detail
NULL_ARGUMENTS
final public static Object[] NULL_ARGUMENTS(Code)
An empty array. Used to invoke accessors via reflection.



defaultTransformers
public static HashMap defaultTransformers(Code)
Maps primitive Class types to transformers. The transformer transform strings into the appropriate primitive wrapper.




Constructor Detail
BeanMap
public BeanMap()(Code)
Constructs a new empty BeanMap.



BeanMap
public BeanMap(Object bean)(Code)
Constructs a new BeanMap that operates on the specified bean. If the given bean is null, then this map will be empty.
Parameters:
  bean - the bean for this map to operate on




Method Detail
clear
public void clear()(Code)
This method reinitializes the bean map to have default values for the bean's properties. This is accomplished by constructing a new instance of the bean which the map uses as its underlying data source. This behavior for clear() differs from the Map contract in that the mappings are not actually removed from the map (the mappings for a BeanMap are fixed).



clone
public Object clone() throws CloneNotSupportedException(Code)
Clone this bean map using the following process:
  • If there is no underlying bean, return a cloned BeanMap without a bean.
  • Since there is an underlying bean, try to instantiate a new bean of the same type using Class.newInstance().
  • If the instantiation fails, throw a CloneNotSupportedException
  • Clone the bean map and set the newly instantiated bean as the underlying bean for the bean map.
  • Copy each property that is both readable and writable from the existing object to a cloned bean map.
  • If anything fails along the way, throw a CloneNotSupportedException.



containsKey
public boolean containsKey(Object name)(Code)
Returns true if the bean defines a property with the given name.

The given name must be a String; if not, this method returns false. This method will also return false if the bean does not define a property with that name.

Write-only properties will not be matched as the test operates against property read methods.
Parameters:
  name - the name of the property to check false if the given name is null or is not a String;false if the bean does not define a property with that name; ortrue if the bean does define a property with that name




containsValue
public boolean containsValue(Object value)(Code)
Returns true if the bean defines a property whose current value is the given object.
Parameters:
  value - the value to check false true if the bean has at least one property whose current value is that object, false otherwise



convertType
protected Object convertType(Class newType, Object value) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException(Code)
Converts the given value to the given type. First, reflection is is used to find a public constructor declared by the given class that takes one argument, which must be the precise type of the given value. If such a constructor is found, a new object is created by passing the given value to that constructor, and the newly constructed object is returned.

If no such constructor exists, and the given type is a primitive type, then the given value is converted to a string using its Object.toString toString() method, and that string is parsed into the correct primitive type using, for instance, Integer.valueOf(String) to convert the string into an int.

If no special constructor exists and the given type is not a primitive type, this method returns the original value.
Parameters:
  newType - the type to convert the value to
Parameters:
  value - the value to convert the converted value
throws:
  NumberFormatException - if newType is a primitive type, and the string representation of the given value cannot be convertedto that type
throws:
  InstantiationException - if the constructor found with reflection raises it
throws:
  InvocationTargetException - if the constructor found withreflection raises it
throws:
  IllegalAccessException - never
throws:
  IllegalArgumentException - never




createWriteMethodArguments
protected Object[] createWriteMethodArguments(Method method, Object value) throws IllegalAccessException, ClassCastException(Code)
Creates an array of parameters to pass to the given mutator method. If the given object is not the right type to pass to the method directly, it will be converted using BeanMap.convertType(Class,Object) .
Parameters:
  method - the mutator method
Parameters:
  value - the value to pass to the mutator method an array containing one object that is either the given valueor a transformed value
throws:
  IllegalAccessException - if BeanMap.convertType(Class,Object)raises it
throws:
  IllegalArgumentException - if any other exception is raisedby BeanMap.convertType(Class,Object)



entryIterator
public Iterator entryIterator()(Code)
Convenience method for getting an iterator over the entries. an iterator over the entries



entrySet
public Set entrySet()(Code)
Gets a Set of MapEntry objects that are the mappings for this BeanMap.

Each MapEntry can be set but not removed. the unmodifiable set of mappings




firePropertyChange
protected void firePropertyChange(Object key, Object oldValue, Object newValue)(Code)
Called during a successful BeanMap.put(Object,Object) operation. Default implementation does nothing. Override to be notified of property changes in the bean caused by this map.
Parameters:
  key - the name of the property that changed
Parameters:
  oldValue - the old value for that property
Parameters:
  newValue - the new value for that property



get
public Object get(Object name)(Code)
Returns the value of the bean's property with the given name.

The given name must be a String and must not be null; otherwise, this method returns null. If the bean defines a property with the given name, the value of that property is returned. Otherwise, null is returned.

Write-only properties will not be matched as the test operates against property read methods.
Parameters:
  name - the name of the property whose value to return the value of the property with that name




getBean
public Object getBean()(Code)
Returns the bean currently being operated on. The return value may be null if this map is empty. the bean being operated on by this map



getReadMethod
public Method getReadMethod(String name)(Code)
Returns the accessor for the property with the given name.
Parameters:
  name - the name of the property the accessor method for the property, or null



getReadMethod
protected Method getReadMethod(Object name)(Code)
Returns the accessor for the property with the given name.
Parameters:
  name - the name of the property null if the name is null; null if the name is not a String; null if no such property exists; or the accessormethod for that property



getType
public Class getType(String name)(Code)
Returns the type of the property with the given name.
Parameters:
  name - the name of the property the type of the property, or null if no suchproperty exists



getTypeTransformer
protected Transformer getTypeTransformer(Class aType)(Code)
Returns a transformer for the given primitive type.
Parameters:
  aType - the primitive type whose transformer to return a transformer that will convert strings into that type,or null if the given type is not a primitive type



getWriteMethod
public Method getWriteMethod(String name)(Code)
Returns the mutator for the property with the given name.
Parameters:
  name - the name of the property the mutator method for the property, or null



getWriteMethod
protected Method getWriteMethod(Object name)(Code)
Returns the mutator for the property with the given name.
Parameters:
  name - the name of the null if the name is null; null if the name is not a String; null if no such property exists; null if the property is read-only; or the mutator method for that property



keyIterator
public Iterator keyIterator()(Code)
Convenience method for getting an iterator over the keys.

Write-only properties will not be returned in the iterator. an iterator over the keys




keySet
public Set keySet()(Code)
Get the keys for this BeanMap.

Write-only properties are not included in the returned set of property names, although it is possible to set their value and to get their type. BeanMap keys. The Set returned by this method is notmodifiable.




logInfo
protected void logInfo(Exception ex)(Code)
Logs the given exception to System.out. Used to display warnings while accessing/mutating the bean.
Parameters:
  ex - the exception to log



logWarn
protected void logWarn(Exception ex)(Code)
Logs the given exception to System.err. Used to display errors while accessing/mutating the bean.
Parameters:
  ex - the exception to log



put
public Object put(Object name, Object value) throws IllegalArgumentException, ClassCastException(Code)
Sets the bean property with the given name to the given value.
Parameters:
  name - the name of the property to set
Parameters:
  value - the value to set that property to the previous value of that property
throws:
  IllegalArgumentException - if the given name is null;if the given name is not a String; if the bean doesn'tdefine a property with that name; or if the bean property withthat name is read-only



putAllWriteable
public void putAllWriteable(BeanMap map)(Code)
Puts all of the writable properties from the given BeanMap into this BeanMap. Read-only and Write-only properties will be ignored.
Parameters:
  map - the BeanMap whose properties to put



reinitialise
protected void reinitialise()(Code)
Reinitializes this bean. Called during BeanMap.setBean(Object) . Does introspection to find properties.



setBean
public void setBean(Object newBean)(Code)
Sets the bean to be operated on by this map. The given value may be null, in which case this map will be empty.
Parameters:
  newBean - the new bean to operate on



size
public int size()(Code)
Returns the number of properties defined by the bean. the number of properties defined by the bean



toString
public String toString()(Code)



valueIterator
public Iterator valueIterator()(Code)
Convenience method for getting an iterator over the values. an iterator over the values



values
public Collection values()(Code)
Returns the values for the BeanMap. values for the BeanMap. The returned collection is notmodifiable.



Methods inherited from java.util.AbstractMap
public void clear()(Code)(Java Doc)
protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean containsKey(Object key)(Code)(Java Doc)
public boolean containsValue(Object value)(Code)(Java Doc)
abstract public Set<Entry<K, V>> entrySet()(Code)(Java Doc)
public boolean equals(Object o)(Code)(Java Doc)
public V get(Object key)(Code)(Java Doc)
public int hashCode()(Code)(Java Doc)
public boolean isEmpty()(Code)(Java Doc)
public Set<K> keySet()(Code)(Java Doc)
public V put(K key, V value)(Code)(Java Doc)
public void putAll(Map<? extends K, ? extends V> m)(Code)(Java Doc)
public V remove(Object key)(Code)(Java Doc)
public int size()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
public Collection<V> values()(Code)(Java Doc)

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.