/ org.htmlparser / src / org / htmlparser / tags / OptionTag.java
OptionTag.java
  1  // HTMLParser Library $Name: v1_6_20060319 $ - A java-based parser for HTML
  2  // http://sourceforge.org/projects/htmlparser
  3  // Copyright (C) 2004 Somik Raha
  4  //
  5  // Revision Control Information
  6  //
  7  // $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/OptionTag.java,v $
  8  // $Author: derrickoswald $
  9  // $Date: 2005/04/10 23:20:45 $
 10  // $Revision: 1.37 $
 11  //
 12  // This library is free software; you can redistribute it and/or
 13  // modify it under the terms of the GNU Lesser General Public
 14  // License as published by the Free Software Foundation; either
 15  // version 2.1 of the License, or (at your option) any later version.
 16  //
 17  // This library is distributed in the hope that it will be useful,
 18  // but WITHOUT ANY WARRANTY; without even the implied warranty of
 19  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 20  // Lesser General Public License for more details.
 21  //
 22  // You should have received a copy of the GNU Lesser General Public
 23  // License along with this library; if not, write to the Free Software
 24  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 25  //
 26  
 27  package org.htmlparser.tags;
 28  
 29  /**
 30   * An option tag within a form.
 31   */
 32  public class OptionTag extends CompositeTag
 33  {
 34      /**
 35       * The set of names handled by this tag.
 36       */
 37      private static final String[] mIds = new String[] {"OPTION"};
 38  
 39      /**
 40       * The set of tag names that indicate the end of this tag.
 41       */
 42      private static final String[] mEnders = new String[] {"INPUT", "TEXTAREA", "SELECT", "OPTION"};
 43  
 44      /**
 45       * The set of end tag names that indicate the end of this tag.
 46       */
 47      private static final String[] mEndTagEnders = new String[] {"SELECT", "FORM", "BODY", "HTML"};
 48  
 49      /**
 50       * Create a new option tag.
 51       */
 52      public OptionTag ()
 53      {
 54      }
 55  
 56      /**
 57       * Return the set of names handled by this tag.
 58       * @return The names to be matched that create tags of this type.
 59       */
 60      public String[] getIds ()
 61      {
 62          return (mIds);
 63      }
 64  
 65      /**
 66       * Return the set of tag names that cause this tag to finish.
 67       * @return The names of following tags that stop further scanning.
 68       */
 69      public String[] getEnders ()
 70      {
 71          return (mEnders);
 72      }
 73  
 74      /**
 75       * Return the set of end tag names that cause this tag to finish.
 76       * @return The names of following end tags that stop further scanning.
 77       */
 78      public String[] getEndTagEnders ()
 79      {
 80          return (mEndTagEnders);
 81      }
 82  
 83      /**
 84       * Get the <code>VALUE</code> attribute, if any.
 85       * @return The value of the <code>VALUE</code> attribute,
 86       * or <code>null</code> if the attribute doesn't exist.
 87       */
 88      public String getValue ()
 89      {
 90          return (getAttribute ("VALUE"));
 91      }
 92  
 93      /**
 94       * Set the value of the value attribute.
 95       * @param value The new value of the <code>VALUE</code> attribute.
 96       */
 97      public void setValue (String value)
 98      {
 99          this.setAttribute("VALUE",value);
100      }
101  
102      /**
103       * Get the text of this option.
104       * @return The textual contents of this <code>OPTION</code> tag.
105       */
106      public String getOptionText()
107      {
108          return toPlainTextString();
109      }
110  
111      /**
112       * Return a string representation of this node suitable for debugging.
113       * @return The value and text of this tag in a string.
114       */
115      public String toString()
116      {
117          String output = "OPTION VALUE: " + getValue() + " TEXT: " + getOptionText()+"\n";
118          return output;
119      }
120  
121  }