com.hfg.xml.XMLContainer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com_hfg Show documentation
Show all versions of com_hfg Show documentation
com.hfg xml, html, svg, and bioinformatics utility library
package com.hfg.xml;
import com.hfg.util.Recursion;
import java.util.Collection;
import java.util.List;
//------------------------------------------------------------------------------
/**
Interface for an unusual XML object that may have content or subtags but not a name or attributes
(for example an IE conditional comment in HTML). Such objects are not true XML tags but
this can be a useful abstraction for constructing HTML.
@author J. Alex Taylor, hairyfatguy.com
*/
//------------------------------------------------------------------------------
// com.hfg XML/HTML Coding Library
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
// [email protected]
//------------------------------------------------------------------------------
public interface XMLContainer extends XMLizable
{
//---------------------------------------------------------------------------
public boolean hasContent();
//---------------------------------------------------------------------------
public XMLContainer setContent(CharSequence inContent);
//---------------------------------------------------------------------------
/**
Clears content (not subtags).
*/
public void clearContent();
//---------------------------------------------------------------------------
public XMLContainer addContent(CharSequence inContent);
//---------------------------------------------------------------------------
public XMLContainer addContentWithoutEscaping(CharSequence inContent);
//---------------------------------------------------------------------------
/**
The returned content does not contain any embedded subtags.
@return the XML tag's content stripped of any subtags
*/
public String getContent();
//----------------------------------------------------------------------------
/**
Expands character entities before retuning the content of this XMLTag.
The returned content does not contain any embedded subtags.
@return the XML tag's unescaped content stripped of any subtags
*/
public String getUnescapedContent();
//---------------------------------------------------------------------------
public void addSubtag(XMLizable inSubtag);
//---------------------------------------------------------------------------
/**
@param inSubtags Collection that should only contain XMLNode objects.
*/
public void addSubtags(Collection extends XMLizable> inSubtags);
//---------------------------------------------------------------------------
/**
Sets the subtags of this object to those specified.
@param inSubtags the list of subtags to be added to this XML tag
*/
public void setSubtags(List inSubtags);
//---------------------------------------------------------------------------
/**
Returns a List of all subtags on this object.
@return the list of subtags (inclusive of XML comments)
*/
public List getSubtags();
//---------------------------------------------------------------------------
/**
Returns a List of all subtags on this object that implement XMLNode.
Useful as a way to avoid XML comments, etc.
@return the list of subtags (exclusive of XML comments)
*/
public List getXMLNodeSubtags();
//---------------------------------------------------------------------------
/**
Removes all instances of the specified subtag from this object.
@param inSubtag the subtag to be removed
*/
public void removeSubtag(XMLizable inSubtag);
//---------------------------------------------------------------------------
/**
Removes all subtags from this object.
*/
public void clearSubtags();
//---------------------------------------------------------------------------
/**
Returns the index of the specified subtag.
@param inSubtag the subtag for which to determine the index
@return the index of the specified subtag or -1 if this tag does not contain the specified subtag.
*/
public int indexOf(XMLizable inSubtag);
//---------------------------------------------------------------------------
/**
Returns the subtag of the specified tag name.
@param inTagName the name of the required subtag
@return the subtag with the specified name
@throws XMLException if zero or more than one subtag with the specified tag name is found.
*/
public T getRequiredSubtagByName(String inTagName);
//---------------------------------------------------------------------------
/**
Returns the subtag of the specified tag name.
@param inTagName the name of the required subtag
@return the subtag with the specified name
@throws XMLException if zero or more than one subtag with the specified tag name is found.
*/
public T getRequiredSubtagByName(XMLName inTagName);
//---------------------------------------------------------------------------
/**
Returns the subtag of the specified tag name.
@param inTagName the name of the optional subtag
@return the subtag with the specified name
@throws XMLException if more than one subtag with the specified tag name is found.
*/
public T getOptionalSubtagByName(String inTagName);
//---------------------------------------------------------------------------
/**
Returns the subtag of the specified tag name.
@param inTagName the name of the optional subtag
@return the subtag with the specified name
@throws XMLException if more than one subtag with the specified tag name is found.
*/
public T getOptionalSubtagByName(XMLName inTagName);
//---------------------------------------------------------------------------
/**
Returns a List of all subtags with the specified tag name on this XMLTag object.
@param inTagName the name of the requested subtags
@return the list of requested subtags
*/
public List getSubtagsByName(String inTagName);
//---------------------------------------------------------------------------
/**
Returns a List of all subtags with the specified tag name on this XMLTag object.
@param inTagName the name of the requested subtags
@return the list of requested subtags
*/
public List getSubtagsByName(XMLName inTagName);
//---------------------------------------------------------------------------
/**
Returns a List of all subtags with the specified tag name on this XMLTag object.
@param inTagName the name of the requested subtags
@param inRecursion flag to indicate whether or not recursion should be used
@return the list of requested subtags
*/
public List getSubtagsByName(String inTagName, Recursion inRecursion);
//---------------------------------------------------------------------------
/**
Returns a List of all subtags with the specified tag name on this XMLTag object.
@param inTagName the name of the requested subtags
@param inRecursion flag to indicate whether or not recursion should be used
@return the list of requested subtags
*/
public List getSubtagsByName(XMLName inTagName, Recursion inRecursion);
//---------------------------------------------------------------------------
/**
Removes all subtags with the specified tag name from this XMLTag object.
@param inTagName the name of the subtags to remove
@return the list of removed subtags
*/
public List removeSubtagsByName(String inTagName);
//---------------------------------------------------------------------------
/**
Removes all subtags with the specified tag name from this XMLTag object.
@param inTagName the name of the subtags to remove
@return the list of removed subtags
*/
public List removeSubtagsByName(XMLName inTagName);
//---------------------------------------------------------------------------
/**
Returns a count of the total number of tags, including this root tag, its
subtags, the subtags' subtags, etc.
@return the total number of XML tags below and including this tag
*/
public int getTotalTagCount();
//---------------------------------------------------------------------------
/**
Returns the number of subtags with the specified tag name on this XMLTag object.
@param inTagName the name of the requested subtags
@return the count of requested subtags
*/
public int countSubtagsByName(String inTagName);
//---------------------------------------------------------------------------
/**
Returns the number of subtags with the specified tag name on this XMLTag object.
@param inTagName the name of the requested subtags
@return the count of requested subtags
*/
public int countSubtagsByName(XMLName inTagName);
//---------------------------------------------------------------------------
/**
Specifies the parent XMLContainer of this XMLContainer. Top level objects should
not have a parent.
@param inParent the XML node for which this tag should be a subnode
*/
public void setParentNode(XMLContainer inParent);
//---------------------------------------------------------------------------
/**
Returns the parent XMLContainer of this XMLContainer. Top level objects should
return null.
@return the parent XML node of this node
*/
public XMLContainer getParentNode();
//---------------------------------------------------------------------------
/**
Returns the previous sibling XMLContainer of this XMLContainer. Returns null if no sibling precedes this object.
@return the previous sibling XMLContainer of this XMLContainer. Returns null if no sibling follows this object.
*/
public XMLContainer getPreviousSibling();
//---------------------------------------------------------------------------
/**
Returns the next sibling XMLContainer of this XMLContainer. Returns null if no sibling follows this object.
@return the next sibling XMLContainer of this XMLContainer. Returns null if no sibling follows this object.
*/
public XMLContainer getNextSibling();
}