Powered by SmartDoc

付録:生成されたコード

RDataList.java
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;

/**
 * <b>RDataList</b> is generated by Relaxer based on data.rlx.
 * This class is derived from:
 * 
 * <!-- for programmer
 * <elementRule label="dataList">
 *   <tag/>
 *   <ref label="dataItem" occurs="*"/>
 * </elementRule>
 * -->
 * <!-- for javadoc -->
 * <pre> &lt;elementRule label="dataList"&gt;
 *   &lt;tag/&gt;
 *   &lt;ref label="dataItem" occurs="*"/&gt;
 * &lt;/elementRule&gt;
 * </pre>
 *
 * @version data.rlx 1.0 (Sat Oct 20 03:14:03 JST 2001)
 * @author  Relaxer 0.14.2 (http://www.relaxer.org)
 */
public class RDataList implements java.io.Serializable {
    // List<RDataItem>
    private java.util.List dataItem_ = new java.util.ArrayList();

    /**
     * Creates a <code>RDataList</code>.
     *
     */
    public RDataList() {
    }

    /**
     * Creates a <code>RDataList</code> by the Stack <code>stack</code>
     * that contains Elements.
     * This constructor is supposed to be used internally
     * by the Relaxer system.
     *
     * @param stack
     */
    public RDataList(RStack stack) {
        setup(stack);
    }

    /**
     * Creates a <code>RDataList</code> by the Document <code>doc</code>.
     *
     * @param doc
     */
    public RDataList(Document doc) {
        setup(doc.getDocumentElement());
    }

    /**
     * Creates a <code>RDataList</code> by the Element <code>element</code>.
     *
     * @param element
     */
    public RDataList(Element element) {
        setup(element);
    }

    /**
     * Creates a <code>RDataList</code> by the File <code>file</code>.
     *
     * @param file
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public RDataList(File file) throws IOException, SAXException, ParserConfigurationException {
        setup(file);
    }

    /**
     * Creates a <code>RDataList</code>
     * by the String representation of URI <code>uri</code>.
     *
     * @param uri
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public RDataList(String uri) throws IOException, SAXException, ParserConfigurationException {
        setup(uri);
    }

    /**
     * Creates a <code>RDataList</code> by the URL <code>url</code>.
     *
     * @param url
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public RDataList(URL url) throws IOException, SAXException, ParserConfigurationException {
        setup(url);
    }

    /**
     * Creates a <code>RDataList</code> by the InputStream <code>in</code>.
     *
     * @param in
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public RDataList(InputStream in) throws IOException, SAXException, ParserConfigurationException {
        setup(in);
    }

    /**
     * Creates a <code>RDataList</code> by the InputSource <code>is</code>.
     *
     * @param is
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public RDataList(InputSource is) throws IOException, SAXException, ParserConfigurationException {
        setup(is);
    }

    /**
     * Creates a <code>RDataList</code> by the Reader <code>reader</code>.
     *
     * @param reader
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public RDataList(Reader reader) throws IOException, SAXException, ParserConfigurationException {
        setup(reader);
    }

    /**
     * Initializes the <code>RDataList</code> by the Document <code>doc</code>.
     *
     * @param doc
     */
    public void setup(Document doc) {
        setup(doc.getDocumentElement());
    }

    /**
     * Initializes the <code>RDataList</code> by the Element <code>element</code>.
     *
     * @param element
     */
    public void setup(Element element) {
        init(element);
    }

    /**
     * Initializes the <code>RDataList</code> by the Stack <code>stack</code>
     * that contains Elements.
     * This constructor is supposed to be used internally
     * by the Relaxer system.
     *
     * @param stack
     */
    public void setup(RStack stack) {
        setup(stack.popElement());
    }

    /**
     * @param element
     */
    private void init(Element element) {
        RStack stack = new RStack(element);
        dataItem_.clear();
        while (!stack.isEmptyElement()) {
            if (RDataItem.isMatch(stack)) {
                addDataItem(new RDataItem(stack));
            } else {
                break;
            }
        }
    }

    /**
     * Creates a DOM representation of the object.
     * Result is appended to the Node <code>parent</code>.
     *
     * @param parent
     */
    public void makeElement(Node parent) {
        Document doc;
        if (parent instanceof Document) {
            doc = (Document)parent;
        } else {
            doc = parent.getOwnerDocument();
        }
        Element element = doc.createElement("dataList");
        int size;
        size = this.dataItem_.size();
        for (int i = 0;i < size;i++) {
            RDataItem value = (RDataItem)this.dataItem_.get(i);
            value.makeElement(element);
        }
        parent.appendChild(element);
    }

