Class BeanUtilsParser

  extended by org.shapelogic.util.BeanUtilsParser
All Implemented Interfaces:

public class BeanUtilsParser
extends java.lang.Object
implements KeyValueParser

IPaser that is using the BeanUtils for setting JavaBeans.
The current solution is not elegant. I would have thougth that there should be a simpler way to parse a property file style string and set it in a JavaBean.
The reason that I am not using Antlr is that I do not what to create dependency on it, since it is using so many other libraries. Not sure if this should be in util package when it it using Commons BeanUtils.
Maybe if the jar file is missing it will just fail.
Otherwise there would need to be special packages for dependencies of other libraries.
XXX: This will not work with the format of the arg from ImageJ.
Current implementation assumes this format of arg: key1=value1 key2=value2

Sami Badawi

Field Summary
protected  java.lang.String _seperators
Constructor Summary
Method Summary
 boolean parse(java.lang.Object bean, java.lang.String arg)
          Parse arguments and set in JavaBean.
 void setProperty(java.lang.Object bean, java.lang.String key, java.lang.Object value)
 java.util.Map<java.lang.String,java.lang.String> split(java.lang.String arg)
          Split the arg into a map.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


protected java.lang.String _seperators
Constructor Detail


public BeanUtilsParser()
Method Detail


public java.util.Map<java.lang.String,java.lang.String> split(java.lang.String arg)
Split the arg into a map.


public void setProperty(java.lang.Object bean,
                        java.lang.String key,
                        java.lang.Object value)
                 throws java.lang.Exception
Specified by:
setProperty in interface KeyValueParser


public boolean parse(java.lang.Object bean,
                     java.lang.String arg)
Description copied from interface: KeyValueParser
Parse arguments and set in JavaBean.

Specified by:
parse in interface KeyValueParser
bean - a JavaBean to set the parsed arguements in
arg - String argument to parse
true if parsing was successful.

Copyright © 2009. All Rights Reserved.