View Javadoc

1   package org.dom4j.persistence;
2   
3   import org.dom4j.Document;
4   import org.dom4j.Node;
5   
6   /*
7    * @author  <a href="mailto:toby-wan-kenobi@gmx.de">Tobias Rademacher</a>
8    * @version 1.0
9    */
10  
11  public class DocumentMemento implements Memento {
12  
13    protected String systemId;
14    protected MarshallingStrategy marshaller;
15  
16    public DocumentMemento(String aSystemId, MarshallingContext context) throws Exception {
17      this.systemId = aSystemId;
18      this.marshaller = DocumentMarshalling.getInstance(context);
19    }
20  
21    public Node getState() {
22      return this.marshaller.unmarshal(this.systemId);
23    }
24  
25    public void setState(Node node) throws Exception {
26      if (this.systemId != null || !this.systemId.equals(""))
27        this.marshaller.marshal(this.systemId, node);
28    }
29  
30    public void setState(Document aState) {
31      this.setState(aState);
32    }
33  
34    public MarshallingStrategy getMarshaller() {
35      return this.marshaller;
36    }
37  
38    public String getSystemId() {
39      return this.systemId;
40    }
41  
42  
43  }