views:

37

answers:

2

Hi,

I'm working with webservices. I have a java object defined for the request. I'd like to create a java object of this type from a String or a XmlObject. Which interface should I implement to use the method parse to do this?

Thanks and regards

A: 

You could create your own interface :)

public interface Parser<E>
{
  E parse(String sourceString);
}
willcodejavaforfood
+2  A: 

Won't you be better off using some kind of serialization/deserialization library such as XStream or something

Jeroen Rosenberg
+1, only I would suggest using a JAXB implementation such as MOXy (http://www.eclipse.org/eclipselink/moxy.php) or Metro (https://jaxb.dev.java.net/)
Blaise Doughan