All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hfg.html.Link Maven / Gradle / Ivy

There is a newer version: 20240423
Show newest version
package com.hfg.html;


import com.hfg.xml.XMLNode;

//------------------------------------------------------------------------------
/**
 * Represents a link (<a>) 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 Link extends HTMLTagWithCoreEvents
{
   //##########################################################################
   // CONSTRUCTORS
   //##########################################################################

   //--------------------------------------------------------------------------
   public Link()
   {
      super(HTML.A);
   }

   //--------------------------------------------------------------------------
   public Link(CharSequence inURL)
   {
      this();
      setURL(inURL);
   }

   //--------------------------------------------------------------------------
   public Link(CharSequence inURL, String inContent)
   {
      this(inURL);
      addContent(inContent);
   }

   //--------------------------------------------------------------------------
   public Link(CharSequence inURL, HTMLTag inContentTag)
   {
      this(inURL);
      addSubtag(inContentTag);
   }

   //--------------------------------------------------------------------------
   public Link(XMLNode inXMLNode)
   {
      this();
      initFromXMLNode(inXMLNode);
   }

   //##########################################################################
   // PUBLIC METHODS
   //##########################################################################

   //--------------------------------------------------------------------------
   public Link setURL(CharSequence inValue)
   {
      setAttribute(HTML.HREF, inValue);

      return this;
   }

   //--------------------------------------------------------------------------
   public String getURL()
   {
      return getAttributeValue(HTML.HREF);
   }

   //--------------------------------------------------------------------------
   /**
    The target for the link can be set to one of several special values or a tab/window name of your choosing.
    (The Target class has constants for the special values.)
    
    _blank      Opens the linked document in a new window or tab
    _self       Opens the linked document in the same frame as it was clicked (this is default)
    _parent     Opens the linked document in the parent frame
    _top        Opens the linked document in the full body of the window
    framename   Opens the linked document in a named frame
    
@param inValue the target name @return this Link object to enable method chaining */ public Link setTarget(String inValue) { setAttribute(HTML.TARGET, inValue); return this; } //-------------------------------------------------------------------------- public String getTarget() { return getAttributeValue(HTML.TARGET); } //-------------------------------------------------------------------------- public Link setName(String inValue) { setAttribute(HTML.NAME, inValue); return this; } //-------------------------------------------------------------------------- public String getName() { return getAttributeValue(HTML.NAME); } //-------------------------------------------------------------------------- public Link setTitle(String inValue) { setAttribute(HTML.TITLE, inValue); return this; } //-------------------------------------------------------------------------- public Span addSpan() { Span span = new Span(); addSubtag(span); return span; } //-------------------------------------------------------------------------- public Span addSpan(String inContent) { Span span = new Span(inContent); addSubtag(span); return span; } //-------------------------------------------------------------------------- public Img addImage(String inSrc) { Img image = new Img(inSrc); addSubtag(image); return image; } // Overrides for HTMLTag setters to allow method chaining. //-------------------------------------------------------------------------- @Override public Link addClass(String inValue) { return (Link) super.addClass(inValue); } //-------------------------------------------------------------------------- @Override public Link setClass(String inValue) { return (Link) super.setClass(inValue); } //-------------------------------------------------------------------------- @Override public Link setId(String inValue) { return (Link) super.setId(inValue); } //-------------------------------------------------------------------------- @Override public Link setStyle(CharSequence inValue) { return (Link) super.setStyle(inValue); } //-------------------------------------------------------------------------- @Override public Link addStyle(String inValue) { return (Link) super.addStyle(inValue); } // Overrides for HTMLTagWithCoreEvents setters to allow method chaining. //-------------------------------------------------------------------------- @Override public Link setOnClick(String inValue) { return (Link) super.setOnClick(inValue); } //-------------------------------------------------------------------------- @Override public Link setOnDblClick(String inValue) { return (Link) super.setOnDblClick(inValue); } //-------------------------------------------------------------------------- @Override public Link setOnMouseDown(String inValue) { return (Link) super.setOnMouseDown(inValue); } //-------------------------------------------------------------------------- @Override public Link setOnMouseMove(String inValue) { return (Link) super.setOnMouseMove(inValue); } //-------------------------------------------------------------------------- @Override public Link setOnMouseOut(String inValue) { return (Link) super.setOnMouseOut(inValue); } //-------------------------------------------------------------------------- @Override public Link setOnMouseOver(String inValue) { return (Link) super.setOnMouseOver(inValue); } //-------------------------------------------------------------------------- @Override public Link setOnMouseUp(String inValue) { return (Link) super.setOnMouseUp(inValue); } //-------------------------------------------------------------------------- @Override public Link setOnKeyDown(String inValue) { return (Link) super.setOnKeyDown(inValue); } //-------------------------------------------------------------------------- @Override public Link setOnKeyPress(String inValue) { return (Link) super.setOnKeyPress(inValue); } //-------------------------------------------------------------------------- @Override public Link setOnKeyUp(String inValue) { return (Link) super.setOnKeyUp(inValue); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy