diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/api/metadata/ModelElement.java b/proposal/myrmidon/src/java/org/apache/myrmidon/api/metadata/ModelElement.java new file mode 100644 index 000000000..c4fd68a39 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/api/metadata/ModelElement.java @@ -0,0 +1,80 @@ +/* + * Copyright (C) The Apache Software Foundation. All rights reserved. + * + * This software is published under the terms of the Apache Software License + * version 1.1, a copy of which has been included with this distribution in + * the LICENSE.txt file. + */ +package org.apache.myrmidon.api.metadata; + +/** + * A ModelElement represents the data necessary to configure + * the task or sub-object. It usually represents an XML element in a + * build file and has similar features to XML elements. + * + *
It has a set of un-ordered attributes with each attribute mapping + * a key to a value. The ModelElement can also have either a set of ordered + * sub-elements or text content (one or the other - not both).
+ * + * @author Peter Donald + * @version $Revision$ $Date$ + */ +public class ModelElement +{ + /** + * Return an array containing all the childModelElement
s
+ * that are contained within this ModelElement
. If this method
+ * returns an array containing 1 or more elements then it must return null
+ * for getContent() method.
+ *
+ * @todo determine whether we return null or an empty array when no
+ * child elements.
+ * @return all the child ModelElement
s
+ * @see #getContent()
+ */
+ public ModelElement[] getChildren()
+ {
+ return null;
+ }
+
+ /**
+ * Return an array containing the names of all the attributes stored
+ * in this ModelElement
. The user can then pass these
+ * parameters into the getAttribute() method of this class to get the
+ * value of the attribute.
+ *
+ * @return an array of the attribute names
+ * @see #getAttribute(String)
+ */
+ public String[] getAttributeNames()
+ {
+ return null;
+ }
+
+ /**
+ * Get the value of the attribute passed in.
+ * If no such attribute exists return null.
+ *
+ * @param name the name of the attribute to retrieve value for
+ * @return the value of the attribute with specified name or null
+ * if no such element.
+ */
+ public String getAttribute( final String name )
+ {
+ return null;
+ }
+
+ /**
+ * Retrieve the content of this element if any. Will return
+ * null if no content available. Note it is invalid for this
+ * method to return a non-null value and the getChildren()
+ * method to return an array of 1 or more child elements.
+ *
+ * @return the content value if any, else null
+ * @see #getChildren()
+ */
+ public String getContent()
+ {
+ return null;
+ }
+}
diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/api/metadata/Modeller.java b/proposal/myrmidon/src/java/org/apache/myrmidon/api/metadata/Modeller.java
new file mode 100644
index 000000000..1f95fdc4b
--- /dev/null
+++ b/proposal/myrmidon/src/java/org/apache/myrmidon/api/metadata/Modeller.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ */
+package org.apache.myrmidon.api.metadata;
+
+/**
+ * The Modeller interface specifies that the implementing object
+ * wishes to handle its own configuration stage. In which case the
+ * object is passed the ModelElement representing itself and it uses
+ * the element to configure itself.
+ *
+ * @author Peter Donald
+ * @version $Revision$ $Date$
+ * @see ModelElement
+ */
+public interface Modeller
+{
+ /**
+ * Pass the object a read-only instance of it's own
+ * model.
+ *
+ * @param element the ModelElement representing object
+ */
+ void model( ModelElement element );
+}