Powered by SmartDoc

References to Labels -- Complex

RefComplex.rlx
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "relaxCore.dtd">
<module>

  <interface>
    <export label="RefComplex"/>
  </interface>

  <elementRule role="RefComplex">
    <ref label="Target"/>
  </elementRule>

  <tag name="ref" role="RefComplex">
  </tag>

  <elementRule role="Target" type="int">
  </elementRule>

  <tag name="target" role="Target">
    <attribute name="id" type="ID"/>
  </tag>

</module>
RefComplex.java
import org.w3c.dom.*;

/**
 * <b>RefComplex</b> is generated by Relaxer based on RefComplex.rlx.
 * This class is derived from:
 * 
 * <!-- for programmer
 * <elementRule role="RefComplex">
 *   <ref label="Target"/>
 * </elementRule>
 * 
 * <tag name="ref" role="RefComplex"/>
 * -->
 * <!-- for javadoc -->
 * <pre> &lt;elementRule role="RefComplex"&gt;
 *   &lt;ref label="Target"/&gt;
 * &lt;/elementRule&gt;
 * &lt;tag name="ref" role="RefComplex"/&gt;
 * </pre>
 *
 * @version RefComplex.rlx (Tue Aug 01 23:55:01 JST 2000)
 * @author  Relaxer 0.10.1b (by ASAMI@Yokohama)
 */
public class RefComplex implements java.io.Serializable {
    private Target target;

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

    /**
     * Creates a <code>RefComplex</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 RefComplex(RStack stack) {
        setup(stack);
    }

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

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

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

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

    /**
     * Initializes the <code>RefComplex</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);
        setTarget(new Target(stack));
    }

    /**
     * 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("ref");
        int size;
        target.makeElement(element);
        parent.appendChild(element);
    }

    /**
     * Gets the Target property <b>target</b>.
     *
     * @return Target
     */
    public final Target getTarget() {
        return (target);
    }

    /**
     * Sets the Target property <b>target</b>.
     *
     * @param target
     */
    public final void setTarget(Target target) {
        this.target = target;
    }

    /**
     * Tests if a Element <code>element</code> is valid
     * for the <code>RefComplex</code>.
     *
     * @param element
     * @return boolean
     */
    public static boolean isMatch(Element element) {
        String tagName = element.getTagName();
        if (!"ref".equals(tagName)) {
            return (false);
        }
        RStack target = new RStack(element);
        Element child;
        if (!Target.isMatchHungry(target)) {
            return (false);
        }
        if (!target.isEmptyElement()) {
            return (false);
        }
        return (true);
    }

    /**
     * Tests if elements contained in a Stack <code>stack</code>
     * is valid for the <code>RefComplex</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>RefComplex</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);
        }
    }
}
Target.java
import org.w3c.dom.*;

/**
 * <b>Target</b> is generated by Relaxer based on RefComplex.rlx.
 * This class is derived from:
 * 
 * <!-- for programmer
 * <elementRule role="Target" type="int"/>
 * 
 * <tag name="target" role="Target">
 *   <attribute name="id" type="ID"/>
 * </tag>
 * -->
 * <!-- for javadoc -->
 * <pre> &lt;elementRule role="Target" type="int"/&gt;
 * &lt;tag name="target" role="Target"&gt;
 *   &lt;attribute name="id" type="ID"/&gt;
 * &lt;/tag&gt;
 * </pre>
 *
 * @version RefComplex.rlx (Tue Aug 01 23:55:01 JST 2000)
 * @author  Relaxer 0.10.1b (by ASAMI@Yokohama)
 */
public class Target implements java.io.Serializable {
    private int content;
    private String id;

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

    /**
     * Creates a <code>Target</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 Target(RStack stack) {
        setup(stack);
    }

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

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

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

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

    /**
     * Initializes the <code>Target</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);
        content = URelaxer.getElementPropertyAsInt(element);
        id = URelaxer.getAttributePropertyAsString(element, "id");
    }

    /**
     * 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("target");
        URelaxer.setElementPropertyByInt(element, content);
        int size;
        URelaxer.setAttributePropertyByString(element, "id", id);
        parent.appendChild(element);
    }

    /**
     * Gets the int property <b>content</b>.
     *
     * @return int
     */
    public final int getContent() {
        return (content);
    }

    /**
     * Sets the int property <b>content</b>.
     *
     * @param content
     */
    public final void setContent(int content) {
        this.content = content;
    }

    /**
     * Gets the String property <b>id</b>.
     *
     * @return String
     */
    public final String getId() {
        return (id);
    }

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

    /**
     * Tests if a Element <code>element</code> is valid
     * for the <code>Target</code>.
     *
     * @param element
     * @return boolean
     */
    public static boolean isMatch(Element element) {
        String tagName = element.getTagName();
        if (!"target".equals(tagName)) {
            return (false);
        }
        RStack target = new RStack(element);
        Element child;
        if (!target.isEmptyElement()) {
            return (false);
        }
        return (true);
    }

    /**
     * Tests if elements contained in a Stack <code>stack</code>
     * is valid for the <code>Target</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>Target</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);
        }
    }
}