Esempio n. 1
0
        /* [Section 30.6, MIL-C-89038] */
        /* [Section A.3.6, MIL-PRF-89041A] */
        public static RPFFrameFilename parseFilename(String filename)
        {
            if (filename == null)
            {
                String message = Logging.getMessage("nullValue.StringIsNull");
                Logging.logger().fine(message);
                throw new ArgumentException(message);
            }
            if (filename.length() != FILENAME_LENGTH)
            {
                String message = Logging.getMessage("RPFFrameFilename.BadFilenameLength", filename);
                Logging.logger().fine(message);
                throw new RPFFrameFilenameFormatException(message);
            }

            char[] buffer = new char[FILENAME_LENGTH];
            filename.getChars(0, FILENAME_LENGTH, buffer, 0);

            char   producerId     = buffer[7];
            String dataSeriesCode = filename.substring(9, 11);
            char   zoneCode       = buffer[11];

            // Default to CADRG filename structure.
            int frameChars   = 5;
            int versionChars = 2;

            if (RPFDataSeries.isCIBDataSeries(dataSeriesCode))
            {
                frameChars   = 6;
                versionChars = 1;
            }

            int frameNumber;
            int version;

            try
            {
                frameNumber = Base34Converter.parseChars(buffer, 0, frameChars);
                version     = Base34Converter.parseChars(buffer, frameChars, versionChars);
            }
            catch (ArgumentException e)
            {
                String message = Logging.getMessage("RPFFrameFilename.IntegerNotParsed");
                Logging.logger().fine(message);
                throw new RPFFrameFilenameFormatException(message, e);
            }

            return(new RPFFrameFilename(dataSeriesCode, frameNumber, producerId, version, zoneCode));
        }
Esempio n. 2
0
        public static bool isFilename(String str)
        {
            if (str == null)
            {
                String message = Logging.getMessage("nullValue.StringIsNull");
                Logging.logger().fine(message);
                throw new ArgumentException(message);
            }

            if (str.length() != FILENAME_LENGTH)
            {
                return(false);
            }

            char[] buffer = new char[FILENAME_LENGTH];
            str.getChars(0, 12, buffer, 0);

            if (!Base34Converter.isBase34(buffer, 0, 7))
            {
                return(false);
            }
            if (!RPFProducer.isProducerId(buffer[7]))
            {
                return(false);
            }
            if ('.' != buffer[8])
            {
                return(false);
            }
            String seriesCode = str.substring(9, 11);

            if (!RPFDataSeries.isDataSeriesCode(seriesCode))
            {
                return(false);
            }
            //noinspection RedundantIfStatement
            if (!RPFZone.isZoneCode(buffer[11]))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        /* [Section 30.6, MIL-C-89038] */
        /* [Section A.3.6, MIL-PRF-89041A] */
        private static void toCharArray(RPFFrameFilename frameFilename, char[] dest)
        {
            // Default to CARDG filename strucutre.
            int frameChars   = 5;
            int versionChars = 2;

            if (RPFDataSeries.isCIBDataSeries(frameFilename.dataSeriesCode))
            {
                frameChars   = 6;
                versionChars = 1;
            }

            Base34Converter.valueOf(frameFilename.frameNumber, dest, 0, frameChars);
            Base34Converter.valueOf(frameFilename.version, dest, frameChars, versionChars);
            dest[7] = frameFilename.producerId;
            dest[8] = '.';
            frameFilename.dataSeriesCode.getChars(0, 2, dest, 9);
            dest[11] = frameFilename.zoneCode;
        }