Class JsonArrayImpl

java.lang.Object
sk.antons.json.impl.JsonValueImpl
sk.antons.json.impl.JsonArrayImpl
All Implemented Interfaces:
JsonGroup, JsonMember, JsonArray, JsonValue

public class JsonArrayImpl extends JsonValueImpl implements JsonArray, JsonGroup, JsonMember
Author:
antons
  • Constructor Details

    • JsonArrayImpl

      public JsonArrayImpl()
  • Method Details

    • values

      public List<JsonValue> values()
    • toCompactString

      protected void toCompactString(Appendable sb)
      Specified by:
      toCompactString in class JsonValueImpl
    • toPrettyString

      protected void toPrettyString(Appendable sb, String prefix, String indent)
      Specified by:
      toPrettyString in class JsonValueImpl
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: JsonArray
      Checks if this json array contains no value.
      Specified by:
      isEmpty in interface JsonArray
      Returns:
      true if json array is empty.
    • size

      public int size()
      Description copied from interface: JsonArray
      Size of json array.
      Specified by:
      size in interface JsonArray
      Returns:
      size of json array.
    • clear

      public void clear()
      Description copied from interface: JsonArray
      Clears content of json array.
      Specified by:
      clear in interface JsonArray
    • get

      public JsonValue get(int index)
      Description copied from interface: JsonArray
      Reads n'th item from json array.
      Specified by:
      get in interface JsonArray
      Parameters:
      index - order if returned item (first element has index=0)
      Returns:
      element of json array at 'index' position
    • remove

      public JsonValue remove(int index)
      Description copied from interface: JsonArray
      Removes n'th element from json array.
      Specified by:
      remove in interface JsonArray
      Parameters:
      index - position of element in json array which should be removed
      Returns:
      removed element
    • first

      public JsonValue first()
      Description copied from interface: JsonArray
      Reads first element of json array.
      Specified by:
      first in interface JsonArray
      Returns:
      first element of json array or null if array is empty.
    • last

      public JsonValue last()
      Description copied from interface: JsonArray
      Reads last element of json array.
      Specified by:
      last in interface JsonArray
      Returns:
      last element of json array or null if array is empty.
    • add

      public JsonArray add(JsonValue value)
      Description copied from interface: JsonArray
      Adds new element to json array.
      Specified by:
      add in interface JsonArray
      Parameters:
      value - value to be added to the array. Should not be empty
      Returns:
      this json array instance
    • add

      public JsonArray add(JsonValue value, int index)
      Description copied from interface: JsonArray
      Adds new element to json array at specified position.
      Specified by:
      add in interface JsonArray
      Parameters:
      value - value to be added to the array. Should not be empty
      index - position where value should be added;
      Returns:
      this json array instance
    • toList

      public List<JsonValue> toList()
      Description copied from interface: JsonArray
      Converts this instance to regulat list of values.
      Specified by:
      toList in interface JsonArray
      Returns:
      list of json array values.
    • memberIndex

      public int memberIndex(JsonMember m)
      Specified by:
      memberIndex in interface JsonGroup
    • findFirst

      public JsonValue findFirst(PathMatcher matcher, List<String> path)
      Specified by:
      findFirst in class JsonValueImpl
    • findAll

      public void findAll(PathMatcher matcher, List<JsonValue> values, List<String> path)
      Specified by:
      findAll in class JsonValueImpl
    • remove

      public void remove(JsonValue value)
    • replaceBy

      public void replaceBy(JsonValue oldValue, JsonValue newValue)
    • copy

      public JsonValue copy()
      Description copied from interface: JsonValue
      Makes deep copy of this value.
      Specified by:
      copy in interface JsonValue
      Returns:
      copy of this
    • asTemplateParam

      public Object asTemplateParam()
      Description copied from interface: JsonValue
      Converts value to value usable for some template frameworks. - JsonObjects is converted to read only Map - JsonArray is converted to read only List - JsonLiteral is converted to its java value
      Specified by:
      asTemplateParam in interface JsonValue
      Returns:
      template parameter form of this value