Class TStream<T>
java.lang.Object
com.saicone.rtag.stream.TStream<T>
- Type Parameters:
T- Object type to write and read.
Tag stream class to handle CompoundTag
with writeable and readable objects.
The TStream instance provide easy methods handle objects has bytes.
With bytes you can write to file or convert into Base64 String.
You can read bytes from file or Base64.
The TStream instance provide easy methods handle objects has bytes.
Write
Object -> CompoundTag -> BytesWith bytes you can write to file or convert into Base64 String.
Read
Bytes -> CompoundTag -> ObjectYou can read bytes from file or Base64.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBuild object type using an CompoundTag.Clone provided object by extract CompoundTag and use it to build new object.Extract object information into CompoundTag.voidConsume new objects if it can be created from Tag object.
Only compatible with ByteArrayTag, ListTag and CompoundTag.T[]fromBase64(String base64) Get array of objects by read Base64 string.voidfromBase64(String base64, Consumer<T> consumer) Consume new objects if it can be created from Base64 string.voidfromBukkitObject(byte[] bytes, Consumer<T> consumer) Consume new objects if it can be created from byte array read by BukkitObjectInputStream.fromBytes(byte[] bytes) Get object from bytes.
This method first read the bytes with ByteArrayInputStream to get an CompoundTag and convert it into object.
Bytes -> CompoundTag -> ObjectvoidConsume new objects if it can be created from byte array.
This method detect any CompoundTag inside provided bytes and convert into current instance object using the detected compression format, it is also compatible with any saved object inside ByteArrayTag, ListTag and BukkitObjectInputStream.fromCompound(Object compound) Create new object from CompoundTag.voidfromCompound(Object compound, Consumer<T> consumer) Consume new object if it can be created from CompoundTag.Get object by read provided file.voidConsume new objects if it can be created from file.voidConsume new objects if it can be created from ListTag object.
Only compatible with list types of ByteArrayTag, ListTag and CompoundTag.Get object by read provided Map of objects.fromString(String snbt) Get object by read provided NBT String.listFromBase64(String base64) Get list of objects by read Base64 string.listFromBytes(byte[] bytes) Get list of objects by read byte array.listToBase64(List<T> objects) Convert list of objects into Base64.final StringConvert objects into Base64.byte[]Convert object into bytes.
This method first convert provided object into CompoundTag, then write compound into ByteArrayOutputStream.
Object -> CompoundTag -> BytestoCompound(T object) Convert object into CompoundTag.Write provided object into file.
Provided file must be exist.
This method first convert provided object into CompoundTag, then write compound into FileOutputStream.Convert object into Map of objects.Convert object into NBT String.
-
Field Details
-
COMPOUND
-
-
Constructor Details
-
TStream
public TStream()
-
-
Method Details
-
clone
-
extract
-
build
-
toCompound
-
fromBase
-
fromCompound
-
fromCompound
-
fromList
-
toMap
-
toString
-
toFile
-
toBase64
Convert objects into Base64.- Parameters:
object- Objects to convert.- Returns:
- A Base64 String that represent provided objects.
-
listToBase64
-
toBytes
Convert object into bytes.
This method first convert provided object into CompoundTag, then write compound into ByteArrayOutputStream.
Object -> CompoundTag -> Bytes- Parameters:
object- Object to convert.- Returns:
- A byte array that represent the object.
-
fromMap
-
fromString
-
fromFile
-
fromFile
-
fromBase64
-
fromBase64
-
listFromBase64
-
listFromBytes
-
fromBytes
Get object from bytes.
This method first read the bytes with ByteArrayInputStream to get an CompoundTag and convert it into object.
Bytes -> CompoundTag -> Object- Parameters:
bytes- Bytes to read.- Returns:
- a compound tag converted to object.
-
fromBytes
Consume new objects if it can be created from byte array.
This method detect any CompoundTag inside provided bytes and convert into current instance object using the detected compression format, it is also compatible with any saved object inside ByteArrayTag, ListTag and BukkitObjectInputStream.- Parameters:
bytes- Byte array to read.consumer- The consumer that accept non-null objects.
-
fromBukkitObject
-