Class KStringHTMLTag<TARGET>

  • All Implemented Interfaces:
    java.lang.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 Detail

      • ordinal

        protected final int ordinal
        The ordinal.
      • isClosed

        protected final boolean isClosed
        Tag closed flag.
    • Constructor Detail

      • KStringHTMLTag

        protected KStringHTMLTag​(KStringTag.Type type,
                                 int position,
                                 int ordinal,
                                 java.util.LinkedHashMap<java.lang.String,​java.lang.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

        public KStringHTMLTag​(int position,
                              int ordinal)
        Creates a closed tag.
    • Method Detail

      • create

        public static KStringHTMLTag<?> create​(int position,
                                               int ordinal,
                                               java.util.LinkedHashMap<java.lang.String,​java.lang.String> attributes,
                                               java.lang.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

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

        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

        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

        public java.lang.String getPLAINTagText​(java.lang.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

        public java.lang.String getHTMLTagText​(java.lang.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

        public java.lang.String getPLAINString​(java.lang.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

        public java.lang.String getHTMLString​(java.lang.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

        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

        public boolean setReference​(java.lang.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

        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.