001package org.dom4j.persistence;
002
003import org.dom4j.Document;
004import org.dom4j.Node;
005
006import org.dom4j.persistence.MarshallingStrategy;
007import org.dom4j.persistence.MarshallingContext;
008
009/*
010 * @author  <a href="mailto:toby-wan-kenobi@gmx.de">Tobias Rademacher</a>
011 * @version 1.0
012 */
013
014public class DocumentMemento implements Memento {
015
016  protected String systemId;
017  protected MarshallingStrategy marshaller;
018
019  public DocumentMemento(String aSystemId, MarshallingContext context) throws Exception {
020    this.systemId = aSystemId;
021    this.marshaller = DocumentMarshalling.getInstance(context);
022  }
023
024  public Node getState() {
025    return this.marshaller.unmarshal(this.systemId);
026  }
027
028  public void setState(Node node) throws Exception {
029    if (this.systemId != null || !this.systemId.equals(""))
030      this.marshaller.marshal(this.systemId, node);
031  }
032
033  public void setState(Document aState) {
034    this.setState(aState);
035  }
036
037  public MarshallingStrategy getMarshaller() {
038    return this.marshaller;
039  }
040
041  public String getSystemId() {
042    return this.systemId;
043  }
044
045
046}