    /**
     * Initializes the <code>RDataList</code> by the File <code>file</code>.
     *
     * @param file
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public void setup(File file) throws IOException, SAXException, ParserConfigurationException {
        setup(file.toURL());
    }

    /**
     * Initializes the <code>RDataList</code>
     * by the String representation of URI <code>uri</code>.
     *
     * @param uri
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public void setup(String uri) throws IOException, SAXException, ParserConfigurationException {
        setup(UJAXP.getDocument(uri, UJAXP.FLAG_VALIDATION));
    }

    /**
     * Initializes the <code>RDataList</code> by the URL <code>url</code>.
     *
     * @param url
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public void setup(URL url) throws IOException, SAXException, ParserConfigurationException {
        setup(UJAXP.getDocument(url, UJAXP.FLAG_VALIDATION));
    }

    /**
     * Initializes the <code>RDataList</code> by the InputStream <code>in</code>.
     *
     * @param in
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public void setup(InputStream in) throws IOException, SAXException, ParserConfigurationException {
        setup(UJAXP.getDocument(in, UJAXP.FLAG_VALIDATION));
    }

    /**
     * Initializes the <code>RDataList</code> by the InputSource <code>is</code>.
     *
     * @param is
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public void setup(InputSource is) throws IOException, SAXException, ParserConfigurationException {
        setup(UJAXP.getDocument(is, UJAXP.FLAG_VALIDATION));
    }

    /**
     * Initializes the <code>RDataList</code> by the Reader <code>reader</code>.
     *
     * @param reader
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public void setup(Reader reader) throws IOException, SAXException, ParserConfigurationException {
        setup(UJAXP.getDocument(reader, UJAXP.FLAG_VALIDATION));
    }

    /**
     * Creates a DOM document representation of the object.
     *
     * @exception ParserConfigurationException
     * @return Document
     */
    public Document makeDocument() throws ParserConfigurationException {
        Document doc = UJAXP.makeDocument();
        makeElement(doc);
        return (doc);
    }

    /**
     * Gets the RDataItem property <b>dataItem</b>.
     *
     * @return RDataItem[]
     */
    public final RDataItem[] getDataItem() {
        RDataItem[] array = new RDataItem[dataItem_.size()];
        return ((RDataItem[])dataItem_.toArray(array));
    }

    /**
     * Sets the RDataItem property <b>dataItem</b>.
     *
     * @param dataItem
     */
    public final void setDataItem(RDataItem[] dataItem) {
        this.dataItem_.clear();
        this.dataItem_.addAll(java.util.Arrays.asList(dataItem));
    }

    /**
     * Sets the RDataItem property <b>dataItem</b>.
     *
     * @param dataItem
     */
    public final void setDataItem(RDataItem dataItem) {
        this.dataItem_.clear();
        this.dataItem_.add(dataItem);
    }

    /**
     * Adds the RDataItem property <b>dataItem</b>.
     *
     * @param dataItem
     */
    public final void addDataItem(RDataItem dataItem) {
        this.dataItem_.add(dataItem);
    }

    /**
     * Gets number of the RDataItem property <b>dataItem</b>.
     *
     * @return int
     */
    public final int getDataItemCount() {
        return (dataItem_.size());
    }

    /**
     * Gets the RDataItem property <b>dataItem</b> by index.
     *
     * @param index
     * @return RDataItem
     */
    public final RDataItem getDataItem(int index) {
        return ((RDataItem)dataItem_.get(index));
    }

    /**
     * Sets the RDataItem property <b>dataItem</b> by index.
     *
     * @param index
     * @param dataItem
     */
    public final void setDataItem(int index, RDataItem dataItem) {
        this.dataItem_.set(index, dataItem);
    }

    /**
     * Makes a XML text representation.
     *
     * @return String
     */
    public String makeTextDocument() {
        StringBuffer buffer = new StringBuffer();
        makeTextElement(buffer);
        return (new String(buffer));
    }

    /**
     * Makes a XML text representation.
     *
     * @param buffer
     */
    public void makeTextElement(StringBuffer buffer) {
        int size;
        buffer.append("<dataList");
        buffer.append(">");
        size = this.dataItem_.size();
        for (int i = 0;i < size;i++) {
            RDataItem value = (RDataItem)this.dataItem_.get(i);
            value.makeTextElement(buffer);
        }
        buffer.append("</dataList>");
    }

