java.lang.Object
com.ardor3d.example.craft.converter.Tag

public class Tag extends Object
NBT IO class
See Also:
  • Constructor Details

    • Tag

      public Tag(Tag.Type type, String name, Tag[] value)
      Create a new TAG_List or TAG_Compound NBT tag.
      Parameters:
      type - either TAG_List or TAG_Compound
      name - name for the new tag or null to create an unnamed tag.
      value - list of tags to add to the new tag.
    • Tag

      public Tag(String name, Tag.Type listType)
      Create a new TAG_List with an empty list. Use addTag(Tag) to add tags later.
      Parameters:
      name - name for this tag or null to create an unnamed tag.
      listType - type of the elements in this empty list.
    • Tag

      public Tag(Tag.Type type, String name, Object value)
      Create a new NBT tag.
      Parameters:
      type - any value from the Tag.Type enum.
      name - name for the new tag or null to create an unnamed tag.
      value - an object that fits the tag type or a Tag.Type to create an empty TAG_List with this list type.
  • Method Details

    • getType

      public Tag.Type getType()
    • getName

      public String getName()
    • getValue

      public Object getValue()
    • getListType

      public Tag.Type getListType()
    • addTag

      public void addTag(Tag tag)
      Add a tag to a TAG_List or a TAG_Compound.
      Parameters:
      tag - the tag to add
    • insertTag

      public void insertTag(Tag tag, int index)
      Add a tag to a TAG_List or a TAG_Compound at the specified index.
      Parameters:
      tag - the tag to insert
      index - the index the index of insertion
    • removeTag

      public Tag removeTag(int index)
      Remove a tag from a TAG_List or a TAG_Compound at the specified index.
      Parameters:
      index - the index the index of removal
      Returns:
      the removed tag
    • removeSubTag

      public void removeSubTag(Tag tag)
      Remove a tag from a TAG_List or a TAG_Compound. If the tag is not a child of this tag then nested tags are searched.
      Parameters:
      tag - tag to look for
    • findTagByName

      public Tag findTagByName(String name)
      Find the first nested tag with specified name in a TAG_Compound.
      Parameters:
      name - the name to look for. May be null to look for unnamed tags.
      Returns:
      the first nested tag that has the specified name.
    • findNextTagByName

      public Tag findNextTagByName(String name, Tag found)
      Find the first nested tag with specified name in a TAG_List or TAG_Compound after a tag with the same name.
      Parameters:
      name - the name to look for. May be null to look for unnamed tags.
      found - the previously found tag with the same name.
      Returns:
      the first nested tag that has the specified name after the previously found tag.
    • readFrom

      public static Tag readFrom(DataInputStream dis) throws IOException
      Read a tag and its nested tags from an InputStream.
      Parameters:
      dis - stream to read from, like a FileInputStream
      Returns:
      NBT tag or structure read from the InputStream
      Throws:
      IOException - if there was no valid NBT structure in the InputStream or if another IOException occurred.
    • writeTo

      public void writeTo(OutputStream os) throws IOException
      Read a tag and its nested tags from an InputStream.
      Parameters:
      os - stream to write to, like a FileOutputStream
      Throws:
      IOException - if this is not a valid NBT structure or if any IOException occurred.
    • print

      public void print()
      Print the NBT structure to System.out