com.hfg.html.Option 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.html;
import com.hfg.xml.XMLNode;
//------------------------------------------------------------------------------
/**
* Represents a list option (<option>) tag.
*
* @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 class Option extends HTMLTagWithCoreEvents
{
//##########################################################################
// CONSTRUCTORS
//##########################################################################
//--------------------------------------------------------------------------
public Option()
{
super(HTML.OPTION);
}
//--------------------------------------------------------------------------
public Option(String inText)
{
this();
setText(inText);
setValue(inText);
setSelected(false);
}
//--------------------------------------------------------------------------
public Option(int inText)
{
this(inText + "");
}
//--------------------------------------------------------------------------
public Option(long inText)
{
this(inText + "");
}
//--------------------------------------------------------------------------
public Option(float inText)
{
this(inText + "");
}
//--------------------------------------------------------------------------
public Option(double inText)
{
this(inText + "");
}
//--------------------------------------------------------------------------
public Option(Object inText)
{
this(inText != null ? inText.toString() : "");
}
//--------------------------------------------------------------------------
public Option(String inText, String inValue)
{
this();
setText(inText);
setValue(inValue);
setSelected(false);
}
//--------------------------------------------------------------------------
public Option(String inText, int inValue)
{
this(inText, inValue + "");
}
//--------------------------------------------------------------------------
public Option(String inText, long inValue)
{
this(inText, inValue + "");
}
//--------------------------------------------------------------------------
public Option(String inText, float inValue)
{
this(inText, inValue + "");
}
//--------------------------------------------------------------------------
public Option(String inText, double inValue)
{
this(inText, inValue + "");
}
//--------------------------------------------------------------------------
public Option(String inText, Object inValue)
{
this(inText, inValue != null ? inValue.toString() : "");
}
//--------------------------------------------------------------------------
public Option(int inText, boolean inSelected)
{
this(inText + "", inSelected);
}
//--------------------------------------------------------------------------
public Option(long inText, boolean inSelected)
{
this(inText + "", inSelected);
}
//--------------------------------------------------------------------------
public Option(float inText, boolean inSelected)
{
this(inText + "", inSelected);
}
//--------------------------------------------------------------------------
public Option(double inText, boolean inSelected)
{
this(inText + "", inSelected);
}
//--------------------------------------------------------------------------
public Option(Object inText, boolean inSelected)
{
this(inText != null ? inText.toString() : "", inSelected);
}
//--------------------------------------------------------------------------
public Option(String inText, boolean inSelected)
{
this();
setText(inText);
setValue(inText);
setSelected(inSelected);
}
//--------------------------------------------------------------------------
public Option(String inText, String inValue, boolean inSelected)
{
this();
setText(inText);
setValue(inValue);
setSelected(inSelected);
}
//--------------------------------------------------------------------------
public Option(String inText, int inValue, boolean inSelected)
{
this(inText, inValue + "", inSelected);
}
//--------------------------------------------------------------------------
public Option(String inText, long inValue, boolean inSelected)
{
this(inText, inValue + "", inSelected);
}
//--------------------------------------------------------------------------
public Option(String inText, float inValue, boolean inSelected)
{
this(inText, inValue + "", inSelected);
}
//--------------------------------------------------------------------------
public Option(String inText, double inValue, boolean inSelected)
{
this(inText, inValue + "", inSelected);
}
//--------------------------------------------------------------------------
public Option(String inText, Object inValue, boolean inSelected)
{
this(inText, inValue != null ? inValue.toString() : "", inSelected);
}
//--------------------------------------------------------------------------
public Option(XMLNode inXMLNode)
{
this();
initFromXMLNode(inXMLNode);
}
//##########################################################################
// PUBLIC METHODS
//##########################################################################
//--------------------------------------------------------------------------
public Option setName(String inValue)
{
setAttribute(HTML.NAME, inValue);
return this;
}
//--------------------------------------------------------------------------
public String getName()
{
return getAttributeValue(HTML.NAME);
}
//--------------------------------------------------------------------------
public Option setSelected(boolean inSelected)
{
if (inSelected)
{
setAttribute(HTML.SELECTED, "true");
}
else
{
removeAttribute(HTML.SELECTED);
}
return this;
}
//--------------------------------------------------------------------------
public boolean isSelected()
{
return hasAttribute(HTML.SELECTED);
}
//--------------------------------------------------------------------------
public Option setValue(String inValue)
{
setAttribute(HTML.VALUE, inValue);
return this;
}
//--------------------------------------------------------------------------
public String getValue()
{
return getAttributeValue(HTML.VALUE);
}
//--------------------------------------------------------------------------
public Option setText(String inValue)
{
setContent(inValue);
return this;
}
//--------------------------------------------------------------------------
public String getText()
{
return getContent();
}
//--------------------------------------------------------------------------
public Option setDisabled(boolean inValue)
{
if (inValue)
{
setAttribute(HTML.DISABLED, "1");
}
else
{
removeAttribute(HTML.DISABLED);
}
return this;
}
//--------------------------------------------------------------------------
public boolean isDisabled()
{
return hasAttribute(HTML.DISABLED);
}
//--------------------------------------------------------------------------
public Option setTitle(String inValue)
{
setAttribute(HTML.TITLE, inValue);
return this;
}
// Overrides for HTMLTag setters to allow method chaining.
//--------------------------------------------------------------------------
@Override
public Option addClass(String inValue)
{
return (Option) super.addClass(inValue);
}
//--------------------------------------------------------------------------
@Override
public Option setClass(String inValue)
{
return (Option) super.setClass(inValue);
}
//--------------------------------------------------------------------------
@Override
public Option setId(String inValue)
{
return (Option) super.setId(inValue);
}
//--------------------------------------------------------------------------
@Override
public Option setStyle(CharSequence inValue)
{
return (Option) super.setStyle(inValue);
}
//--------------------------------------------------------------------------
@Override
public Option addStyle(String inValue)
{
return (Option) super.addStyle(inValue);
}
// Overrides for HTMLTagWithCoreEvents setters to allow method chaining.
//--------------------------------------------------------------------------
@Override
public Option setOnClick(String inValue)
{
return (Option) super.setOnClick(inValue);
}
//--------------------------------------------------------------------------
@Override
public Option setOnDblClick(String inValue)
{
return (Option) super.setOnDblClick(inValue);
}
//--------------------------------------------------------------------------
@Override
public Option setOnMouseDown(String inValue)
{
return (Option) super.setOnMouseDown(inValue);
}
//--------------------------------------------------------------------------
@Override
public Option setOnMouseMove(String inValue)
{
return (Option) super.setOnMouseMove(inValue);
}
//--------------------------------------------------------------------------
@Override
public Option appendToOnMouseOut(String inValue)
{
return (Option) super.appendToOnMouseOut(inValue);
}
//--------------------------------------------------------------------------
@Override
public Option setOnMouseOut(String inValue)
{
return (Option) super.setOnMouseOut(inValue);
}
//--------------------------------------------------------------------------
@Override
public Option appendToOnMouseOver(String inValue)
{
return (Option) super.appendToOnMouseOver(inValue);
}
//--------------------------------------------------------------------------
@Override
public Option setOnMouseOver(String inValue)
{
return (Option) super.setOnMouseOver(inValue);
}
//--------------------------------------------------------------------------
@Override
public Option setOnMouseUp(String inValue)
{
return (Option) super.setOnMouseUp(inValue);
}
//--------------------------------------------------------------------------
@Override
public Option setOnKeyDown(String inValue)
{
return (Option) super.setOnKeyDown(inValue);
}
//--------------------------------------------------------------------------
@Override
public Option setOnKeyPress(String inValue)
{
return (Option) super.setOnKeyPress(inValue);
}
//--------------------------------------------------------------------------
@Override
public Option setOnKeyUp(String inValue)
{
return (Option) super.setOnKeyUp(inValue);
}
}