    /**
     * Makes a XML text representation.
     *
     * @param buffer
     */
    public void makeTextElement(PrintWriter buffer) {
        int size;
        buffer.print("<dataList");
        buffer.print(">");
        size = this.dataItem_.size();
        for (int i = 0;i < size;i++) {
            RDataItem value = (RDataItem)this.dataItem_.get(i);
            value.makeTextElement(buffer);
        }
        buffer.print("</dataList>");
    }

    /**
     * Tests if a Element <code>element</code> is valid
     * for the <code>RDataList</code>.
     *
     * @param element
     * @return boolean
     */
    public static boolean isMatch(Element element) {
        if (!URelaxer.isTargetElement(element, "dataList")) {
            return (false);
        }
        RStack target = new RStack(element);
        Element child;
        while (!target.isEmptyElement()) {
            if (!RDataItem.isMatchHungry(target)) {
                break;
            }
        }
        if (!target.isEmptyElement()) {
            return (false);
        }
        return (true);
    }

    /**
     * Tests if elements contained in a Stack <code>stack</code>
     * is valid for the <code>RDataList</code>.
     * This mehtod is supposed to be used internally
     * by the Relaxer system.
     *
     * @param stack
     * @return boolean
     */
    public static boolean isMatch(RStack stack) {
        Element element = stack.peekElement();
        if (element == null) {
            return (false);
        }
        return (isMatch(element));
    }

    /**
     * Tests if elements contained in a Stack <code>stack</code>
     * is valid for the <code>RDataList</code>.
     * This method consumes the stack contents during matching operation.
     * This mehtod is supposed to be used internally
     * by the Relaxer system.
     *
     * @param stack
     * @return boolean
     */
    public static boolean isMatchHungry(RStack stack) {
        Element element = stack.peekElement();
        if (element == null) {
            return (false);
        }
        if (isMatch(element)) {
            stack.popElement();
            return (true);
        } else {
            return (false);
        }
    }
}
RDataItem.java
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;

/**
 * <b>RDataItem</b> is generated by Relaxer based on data.rlx.
 * This class is derived from:
 * 
 * <!-- for programmer
 * <elementRule label="dataItem">
 *   <tag/>
 *   <sequence>
 *     <element name="name" type="string"/>
 *     <element name="cost" type="integer"/>
 *     <element name="note" type="string"/>
 *   </sequence>
 * </elementRule>
 * -->
 * <!-- for javadoc -->
 * <pre> &lt;elementRule label="dataItem"&gt;
 *   &lt;tag/&gt;
 *   &lt;sequence&gt;
 *     &lt;element name="name" type="string"/&gt;
 *     &lt;element name="cost" type="integer"/&gt;
 *     &lt;element name="note" type="string"/&gt;
 *   &lt;/sequence&gt;
 * &lt;/elementRule&gt;
 * </pre>
 *
 * @version data.rlx 1.0 (Sat Oct 20 03:14:04 JST 2001)
 * @author  Relaxer 0.14.2 (http://www.relaxer.org)
 */
public class RDataItem implements java.io.Serializable {
    private String name_;
    private java.math.BigInteger cost_;
    private String note_;

    /**
     * Creates a <code>RDataItem</code>.
     *
     */
    public RDataItem() {
    }

    /**
     * Creates a <code>RDataItem</code> by the Stack <code>stack</code>
     * that contains Elements.
     * This constructor is supposed to be used internally
     * by the Relaxer system.
     *
     * @param stack
     */
    public RDataItem(RStack stack) {
        setup(stack);
    }

    /**
     * Creates a <code>RDataItem</code> by the Document <code>doc</code>.
     *
     * @param doc
     */
    public RDataItem(Document doc) {
        setup(doc.getDocumentElement());
    }

    /**
     * Creates a <code>RDataItem</code> by the Element <code>element</code>.
     *
     * @param element
     */
    public RDataItem(Element element) {
        setup(element);
    }

