Class PropErrorItem

java.lang.Object
com.iizix.prop.PropErrorItem
All Implemented Interfaces:
IPropErrorItem, Cloneable
Direct Known Subclasses:
PropErrorItemValue

public class PropErrorItem extends Object implements IPropErrorItem
Class holding information about an error for the Property Editor in the Designer. Several errors can be set for a single property, e.g. when there are of multi-style.
Author:
Christopher Mindus
  • Constructor Details

    • PropErrorItem

      public PropErrorItem()
      Constructs a new instance from an XML element.
    • PropErrorItem

      public PropErrorItem(String id, String message, int level)
      Constructs a new instance.
      Parameters:
      id - The ID of the message, never null.
      message - The error message string, never null.
      level - The severity level: INFO, WARNING or ERROR.
      Throws:
      IllegalArgumentException - If level is not INFO, WARNING or ERROR.
      NullPointerException - If id or message is null.
    • PropErrorItem

      public PropErrorItem(String id, String message, int level, String... quickFixes)
      Constructs a new instance.
      Parameters:
      id - The ID of the message, never null.
      message - The error message string, never null.
      level - The severity level: INFO, WARNING or ERROR.
      quickFixes - The quick-fix ID's.
      Throws:
      IllegalArgumentException - If level is not INFO, WARNING or ERROR.
      NullPointerException - If id or message is null.
    • PropErrorItem

      public PropErrorItem(String id, String message, String location, int level, String... quickFixes)
      Constructs a new instance.
      Parameters:
      id - The ID of the message, never null.
      message - The error message string, never null.
      location - The location, null for none.
      level - The severity level: INFO, WARNING or ERROR.
      quickFixes - The quick-fix ID's.
      Throws:
      IllegalArgumentException - If level is not INFO, WARNING or ERROR.
      NullPointerException - If id or message is null.
  • Method Details

    • load

      public void load(Element element) throws Exception
      Loads the error from XML.
      Specified by:
      load in interface IPropErrorItem
      Parameters:
      element - The errorItem element.
      Throws:
      Exception - For errors in XML.
    • setIndex

      public void setIndex(int index)
      Sets the index for a multi-property.
      Specified by:
      setIndex in interface IPropErrorItem
      Parameters:
      index - 0 for main part, otherwise one-based index for errored property value.
    • getID

      public String getID()
      Gets the ID.
      Specified by:
      getID in interface IPropErrorItem
    • getMessage

      public String getMessage()
      Gets the message.
      Specified by:
      getMessage in interface IPropErrorItem
      Returns:
      The error message.
    • getIndex

      public int getIndex()
      Gets the index for a multi-property.
      Specified by:
      getIndex in interface IPropErrorItem
      Returns:
      -1 for none, 0 for main part, otherwise one-based index for errored property value.
    • getLocation

      public String getLocation()
      Gets the location of an error, for user info only.
      Specified by:
      getLocation in interface IPropErrorItem
      Returns:
      The location, or null for none.
    • getLocationOrName

      public String getLocationOrName()
      Gets the location or property name of an error, for user info only.
      Specified by:
      getLocationOrName in interface IPropErrorItem
      Returns:
      The location, or the property name if none is defined, never null.
    • getQuickFixes

      public String[] getQuickFixes()
      Gets the quick-fix ID's.
      Specified by:
      getQuickFixes in interface IPropErrorItem
      Returns:
      The list of quick-fix ID's or null for none.
    • getSeverity

      public int getSeverity()
      Gets the severity.
      Specified by:
      getSeverity in interface IPropErrorItem
      Returns:
      INFO, WARNING or ERROR.
    • equals

      public boolean equals(Object o)
      Checks if two items are equal.
      Specified by:
      equals in interface IPropErrorItem
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Formats the error input to a string.
      Overrides:
      toString in class Object
    • paramString

      protected String paramString()
      The parameter string.
    • getText

      public String getText(boolean includeID)
      Gets a textual error description as "LEVEL[{\t}id]{\t}text" (where {\t} is the tab character).
      Specified by:
      getText in interface IPropErrorItem
      Parameters:
      includeID - Flag to include ID or not.
    • save

      public void save(Element element)
      Called when the XML file for the error tree is serialized from properties.
      Specified by:
      save in interface IPropErrorItem
      Parameters:
      element - The Element to initialize.
    • clone

      public PropErrorItem clone()
      Clones this instance.
      Specified by:
      clone in interface IPropErrorItem
      Overrides:
      clone in class Object
      Returns:
      A clone.