org.shapelogic.util
Class BeanUtilsParser
java.lang.Object
org.shapelogic.util.BeanUtilsParser
- All Implemented Interfaces:
- KeyValueParser
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
- Author:
- Sami Badawi
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 |
_seperators
protected java.lang.String _seperators
BeanUtilsParser
public BeanUtilsParser()
split
public java.util.Map<java.lang.String,java.lang.String> split(java.lang.String arg)
- Split the arg into a map.
setProperty
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
- Throws:
java.lang.Exception
parse
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
- Parameters:
bean
- a JavaBean to set the parsed arguements inarg
- String argument to parse
- Returns:
- true if parsing was successful.
Copyright © 2008. All Rights Reserved.