    /**
     * Creates a <code>RDataItem</code> by the File <code>file</code>.
     *
     * @param file
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public RDataItem(File file) throws IOException, SAXException, ParserConfigurationException {
        setup(file);
    }

    /**
     * Creates a <code>RDataItem</code>
     * by the String representation of URI <code>uri</code>.
     *
     * @param uri
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public RDataItem(String uri) throws IOException, SAXException, ParserConfigurationException {
        setup(uri);
    }

    /**
     * Creates a <code>RDataItem</code> by the URL <code>url</code>.
     *
     * @param url
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public RDataItem(URL url) throws IOException, SAXException, ParserConfigurationException {
        setup(url);
    }

    /**
     * Creates a <code>RDataItem</code> by the InputStream <code>in</code>.
     *
     * @param in
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public RDataItem(InputStream in) throws IOException, SAXException, ParserConfigurationException {
        setup(in);
    }

    /**
     * Creates a <code>RDataItem</code> by the InputSource <code>is</code>.
     *
     * @param is
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public RDataItem(InputSource is) throws IOException, SAXException, ParserConfigurationException {
        setup(is);
    }

    /**
     * Creates a <code>RDataItem</code> by the Reader <code>reader</code>.
     *
     * @param reader
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public RDataItem(Reader reader) throws IOException, SAXException, ParserConfigurationException {
        setup(reader);
    }

    /**
     * Initializes the <code>RDataItem</code> by the Document <code>doc</code>.
     *
     * @param doc
     */
    public void setup(Document doc) {
        setup(doc.getDocumentElement());
    }

    /**
     * Initializes the <code>RDataItem</code> by the Element <code>element</code>.
     *
     * @param element
     */
    public void setup(Element element) {
        init(element);
    }

    /**
     * Initializes the <code>RDataItem</code> by the Stack <code>stack</code>
     * that contains Elements.
     * This constructor is supposed to be used internally
     * by the Relaxer system.
     *
     * @param stack
     */
    public void setup(RStack stack) {
        setup(stack.popElement());
    }

    /**
     * @param element
     */
    private void init(Element element) {
        RStack stack = new RStack(element);
        name_ = URelaxer.getElementPropertyAsString(stack.popElement());
        cost_ = URelaxer.getElementPropertyAsBigInteger(stack.popElement());
        note_ = URelaxer.getElementPropertyAsString(stack.popElement());
    }

    /**
     * Creates a DOM representation of the object.
     * Result is appended to the Node <code>parent</code>.
     *
     * @param parent
     */
    public void makeElement(Node parent) {
        Document doc;
        if (parent instanceof Document) {
            doc = (Document)parent;
        } else {
            doc = parent.getOwnerDocument();
        }
        Element element = doc.createElement("dataItem");
        int size;
        URelaxer.setElementPropertyByString(element, "name", this.name_);
        URelaxer.setElementPropertyByBigInteger(element, "cost", this.cost_);
        URelaxer.setElementPropertyByString(element, "note", this.note_);
        parent.appendChild(element);
    }

    /**
     * Initializes the <code>RDataItem</code> by the File <code>file</code>.
     *
     * @param file
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public void setup(File file) throws IOException, SAXException, ParserConfigurationException {
        setup(file.toURL());
    }

    /**
     * Initializes the <code>RDataItem</code>
     * by the String representation of URI <code>uri</code>.
     *
     * @param uri
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public void setup(String uri) throws IOException, SAXException, ParserConfigurationException {
        setup(UJAXP.getDocument(uri, UJAXP.FLAG_VALIDATION));
    }

    /**
     * Initializes the <code>RDataItem</code> by the URL <code>url</code>.
     *
     * @param url
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public void setup(URL url) throws IOException, SAXException, ParserConfigurationException {
        setup(UJAXP.getDocument(url, UJAXP.FLAG_VALIDATION));
    }

    /**
     * Initializes the <code>RDataItem</code> by the InputStream <code>in</code>.
     *
     * @param in
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public void setup(InputStream in) throws IOException, SAXException, ParserConfigurationException {
        setup(UJAXP.getDocument(in, UJAXP.FLAG_VALIDATION));
    }

    /**
     * Initializes the <code>RDataItem</code> by the InputSource <code>is</code>.
     *
     * @param is
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public void setup(InputSource is) throws IOException, SAXException, ParserConfigurationException {
        setup(UJAXP.getDocument(is, UJAXP.FLAG_VALIDATION));
    }

    /**
     * Initializes the <code>RDataItem</code> by the Reader <code>reader</code>.
     *
     * @param reader
     * @exception IOException
     * @exception SAXException
     * @exception ParserConfigurationException
     */
    public void setup(Reader reader) throws IOException, SAXException, ParserConfigurationException {
        setup(UJAXP.getDocument(reader, UJAXP.FLAG_VALIDATION));
    }

