Class KStringHTMLTag<TARGET>

java.lang.Object
com.iizix.text.KStringTag<TARGET>
com.iizix.text.KStringHTMLTag<TARGET>
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
KStringHTMLDynamicTag

public class KStringHTMLTag<TARGET> extends KStringTag<TARGET>
Class for the HTML tag entry in the string. If not overridden, it handles the default tags.
Author:
Christopher Mindus
  • Field Details Link icon

    • ordinal Link icon

      protected final int ordinal
      The ordinal.
    • isClosed Link icon

      protected final boolean isClosed
      Tag closed flag.
  • Constructor Details Link icon

    • KStringHTMLTag Link icon

      protected KStringHTMLTag(KStringTag.Type type, int position, int ordinal, LinkedHashMap<String,String> attributes)
      Creates a normal or dynamic tag.
      Parameters:
      position - The position of the tag in the parsed string.
      ordinal - The ordinal of the tag.
      attributes - The tag attributes.
    • KStringHTMLTag Link icon

      public KStringHTMLTag(int position, int ordinal)
      Creates a closed tag.
  • Method Details Link icon

    • create Link icon

      public static KStringHTMLTag<?> create(int position, int ordinal, LinkedHashMap<String,String> attributes, String inputString, int parsePosition, boolean isOpenClosed, boolean forEditor) throws KStringParseException
      Creates the correct tag class depending on the HTML tag.
      Parameters:
      position - The position of the tag in the parsed string.
      ordinal - The ordinal of the tag.
      attributes - The tag attributes.
      inputString - The input string to KString.
      parsePosition - The parsing position where tag starts.
      forEditor - Flag indicating an INPUT tag has been replaced with IZ.
      Returns:
      The new HTML tag instance that corresponds with the tag name.
      Throws:
      KStringParseException - For invalid tag name or reference/missing attributes.
    • disposeTagReference Link icon

      protected final void disposeTagReference()
      Disposes of the tag reference, used in the Editor for references.
      Overrides:
      disposeTagReference in class KStringTag<TARGET>
    • willLoseFormatting Link icon

      public boolean willLoseFormatting()
      Checks if this string will lose formatting when translated to PLAIN. Note that translating PLAIN to HTML never loses formatting.
      Specified by:
      willLoseFormatting in class KStringTag<TARGET>
      Returns:
      Always true for opened tags.
    • isReferenceTag Link icon

      public boolean isReferenceTag()
      Checks if this tag is of reference type, i.e. for HTML, the tags A, IMG, IZ. For PLAIN KString type, this method always returns true.
      Specified by:
      isReferenceTag in class KStringTag<TARGET>
    • getPLAINTagText Link icon

      public String getPLAINTagText(StringBuilder useme)
      Gets the "unparsed" string representation of this tag in the PLAIN format, i.e. this HTML tag will reformat or translate itself for PLAIN. For the basic HTML tags, this results in an empty string.
      Specified by:
      getPLAINTagText in class KStringTag<TARGET>
    • getHTMLTagText Link icon

      public String getHTMLTagText(StringBuilder useme, IKStringInfoProvider provider)
      Gets the "unparsed" string representation of this tag in the HTML format.
      Specified by:
      getHTMLTagText in class KStringTag<TARGET>
      Parameters:
      useme - Temporary StringBuilder for any use.
      provider - The information provider or null for none.
    • getPLAINString Link icon

      public String getPLAINString(StringBuilder useme, IKStringInfoProvider provider)
      Gets the string representation of this tag in the PLAIN format, i.e. returns empty string.

      The only tag [BR] returns [LF] character code 0x10.

      Specified by:
      getPLAINString in class KStringTag<TARGET>
      Parameters:
      useme - Temporary StringBuilder for any use.
      provider - The information provider or null for none.
    • getHTMLString Link icon

      public String getHTMLString(StringBuilder useme, IKStringInfoProvider provider)
      Gets the string representation of this tag in the HTML format.
      Specified by:
      getHTMLString in class KStringTag<TARGET>
      Parameters:
      useme - Temporary StringBuilder for any use.
      provider - The information provider or null for none.
    • equalsName Link icon

      public boolean equalsName(KStringTag<?> kst)
      Checks for the same "name" (tag ordinal and closing tag for HTML, tag name for PLAIN).
      Overrides:
      equalsName in class KStringTag<TARGET>
    • setReference Link icon

      public boolean setReference(String ref)
      Updates the tag reference.
      Specified by:
      setReference in class KStringTag<TARGET>
      Parameters:
      ref - The new reference.
      Returns:
      true if changed, false for no change.
    • resolve Link icon

      public void resolve(KStringHolder holder, boolean doReCheck, GEvent triggerEvent)
      Resolves the reference. This method checks for any on* attributes for VS component references.
      Overrides:
      resolve in class KStringTag<TARGET>
      Parameters:
      holder - The KString holder.
      doReCheck - Rechecks the references.
      triggerEvent - The trigger event.