Class TagBase

java.lang.Object
com.saicone.rtag.tag.TagBase

public class TagBase extends Object
Class to invoke methods inside classes that extends Tag.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Clear the provided CompoundTag or ListTag.
    static Object
    Copy provided Tag object into new one.
    static byte
    Get current tag type ID.
    Byte = 1 | Short = 2 | Int = 3 | Long = 4 | Float = 5 | Double = 6 | ByteArray = 7 | String = 8 | List = 9 | Compound = 10 | IntArray = 11 | LongArray = 12
    static Object
    getValue(RtagMirror mirror, Object tag)
    Get Java value recursively of any Tag tag.
    For example CompoundTag -> Map.
    static Object
    Get Java value of Tag tag.
    For example StringTag -> String.
    static boolean
    isTag(Object object)
    Check if the provided object is instance of Tag class.
    static boolean
    isTypeOf(Object tag, byte type)
    Check if Tag object type is equals to provided type id.
    static boolean
    isTypeOf(Object tag1, Object tag2)
    Check if two Tag objects has the same type.
    static Object
    newTag(RtagMirror mirror, Object object)
    Constructs a Tag recursively with provided object.
    For example List -> ListTag
    static Object
    newTag(Object object)
    Constructs a Tag directly associated with Java object.
    For example Float -> FloatTag
    static int
    size(Object tag)
    Get the size of elements inside CompoundTag or ListTag.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • newTag

      public static Object newTag(Object object) throws IllegalArgumentException
      Constructs a Tag directly associated with Java object.
      For example Float -> FloatTag
      Parameters:
      object - java object that can be represented as Tag.
      Returns:
      a Tag associated with provided object.
      Throws:
      IllegalArgumentException - if the object is not supported by this method.
      See Also:
    • newTag

      public static Object newTag(RtagMirror mirror, Object object) throws IllegalArgumentException
      Constructs a Tag recursively with provided object.
      For example List -> ListTag
      Parameters:
      mirror - RtagMirror to convert objects into tags.
      object - Object that can be represented as Tag.
      Returns:
      a Tag associated with provided object.
      Throws:
      IllegalArgumentException - if the object is not supported.
    • isTag

      public static boolean isTag(Object object)
      Check if the provided object is instance of Tag class.
      Parameters:
      object - the object to check.
      Returns:
      true if the object is an instance of Tag class.
    • isTypeOf

      public static boolean isTypeOf(Object tag, byte type)
      Check if Tag object type is equals to provided type id.
      Parameters:
      tag - the Tag object to check.
      type - the nbt type id.
      Returns:
      true if Tag type is equals.
    • isTypeOf

      public static boolean isTypeOf(Object tag1, Object tag2)
      Check if two Tag objects has the same type.
      Parameters:
      tag1 - the first Tag object to check.
      tag2 - the second Tag object to check.
      Returns:
      true if the two Tag type are equals.
    • clone

      public static Object clone(Object tag)
      Copy provided Tag object into new one.
      Parameters:
      tag - the Tag to copy.
      Returns:
      a Tag with the same value.
    • getTypeId

      public static byte getTypeId(Object tag)
      Get current tag type ID.
      Byte = 1 | Short = 2 | Int = 3 | Long = 4 | Float = 5 | Double = 6 | ByteArray = 7 | String = 8 | List = 9 | Compound = 10 | IntArray = 11 | LongArray = 12
      Parameters:
      tag - TagBase instance to get the ID.
      Returns:
      An ID that represents the tag type.
    • getValue

      public static Object getValue(Object tag) throws IllegalArgumentException
      Get Java value of Tag tag.
      For example StringTag -> String.
      Parameters:
      tag - the Tag to extract value.
      Returns:
      a java object inside Tag tag.
      Throws:
      IllegalArgumentException - if tag is not supported by this class.
      See Also:
    • getValue

      public static Object getValue(RtagMirror mirror, Object tag) throws IllegalArgumentException
      Get Java value recursively of any Tag tag.
      For example CompoundTag -> Map.
      Parameters:
      mirror - RtagMirror to convert objects into tags.
      tag - Tag to extract value.
      Returns:
      a java object represented as Tag.
      Throws:
      IllegalArgumentException - if tag is not supported.
    • size

      public static int size(Object tag)
      Get the size of elements inside CompoundTag or ListTag.
      Parameters:
      tag - the Tag instance.
      Returns:
      size of map or list inside.
    • clear

      public static void clear(Object tag)
      Clear the provided CompoundTag or ListTag.
      Parameters:
      tag - the Tag instance.