001    /*
002    // $Id: //open/util/resgen/src/org/eigenbase/xom/NodeDef.java#4 $
003    // Package org.eigenbase.xom is an XML Object Mapper.
004    // Copyright (C) 2005-2008 The Eigenbase Project
005    // Copyright (C) 2005-2008 Disruptive Tech
006    // Copyright (C) 2005-2008 LucidEra, Inc.
007    // Portions Copyright (C) 2001-2005 Kana Software, Inc. and others.
008    //
009    // This library is free software; you can redistribute it and/or modify it
010    // under the terms of the GNU Lesser General Public License as published by the
011    // Free Software Foundation; either version 2 of the License, or (at your
012    // option) any later version approved by The Eigenbase Project.
013    //
014    // This library is distributed in the hope that it will be useful,
015    // but WITHOUT ANY WARRANTY; without even the implied warranty of
016    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017    // GNU Lesser General Public License for more details.
018    //
019    // You should have received a copy of the GNU Lesser General Public License
020    // along with this library; if not, write to the Free Software
021    // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
022    //
023    // jhyde, 11 October, 2001
024    */
025    
026    package org.eigenbase.xom;
027    import java.io.PrintWriter;
028    
029    /**
030     * <code>NodeDef</code> represents a node in a parse tree. It is a base class
031     * for {@link ElementDef}, {@link TextDef}, etc.
032     *
033     * @author jhyde
034     * @since 11 October, 2001
035     * @version $Id: //open/util/resgen/src/org/eigenbase/xom/NodeDef.java#4 $
036     **/
037    public interface NodeDef {
038    
039        /**
040         * Returns the name of this node's tag.
041         **/
042        String getName();
043    
044        /**
045         * Returns the type of this element.
046         * Values are as for {@link DOMWrapper#getType}.
047         */
048        int getType();
049    
050        /**
051         * Returns the text inside this node.
052         **/
053        String getText();
054    
055        /**
056         * Returns the children of this node.
057         **/
058        NodeDef[] getChildren();
059    
060        /**
061         * Outputs this element definition in XML to any XMLOutput.
062         * @param out the XMLOutput class to display the XML
063         **/
064        void displayXML(XMLOutput out, int indent);
065    
066        /**
067         * Outputs this node to any PrintWriter,
068         * in a formatted fashion with automatic indenting.
069         * @param out the PrintWriter to which to write this NodeDef.
070         * @param indent the indentation level for the printout.
071         */
072        void display(PrintWriter out, int indent);
073    
074        /**
075         * Retrieves the {@link DOMWrapper} which was used to create this
076         * node. Only works if this nodes's {@link MetaDef.Element#keepDef} was
077         * true (or, if it is not set, if the default
078         * {@link MetaDef.Model#defaultKeepDef} is true);
079         * otherwise, returns <code>null</code>.
080         *
081         * @return wrapper underlying this node
082         */
083        DOMWrapper getWrapper();
084    
085        /**
086         * Returns the location of this element in its document.
087         *
088         * @return location of this element, or null if location is not available
089         */
090        Location getLocation();
091    }
092    
093    // End NodeDef.java