Commons Collections僥楼永芝?膨?
扮寂:2011-07-20 鴬人坩 Phinecos
BeanMap宸倖Map窃喘噐委匯倖javaBean廬算葎Map,壓凪嶄贋刈阻javaBean議光倖奉來議setXXX圭隈才getXXX圭隈?奉來議窃侏。
public class BeanMap extends AbstractMap implements Cloneable
{
private transient Object bean;//javaBean斤?
private transient HashMap readMethods = new HashMap();//getXXX圭隈鹿
private transient HashMap writeMethods = new HashMap();//setXXX圭隈鹿
private transient HashMap types = new HashMap();//撹埀延楚窃侏鹿
public static final Object[] NULL_ARGUMENTS = {};//**歌方鹿?喘噐宥狛reflection距喘getXXX圭隈
public static HashMap defaultTransformers = new HashMap();//委児云窃侏啌符葎transformer窃侏?朔宀喘噐繍忖憲堪廬算葎栽 癖議児云侏議**廾窃
//潮範transformer
static
{
defaultTransformers.put( Boolean.TYPE, new Transformer()
{
public Object transform( Object input )
{
return Boolean.valueOf( input.toString() );
}
}
);
defaultTransformers.put( Character.TYPE, new Transformer()
{
public Object transform( Object input )
{
return new Character( input.toString().charAt( 0 ) );
}
}
);
defaultTransformers.put( Byte.TYPE, new Transformer()
{
public Object transform( Object input )
{
return Byte.valueOf( input.toString() );
}
}
);
defaultTransformers.put( Short.TYPE, new Transformer()
{
public Object transform( Object input )
{
return Short.valueOf( input.toString() );
}
}
);
defaultTransformers.put(
Integer.TYPE,
new Transformer() {
public Object transform( Object input ) {
return Integer.valueOf( input.toString() );
}
}
);
defaultTransformers.put( Long.TYPE, new Transformer()
{
public Object transform( Object input ) {
return Long.valueOf( input.toString() );
}
}
);
defaultTransformers.put( Float.TYPE, new Transformer()
{
public Object transform( Object input ) {
return Float.valueOf( input.toString() );
}
}
);
defaultTransformers.put( Double.TYPE, new Transformer()
{
public Object transform( Object input ) {
return Double.valueOf( input.toString() );
}
}
);
}
public BeanMap(Object bean) {
this.bean = bean;
initialise();
}
public Object clone() throws CloneNotS
|