@Override public NBTList<NBTRecord> read(final PushBackReader in, final String name) throws IOException { final NBTType type = forTagId(in.readByte()); final int length = in.readInt(); final NBTRecord[] list = new NBTRecord[length]; for (int i = 0; i < length; ++i) { list[i] = type.read(in, null); } return new NBTList<NBTRecord>(name, type, list); }
/** * Returns a type for the id. * * @param tagId The id. * @return The corresponding type. */ public static NBTType forTagId(final int tagId) { if (lookup == null) { lookup = NBTType.values(); int i = lookup.length; while (--i >= 0) { if (lookup[i].byteValue != i) throw new InternalError("check order of NBTType"); } } return lookup[tagId]; }
/** * Reads a record from the stream. * * @param in The stream. * @return The record. * @throws IOException I/O Exception. */ public static final NBTRecord readRecord(final PushBackReader in) throws IOException { final NBTType type = forTagId(in.readByte()); final String name = type == END ? null : in.readString(); return type.read(in, name); }