View Javadoc

1   /*
2    * @(#)$Id: JdomTextDescriptor.java 689 2009-07-22 00:10:27Z bsigner $
3    *
4    * Author       :   Ueli Kurmann, igesture@uelikurmann.ch
5    *
6    * Purpose      :   XML support for the TextDescriptor class.
7    *
8    * -----------------------------------------------------------------------
9    *
10   * Revision Information:
11   *
12   * Date             Who         Reason
13   *
14   * Dec 26, 2006     ukurmann    Initial Release
15   * Mar 22, 2007     bsigner     Cleanup
16   *
17   * -----------------------------------------------------------------------
18   *
19   * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
20   *
21   * This software is the proprietary information of ETH Zurich.
22   * Use is subject to license terms.
23   * 
24   */
25  
26  
27  package org.ximtec.igesture.core.jdom;
28  
29  import org.jdom.Element;
30  import org.sigtec.jdom.element.JdomStringElement;
31  import org.ximtec.igesture.core.TextDescriptor;
32  
33  
34  /**
35   * XML support for the TextDescriptor class.
36   * 
37   * @version 1.0, Dec 2006
38   * @author Ueli Kurmann, igesture@uelikurmann.ch
39   * @author Beat Signer, signer@inf.ethz.ch
40   */
41  public class JdomTextDescriptor extends Element {
42  
43     public static final String ROOT_TAG = "textDescriptor";
44  
45     public static final String UUID_ATTRIBUTE = "id";
46  
47     public static final String TEXT = "text";
48  
49  
50     public JdomTextDescriptor(TextDescriptor descriptor) {
51        super(ROOT_TAG);
52        setAttribute(UUID_ATTRIBUTE, descriptor.getId());
53        addContent(new JdomStringElement(TEXT, descriptor.getText()));
54     }
55  
56  
57     public static Object unmarshal(Element descriptor) {
58        final String uuid = descriptor.getAttributeValue(UUID_ATTRIBUTE);
59        final TextDescriptor textDescriptor = new TextDescriptor();
60        textDescriptor.setId(uuid);
61        textDescriptor.setText(descriptor.getChild(TEXT).getText());
62        return textDescriptor;
63     } // unmarshal
64  
65  }