示例#1
0
        /** Peek into the parentInput's input stream and if the next item
         * is a NIFF String Table, then decode it and store it in the
         * root RIFFForNIFF object.
         * If the next item is not a NIFF String Table, do nothing
         * and leave the input stream unchanged.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream.
         *        If parentInput.getParent() is not of type RIFFForNIFF, then this
         *        moves the input past the String Table but does not store it.
         * @return true if the String Table was processed, false if this is
         *         not a String Table.
         */
        static public bool maybeDecode(Riff parentInput)
        {
            if (!parentInput.peekFOURCC().Equals(RIFF_ID))
            {
                return(false);
            }

            Riff riffInput = new Riff(parentInput, RIFF_ID);

            if (!(parentInput.getParent() is RiffForNiff))
            {
                // There is no place to store the data
                riffInput.skipRemaining();
                return(true);
            }
            RiffForNiff riffForNiff = (RiffForNiff)parentInput.getParent();

            // Read the entire string table into a byte array
            byte[] stringTable = new byte[riffInput.getBytesRemaining()];
            for (int i = 0; i < stringTable.Length; ++i)
            {
                stringTable[i] = (byte)riffInput.readBYTE();
            }
            riffForNiff.setStringTable(stringTable);

            // This skips possible pad byte
            riffInput.skipRemaining();

            return(true);
        }
示例#2
0
        /** This is a static method to find the parent of riff which is
         * a RIFFForNIFF and return its getStringTable().
         *
         * @param riff   this, or one of its parents going up the chain
         *      should be an is RIFFForNIFF
         * @return the getStringTable() from the first parent or riff
         *      which is a RIFFForNIFF, or return a zero length byte array
         *      if there is no such parent.
         */
        public static byte[] getStringTable(Riff riff)
        {
            while (riff != null) {
            if (riff is RiffForNiff)
              return ((RiffForNiff)riff).getStringTable();
            riff = riff.getParent();
              }

              return new byte[0];
        }
示例#3
0
        /** This is a static method to find the parent of riff which is
         * a RIFFForNIFF and return its getStringTable().
         *
         * @param riff   this, or one of its parents going up the chain
         *      should be an is RIFFForNIFF
         * @return the getStringTable() from the first parent or riff
         *      which is a RIFFForNIFF, or return a zero length byte array
         *      if there is no such parent.
         */
        static public byte[] getStringTable(Riff riff)
        {
            while (riff != null)
            {
                if (riff is RiffForNiff)
                {
                    return(((RiffForNiff)riff).getStringTable());
                }
                riff = riff.getParent();
            }

            return(new byte[0]);
        }
示例#4
0
        /** Peek into the parentInput's input stream and if the next item
         * is a NIFF String Table, then decode it and store it in the
         * root RIFFForNIFF object.
         * If the next item is not a NIFF String Table, do nothing
         * and leave the input stream unchanged.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream.
         *        If parentInput.getParent() is not of type RIFFForNIFF, then this
         *        moves the input past the String Table but does not store it.
         * @return true if the String Table was processed, false if this is
         *         not a String Table.
         */
        public static bool maybeDecode(Riff parentInput)
        {
            if (!parentInput.peekFOURCC().Equals(RIFF_ID))
            return false;

              Riff riffInput = new Riff(parentInput, RIFF_ID);

              if (!(parentInput.getParent() is RiffForNiff)) {
            // There is no place to store the data
            riffInput.skipRemaining();
            return true;
              }
              RiffForNiff riffForNiff = (RiffForNiff)parentInput.getParent();

              // Read the entire string table into a byte array
              byte[] stringTable = new byte[riffInput.getBytesRemaining()];
              for (int i = 0; i < stringTable.Length; ++i)
            stringTable[i] = (byte)riffInput.readBYTE();
              riffForNiff.setStringTable(stringTable);

              // This skips possible pad byte
              riffInput.skipRemaining();

              return true;
        }