Enum Class ElementKind

java.lang.Object
java.lang.Enum<ElementKind>
uk.blankaspect.common.jsonxml.ElementKind
All Implemented Interfaces:
Serializable, Comparable<ElementKind>, Constable

public enum ElementKind extends Enum<ElementKind>
This is an enumeration of the kinds of element that may appear in a tree of JSON-XML.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    This class implements an unchecked exception that may be thrown if an XML element is encountered where a JSON-XML element is expected.

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Corresponds to a JSON array.
    Corresponds to a JSON Boolean value.
    Corresponds to a JSON null value.
    Corresponds to a JSON number.
    Corresponds to a JSON object.
    Corresponds to a JSON string.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Set<ElementKind>
    The kinds of element that correspond to compound JSON values.
    static final Set<ElementKind>
    The kinds of element that correspond to simple JSON values.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    anyMatch(Element element)
    Returns true if the specified XML element matches any kind of JSON-XML element.
    Creates and returns a new instance of a JSON-XML element of this kind using the specified facade.
    boolean
    Returns true if this kind of JSON-XML element corresponds to a compound JSON value (array or object).
    static boolean
    Returns true if the specified XML element matches a kind of JSON-XML element that corresponds to a compound JSON value (array or object).
    boolean
    Returns true if this kind of JSON-XML element corresponds to a simple JSON value (null, Boolean, number or string).
    static boolean
    isSimple(Element element)
    Returns true if the specified XML element matches a kind of JSON-XML element that corresponds to a simple JSON value (null, Boolean, number or string).
    key()
    Returns the key of this kind of JSON-XML element.
    boolean
    matches(Element element)
    Returns true if the specified XML element matches this kind of JSON-XML element.
    static boolean
    matches(Element element, Iterable<ElementKind> elementKinds)
    Returns true if the specified XML element matches one of the specified kinds of JSON-XML element.
    static boolean
    matches(Element element, ElementKind... elementKinds)
    Returns true if the specified XML element matches one of the specified kinds of JSON-XML element.
    of(Element element)
    Returns the kind of JSON-XML element of the specified XML element.
    ofThrow(Element element)
    Returns the kind of JSON-XML element of the specified XML element.
    Returns the enum constant of this class with the specified name.
    static ElementKind[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • NULL

      public static final ElementKind NULL
      Corresponds to a JSON null value.
    • BOOLEAN

      public static final ElementKind BOOLEAN
      Corresponds to a JSON Boolean value.
    • NUMBER

      public static final ElementKind NUMBER
      Corresponds to a JSON number.
    • STRING

      public static final ElementKind STRING
      Corresponds to a JSON string.
    • ARRAY

      public static final ElementKind ARRAY
      Corresponds to a JSON array.
    • OBJECT

      public static final ElementKind OBJECT
      Corresponds to a JSON object.
  • Field Details

    • SIMPLE_KINDS

      public static final Set<ElementKind> SIMPLE_KINDS
      The kinds of element that correspond to simple JSON values.
    • COMPOUND_KINDS

      public static final Set<ElementKind> COMPOUND_KINDS
      The kinds of element that correspond to compound JSON values.
  • Method Details

    • values

      public static ElementKind[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ElementKind valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • of

      public static ElementKind of(Element element)
      Returns the kind of JSON-XML element of the specified XML element.
      Parameters:
      element - the XML element of interest.
      Returns:
      the kind of JSON-XML element of element, or null if the element is not a JSON-XML element.
    • ofThrow

      public static ElementKind ofThrow(Element element)
      Returns the kind of JSON-XML element of the specified XML element. An exception is thrown if the element is not a JSON-XML element.
      Parameters:
      element - the XML element of interest.
      Returns:
      the kind of JSON-XML element of element.
      Throws:
      ElementKind.UnexpectedKindException - if element is not a JSON-XML element.
    • matches

      public static boolean matches(Element element, ElementKind... elementKinds)
      Returns true if the specified XML element matches one of the specified kinds of JSON-XML element.
      Parameters:
      element - the XML element of interest.
      elementKinds - the kinds of JSON-XML element against which element will be tested.
      Returns:
      true if element matches one of elementKinds; false otherwise.
    • matches

      public static boolean matches(Element element, Iterable<ElementKind> elementKinds)
      Returns true if the specified XML element matches one of the specified kinds of JSON-XML element.
      Parameters:
      element - the XML element of interest.
      elementKinds - the kinds of JSON-XML element against which element will be tested.
      Returns:
      true if element matches one of elementKinds; false otherwise.
    • anyMatch

      public static boolean anyMatch(Element element)
      Returns true if the specified XML element matches any kind of JSON-XML element.
      Parameters:
      element - the XML element of interest.
      Returns:
      true if element matches any kind of JSON-XML element; false otherwise.
    • isSimple

      public static boolean isSimple(Element element)
      Returns true if the specified XML element matches a kind of JSON-XML element that corresponds to a simple JSON value (null, Boolean, number or string).
      Parameters:
      element - the XML element of interest.
      Returns:
      true if element matches a kind of JSON-XML element that corresponds to a simple JSON value (null, Boolean, number or string); false otherwise.
    • isCompound

      public static boolean isCompound(Element element)
      Returns true if the specified XML element matches a kind of JSON-XML element that corresponds to a compound JSON value (array or object).
      Parameters:
      element - the XML element of interest.
      Returns:
      true if element matches a kind of JSON-XML element that corresponds to a compound JSON value (array or object); false otherwise.
    • key

      public String key()
      Returns the key of this kind of JSON-XML element.
      Returns:
      the key of this kind of JSON-XML element.
    • isSimple

      public boolean isSimple()
      Returns true if this kind of JSON-XML element corresponds to a simple JSON value (null, Boolean, number or string).
      Returns:
      true if this kind of JSON-XML element corresponds to a simple JSON value (null, Boolean, number or string); false otherwise.
    • isCompound

      public boolean isCompound()
      Returns true if this kind of JSON-XML element corresponds to a compound JSON value (array or object).
      Returns:
      true if this kind of JSON-XML element corresponds to a compound JSON value (array or object); false otherwise.
    • matches

      public boolean matches(Element element)
      Returns true if the specified XML element matches this kind of JSON-XML element.
      Parameters:
      element - the XML element of interest.
      Returns:
      true if element matches this kind of JSON-XML element; false otherwise.
    • createElement

      public Element createElement(IElementFacade elementFacade)
      Creates and returns a new instance of a JSON-XML element of this kind using the specified facade.
      Parameters:
      elementFacade - the facade through which the JSON-XML element will be created.
      Returns:
      a new instance of a JSON-XML element whose name is derived from the key of this kind of element.