001 package jp.osdl.jbento2.report; 002 003 import java.io.File; 004 import java.util.regex.Matcher; 005 import java.util.regex.Pattern; 006 007 public class FileMatcher { 008 009 private static Pattern analyzeDirPattern = Pattern.compile(".*_(\\d*)"); 010 011 public static boolean isAnalyzeDir(File f) { 012 Matcher matcher = analyzeDirPattern.matcher(f.getName()); 013 return matcher.matches(); 014 } 015 016 public static int compareAnalyzeDir(String str1, String str2) { 017 int number1 = -1; 018 int number2 = -1; 019 020 Matcher matcher = analyzeDirPattern.matcher(str1); 021 if (matcher.matches()) { 022 number1 = Integer.parseInt(matcher.group(1)); 023 } 024 matcher = analyzeDirPattern.matcher(str2); 025 if (matcher.matches()) { 026 number2 = Integer.parseInt(matcher.group(1)); 027 } 028 029 if (number1 == -1 || number2 == -1) { 030 return str1.compareTo(str2); 031 } 032 033 return number1 - number2; 034 } 035 036 }