    /**
     * Creates a DOM document representation of the object.
     *
     * @exception ParserConfigurationException
     * @return Document
     */
    public Document makeDocument() throws ParserConfigurationException {
        Document doc = UJAXP.makeDocument();
        makeElement(doc);
        return (doc);
    }

    /**
     * Gets the String property <b>name</b>.
     *
     * @return String
     */
    public final String getName() {
        return (name_);
    }

    /**
     * Sets the String property <b>name</b>.
     *
     * @param name
     */
    public final void setName(String name) {
        this.name_ = name;
    }

    /**
     * Gets the java.math.BigInteger property <b>cost</b>.
     *
     * @return java.math.BigInteger
     */
    public final java.math.BigInteger getCost() {
        return (cost_);
    }

    /**
     * Sets the java.math.BigInteger property <b>cost</b>.
     *
     * @param cost
     */
    public final void setCost(java.math.BigInteger cost) {
        this.cost_ = cost;
    }

    /**
     * Gets the String property <b>note</b>.
     *
     * @return String
     */
    public final String getNote() {
        return (note_);
    }

    /**
     * Sets the String property <b>note</b>.
     *
     * @param note
     */
    public final void setNote(String note) {
        this.note_ = note;
    }

    /**
     * Makes a XML text representation.
     *
     * @return String
     */
    public String makeTextDocument() {
        StringBuffer buffer = new StringBuffer();
        makeTextElement(buffer);
        return (new String(buffer));
    }

    /**
     * Makes a XML text representation.
     *
     * @param buffer
     */
    public void makeTextElement(StringBuffer buffer) {
        int size;
        buffer.append("<dataItem");
        buffer.append(">");
        buffer.append("<name>");
        buffer.append(URelaxer.escapeCharData(getName()));
        buffer.append("</name>");
        buffer.append("<cost>");
        buffer.append(getCost().toString());
        buffer.append("</cost>");
        buffer.append("<note>");
        buffer.append(URelaxer.escapeCharData(getNote()));
        buffer.append("</note>");
        buffer.append("</dataItem>");
    }

    /**
     * Makes a XML text representation.
     *
     * @param buffer
     */
    public void makeTextElement(PrintWriter buffer) {
        int size;
        buffer.print("<dataItem");
        buffer.print(">");
        buffer.print("<name>");
        buffer.print(URelaxer.escapeCharData(getName()));
        buffer.print("</name>");
        buffer.print("<cost>");
        buffer.print(getCost().toString());
        buffer.print("</cost>");
        buffer.print("<note>");
        buffer.print(URelaxer.escapeCharData(getNote()));
        buffer.print("</note>");
        buffer.print("</dataItem>");
    }

    /**
     * Tests if a Element <code>element</code> is valid
     * for the <code>RDataItem</code>.
     *
     * @param element
     * @return boolean
     */
    public static boolean isMatch(Element element) {
        if (!URelaxer.isTargetElement(element, "dataItem")) {
            return (false);
        }
        RStack target = new RStack(element);
        Element child;
        child = target.popElement();
        if (child == null) {
            return (false);
        }
        if (!URelaxer.isTargetElement(child, "name")) {
            return (false);
        }
        child = target.popElement();
        if (child == null) {
            return (false);
        }
        if (!URelaxer.isTargetElement(child, "cost")) {
            return (false);
        }
        child = target.popElement();
        if (child == null) {
            return (false);
        }
        if (!URelaxer.isTargetElement(child, "note")) {
            return (false);
        }
        if (!target.isEmptyElement()) {
            return (false);
        }
        return (true);
    }

    /**
     * Tests if elements contained in a Stack <code>stack</code>
     * is valid for the <code>RDataItem</code>.
     * This mehtod is supposed to be used internally
     * by the Relaxer system.
     *
     * @param stack
     * @return boolean
     */
    public static boolean isMatch(RStack stack) {
        Element element = stack.peekElement();
        if (element == null) {
            return (false);
        }
        return (isMatch(element));
    }

    /**
     * Tests if elements contained in a Stack <code>stack</code>
     * is valid for the <code>RDataItem</code>.
     * This method consumes the stack contents during matching operation.
     * This mehtod is supposed to be used internally
     * by the Relaxer system.
     *
     * @param stack
     * @return boolean
     */
    public static boolean isMatchHungry(RStack stack) {
        Element element = stack.peekElement();
        if (element == null) {
            return (false);
        }
        if (isMatch(element)) {
            stack.popElement();
            return (true);
        } else {
            return (false);
        }
    }
}