/*
 * This file is part of libbluray
 * Copyright (C) 2010  William Hahne
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see
 * <http://www.gnu.org/licenses/>.
 */

package org.videolan;

import java.text.DecimalFormat;

public class BDJUtil {
    /**
     * Make a five digit zero padded string based on an integer
     * Ex. integer 1 -> string "00001"
     * 
     * @param id
     * @return
     */
    public static String makeFiveDigitStr(int id) 
    {
        DecimalFormat fmt = new DecimalFormat();
        fmt.setMaximumIntegerDigits(5);
        fmt.setMinimumIntegerDigits(5);
        fmt.setGroupingUsed(false);
        
        return fmt.format(id);
    }
    
    /**
     * Make a path based on the disc root to an absolute path based on the filesystem of the computer
     * Ex. /BDMV/JAR/00000.jar -> /bluray/disc/mount/point/BDMV/JAR/00000.jar
     * @param path
     * @return
     */
    public static String discRootToFilesystem(String path)
    {
        String vfsRoot = System.getProperty("bluray.vfs.root");
        if (vfsRoot == null) {
            System.err.println("discRootToFilesystem(): disc root not set !");
            return path;
        }
        return vfsRoot + path;
    }
}

@@ -942,17 +942,16 @@
 %22%0A     *
- 
 %0A     * 
@@ -1036,16 +1036,307 @@
  id)
- 
 %0A    %7B%0A
+        if (id %3C 0 %7C%7C id %3E 99999) %7B%0A            System.err.println(%22Invalid ID: %22 + id);%0A            throw new IllegalArgumentException(%22Invalid ID %22 + id);%0A        %7D%0A        String s = %22%22 + id;%0A        while (s.length() %3C 5) %7B%0A            s = %220%22 + s;%0A        %7D%0A        return s;%0A        /*%0A
     
@@ -1496,24 +1496,16 @@
 false);%0A
-        
 %0A       
@@ -1528,26 +1528,33 @@
 at(id);%0A
+        */%0A
     %7D%0A
-    
 %0A    /**

check range. Avoid using DecimalFormat.