Package com.iizix.text
Class KStringHTMLTag<TARGET>
- java.lang.Object
- com.iizix.text.KStringTag<TARGET>
- com.iizix.text.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
Nested Class Summary
Nested classes/interfaces inherited from class com.iizix.text.KStringTag
KStringTag.Type
Constructor Summary
Constructors Modifier Constructor Description KStringHTMLTag(int position, int ordinal)
Creates a closed tag.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.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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)
Creates the correct tag class depending on the HTML tag.protected void
disposeTagReference()
Disposes of the tag reference, used in the Editor for references.boolean
equalsName(KStringTag<?> kst)
Checks for the same "name" (tag ordinal and closing tag for HTML, tag name for PLAIN).java.lang.String
getHTMLString(java.lang.StringBuilder useme, IKStringInfoProvider provider)
Gets the string representation of this tag in the HTML format.java.lang.String
getHTMLTagText(java.lang.StringBuilder useme, IKStringInfoProvider provider)
Gets the "unparsed" string representation of this tag in the HTML format.java.lang.String
getPLAINString(java.lang.StringBuilder useme, IKStringInfoProvider provider)
Gets the string representation of this tag in the PLAIN format, i.e.java.lang.String
getPLAINTagText(java.lang.StringBuilder useme)
Gets the "unparsed" string representation of this tag in the PLAIN format, i.e.boolean
isReferenceTag()
Checks if this tag is of reference type, i.e.void
resolve(KStringHolder holder, boolean doReCheck, GEvent triggerEvent)
Resolves the reference.boolean
setReference(java.lang.String ref)
Updates the tag reference.boolean
willLoseFormatting()
Checks if this string will lose formatting when translated to PLAIN.Methods inherited from class com.iizix.text.KStringTag
appendHTMLAttributes, appendHTMLAttributes, appendHTMLAttributesSkip, appendPLAINAttributes, appendPLAINValue, clone, equals, getAttribute, getReference, getReferenceClass, getReferenceDescription, getReferenceError, getSourceEndPosition, getSourceLength, getSourcePosition, getType, isReferenceValid, isRefreshRequired, isRefreshRequired, setAttribute, setSourceLocation, verify
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 classKStringTag<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 classKStringTag<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 classKStringTag<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 classKStringTag<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 classKStringTag<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 classKStringTag<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 classKStringTag<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 classKStringTag<TARGET>
setReference
public boolean setReference(java.lang.String ref)
Updates the tag reference.- Specified by:
setReference
in classKStringTag<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 classKStringTag<TARGET>
- Parameters:
holder
- The KString holder.doReCheck
- Rechecks the references.triggerEvent
- The trigger event.