Thread: [Htmlparser-cvs] htmlparser/src/org/htmlparser Tag.java,NONE,1.1 PrototypicalNodeFactory.java,1.5,1.
Brought to you by:
derrickoswald
From: Derrick O. <der...@us...> - 2004-03-20 17:13:52
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15661 Modified Files: PrototypicalNodeFactory.java Added Files: Tag.java Log Message: First pass refactoring. Create Tag interface, which isn't really used yet. Index: PrototypicalNodeFactory.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/PrototypicalNodeFactory.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PrototypicalNodeFactory.java 25 Jan 2004 21:32:56 -0000 1.5 --- PrototypicalNodeFactory.java 20 Mar 2004 17:03:53 -0000 1.6 *************** *** 36,40 **** import org.htmlparser.lexer.nodes.Attribute; import org.htmlparser.lexer.nodes.NodeFactory; ! import org.htmlparser.tags.*; // import everything for now import org.htmlparser.util.ParserException; --- 36,69 ---- import org.htmlparser.lexer.nodes.Attribute; import org.htmlparser.lexer.nodes.NodeFactory; ! import org.htmlparser.tags.AppletTag; ! import org.htmlparser.tags.BaseHrefTag; ! import org.htmlparser.tags.BodyTag; ! import org.htmlparser.tags.Bullet; ! import org.htmlparser.tags.BulletList; ! import org.htmlparser.tags.Div; ! import org.htmlparser.tags.DoctypeTag; ! import org.htmlparser.tags.FormTag; ! import org.htmlparser.tags.FrameSetTag; ! import org.htmlparser.tags.FrameTag; ! import org.htmlparser.tags.HeadTag; ! import org.htmlparser.tags.Html; ! import org.htmlparser.tags.ImageTag; ! import org.htmlparser.tags.InputTag; ! import org.htmlparser.tags.JspTag; ! import org.htmlparser.tags.LabelTag; ! import org.htmlparser.tags.LinkTag; ! import org.htmlparser.tags.MetaTag; ! import org.htmlparser.tags.OptionTag; ! import org.htmlparser.tags.ScriptTag; ! import org.htmlparser.tags.SelectTag; ! import org.htmlparser.tags.Span; ! import org.htmlparser.tags.StyleTag; ! import org.htmlparser.tags.TableColumn; ! import org.htmlparser.tags.TableHeader; ! import org.htmlparser.tags.TableRow; ! import org.htmlparser.tags.TableTag; ! import org.htmlparser.tags.Tag; ! import org.htmlparser.tags.TextareaTag; ! import org.htmlparser.tags.TitleTag; import org.htmlparser.util.ParserException; --- NEW FILE: Tag.java --- // HTMLParser Library $Name: $ - A java-based parser for HTML // http://sourceforge.org/projects/htmlparser // Copyright (C) 2004 Derrick Oswald // // Revision Control Information // // $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/Tag.java,v $ // $Author: derrickoswald $ // $Date: 2004/03/20 17:03:53 $ // $Revision: 1.1 $ // // 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 // package org.htmlparser; import java.util.Vector; import org.htmlparser.lexer.nodes.Attribute; /** * Identifies what a Tag such as <XXX xxx yyy="zzz"> can do. * Adds features to a Node that are specific to a tag. */ public interface Tag extends Node { /** * Returns the value of an attribute. * @param name Name of attribute, case insensitive. * @return The value associated with the attribute or null if it does * not exist, or is a stand-alone or */ public String getAttribute (String name); /** * Set attribute with given key, value pair. * Figures out a quote character to use if necessary. * @param key The name of the attribute. * @param value The value of the attribute. */ public void setAttribute (String key, String value); /** * Set attribute with given key, value pair where the value is quoted by quote. * @param key The name of the attribute. * @param value The value of the attribute. * @param quote The quote character to be used around value. * If zero, it is an unquoted value. */ public void setAttribute (String key, String value, char quote); /** * Remove the attribute with the given key, if it exists. * @param key The name of the attribute. */ public void removeAttribute (String key); /** * Returns the attribute with the given name. * @param name Name of attribute, case insensitive. * @return The attribute or null if it does * not exist. */ public Attribute getAttributeEx (String name); /** * Set an attribute. * This replaces an attribute of the same name. * To set the zeroth attribute (the tag name), use setTagName(). * @param attribute The attribute to set. */ public void setAttributeEx (Attribute attribute); /** * Gets the attributes in the tag. * @return Returns the list of {@link Attribute Attributes} in the tag. */ public Vector getAttributesEx (); /** * Sets the attributes. * NOTE: Values of the extended hashtable are two element arrays of String, * with the first element being the original name (not uppercased), * and the second element being the value. * @param attribs The attribute collection to set. */ public void setAttributesEx (Vector attribs); /** * Return the name of this tag. * <p> * <em> * Note: This value is converted to uppercase and does not * begin with "/" if it is an end tag. Nor does it end with * a slash in the case of an XML type tag. * To get at the original text of the tag name use * {@link #getRawTagName getRawTagName()}. * The conversion to uppercase is performed with an ENGLISH locale. * </em> * @return The tag name. */ public String getTagName (); /** * Set the name of this tag. * This creates or replaces the first attribute of the tag (the * zeroth element of the attribute vector). * @param name The tag name. */ public void setTagName (String name); /** * Determines if the given tag breaks the flow of text. * @return <code>true</code> if following text would start on a new line, * <code>false</code> otherwise. */ public boolean breaksFlow (); /** * Predicate to determine if this tag is an end tag (i.e. </HTML>). * @return <code>true</code> if this tag is an end tag. */ public boolean isEndTag (); /** * Set this tag to be an end tag, or not. * Adds or removes the leading slash on the tag name. * @param endTag If true, this tag is made into an end tag. * Any attributes it may have had are dropped. */ // public void setEndTag (boolean endTag); /** * Is this an empty xml tag of the form <tag/>. * @return true if the last character of the last attribute is a '/'. */ public boolean isEmptyXmlTag (); /** * Set this tag to be an empty xml node, or not. * Adds or removes an ending slash on the tag. * @param emptyXmlTag If true, ensures there is an ending slash in the node, * i.e. <tag/>, otherwise removes it. */ public void setEmptyXmlTag (boolean emptyXmlTag); } |