org.ejen
Class EjenSaveNode

java.lang.Object
  |
  +--org.ejen.EjenChildNode
        |
        +--org.ejen.EjenSaveNode
All Implemented Interfaces:
EjenConstants

public class EjenSaveNode
extends EjenChildNode

Save node class.

A Save node saves the current in memory DOM tree to file.

Usage (ant build file)

  <?xml version="1.0" encoding="UTF-8"?>

  <project name="generate" default="build">

    <taskdef name="ejen" classname="org.ejen.EjenTask"/>

    <target name="build">
      <ejen ...>
        ...
        <save file="saved.xml"
             [encoding="iso-8859-1"]
             [indent="(yes|no)"]
             [amount="2"]
        />
        ...
      </ejen>
    </target>

  </project>
 

Windows users: an understandable (but stupid) problem with Windows platforms comes with carriage return conversion on saving. If the DOM tree to be saved contains a Node with the "\r\n" (0D0A) String (alone or not), the saved file will contain the "\r\r\n" (0D0D0A) String instead.

Parent nodes:

Version:
1.0
Author:
F. Wolff

Field Summary
protected  String _amount
           
protected  String _encoding
           
protected  String _file
           
protected  String _indent
           
 
Fields inherited from class org.ejen.EjenChildNode
_messageIndent
 
Fields inherited from interface org.ejen.EjenConstants
CTX_DOM_SOURCE, CTX_STYLESHEET_HANDLER, CTX_STYLESHEET_ROOT, CTX_TRANSFORMER_FACTORY_IMPL, CTX_TRANSFORMER_IMPL, DEFAULT_XML_DATA, DEFAULT_XML_DATA_ENCODING, DEFAULT_XSL_DATA, LOG_INDENT_STR1, LOG_INDENT_STR2, MSG_DEBUG, MSG_ERR, MSG_INFO, MSG_VERBOSE, MSG_WARN, STATE_AFTER_PROCESS, STATE_BEFORE_PROCESS, STATE_CHECK, STATE_IDLE, STATE_PROCESS, STATES
 
Constructor Summary
EjenSaveNode()
           
 
Method Summary
 void check()
          Checks this EjenSaveNode for mandatory attributes.
 Properties getAttributes()
          Returns all non null attributes of this EjenSaveNode.
 String nodeName()
          Returns the name of this EjenSaveNode (always "save").
 void process()
          Executes this EjenSaveNode.
 void setAmount(String amount)
          [optional/AVT] - sets the (indent) amount attribute.
 void setEncoding(String encoding)
          [optional/AVT] - sets the encoding attribute.
 void setFile(String file)
          [mandatory/AVT] - sets the file attribute.
 void setIndent(String indent)
          [optional/AVT] - sets the indent attribute.
 
Methods inherited from class org.ejen.EjenChildNode
afterProcess, beforeProcess, cloneContext, evaluateAVT, evaluateAVT, getChildren, getFromContext, getFromContext, getFromGlobalContext, getListener, getState, idle, popContext, pushContext, putInContext, putInGlobalContext, sendMessageEvent, sendMessageEvent, sendStateEvent, sendXSLMessageEvent, sendXSLMessageEvent, setListener, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_file

protected String _file

_encoding

protected String _encoding

_indent

protected String _indent

_amount

protected String _amount
Constructor Detail

EjenSaveNode

public EjenSaveNode()
Method Detail

nodeName

public String nodeName()
Returns the name of this EjenSaveNode (always "save").

Specified by:
nodeName in class EjenChildNode
Returns:
the name of this EjenSaveNode.

getAttributes

public Properties getAttributes()
Returns all non null attributes of this EjenSaveNode.

Overrides:
getAttributes in class EjenChildNode
Returns:
non null attributes of this EjenSaveNode.

setFile

public void setFile(String file)
[mandatory/AVT] - sets the file attribute.

Parameters:
file - name of the XML file to created.

setEncoding

public void setEncoding(String encoding)
[optional/AVT] - sets the encoding attribute.

Parameters:
encoding - encoding String (default is "iso-8859-1").

setIndent

public void setIndent(String indent)
[optional/AVT] - sets the indent attribute.

Parameters:
indent - "yes" or "no" (default is "yes").

setAmount

public void setAmount(String amount)
[optional/AVT] - sets the (indent) amount attribute.


check

public void check()
Checks this EjenSaveNode for mandatory attributes.

Overrides:
check in class EjenChildNode
Throws:
EjenException - if file attribute is not set.

process

public void process()
Executes this EjenSaveNode.

Overrides:
process in class EjenChildNode
Throws:
EjenException - if something goes wrong...