001    // Copyright 2004, 2005 The Apache Software Foundation
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    //     http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    
015    package org.apache.hivemind;
016    
017    import java.util.List;
018    
019    
020    /**
021     * Simplified read-only thread safe DOM.
022     * Currently, no support for namespaces, but that may come.
023     *
024     * @author Howard Lewis Ship
025     */
026    public interface Element extends Locatable
027    {
028            /**
029             * Returns the name of the element, as in, the name of the tag for the element.
030             */
031            public String getElementName();
032            
033            /**
034             * Returns an unmodifiable list of {@link Attribute} for this element.
035             * May return an empty list, but won't return null.  The attributes
036             * are in no specific order.
037             */
038            public List getAttributes();
039            
040            /**
041             * Returns the value for an attribute, or null if the attribute is not specified.
042             */
043            
044            public String getAttributeValue(String attributeName);
045            
046            /**
047             * Returns true if this element contains no other elements.
048             */
049            public boolean isEmpty();
050            
051            /**
052             * Returns an unmodifiable list of {@link Element} directly contained
053             * by this element.  May return an empty list, but won't return null.
054             * The elements are returned in the order in which they were encountered
055             * in the XML.
056             */
057            public List getElements();
058            
059            /**
060             * Returns the content of the element.  This is a concatination of
061             * all the text directly enclosed by the element.  Ignorable whitespace
062             * is ignored.  The content is trimmed of leading and trailing whitespace.
063             */
064            
065            public String getContent();
066    }