Package com.thoughtworks.xstream.io.xml

Examples of com.thoughtworks.xstream.io.xml.Dom4JDriver


  public static  String asXML(DesignTemplateStore ts){
    return new XStream().toXML(ts);
  }
 
  public static DesignTemplateStore fromXML(String xml){
    XStream xstream = new XStream(new Dom4JDriver());
    return (DesignTemplateStore)xstream.fromXML(xml);
  }
View Full Code Here


   * @throws IOException
   * @throws ConfigurationException
   */
  public static void main(String[] args) throws IOException {

    XStream xStream = new XStream(new Dom4JDriver());
    xStream.alias("TestObj", TestObj.class);
    Map<String, TestObj> list = new HashMap<String, TestObj>();
    {
      TestObj testObj = new TestObj();
      testObj.setName("aa");
View Full Code Here

   */
  @Transactional
  public void saveOption(List<Option> optionList) throws Exception {
    log.info("saveOption:" + optionList);
    try {
      XStream xStream = new XStream(new Dom4JDriver());
      xStream.alias("Option", Option.class);

      Map<String, Option> optionMap = new HashMap<String, Option>();
      // 循环数组.
      for (Option option : optionList) {
View Full Code Here

    try {
      List<Option> tempList = new ArrayList<Option>();
      // 读取xml文件.
      File confFile = new File(FreemakerTemplateEngine.WEBAPP_PATH
          + OPTION_CONF_FILE);
      XStream xStream = new XStream(new Dom4JDriver());
      xStream.alias("Option", Option.class);
      Map<String, Option> optionMap = new HashMap<String, Option>();
      // 如果文件存在.
      if (confFile.exists()) {
        optionMap = (Map<String, Option>) xStream.fromXML(confFile);
View Full Code Here

* @see Dom4JDriver
*/
public class XStreamDom4J extends XStreamDriver {

    public XStreamDom4J() {
        super(new Dom4JDriver() {

            public HierarchicalStreamWriter createWriter(Writer out) {
                return new PrettyPrintWriter(out);
            }
           
View Full Code Here

                "</person>";

        xstream.registerConverter(new ElementConverter());
        xstream.alias("person", Person.class);

        Dom4JDriver driver = new Dom4JDriver();
        Person person = (Person) xstream.unmarshal(driver.createReader(new StringReader(xml)));

        assertEquals("jason", person.firstName);
        assertEquals("van Zyl", person.lastName);
        assertNotNull(person.element);
        assertEquals("bar", person.element.element("foo").getText());
View Full Code Here

        return new DriverEndToEndTestSuite();
    }

    public DriverEndToEndTestSuite() {
        super(DriverEndToEndTestSuite.class.getName());
        addDriverTest(new Dom4JDriver());
        addDriverTest(new DomDriver());
        addDriverTest(new JDomDriver());
        addDriverTest(new StaxDriver());
        addDriverTest(new XppDomDriver());
        addDriverTest(new XppDriver());
View Full Code Here

        private String data;
    }

    public EncodingTestSuite() {
        super(EncodingTestSuite.class.getName());
        addDriverTest(new Dom4JDriver());
        addDriverTest(new DomDriver());
        addDriverTest(new JDomDriver());
        addDriverTest(new StaxDriver());
        addDriverTest(new XppDomDriver());
        addDriverTest(new XppDriver());
View Full Code Here

    protected static Object readItemValue(Item item) throws WGIllegalDataException, WGSystemException {
        switch (item.getType()) {
       
            case ITEMTYPE_SERIALIZED_XSTREAM:
                try {
                    XStream xstream = new XStream(new Dom4JDriver());
                    return xstream.fromXML(item.getText());
                }
                catch (Exception e) {
                    throw new WGIllegalDataException("Error deserializing itemvalue of type 'ITEMTYPE_SERIALIZED_XSTREAM'.", e);
                }
View Full Code Here

            item.setType(ITEMTYPE_BOOLEAN);
        }
        else {
            // serialize with xstream
            try {
                XStream xstream = new XStream(new Dom4JDriver());
                String serializedValue = xstream.toXML(value);
                item.setText(serializedValue);
                item.setType(ITEMTYPE_SERIALIZED_XSTREAM);
            } catch (Exception e) {
                throw new WGIllegalArgumentException("Unable to serialize item value." , e);
View Full Code Here

TOP

Related Classes of com.thoughtworks.xstream.io.xml.Dom4JDriver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.