Class KStringEditorKind

java.lang.Object
com.iizigo.text.KStringEditorKind

public final class KStringEditorKind extends Object
The kind of KString an editor of the Designer is editing, and the parse that follows it: a text of the trusted kind is validated and rebuilt by the trusted kind's rules, a classical text by the classical rules, so that the Designer neither flags what a trusted text may hold nor changes the kind of the text it edits.

The class has no state and uses no widget: KStringStyledText, the raw and the rich text editor, the common text actions, the property sheet's entry fields and the text table's cells call it wherever they build a KString from the text being edited.

Author:
Christopher Mindus
  • Method Details

    • of

      public static KString.Kind of(KString ks)
      Gets the kind of a KString being edited.
      Parameters:
      ks - The KString, null for a new text.
      Returns:
      The kind of the KString; KString.Kind.CLASSICAL for a new text and for every PLAIN text.
    • ofAll

      public static KString.Kind ofAll(Iterable<? extends KString> values)
      Gets the kind of the KStrings edited together in one entry field: the texts of the selected properties.
      Parameters:
      values - The KStrings, null entries are skipped; null for none.
      Returns:
      The kind every KString has; KString.Kind.CLASSICAL when there is none (a new text) and when the kinds differ, so that one text typed over a mixed selection never makes a classical text trusted.
    • parse

      public static KString parse(KString.Kind kind, KString.Type type, String input, boolean useTags, ArrayList<KStringStyleRange> styles) throws KStringException
      Parses the text of an editor by the rules of a kind, filling in the style ranges of the parse, and returns the value to set in the edited property.

      The classical kind, the trusted kind and every PLAIN text return the styling parse itself: the trusted kind is parsed once, with the trusted tables, and its styling parse writes the trusted attribute when the property is saved. The trusted unparsed kind is not parsed at all: no rule applies to it, nothing is styled.

      Parameters:
      kind - The kind of the text being edited, null for classical.
      type - The type of KString.
      input - The text of the editor.
      useTags - Flag for tag usage.
      styles - Array that is filled with KStringStyleRange's when parsed.
      Returns:
      The KString of the kind for the text.
      Throws:
      KStringException - For string or parsing errors.
    • create

      public static KString create(KString.Kind kind, KString.Type type, String input, boolean useTags) throws KStringException
      Creates the KString of a kind from the text of an editor, without styles.
      Parameters:
      kind - The kind of the text being edited, null for classical.
      type - The type of KString.
      input - The text of the editor.
      useTags - Flag for tag usage.
      Returns:
      The KString of the kind for the text; a PLAIN text is always classical.
      Throws:
      KStringException - For string or parsing errors.
    • forRichEditor

      public static KString forRichEditor(KString.Kind kind, String html, boolean useTags) throws KStringException
      Creates the KString of a kind from the HTML the rich text editor hands back. A parsed kind is converted to a KString once, then to the string without the editor's special formatting, then back to a KString again, which removes the extra information in e.g. the IMG tag. The trusted unparsed kind takes the HTML as it is.
      Parameters:
      kind - The kind of the text being edited, null for classical.
      html - The HTML of the rich text editor.
      useTags - Flag for tag usage.
      Returns:
      The HTML KString of the kind.
      Throws:
      KStringException - For string or parsing errors.