From 6e94185c884573a74c64713cd53a94032477580d Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Thu, 21 Mar 2002 10:22:48 +0000 Subject: [PATCH] Add in proposals for replacement of the Avalon Configuration system git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271941 13f79535-47bb-0310-9956-ffa450edef68 --- .../myrmidon/api/metadata/ModelElement.java | 80 +++++++++++++++++++ .../myrmidon/api/metadata/Modeller.java | 29 +++++++ 2 files changed, 109 insertions(+) create mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/api/metadata/ModelElement.java create mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/api/metadata/Modeller.java 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 child ModelElements + * 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 ModelElements + * @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 ); +}