001    // Copyright 2005-2006 Ferdinand Prantl <prantl@users.sourceforge.net>
002    // Copyright 2001-2004 The Apache Software Foundation
003    // All rights reserved.
004    //
005    // Licensed under the Apache License, Version 2.0 (the "License");
006    // you may not use this file except in compliance with the License.
007    // You may obtain a copy of the License at
008    //
009    // http://www.apache.org/licenses/LICENSE-2.0
010    //
011    // Unless required by applicable law or agreed to in writing, software
012    // distributed under the License is distributed on an "AS IS" BASIS,
013    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014    // See the License for the specific language governing permissions and
015    // limitations under the License.
016    //
017    // See http://ant-eclipse.sourceforge.net for the most recent version
018    // and more information.
019    
020    package prantl.ant.eclipse;
021    
022    import org.apache.tools.ant.BuildException;
023    
024    /**
025     * Base for the entries under the element classpath, specifically the elements
026     * <tt>classpathentry</tt>.
027     * 
028     * @since Ant-Eclipse 1.0
029     * @author Ferdinand Prantl &lt;prantl@users.sourceforge.net&gt;
030     */
031    public abstract class ClassPathEntryElement {
032    
033        private String path = null;
034    
035        /**
036         * Creates a new instance of the classpathentry element.
037         * 
038         * @since Ant-Eclipse 1.0
039         */
040        ClassPathEntryElement() {
041        }
042    
043        /**
044         * Returns a kind-of-element specific path value or <tt>null</tt> if it has not been
045         * set, which should be considered an error. However, descendant classes may set a
046         * default for this attribute.
047         * 
048         * @return A kind-of-element specific path value or <tt>null</tt> if not having been
049         *         set (descendant classes may return a default in this case).
050         */
051        public String getPath() {
052            return path;
053        }
054    
055        /**
056         * Sets the path of the classpathentry element.
057         * 
058         * @param value
059         *        A kind-of-element specific path value.
060         * @since Ant-Eclipse 1.0
061         */
062        public void setPath(String value) {
063            path = value;
064        }
065    
066        /**
067         * Performs the validation of the element at the time when the whole build file was
068         * parsed checking the content of the element and possibly adding mandatory attributes
069         * with default settings.
070         * 
071         * @since Ant-Eclipse 1.0
072         */
073        public void validate() {
074            if (path == null)
075                throw new BuildException(
076                        "The mandatory attribute \"path\" was missing in an element under \"classpath\".");
077        }
078    
079    }