id
int32
0
12.9k
code
sequencelengths
2
264k
900
[ "<s>", "package", "net", ".", "muteheadlight", ".", "docksoundredir", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "net", ".", "muteheadlight", ".", "dockredir", ".", "R", ";", "import", "android", ".", "app", ".", "ListActivity", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "content", ".", "pm", ".", "PackageInfo", ";", "import", "android", ".", "content", ".", "pm", ".", "PackageManager", ".", "NameNotFoundException", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "View", ".", "OnClickListener", ";", "import", "android", ".", "widget", ".", "ArrayAdapter", ";", "import", "android", ".", "widget", ".", "Button", ";", "import", "android", ".", "widget", ".", "TextView", ";", "import", "android", ".", "widget", ".", "ToggleButton", ";", "public", "class", "dsrListView", "extends", "ListActivity", "{", "public", "void", "onCreate", "(", "Bundle", "icicle", ")", "{", "super", ".", "onCreate", "(", "icicle", ")", ";", "if", "(", "dockRedirCentral", ".", "imSupported", "(", "this", ",", "true", ")", ")", "{", "dockRedirCentral", ".", "warmUp", "(", "this", ")", ";", "dockRedirCentral", ".", "getDockDeviceNumber", "(", "getApplicationContext", "(", ")", ")", ";", "setContentView", "(", "R", ".", "layout", ".", "main", ")", ";", "TextView", "ver", "=", "(", "TextView", ")", "findViewById", "(", "R", ".", "id", ".", "app_info", ")", ";", "try", "{", "PackageInfo", "packageInfo", "=", "getPackageManager", "(", ")", ".", "getPackageInfo", "(", "getPackageName", "(", ")", ",", "0", ")", ";", "ver", ".", "append", "(", "packageInfo", ".", "versionName", ")", ";", "}", "catch", "(", "NameNotFoundException", "e", ")", "{", "ver", ".", "append", "(", "\"unknown\"", ")", ";", "}", "final", "ToggleButton", "redir1", "=", "(", "ToggleButton", ")", "findViewById", "(", "R", ".", "id", ".", "toggleRedir", ")", ";", "redir1", ".", "setOnClickListener", "(", "new", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "final", "ToggleButton", "redir1", "=", "(", "ToggleButton", ")", "findViewById", "(", "R", ".", "id", ".", "toggleRedir", ")", ";", "Intent", "intent1", "=", "new", "Intent", "(", ")", ";", "intent1", ".", "setAction", "(", "\"\"", ")", ";", "if", "(", "redir1", ".", "isChecked", "(", ")", ")", "{", "intent1", ".", "putExtra", "(", "\"\"", ",", "1", ")", ";", "}", "else", "{", "intent1", ".", "putExtra", "(", "\"\"", ",", "0", ")", ";", "}", "sendBroadcast", "(", "intent1", ")", ";", "}", "}", ")", ";", "SharedPreferences", "settings", "=", "getSharedPreferences", "(", "dockRedirCentral", ".", "PREFS_NAME", ",", "0", ")", ";", "redir1", ".", "setEnabled", "(", "settings", ".", "getBoolean", "(", "\"_docked\"", ",", "false", ")", ")", ";", "redir1", ".", "setChecked", "(", "settings", ".", "getBoolean", "(", "\"_redirected\"", ",", "false", ")", ")", ";", "final", "Button", "supReq", "=", "(", "Button", ")", "findViewById", "(", "R", ".", "id", ".", "supportButton", ")", ";", "supReq", ".", "setOnClickListener", "(", "dockRedirCentral", ".", "onSupClick", "(", ")", ")", ";", "ArrayAdapter", "<", "Setting", ">", "adapter", "=", "new", "InteractiveArrayAdapter", "(", "this", ",", "listSettings", "(", ")", ")", ";", "setListAdapter", "(", "adapter", ")", ";", "}", "else", "{", "Log", ".", "i", "(", "dockRedirCentral", ".", "getTag", "(", ")", ",", "\"\"", ")", ";", "setContentView", "(", "R", ".", "layout", ".", "unsupported", ")", ";", "}", "}", "@", "Override", "public", "void", "onResume", "(", ")", "{", "super", ".", "onStart", "(", ")", ";", "if", "(", "dockRedirCentral", ".", "imSupported", "(", "this", ",", "true", ")", ")", "{", "SharedPreferences", "settings", "=", "getSharedPreferences", "(", "dockRedirCentral", ".", "PREFS_NAME", ",", "0", ")", ";", "boolean", "_docked", "=", "settings", ".", "getBoolean", "(", "\"_docked\"", ",", "false", ")", ";", "boolean", "_redirected", "=", "settings", ".", "getBoolean", "(", "\"_redirected\"", ",", "false", ")", ";", "final", "ToggleButton", "redir1", "=", "(", "ToggleButton", ")", "findViewById", "(", "R", ".", "id", ".", "toggleRedir", ")", ";", "redir1", ".", "setEnabled", "(", "_docked", ")", ";", "redir1", ".", "setChecked", "(", "_redirected", ")", ";", "}", "}", "private", "List", "<", "Setting", ">", "listSettings", "(", ")", "{", "List", "<", "Setting", ">", "list", "=", "new", "ArrayList", "<", "Setting", ">", "(", ")", ";", "String", "[", "]", "settingKeys", "=", "getResources", "(", ")", ".", "getStringArray", "(", "R", ".", "array", ".", "checks_keys", ")", ";", "String", "[", "]", "settingTexts", "=", "getResources", "(", ")", ".", "getStringArray", "(", "R", ".", "array", ".", "checks", ")", ";", "int", "x", "=", "0", ";", "for", "(", "String", "settingText", ":", "settingTexts", ")", "{", "list", ".", "add", "(", "new", "Setting", "(", "settingText", ",", "settingKeys", "[", "x", "]", ",", "getApplicationContext", "(", ")", ")", ")", ";", "if", "(", "settingKeys", "[", "x", "]", ".", "contentEquals", "(", "\"fallback\"", ")", ")", "{", "if", "(", "!", "dockRedirCentral", ".", "imSupported", "(", "getApplicationContext", "(", ")", ")", ")", "{", "Setting", "fallback", "=", "list", ".", "get", "(", "x", ")", ";", "fallback", ".", "setDisabled", "(", "true", ")", ";", "list", ".", "set", "(", "x", ",", "fallback", ")", ";", "}", "}", "x", "++", ";", "}", "return", "list", ";", "}", "}", "</s>" ]
901
[ "<s>", "package", "net", ".", "muteheadlight", ".", "docksoundredir", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "public", "class", "Setting", "{", "private", "String", "text", ";", "private", "String", "key", ";", "private", "static", "Context", "context", ";", "private", "boolean", "disabled", ";", "public", "Setting", "(", "String", "text", ",", "String", "key", ",", "Context", "context", ")", "{", "this", ".", "text", "=", "text", ";", "this", ".", "key", "=", "key", ";", "Setting", ".", "context", "=", "context", ";", "disabled", "=", "false", ";", "}", "public", "String", "getText", "(", ")", "{", "return", "text", ";", "}", "public", "void", "setText", "(", "String", "text", ")", "{", "this", ".", "text", "=", "text", ";", "}", "public", "boolean", "getChecked", "(", ")", "{", "SharedPreferences", "settings", "=", "context", ".", "getSharedPreferences", "(", "dockRedirCentral", ".", "PREFS_NAME", ",", "0", ")", ";", "return", "settings", ".", "getBoolean", "(", "key", ",", "false", ")", ";", "}", "public", "void", "setChecked", "(", "boolean", "selected", ")", "{", "SharedPreferences", "settings", "=", "context", ".", "getSharedPreferences", "(", "dockRedirCentral", ".", "PREFS_NAME", ",", "0", ")", ";", "SharedPreferences", ".", "Editor", "editor", "=", "settings", ".", "edit", "(", ")", ";", "editor", ".", "putBoolean", "(", "key", ",", "selected", ")", ";", "editor", ".", "commit", "(", ")", ";", "dockRedirCentral", ".", "logD", "(", "key", ".", "concat", "(", "\"\"", ")", ".", "concat", "(", "String", ".", "valueOf", "(", "selected", ")", ")", ")", ";", "}", "public", "boolean", "isDisabled", "(", ")", "{", "return", "disabled", ";", "}", "public", "void", "setDisabled", "(", "boolean", "disabled", ")", "{", "this", ".", "disabled", "=", "disabled", ";", "}", "}", "</s>" ]
902
[ "<s>", "package", "net", ".", "muteheadlight", ".", "docksoundredir", ".", "widget", ";", "import", "net", ".", "muteheadlight", ".", "dockredir", ".", "R", ";", "import", "net", ".", "muteheadlight", ".", "docksoundredir", ".", "dockRedirCentral", ";", "import", "android", ".", "app", ".", "PendingIntent", ";", "import", "android", ".", "appwidget", ".", "AppWidgetManager", ";", "import", "android", ".", "appwidget", ".", "AppWidgetProvider", ";", "import", "android", ".", "content", ".", "ComponentName", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "widget", ".", "RemoteViews", ";", "public", "class", "RedirWidget", "extends", "AppWidgetProvider", "{", "@", "Override", "public", "void", "onUpdate", "(", "Context", "context", ",", "AppWidgetManager", "appWidgetManager", ",", "int", "[", "]", "appWidgetIds", ")", "{", "dockRedirCentral", ".", "logD", "(", "\"\"", ")", ";", "Intent", "i", "=", "new", "Intent", "(", ")", ";", "i", ".", "setAction", "(", "\"\"", ")", ";", "PendingIntent", "x", "=", "PendingIntent", ".", "getBroadcast", "(", "context", ",", "0", ",", "i", ",", "PendingIntent", ".", "FLAG_UPDATE_CURRENT", ")", ";", "RemoteViews", "view", "=", "new", "RemoteViews", "(", "context", ".", "getPackageName", "(", ")", ",", "R", ".", "layout", ".", "widget", ")", ";", "view", ".", "setOnClickPendingIntent", "(", "R", ".", "id", ".", "widgetButton", ",", "x", ")", ";", "appWidgetManager", ".", "updateAppWidget", "(", "new", "ComponentName", "(", "context", ",", "RedirWidget", ".", "class", ")", ",", "view", ")", ";", "}", "}", "</s>" ]
903
[ "<s>", "package", "net", ".", "muteheadlight", ".", "docksoundredir", ";", "import", "java", ".", "io", ".", "BufferedWriter", ";", "import", "java", ".", "io", ".", "FileWriter", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "lang", ".", "reflect", ".", "Method", ";", "import", "android", ".", "content", ".", "BroadcastReceiver", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "media", ".", "AudioManager", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "widget", ".", "Toast", ";", "public", "class", "dockSoundRedirect", "extends", "BroadcastReceiver", "{", "private", "static", "final", "int", "DEVICE_OUT_WIRED_HEADPHONE", "=", "0x8", ";", "private", "Context", "_context", ";", "@", "Override", "public", "void", "onReceive", "(", "Context", "context", ",", "Intent", "intent", ")", "{", "_context", "=", "context", ";", "String", "intentAction", "=", "intent", ".", "getAction", "(", ")", ";", "SharedPreferences", "settings", "=", "_context", ".", "getSharedPreferences", "(", "dockRedirCentral", ".", "PREFS_NAME", ",", "0", ")", ";", "dockRedirCentral", ".", "logD", "(", "\"\"", "+", "intentAction", ")", ";", "SharedPreferences", ".", "Editor", "editor", "=", "settings", ".", "edit", "(", ")", ";", "editor", ".", "putString", "(", "\"_lastIntent\"", ",", "intentAction", ")", ";", "editor", ".", "commit", "(", ")", ";", "boolean", "carRedir", "=", "settings", ".", "getBoolean", "(", "\"carRedir\"", ",", "true", ")", ";", "boolean", "deskRedir", "=", "settings", ".", "getBoolean", "(", "\"deskRedir\"", ",", "true", ")", ";", "boolean", "useKernel", "=", "settings", ".", "getBoolean", "(", "\"_useKernel\"", ",", "false", ")", ";", "boolean", "showToast", "=", "settings", ".", "getBoolean", "(", "\"showToast\"", ",", "true", ")", ";", "boolean", "_docked", "=", "settings", ".", "getBoolean", "(", "\"_docked\"", ",", "false", ")", ";", "boolean", "screenOn", "=", "settings", ".", "getBoolean", "(", "\"screenOn\"", ",", "false", ")", ";", "boolean", "fallback", "=", "settings", ".", "getBoolean", "(", "\"fallback\"", ",", "false", ")", ";", "boolean", "mediaVolume", "=", "false", ";", "try", "{", "mediaVolume", "=", "settings", ".", "getBoolean", "(", "\"mediaVolume\"", ",", "false", ")", ";", "}", "catch", "(", "ClassCastException", "e", ")", "{", "editor", ".", "remove", "(", "\"mediaVolume\"", ")", ".", "putBoolean", "(", "\"mediaVolume\"", ",", "true", ")", ";", "editor", ".", "commit", "(", ")", ";", "}", "int", "_mediaVolume", "=", "settings", ".", "getInt", "(", "\"_mediaVolume\"", ",", "-", "1", ")", ";", "int", "_deviceNum", "=", "settings", ".", "getInt", "(", "\"_deviceNum\"", ",", "0x0000", ")", ";", "if", "(", "intent", ".", "getAction", "(", ")", ".", "compareTo", "(", "Intent", ".", "ACTION_BOOT_COMPLETED", ")", "==", "0", "||", "intent", ".", "getAction", "(", ")", ".", "compareTo", "(", "Intent", ".", "ACTION_PACKAGE_REPLACED", ")", "==", "0", ")", "{", "dockRedirCentral", ".", "logD", "(", "\"\"", "+", "intent", ".", "getAction", "(", ")", ")", ";", "if", "(", "dockRedirCentral", ".", "imSupported", "(", "_context", ",", "true", ")", ")", "{", "editor", ".", "putBoolean", "(", "\"_useKernel\"", ",", "dockRedirCentral", ".", "useKernel", "(", ")", ")", ";", "dockRedirCentral", ".", "warmUp", "(", "_context", ")", ";", "_deviceNum", "=", "dockRedirCentral", ".", "getDockDeviceNumber", "(", "_context", ")", ";", "}", "}", "else", "{", "if", "(", "!", "dockRedirCentral", ".", "imSupported", "(", "_context", ",", "true", ")", ")", "return", ";", "int", "dockstate", ";", "if", "(", "intent", ".", "getAction", "(", ")", ".", "contains", "(", "\"WIDGET\"", ")", ")", "{", "dockRedirCentral", ".", "logD", "(", "\"\"", ")", ";", "if", "(", "!", "settings", ".", "getBoolean", "(", "\"_redirected\"", ",", "false", ")", "&&", "_docked", ")", "{", "dockstate", "=", "10", ";", "}", "else", "{", "dockstate", "=", "0", ";", "}", "}", "else", "{", "dockstate", "=", "intent", ".", "getIntExtra", "(", "\"\"", ",", "0", ")", ";", "}", "editor", ".", "putString", "(", "\"_lastIntent\"", ",", "settings", ".", "getString", "(", "\"_lastIntent\"", ",", "\"None\"", ")", ".", "concat", "(", "\"", "-", "devID:", "\"", "+", "dockstate", ")", ")", ";", "if", "(", "(", "dockstate", "==", "1", "||", "dockstate", "==", "2", ")", "&&", "_docked", "&&", "(", "intent", ".", "getAction", "(", ")", ".", "compareTo", "(", "\"\"", ")", "!=", "0", ")", "&&", "!", "intent", ".", "getAction", "(", ")", ".", "contains", "(", "\"WIDGET\"", ")", ")", "return", ";", "if", "(", "dockstate", "==", "0", "&&", "!", "_docked", ")", "return", ";", "CharSequence", "text", "=", "\"\"", ";", "if", "(", "dockstate", ">", "0", ")", "{", "if", "(", "(", "dockstate", "==", "2", "&", "carRedir", ")", "||", "(", "dockstate", "==", "1", "&&", "deskRedir", ")", "||", "(", "intent", ".", "getAction", "(", ")", ".", "compareTo", "(", "\"\"", ")", "==", "0", ")", "||", "intent", ".", "getAction", "(", ")", ".", "contains", "(", "\"WIDGET\"", ")", ")", "{", "if", "(", "!", "fallback", ")", "{", "redirectConnectionState", "(", "_deviceNum", ",", "1", ")", ";", "}", "else", "{", "if", "(", "useKernel", ")", "redirectKernel", "(", "1", ")", ";", "else", "redirectSamsung", "(", "1", ")", ";", "}", "if", "(", "screenOn", ")", "{", "try", "{", "dockRedirCentral", ".", "mWakeLock", ".", "acquire", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Log", ".", "d", "(", "dockRedirCentral", ".", "getTag", "(", ")", ",", "\"\"", ")", ";", "}", "}", "if", "(", "mediaVolume", ")", "{", "AudioManager", "audioManager", "=", "(", "AudioManager", ")", "_context", ".", "getSystemService", "(", "Context", ".", "AUDIO_SERVICE", ")", ";", "editor", ".", "putInt", "(", "\"_mediaVolume\"", ",", "audioManager", ".", "getStreamVolume", "(", "AudioManager", ".", "STREAM_MUSIC", ")", ")", ";", "audioManager", ".", "setStreamVolume", "(", "AudioManager", ".", "STREAM_MUSIC", ",", "audioManager", ".", "getStreamMaxVolume", "(", "AudioManager", ".", "STREAM_MUSIC", ")", ",", "AudioManager", ".", "FLAG_SHOW_UI", ")", ";", "}", "text", "=", "\"\"", ";", "editor", ".", "putBoolean", "(", "\"_redirected\"", ",", "true", ")", ";", "}", "if", "(", "intent", ".", "getAction", "(", ")", ".", "compareTo", "(", "\"\"", ")", "!=", "0", "&&", "!", "intent", ".", "getAction", "(", ")", ".", "contains", "(", "\"WIDGET\"", ")", ")", "editor", ".", "putBoolean", "(", "\"_docked\"", ",", "true", ")", ";", "}", "else", "{", "if", "(", "intent", ".", "getAction", "(", ")", ".", "compareTo", "(", "\"\"", ")", "!=", "0", "&&", "!", "intent", ".", "getAction", "(", ")", ".", "contains", "(", "\"WIDGET\"", ")", ")", "editor", ".", "putBoolean", "(", "\"_docked\"", ",", "false", ")", ";", "Intent", "intent1", "=", "new", "Intent", "(", "AudioManager", ".", "ACTION_AUDIO_BECOMING_NOISY", ")", ";", "_context", ".", "sendBroadcast", "(", "intent1", ")", ";", "if", "(", "!", "fallback", ")", "{", "redirectConnectionState", "(", "_deviceNum", ",", "0", ")", ";", "}", "else", "{", "if", "(", "useKernel", ")", "redirectKernel", "(", "0", ")", ";", "else", "redirectSamsung", "(", "0", ")", ";", "}", "if", "(", "screenOn", ")", "{", "try", "{", "if", "(", "dockRedirCentral", ".", "mWakeLock", ".", "isHeld", "(", ")", ")", "dockRedirCentral", ".", "mWakeLock", ".", "release", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Log", ".", "d", "(", "dockRedirCentral", ".", "getTag", "(", ")", ",", "\"\"", ")", ";", "}", "}", "if", "(", "mediaVolume", ")", "{", "AudioManager", "audioManager", "=", "(", "AudioManager", ")", "_context", ".", "getSystemService", "(", "Context", ".", "AUDIO_SERVICE", ")", ";", "audioManager", ".", "setStreamVolume", "(", "AudioManager", ".", "STREAM_MUSIC", ",", "_mediaVolume", ",", "AudioManager", ".", "FLAG_SHOW_UI", ")", ";", "}", "text", "=", "\"\"", ";", "editor", ".", "putBoolean", "(", "\"_redirected\"", ",", "false", ")", ";", "}", "int", "duration", "=", "Toast", ".", "LENGTH_SHORT", ";", "if", "(", "showToast", ")", "{", "Toast", "toast", "=", "Toast", ".", "makeText", "(", "_context", ",", "text", ",", "duration", ")", ";", "toast", ".", "show", "(", ")", ";", "}", "editor", ".", "commit", "(", ")", ";", "dockRedirCentral", ".", "logD", "(", "(", "String", ")", "text", ")", ";", "}", "}", "private", "void", "redirectSamsung", "(", "int", "enable", ")", "{", "Intent", "intent1", "=", "new", "Intent", "(", ")", ";", "intent1", ".", "setAction", "(", "\"\"", ")", ";", "intent1", ".", "putExtra", "(", "\"state\"", ",", "enable", ")", ";", "_context", ".", "sendBroadcast", "(", "intent1", ")", ";", "dockRedirCentral", ".", "logD", "(", "\"\"", ")", ";", "}", "private", "void", "redirectKernel", "(", "int", "enable", ")", "{", "try", "{", "BufferedWriter", "writer", "=", "new", "BufferedWriter", "(", "new", "FileWriter", "(", "\"\"", ")", ",", "256", ")", ";", "try", "{", "writer", ".", "write", "(", "Integer", ".", "toString", "(", "enable", ")", ")", ";", "}", "finally", "{", "writer", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "dockRedirCentral", ".", "logD", "(", "e", ".", "toString", "(", ")", ")", ";", "}", "setDeviceConnectionState", "(", "DEVICE_OUT_WIRED_HEADPHONE", ",", "enable", ",", "\"\"", ")", ";", "dockRedirCentral", ".", "logD", "(", "\"\"", ")", ";", "}", "private", "void", "redirectConnectionState", "(", "int", "_deviceNum", ",", "int", "enable", ")", "{", "if", "(", "_deviceNum", "==", "0x0000", ")", "{", "_deviceNum", "=", "dockRedirCentral", ".", "getDockDeviceNumber", "(", "_context", ")", ";", "}", "setDeviceConnectionState", "(", "_deviceNum", ",", "enable", ",", "\"\"", ")", ";", "dockRedirCentral", ".", "logD", "(", "\"\"", "+", "String", ".", "valueOf", "(", "_deviceNum", ")", ")", ";", "}", "private", "void", "setDeviceConnectionState", "(", "final", "int", "device", ",", "final", "int", "state", ",", "final", "String", "address", ")", "{", "try", "{", "Class", "<", "?", ">", "audioSystem", "=", "Class", ".", "forName", "(", "\"\"", ")", ";", "Method", "setDeviceConnectionState", "=", "audioSystem", ".", "getMethod", "(", "\"\"", ",", "int", ".", "class", ",", "int", ".", "class", ",", "String", ".", "class", ")", ";", "setDeviceConnectionState", ".", "invoke", "(", "audioSystem", ",", "device", ",", "state", ",", "address", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "dockRedirCentral", ".", "logD", "(", "\"\"", "+", "e", ")", ";", "}", "}", "}", "</s>" ]
904
[ "<s>", "package", "net", ".", "muteheadlight", ".", "docksoundredir", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "FileReader", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "content", ".", "SharedPreferences", ";", "import", "android", ".", "content", ".", "pm", ".", "PackageInfo", ";", "import", "android", ".", "content", ".", "pm", ".", "PackageManager", ";", "import", "android", ".", "content", ".", "pm", ".", "PackageManager", ".", "NameNotFoundException", ";", "import", "android", ".", "os", ".", "Build", ";", "import", "android", ".", "os", ".", "PowerManager", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "View", ".", "OnClickListener", ";", "public", "final", "class", "dockRedirCentral", "{", "static", "private", "final", "String", "TAG", "=", "\"\"", ";", "static", "final", "String", "PREFS_NAME", "=", "\"\"", ";", "protected", "static", "PowerManager", ".", "WakeLock", "mWakeLock", ";", "private", "static", "boolean", "debuggable", "=", "false", ";", "public", "static", "String", "getTag", "(", ")", "{", "return", "TAG", ";", "}", "public", "static", "final", "void", "logD", "(", "String", "message", ")", "{", "if", "(", "debuggable", ")", "Log", ".", "d", "(", "TAG", ",", "message", ")", ";", "}", "public", "static", "final", "boolean", "useKernel", "(", ")", "{", "boolean", "supported", "=", "false", ";", "try", "{", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "FileReader", "(", "\"\"", ")", ",", "256", ")", ";", "try", "{", "if", "(", "reader", ".", "readLine", "(", ")", ".", "contains", "(", "\"1\"", ")", ")", "supported", "=", "true", ";", "}", "finally", "{", "reader", ".", "close", "(", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "supported", "=", "false", ";", "logD", "(", "\"\"", ")", ";", "}", "return", "supported", ";", "}", "public", "static", "final", "boolean", "imSupported", "(", "Context", "context", ")", "{", "boolean", "supported", "=", "false", ";", "if", "(", "!", "imSupported", "(", "context", ",", "true", ")", ")", "{", "return", "false", ";", "}", "if", "(", "useKernel", "(", ")", ")", "return", "true", ";", "try", "{", "final", "PackageManager", "packageManager", "=", "context", ".", "getPackageManager", "(", ")", ";", "if", "(", "packageManager", ".", "getApplicationInfo", "(", "\"\"", ",", "0", ")", ".", "enabled", ")", "supported", "=", "true", ";", "}", "catch", "(", "PackageManager", ".", "NameNotFoundException", "e", ")", "{", "supported", "=", "false", ";", "logD", "(", "\"\"", ")", ";", "}", "return", "supported", ";", "}", "public", "static", "final", "boolean", "imSupported", "(", "Context", "context", ",", "boolean", "limited", ")", "{", "if", "(", "limited", ")", "{", "if", "(", "!", "Build", ".", "MANUFACTURER", ".", "equalsIgnoreCase", "(", "\"samsung\"", ")", "&&", "!", "debuggable", ")", "{", "logD", "(", "\"\"", ")", ";", "return", "false", ";", "}", "else", "{", "return", "true", ";", "}", "}", "else", "{", "return", "imSupported", "(", "context", ")", ";", "}", "}", "public", "static", "final", "OnClickListener", "onSupClick", "(", ")", "{", "return", "new", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "Context", "context", "=", "v", ".", "getContext", "(", ")", ";", "String", "mailText", "=", "\"\"", ";", "mailText", "=", "mailText", ".", "concat", "(", "\"Device:", "\"", "+", "Build", ".", "DEVICE", "+", "\"", "-", "\"", "+", "Build", ".", "MODEL", "+", "\"n\"", ")", ";", "mailText", "=", "mailText", ".", "concat", "(", "\"OS:", "\"", "+", "Build", ".", "VERSION", ".", "RELEASE", "+", "\"", "-", "\"", "+", "Build", ".", "DISPLAY", "+", "\"n\"", ")", ";", "SharedPreferences", "settings", "=", "context", ".", "getSharedPreferences", "(", "dockRedirCentral", ".", "PREFS_NAME", ",", "0", ")", ";", "mailText", "=", "mailText", ".", "concat", "(", "\"\"", "+", "settings", ".", "getString", "(", "\"_lastIntent\"", ",", "\"None\"", ")", "+", "\"n\"", ")", ";", "mailText", "=", "mailText", ".", "concat", "(", "\"\"", "+", "String", ".", "valueOf", "(", "settings", ".", "getInt", "(", "\"_deviceNum\"", ",", "-", "1", ")", ")", "+", "\"n\"", ")", ";", "try", "{", "PackageInfo", "packageInfo", "=", "context", ".", "getPackageManager", "(", ")", ".", "getPackageInfo", "(", "context", ".", "getPackageName", "(", ")", ",", "0", ")", ";", "mailText", "=", "mailText", ".", "concat", "(", "\"\"", "+", "packageInfo", ".", "versionName", "+", "\"n\"", ")", ";", "}", "catch", "(", "NameNotFoundException", "e", ")", "{", "mailText", "=", "mailText", ".", "concat", "(", "\"\"", ")", ";", "}", "Intent", "email", "=", "new", "Intent", "(", "Intent", ".", "ACTION_SEND", ")", ";", "email", ".", "putExtra", "(", "Intent", ".", "EXTRA_EMAIL", ",", "new", "String", "[", "]", "{", "\"\"", "}", ")", ";", "email", ".", "putExtra", "(", "Intent", ".", "EXTRA_SUBJECT", ",", "\"\"", ")", ";", "email", ".", "putExtra", "(", "Intent", ".", "EXTRA_TEXT", ",", "mailText", ")", ";", "email", ".", "setType", "(", "\"\"", ")", ";", "context", ".", "startActivity", "(", "Intent", ".", "createChooser", "(", "email", ",", "\"\"", ")", ")", ";", "}", "}", ";", "}", "public", "static", "final", "void", "warmUp", "(", "Context", "context", ")", "{", "logD", "(", "\"\"", ")", ";", "SharedPreferences", "settings", "=", "context", ".", "getSharedPreferences", "(", "dockRedirCentral", ".", "PREFS_NAME", ",", "0", ")", ";", "if", "(", "settings", ".", "getInt", "(", "\"_mediaVolume\"", ",", "-", "999", ")", "==", "-", "999", ")", "{", "SharedPreferences", ".", "Editor", "editor", "=", "settings", ".", "edit", "(", ")", ";", "editor", ".", "putBoolean", "(", "\"carRedir\"", ",", "true", ")", ";", "editor", ".", "putBoolean", "(", "\"deskRedir\"", ",", "true", ")", ";", "editor", ".", "putBoolean", "(", "\"showToast\"", ",", "true", ")", ";", "editor", ".", "remove", "(", "\"mediaVolume\"", ")", ".", "putBoolean", "(", "\"mediaVolume\"", ",", "false", ")", ";", "editor", ".", "putInt", "(", "\"_mediaVolume\"", ",", "-", "1", ")", ";", "editor", ".", "commit", "(", ")", ";", "logD", "(", "\"\"", ")", ";", "}", "final", "PowerManager", "pm", "=", "(", "PowerManager", ")", "context", ".", "getSystemService", "(", "Context", ".", "POWER_SERVICE", ")", ";", "mWakeLock", "=", "pm", ".", "newWakeLock", "(", "PowerManager", ".", "SCREEN_DIM_WAKE_LOCK", ",", "dockRedirCentral", ".", "getTag", "(", ")", ")", ";", "}", "public", "static", "final", "int", "getDockDeviceNumber", "(", "Context", "context", ")", "{", "int", "_deviceNum", "=", "0x0000", ";", "String", "dev", "=", "Build", ".", "DEVICE", ".", "toLowerCase", "(", ")", ";", "if", "(", "Build", ".", "DISPLAY", ".", "toLowerCase", "(", ")", ".", "contains", "(", "\"cm\"", ")", "||", "(", "dev", ".", "contains", "(", "\"i9000\"", ")", "&&", "(", "!", "Build", ".", "DISPLAY", ".", "contains", "(", "\".\"", ")", "||", "Build", ".", "DISPLAY", ".", "matches", "(", "\"\\\\d\\\\.\\\\d\"", ")", ")", ")", "||", "(", "dev", ".", "contains", "(", "\"t959\"", ")", "&&", "(", "!", "Build", ".", "DISPLAY", ".", "contains", "(", "\".\"", ")", "||", "Build", ".", "DISPLAY", ".", "matches", "(", "\"\\\\d\\\\.\\\\d\"", ")", ")", ")", ")", "{", "_deviceNum", "=", "0x800", ";", "}", "else", "if", "(", "dev", ".", "contains", "(", "\"d700\"", ")", "||", "dev", ".", "contains", "(", "\"g70\"", ")", "||", "dev", ".", "contains", "(", "\"gi1\"", ")", "||", "dev", ".", "contains", "(", "\"i400\"", ")", "||", "dev", ".", "contains", "(", "\"i500\"", ")", "||", "dev", ".", "contains", "(", "\"i510\"", ")", "||", "dev", ".", "contains", "(", "\"i777\"", ")", "||", "dev", ".", "contains", "(", "\"i896\"", ")", "||", "dev", ".", "contains", "(", "\"i897\"", ")", "||", "dev", ".", "contains", "(", "\"i9000\"", ")", "||", "dev", ".", "contains", "(", "\"i9003\"", ")", "||", "dev", ".", "contains", "(", "\"i997\"", ")", "||", "dev", ".", "contains", "(", "\"t959\"", ")", "||", "dev", ".", "contains", "(", "\"t989\"", ")", ")", "{", "_deviceNum", "=", "0x1000", ";", "}", "else", "if", "(", "dev", ".", "contains", "(", "\"i9001\"", ")", "||", "dev", ".", "contains", "(", "\"s5360\"", ")", "||", "dev", ".", "contains", "(", "\"s5830\"", ")", ")", "{", "_deviceNum", "=", "0x4000", ";", "}", "else", "{", "_deviceNum", "=", "0x800", ";", "}", "SharedPreferences", "settings", "=", "context", ".", "getSharedPreferences", "(", "dockRedirCentral", ".", "PREFS_NAME", ",", "0", ")", ";", "SharedPreferences", ".", "Editor", "editor", "=", "settings", ".", "edit", "(", ")", ";", "editor", ".", "putInt", "(", "\"_deviceNum\"", ",", "_deviceNum", ")", ";", "editor", ".", "commit", "(", ")", ";", "return", "_deviceNum", ";", "}", "}", "</s>" ]
905
[ "<s>", "package", "net", ".", "muteheadlight", ".", "docksoundredir", ".", "tasker", ";", "import", "net", ".", "muteheadlight", ".", "dockredir", ".", "R", ";", "import", "net", ".", "muteheadlight", ".", "docksoundredir", ".", "dockRedirCentral", ";", "import", "android", ".", "os", ".", "Bundle", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "util", ".", "Log", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "View", ".", "OnClickListener", ";", "import", "android", ".", "widget", ".", "Button", ";", "public", "class", "TaskerChooser", "extends", "Activity", "{", "private", "int", "redirectDirection", "=", "-", "1", ";", "@", "Override", "public", "void", "onCreate", "(", "Bundle", "savedInstanceState", ")", "{", "super", ".", "onCreate", "(", "savedInstanceState", ")", ";", "if", "(", "dockRedirCentral", ".", "imSupported", "(", "this", ",", "true", ")", ")", "{", "setContentView", "(", "R", ".", "layout", ".", "activity_tasker_chooser", ")", ";", "Button", "btnTasker", "=", "(", "Button", ")", "findViewById", "(", "R", ".", "id", ".", "taskerRedirectButton", ")", ";", "btnTasker", ".", "setOnClickListener", "(", "onBtnClick", "(", "1", ")", ")", ";", "btnTasker", "=", "(", "Button", ")", "findViewById", "(", "R", ".", "id", ".", "taskerNormalButton", ")", ";", "btnTasker", ".", "setOnClickListener", "(", "onBtnClick", "(", "0", ")", ")", ";", "}", "else", "{", "Log", ".", "i", "(", "dockRedirCentral", ".", "getTag", "(", ")", ",", "\"\"", ")", ";", "setContentView", "(", "R", ".", "layout", ".", "unsupported", ")", ";", "}", "}", "@", "Override", "public", "void", "finish", "(", ")", "{", "if", "(", "redirectDirection", "==", "-", "1", ")", "{", "setResult", "(", "RESULT_CANCELED", ")", ";", "}", "else", "{", "final", "Intent", "resultIntent", "=", "new", "Intent", "(", ")", ";", "final", "Bundle", "resultBundle", "=", "new", "Bundle", "(", ")", ";", "resultBundle", ".", "putInt", "(", "PluginBundleManager", ".", "BUNDLE_EXTRA_NAME", ",", "redirectDirection", ")", ";", "resultIntent", ".", "putExtra", "(", "com", ".", "twofortyfouram", ".", "locale", ".", "Intent", ".", "EXTRA_BUNDLE", ",", "resultBundle", ")", ";", "if", "(", "redirectDirection", "==", "1", ")", "{", "resultIntent", ".", "putExtra", "(", "com", ".", "twofortyfouram", ".", "locale", ".", "Intent", ".", "EXTRA_STRING_BLURB", ",", "\"\"", ")", ";", "}", "else", "{", "resultIntent", ".", "putExtra", "(", "com", ".", "twofortyfouram", ".", "locale", ".", "Intent", ".", "EXTRA_STRING_BLURB", ",", "\"\"", ")", ";", "}", "setResult", "(", "RESULT_OK", ",", "resultIntent", ")", ";", "}", "super", ".", "finish", "(", ")", ";", "}", "private", "OnClickListener", "onBtnClick", "(", "final", "int", "redirect", ")", "{", "return", "new", "OnClickListener", "(", ")", "{", "public", "void", "onClick", "(", "View", "v", ")", "{", "redirectDirection", "=", "redirect", ";", "finish", "(", ")", ";", "}", "}", ";", "}", "}", "</s>" ]
906
[ "<s>", "package", "net", ".", "muteheadlight", ".", "docksoundredir", ".", "tasker", ";", "import", "net", ".", "muteheadlight", ".", "docksoundredir", ".", "dockRedirCentral", ";", "import", "android", ".", "os", ".", "Bundle", ";", "public", "final", "class", "PluginBundleManager", "{", "private", "PluginBundleManager", "(", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"\"", ")", ";", "}", "public", "static", "final", "String", "BUNDLE_EXTRA_NAME", "=", "\"\"", ";", "public", "static", "boolean", "isBundleValid", "(", "final", "Bundle", "bundle", ")", "{", "if", "(", "null", "==", "bundle", ")", "{", "return", "false", ";", "}", "if", "(", "!", "bundle", ".", "containsKey", "(", "BUNDLE_EXTRA_NAME", ")", ")", "{", "dockRedirCentral", ".", "logD", "(", "String", ".", "format", "(", "\"\"", ")", ")", ";", "return", "false", ";", "}", "if", "(", "1", "!=", "bundle", ".", "keySet", "(", ")", ".", "size", "(", ")", ")", "{", "dockRedirCentral", ".", "logD", "(", "String", ".", "format", "(", "\"\"", ",", "Integer", ".", "valueOf", "(", "bundle", ".", "keySet", "(", ")", ".", "size", "(", ")", ")", ",", "bundle", ".", "keySet", "(", ")", ")", ")", ";", "return", "false", ";", "}", "if", "(", "bundle", ".", "getInt", "(", "BUNDLE_EXTRA_NAME", ",", "-", "1", ")", "==", "-", "1", ")", "{", "dockRedirCentral", ".", "logD", "(", "String", ".", "format", "(", "\"\"", ")", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}", "}", "</s>" ]
907
[ "<s>", "package", "net", ".", "muteheadlight", ".", "docksoundredir", ".", "tasker", ";", "import", "android", ".", "content", ".", "BroadcastReceiver", ";", "import", "android", ".", "content", ".", "Context", ";", "import", "android", ".", "content", ".", "Intent", ";", "import", "android", ".", "os", ".", "Bundle", ";", "public", "class", "TaskerReceiver", "extends", "BroadcastReceiver", "{", "public", "TaskerReceiver", "(", ")", "{", "}", "@", "Override", "public", "void", "onReceive", "(", "Context", "context", ",", "Intent", "intent", ")", "{", "final", "Bundle", "bundle", "=", "intent", ".", "getBundleExtra", "(", "com", ".", "twofortyfouram", ".", "locale", ".", "Intent", ".", "EXTRA_BUNDLE", ")", ";", "if", "(", "PluginBundleManager", ".", "isBundleValid", "(", "bundle", ")", ")", "{", "Intent", "intent1", "=", "new", "Intent", "(", ")", ";", "intent1", ".", "setAction", "(", "\"\"", ")", ";", "intent1", ".", "putExtra", "(", "\"\"", ",", "bundle", ".", "getInt", "(", "PluginBundleManager", ".", "BUNDLE_EXTRA_NAME", ")", ")", ";", "context", ".", "sendBroadcast", "(", "intent1", ")", ";", "}", "}", "}", "</s>" ]
908
[ "<s>", "package", "net", ".", "muteheadlight", ".", "docksoundredir", ";", "import", "java", ".", "util", ".", "List", ";", "import", "net", ".", "muteheadlight", ".", "dockredir", ".", "R", ";", "import", "android", ".", "app", ".", "Activity", ";", "import", "android", ".", "view", ".", "LayoutInflater", ";", "import", "android", ".", "view", ".", "View", ";", "import", "android", ".", "view", ".", "ViewGroup", ";", "import", "android", ".", "widget", ".", "ArrayAdapter", ";", "import", "android", ".", "widget", ".", "CheckBox", ";", "import", "android", ".", "widget", ".", "CompoundButton", ";", "import", "android", ".", "widget", ".", "TextView", ";", "public", "class", "InteractiveArrayAdapter", "extends", "ArrayAdapter", "<", "Setting", ">", "{", "private", "final", "List", "<", "Setting", ">", "list", ";", "private", "final", "Activity", "context", ";", "public", "InteractiveArrayAdapter", "(", "Activity", "context", ",", "List", "<", "Setting", ">", "list", ")", "{", "super", "(", "context", ",", "R", ".", "layout", ".", "rowbuttonlayout", ",", "list", ")", ";", "this", ".", "context", "=", "context", ";", "this", ".", "list", "=", "list", ";", "}", "static", "class", "ViewHolder", "{", "protected", "TextView", "text", ";", "protected", "CheckBox", "checkbox", ";", "}", "@", "Override", "public", "View", "getView", "(", "int", "position", ",", "View", "convertView", ",", "ViewGroup", "parent", ")", "{", "View", "view", "=", "null", ";", "if", "(", "convertView", "==", "null", ")", "{", "LayoutInflater", "inflator", "=", "context", ".", "getLayoutInflater", "(", ")", ";", "view", "=", "inflator", ".", "inflate", "(", "R", ".", "layout", ".", "rowbuttonlayout", ",", "null", ")", ";", "final", "ViewHolder", "viewHolder", "=", "new", "ViewHolder", "(", ")", ";", "viewHolder", ".", "text", "=", "(", "TextView", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "label", ")", ";", "viewHolder", ".", "checkbox", "=", "(", "CheckBox", ")", "view", ".", "findViewById", "(", "R", ".", "id", ".", "check", ")", ";", "viewHolder", ".", "checkbox", ".", "setOnCheckedChangeListener", "(", "new", "CompoundButton", ".", "OnCheckedChangeListener", "(", ")", "{", "public", "void", "onCheckedChanged", "(", "CompoundButton", "buttonView", ",", "boolean", "isChecked", ")", "{", "Setting", "element", "=", "(", "Setting", ")", "viewHolder", ".", "checkbox", ".", "getTag", "(", ")", ";", "element", ".", "setChecked", "(", "buttonView", ".", "isChecked", "(", ")", ")", ";", "}", "}", ")", ";", "view", ".", "setTag", "(", "viewHolder", ")", ";", "viewHolder", ".", "checkbox", ".", "setTag", "(", "list", ".", "get", "(", "position", ")", ")", ";", "}", "else", "{", "view", "=", "convertView", ";", "(", "(", "ViewHolder", ")", "view", ".", "getTag", "(", ")", ")", ".", "checkbox", ".", "setTag", "(", "list", ".", "get", "(", "position", ")", ")", ";", "}", "ViewHolder", "holder", "=", "(", "ViewHolder", ")", "view", ".", "getTag", "(", ")", ";", "holder", ".", "text", ".", "setText", "(", "list", ".", "get", "(", "position", ")", ".", "getText", "(", ")", ")", ";", "holder", ".", "checkbox", ".", "setChecked", "(", "list", ".", "get", "(", "position", ")", ".", "getChecked", "(", ")", ")", ";", "holder", ".", "checkbox", ".", "setEnabled", "(", "!", "list", ".", "get", "(", "position", ")", ".", "isDisabled", "(", ")", ")", ";", "return", "view", ";", "}", "}", "</s>" ]
909
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "examples", ";", "public", "class", "Main", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "}", "</s>" ]
910
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "changes", ";", "import", "java", ".", "io", ".", "ByteArrayInputStream", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "descriptors", ".", "PackageDescriptor", ";", "public", "final", "class", "TextfileChangesProviderTestCase", "extends", "TestCase", "{", "public", "void", "testParsing", "(", ")", "throws", "Exception", "{", "final", "String", "input", "=", "\"", "*", "change1n\"", "+", "\"", "*", "change2n\"", "+", "\"\"", "+", "\"", "*", "change1n\"", "+", "\"", "*", "change2n\"", "+", "\"\"", "+", "\"", "*", "change1n\"", "+", "\"", "*", "change2n\"", ";", "final", "PackageDescriptor", "descriptor", "=", "new", "PackageDescriptor", "(", ")", ";", "descriptor", ".", "set", "(", "\"Package\"", ",", "\"package\"", ")", ";", "descriptor", ".", "set", "(", "\"Version\"", ",", "\"version\"", ")", ";", "descriptor", ".", "set", "(", "\"Distribution\"", ",", "\"distribution\"", ")", ";", "descriptor", ".", "set", "(", "\"Date\"", ",", "\"\"", ")", ";", "final", "TextfileChangesProvider", "provider", "=", "new", "TextfileChangesProvider", "(", "new", "ByteArrayInputStream", "(", "input", ".", "getBytes", "(", "\"UTF-8\"", ")", ")", ",", "descriptor", ")", ";", "final", "ChangeSet", "[", "]", "changeSets", "=", "provider", ".", "getChangesSets", "(", ")", ";", "assertNotNull", "(", "changeSets", ")", ";", "assertEquals", "(", "3", ",", "changeSets", ".", "length", ")", ";", "}", "public", "void", "testDistributionFromChangesProvider", "(", ")", "throws", "Exception", "{", "final", "String", "input", "=", "\"\"", "+", "\"", "*", "change1n\"", "+", "\"", "*", "change2n\"", "+", "\"\"", "+", "\"", "*", "change1n\"", "+", "\"", "*", "change2n\"", "+", "\"\"", "+", "\"", "*", "change1n\"", "+", "\"", "*", "change2n\"", ";", "final", "PackageDescriptor", "descriptor", "=", "new", "PackageDescriptor", "(", ")", ";", "descriptor", ".", "set", "(", "\"Package\"", ",", "\"package\"", ")", ";", "descriptor", ".", "set", "(", "\"Version\"", ",", "\"version\"", ")", ";", "descriptor", ".", "set", "(", "\"Date\"", ",", "\"\"", ")", ";", "final", "TextfileChangesProvider", "provider", "=", "new", "TextfileChangesProvider", "(", "new", "ByteArrayInputStream", "(", "input", ".", "getBytes", "(", "\"UTF-8\"", ")", ")", ",", "descriptor", ")", ";", "final", "ChangeSet", "[", "]", "changeSets", "=", "provider", ".", "getChangesSets", "(", ")", ";", "assertNotNull", "(", "changeSets", ")", ";", "assertEquals", "(", "3", ",", "changeSets", ".", "length", ")", ";", "assertEquals", "(", "\"production\"", ",", "changeSets", "[", "0", "]", ".", "getDistribution", "(", ")", ")", ";", "assertEquals", "(", "\"staging\"", ",", "changeSets", "[", "1", "]", ".", "getDistribution", "(", ")", ")", ";", "assertEquals", "(", "\"development\"", ",", "changeSets", "[", "2", "]", ".", "getDistribution", "(", ")", ")", ";", "}", "}", "</s>" ]
911
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "maven", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileNotFoundException", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "public", "class", "DataTestCase", "extends", "TestCase", "{", "private", "Data", "data", ";", "private", "File", "missingFile", ";", "private", "File", "file", ";", "protected", "void", "setUp", "(", ")", "throws", "Exception", "{", "data", "=", "new", "Data", "(", ")", ";", "missingFile", "=", "new", "File", "(", "\"\"", ")", ";", "file", "=", "File", ".", "createTempFile", "(", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ",", "\"dat\"", ")", ";", "}", "protected", "void", "tearDown", "(", ")", "throws", "Exception", "{", "if", "(", "file", "!=", "null", ")", "{", "file", ".", "delete", "(", ")", ";", "}", "}", "public", "void", "testSrcAndPathsNotSetFails", "(", ")", "throws", "IOException", "{", "RuntimeException", "expectedException", "=", "null", ";", "try", "{", "data", ".", "setPaths", "(", "null", ")", ";", "data", ".", "setSrc", "(", "null", ")", ";", "data", ".", "produce", "(", "null", ")", ";", "fail", "(", ")", ";", "}", "catch", "(", "RuntimeException", "expected", ")", "{", "expectedException", "=", "expected", ";", "}", "assertEquals", "(", "\"\"", ",", "expectedException", ".", "getMessage", "(", ")", ")", ";", "}", "public", "void", "testPathsMaySubstituteSrc", "(", ")", "throws", "IOException", "{", "IOException", "expectedException", "=", "null", ";", "try", "{", "data", ".", "setPaths", "(", "new", "String", "[", "]", "{", "\"/var/log\"", ",", "\"/var/lib\"", "}", ")", ";", "data", ".", "setSrc", "(", "null", ")", ";", "data", ".", "produce", "(", "null", ")", ";", "fail", "(", ")", ";", "}", "catch", "(", "IOException", "expected", ")", "{", "expectedException", "=", "expected", ";", "}", "assertTrue", "(", "expectedException", ".", "getMessage", "(", ")", ".", "startsWith", "(", "\"\"", ")", ")", ";", "}", "public", "void", "testFailOnUnknownValue", "(", ")", "throws", "IOException", "{", "try", "{", "data", ".", "setSrc", "(", "missingFile", ")", ";", "data", ".", "setMissingSrc", "(", "\"\"", ")", ";", "data", ".", "produce", "(", "null", ")", ";", "fail", "(", ")", ";", "}", "catch", "(", "IllegalArgumentException", "expected", ")", "{", "}", "}", "public", "void", "testFailOnMissingSrcDefaultFileMissing", "(", ")", "throws", "IOException", "{", "try", "{", "data", ".", "setSrc", "(", "missingFile", ")", ";", "data", ".", "produce", "(", "null", ")", ";", "fail", "(", ")", ";", "}", "catch", "(", "FileNotFoundException", "expected", ")", "{", "}", "}", "public", "void", "testFailOnMissingSrcIgnoreFileMissing", "(", ")", "throws", "IOException", "{", "data", ".", "setSrc", "(", "missingFile", ")", ";", "data", ".", "setMissingSrc", "(", "\"ignore\"", ")", ";", "data", ".", "produce", "(", "null", ")", ";", "}", "public", "void", "testFailOnMissingSrcIgnoreFileMissingVaryInput", "(", ")", "throws", "IOException", "{", "data", ".", "setSrc", "(", "missingFile", ")", ";", "data", ".", "setMissingSrc", "(", "\"", "IGNORE", "\"", ")", ";", "data", ".", "produce", "(", "null", ")", ";", "}", "public", "void", "testFailOnMissingSrcFailFileMissing", "(", ")", "throws", "IOException", "{", "try", "{", "data", ".", "setSrc", "(", "missingFile", ")", ";", "data", ".", "setMissingSrc", "(", "\"fail\"", ")", ";", "data", ".", "produce", "(", "null", ")", ";", "fail", "(", ")", ";", "}", "catch", "(", "FileNotFoundException", "expected", ")", "{", "}", "}", "public", "void", "testFailOnMissingSrcDefaultFileExists", "(", ")", "throws", "IOException", "{", "IOException", "unknownTypeException", "=", "null", ";", "try", "{", "data", ".", "setSrc", "(", "file", ")", ";", "data", ".", "produce", "(", "null", ")", ";", "}", "catch", "(", "IOException", "expected", ")", "{", "unknownTypeException", "=", "expected", ";", "}", "assertTrue", "(", "unknownTypeException", ".", "getMessage", "(", ")", ".", "startsWith", "(", "\"Unknown", "type\"", ")", ")", ";", "}", "public", "void", "testFailOnMissingSrcIgnoreFileExists", "(", ")", "throws", "IOException", "{", "IOException", "unknownTypeException", "=", "null", ";", "try", "{", "data", ".", "setSrc", "(", "file", ")", ";", "data", ".", "setMissingSrc", "(", "\"ignore\"", ")", ";", "data", ".", "produce", "(", "null", ")", ";", "}", "catch", "(", "IOException", "expected", ")", "{", "unknownTypeException", "=", "expected", ";", "}", "assertTrue", "(", "unknownTypeException", ".", "getMessage", "(", ")", ".", "startsWith", "(", "\"Unknown", "type\"", ")", ")", ";", "}", "public", "void", "testFailOnMissingSrcFailFileExists", "(", ")", "throws", "IOException", "{", "IOException", "unknownTypeException", "=", "null", ";", "try", "{", "data", ".", "setSrc", "(", "file", ")", ";", "data", ".", "setMissingSrc", "(", "\"fail\"", ")", ";", "data", ".", "produce", "(", "null", ")", ";", "}", "catch", "(", "IOException", "expected", ")", "{", "unknownTypeException", "=", "expected", ";", "}", "assertTrue", "(", "unknownTypeException", ".", "getMessage", "(", ")", ".", "startsWith", "(", "\"Unknown", "type\"", ")", ")", ";", "}", "}", "</s>" ]
912
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "signing", ";", "import", "java", ".", "io", ".", "ByteArrayInputStream", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "public", "final", "class", "SigningTestCase", "extends", "TestCase", "{", "public", "void", "testClearSign", "(", ")", "throws", "Exception", "{", "final", "InputStream", "ring", "=", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ".", "getResourceAsStream", "(", "\"\"", ")", ";", "assertNotNull", "(", "ring", ")", ";", "final", "String", "inputStr", "=", "\"\"", ";", "final", "byte", "[", "]", "input", "=", "inputStr", ".", "getBytes", "(", "\"UTF-8\"", ")", ";", "final", "String", "expectedOutputStr", "=", "\"\"", "+", "\"Hash:", "SHA1n\"", "+", "\"n\"", "+", "\"TEST1n\"", "+", "\"-", "-TEST2n\"", "+", "\"n\"", "+", "\"TEST3n\"", "+", "\"\"", "+", "\"\"", "+", "\"n\"", "+", "\"\"", "+", "\"\"", "+", "\"=aAATn\"", "+", "\"\"", ";", "final", "byte", "[", "]", "expectedOutput", "=", "expectedOutputStr", ".", "getBytes", "(", "\"UTF-8\"", ")", ";", "final", "ByteArrayOutputStream", "os", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "SigningUtils", ".", "clearSign", "(", "new", "ByteArrayInputStream", "(", "input", ")", ",", "ring", ",", "\"2E074D8F\"", ",", "\"test\"", ",", "os", ")", ";", "final", "byte", "[", "]", "output", "=", "fixCRLF", "(", "os", ".", "toByteArray", "(", ")", ")", ";", "final", "int", "from", "=", "expectedOutputStr", ".", "indexOf", "(", "\"iEYEAREC\"", ")", ";", "final", "int", "until", "=", "expectedOutputStr", ".", "indexOf", "(", "\"=aAAT\"", ")", "+", "5", ";", "Arrays", ".", "fill", "(", "output", ",", "from", ",", "until", ",", "(", "byte", ")", "'?'", ")", ";", "Arrays", ".", "fill", "(", "expectedOutput", ",", "from", ",", "until", ",", "(", "byte", ")", "'?'", ")", ";", "assertEquals", "(", "new", "String", "(", "expectedOutput", ")", ",", "new", "String", "(", "output", ")", ")", ";", "}", "private", "byte", "[", "]", "fixCRLF", "(", "byte", "[", "]", "b", ")", "{", "String", "s", "=", "new", "String", "(", "b", ")", ";", "s", "=", "s", ".", "replaceAll", "(", "\"rn\"", ",", "\"n\"", ")", ";", "return", "s", ".", "getBytes", "(", ")", ";", "}", "}", "</s>" ]
913
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "producers", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "tar", ".", "TarArchiveEntry", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataConsumer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataProducer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "Mapper", ";", "public", "class", "DataProducerPathTemplateTestCase", "extends", "TestCase", "{", "private", "static", "final", "String", "[", "]", "INCLUDES", "=", "{", "}", ";", "private", "static", "final", "String", "[", "]", "EXCLUDES", "=", "{", "}", ";", "private", "CaptureDataConsumer", "captureDataConsumer", "=", "new", "CaptureDataConsumer", "(", ")", ";", "private", "Mapper", "[", "]", "mappers", "=", "new", "Mapper", "[", "0", "]", ";", "private", "DataProducer", "dataProducer", ";", "public", "void", "testTypical", "(", ")", "throws", "Exception", "{", "String", "[", "]", "paths", "=", "{", "\"/var/log\"", ",", "\"/var/lib\"", "}", ";", "dataProducer", "=", "new", "DataProducerPathTemplate", "(", "paths", ",", "INCLUDES", ",", "EXCLUDES", ",", "mappers", ")", ";", "dataProducer", ".", "produce", "(", "captureDataConsumer", ")", ";", "assertEquals", "(", "2", ",", "captureDataConsumer", ".", "invocations", ".", "size", "(", ")", ")", ";", "CaptureDataConsumer", ".", "Invocation", "invocation", "=", "captureDataConsumer", ".", "invocations", ".", "get", "(", "0", ")", ";", "assertEquals", "(", "invocation", ".", "dirname", ",", "\"/var/log\"", ")", ";", "assertEquals", "(", "invocation", ".", "gid", ",", "0", ")", ";", "assertEquals", "(", "invocation", ".", "group", ",", "\"root\"", ")", ";", "assertEquals", "(", "invocation", ".", "linkname", ",", "\"\"", ")", ";", "assertEquals", "(", "invocation", ".", "mode", ",", "TarArchiveEntry", ".", "DEFAULT_DIR_MODE", ")", ";", "assertEquals", "(", "invocation", ".", "size", ",", "0", ")", ";", "assertEquals", "(", "invocation", ".", "uid", ",", "0", ")", ";", "assertEquals", "(", "invocation", ".", "user", ",", "\"root\"", ")", ";", "invocation", "=", "captureDataConsumer", ".", "invocations", ".", "get", "(", "1", ")", ";", "assertEquals", "(", "invocation", ".", "dirname", ",", "\"/var/lib\"", ")", ";", "assertEquals", "(", "invocation", ".", "gid", ",", "0", ")", ";", "assertEquals", "(", "invocation", ".", "group", ",", "\"root\"", ")", ";", "assertEquals", "(", "invocation", ".", "linkname", ",", "\"\"", ")", ";", "assertEquals", "(", "invocation", ".", "mode", ",", "TarArchiveEntry", ".", "DEFAULT_DIR_MODE", ")", ";", "assertEquals", "(", "invocation", ".", "size", ",", "0", ")", ";", "assertEquals", "(", "invocation", ".", "uid", ",", "0", ")", ";", "assertEquals", "(", "invocation", ".", "user", ",", "\"root\"", ")", ";", "}", "public", "class", "CaptureDataConsumer", "implements", "DataConsumer", "{", "private", "List", "<", "Invocation", ">", "invocations", ";", "public", "CaptureDataConsumer", "(", ")", "{", "invocations", "=", "new", "ArrayList", "<", "Invocation", ">", "(", ")", ";", "}", "@", "Override", "public", "void", "onEachDir", "(", "String", "dirname", ",", "String", "linkname", ",", "String", "user", ",", "int", "uid", ",", "String", "group", ",", "int", "gid", ",", "int", "mode", ",", "long", "size", ")", "throws", "IOException", "{", "invocations", ".", "add", "(", "new", "Invocation", "(", "dirname", ",", "linkname", ",", "user", ",", "uid", ",", "group", ",", "gid", ",", "mode", ",", "size", ")", ")", ";", "}", "@", "Override", "public", "void", "onEachFile", "(", "InputStream", "input", ",", "String", "filename", ",", "String", "linkname", ",", "String", "user", ",", "int", "uid", ",", "String", "group", ",", "int", "gid", ",", "int", "mode", ",", "long", "size", ")", "throws", "IOException", "{", "}", "@", "Override", "public", "void", "onEachLink", "(", "String", "path", ",", "String", "linkName", ",", "boolean", "symlink", ",", "String", "user", ",", "int", "uid", ",", "String", "group", ",", "int", "gid", ")", "throws", "IOException", "{", "}", "private", "class", "Invocation", "{", "private", "String", "dirname", ";", "private", "String", "linkname", ";", "private", "String", "user", ";", "private", "int", "uid", ";", "private", "String", "group", ";", "private", "int", "gid", ";", "private", "int", "mode", ";", "private", "long", "size", ";", "private", "Invocation", "(", "String", "dirname", ",", "String", "linkname", ",", "String", "user", ",", "int", "uid", ",", "String", "group", ",", "int", "gid", ",", "int", "mode", ",", "long", "size", ")", "throws", "IOException", "{", "this", ".", "dirname", "=", "dirname", ";", "this", ".", "linkname", "=", "linkname", ";", "this", ".", "user", "=", "user", ";", "this", ".", "uid", "=", "uid", ";", "this", ".", "group", "=", "group", ";", "this", ".", "gid", "=", "gid", ";", "this", ".", "mode", "=", "mode", ";", "this", ".", "size", "=", "size", ";", "}", "}", "}", "}", "</s>" ]
914
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "java", ".", "util", ".", "zip", ".", "GZIPInputStream", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "ar", ".", "ArArchiveEntry", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "ar", ".", "ArArchiveInputStream", ";", "import", "org", ".", "apache", ".", "tools", ".", "tar", ".", "TarEntry", ";", "import", "org", ".", "apache", ".", "tools", ".", "tar", ".", "TarInputStream", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "ar", ".", "NonClosingInputStream", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "descriptors", ".", "PackageDescriptor", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "producers", ".", "DataProducerArchive", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "producers", ".", "DataProducerDirectory", ";", "public", "final", "class", "DataProducerTestCase", "extends", "TestCase", "{", "public", "void", "testCreation", "(", ")", "throws", "Exception", "{", "final", "Processor", "processor", "=", "new", "Processor", "(", "new", "Console", "(", ")", "{", "public", "void", "info", "(", "String", "s", ")", "{", "}", "public", "void", "warn", "(", "String", "s", ")", "{", "}", "}", ",", "null", ")", ";", "final", "File", "control", "=", "new", "File", "(", "getClass", "(", ")", ".", "getResource", "(", "\"\"", ")", ".", "toURI", "(", ")", ")", ";", "final", "File", "archive1", "=", "new", "File", "(", "getClass", "(", ")", ".", "getResource", "(", "\"deb/data.tgz\"", ")", ".", "toURI", "(", ")", ")", ";", "final", "File", "archive2", "=", "new", "File", "(", "getClass", "(", ")", ".", "getResource", "(", "\"\"", ")", ".", "toURI", "(", ")", ")", ";", "final", "File", "archive3", "=", "new", "File", "(", "getClass", "(", ")", ".", "getResource", "(", "\"deb/data.zip\"", ")", ".", "toURI", "(", ")", ")", ";", "final", "File", "directory", "=", "new", "File", "(", "getClass", "(", ")", ".", "getResource", "(", "\"deb/data\"", ")", ".", "toURI", "(", ")", ")", ";", "final", "DataProducer", "[", "]", "data", "=", "new", "DataProducer", "[", "]", "{", "new", "DataProducerArchive", "(", "archive1", ",", "null", ",", "null", ",", "null", ")", ",", "new", "DataProducerArchive", "(", "archive2", ",", "null", ",", "null", ",", "null", ")", ",", "new", "DataProducerArchive", "(", "archive3", ",", "null", ",", "null", ",", "null", ")", ",", "new", "DataProducerDirectory", "(", "directory", ",", "null", ",", "new", "String", "[", "]", "{", "\"**/.svn/**\"", "}", ",", "null", ")", "}", ";", "final", "File", "deb", "=", "File", ".", "createTempFile", "(", "\"jdeb\"", ",", "\".deb\"", ")", ";", "final", "PackageDescriptor", "packageDescriptor", "=", "processor", ".", "createDeb", "(", "new", "File", "[", "]", "{", "control", "}", ",", "data", ",", "deb", ",", "\"gzip\"", ")", ";", "assertTrue", "(", "packageDescriptor", ".", "isValid", "(", ")", ")", ";", "final", "Set", "filesInDeb", "=", "new", "HashSet", "(", ")", ";", "final", "ArArchiveInputStream", "ar", "=", "new", "ArArchiveInputStream", "(", "new", "FileInputStream", "(", "deb", ")", ")", ";", "while", "(", "true", ")", "{", "final", "ArArchiveEntry", "arEntry", "=", "ar", ".", "getNextArEntry", "(", ")", ";", "if", "(", "arEntry", "==", "null", ")", "{", "break", ";", "}", "if", "(", "\"data.tar.gz\"", ".", "equals", "(", "arEntry", ".", "getName", "(", ")", ")", ")", "{", "final", "TarInputStream", "tar", "=", "new", "TarInputStream", "(", "new", "GZIPInputStream", "(", "new", "NonClosingInputStream", "(", "ar", ")", ")", ")", ";", "while", "(", "true", ")", "{", "final", "TarEntry", "tarEntry", "=", "tar", ".", "getNextEntry", "(", ")", ";", "if", "(", "tarEntry", "==", "null", ")", "{", "break", ";", "}", "filesInDeb", ".", "add", "(", "tarEntry", ".", "getName", "(", ")", ")", ";", "}", "tar", ".", "close", "(", ")", ";", "break", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "arEntry", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "ar", ".", "read", "(", ")", ";", "}", "}", "ar", ".", "close", "(", ")", ";", "assertTrue", "(", "\"\"", ",", "filesInDeb", ".", "contains", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "filesInDeb", ".", "contains", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "filesInDeb", ".", "contains", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "filesInDeb", ".", "contains", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "\"\"", "+", "deb", ",", "deb", ".", "delete", "(", ")", ")", ";", "}", "}", "</s>" ]
915
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ";", "import", "java", ".", "io", ".", "File", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "Project", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "types", ".", "FileSet", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "producers", ".", "DataProducerFileSet", ";", "public", "class", "ProcessorTestCase", "extends", "TestCase", "{", "public", "void", "testBuildDataWithFileSet", "(", ")", "throws", "Exception", "{", "Processor", "processor", "=", "new", "Processor", "(", "new", "Console", "(", ")", "{", "public", "void", "info", "(", "String", "s", ")", "{", "}", "public", "void", "warn", "(", "String", "s", ")", "{", "}", "}", ",", "null", ")", ";", "Project", "project", "=", "new", "Project", "(", ")", ";", "project", ".", "setCoreLoader", "(", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ")", ";", "project", ".", "init", "(", ")", ";", "FileSet", "fileset", "=", "new", "FileSet", "(", ")", ";", "fileset", ".", "setDir", "(", "new", "File", "(", "getClass", "(", ")", ".", "getResource", "(", "\"deb/data\"", ")", ".", "toURI", "(", ")", ")", ")", ";", "fileset", ".", "setIncludes", "(", "\"**/*\"", ")", ";", "fileset", ".", "setProject", "(", "project", ")", ";", "StringBuilder", "md5s", "=", "new", "StringBuilder", "(", ")", ";", "processor", ".", "buildData", "(", "new", "DataProducer", "[", "]", "{", "new", "DataProducerFileSet", "(", "fileset", ")", "}", ",", "new", "File", "(", "\"\"", ")", ",", "md5s", ",", "\"gz\"", ")", ";", "assertTrue", "(", "\"\"", ",", "md5s", ".", "length", "(", ")", ">", "0", ")", ";", "assertFalse", "(", "\"\"", ",", "md5s", ".", "indexOf", "(", "\"\\\\\"", ")", "!=", "-", "1", ")", ";", "}", "}", "</s>" ]
916
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ";", "import", "java", ".", "io", ".", "ByteArrayInputStream", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "tar", ".", "TarArchiveEntry", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "LsMapper", ".", "ParseError", ";", "public", "final", "class", "LsMapperTestCase", "extends", "TestCase", "{", "private", "final", "static", "String", "output", "=", "\"total", "0n\"", "+", "\"\"", "+", "\"\"", "+", "\"n\"", "+", "\"\"", "+", "\"total", "176n\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"n\"", "+", "\"\"", "+", "\"total", "76n\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"\"", "+", "\"n\"", ";", "public", "void", "testModes", "(", ")", "throws", "Exception", "{", "final", "ByteArrayInputStream", "is", "=", "new", "ByteArrayInputStream", "(", "output", ".", "getBytes", "(", "\"UTF-8\"", ")", ")", ";", "final", "Mapper", "mapper", "=", "new", "LsMapper", "(", "is", ")", ";", "final", "TarArchiveEntry", "entry1", "=", "mapper", ".", "map", "(", "new", "TarArchiveEntry", "(", "\"\"", ",", "true", ")", ")", ";", "assertEquals", "(", "493", ",", "entry1", ".", "getMode", "(", ")", ")", ";", "assertEquals", "(", "\"tcurdt\"", ",", "entry1", ".", "getUserName", "(", ")", ")", ";", "assertEquals", "(", "\"tcurdt\"", ",", "entry1", ".", "getGroupName", "(", ")", ")", ";", "final", "TarArchiveEntry", "entry2", "=", "mapper", ".", "map", "(", "new", "TarArchiveEntry", "(", "\"\"", ",", "true", ")", ")", ";", "assertEquals", "(", "420", ",", "entry2", ".", "getMode", "(", ")", ")", ";", "assertEquals", "(", "\"tcurdt\"", ",", "entry2", ".", "getUserName", "(", ")", ")", ";", "assertEquals", "(", "\"tcurdt\"", ",", "entry2", ".", "getGroupName", "(", ")", ")", ";", "}", "public", "void", "testSuccessfulParsing", "(", ")", "throws", "Exception", "{", "final", "ByteArrayInputStream", "is", "=", "new", "ByteArrayInputStream", "(", "output", ".", "getBytes", "(", "\"UTF-8\"", ")", ")", ";", "final", "Mapper", "mapper", "=", "new", "LsMapper", "(", "is", ")", ";", "final", "TarArchiveEntry", "unknown", "=", "new", "TarArchiveEntry", "(", "\"xyz\"", ",", "true", ")", ";", "assertSame", "(", "unknown", ",", "mapper", ".", "map", "(", "unknown", ")", ")", ";", "final", "TarArchiveEntry", "known", "=", "new", "TarArchiveEntry", "(", "\"\"", ",", "true", ")", ";", "final", "TarArchiveEntry", "knownMapped", "=", "mapper", ".", "map", "(", "known", ")", ";", "assertNotSame", "(", "known", ",", "knownMapped", ")", ";", "}", "public", "void", "testPrematureEOF", "(", ")", "throws", "Exception", "{", "final", "ByteArrayInputStream", "is", "=", "new", "ByteArrayInputStream", "(", "output", ".", "substring", "(", "0", ",", "200", ")", ".", "getBytes", "(", "\"UTF-8\"", ")", ")", ";", "try", "{", "new", "LsMapper", "(", "is", ")", ";", "fail", "(", "\"\"", ")", ";", "}", "catch", "(", "ParseError", "e", ")", "{", "}", "}", "public", "void", "testWrongFormat", "(", ")", "throws", "Exception", "{", "final", "ByteArrayInputStream", "is", "=", "new", "ByteArrayInputStream", "(", "\"asasn\"", ".", "getBytes", "(", "\"UTF-8\"", ")", ")", ";", "try", "{", "new", "LsMapper", "(", "is", ")", ";", "fail", "(", "\"\"", ")", ";", "}", "catch", "(", "ParseError", "e", ")", "{", "}", "}", "}", "</s>" ]
917
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "utils", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "public", "class", "InformationInputStreamTestCase", "extends", "TestCase", "{", "private", "InputStream", "getStream", "(", "String", "file", ")", "{", "return", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ".", "getResourceAsStream", "(", "\"\"", "+", "file", ")", ";", "}", "public", "void", "testUTF8", "(", ")", "throws", "Exception", "{", "InformationInputStream", "informationStream", "=", "new", "InformationInputStream", "(", "getStream", "(", "\"utf8-lf.txt\"", ")", ")", ";", "Utils", ".", "copy", "(", "informationStream", ",", "new", "ByteArrayOutputStream", "(", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "informationStream", ".", "isShell", "(", ")", ")", ";", "assertTrue", "(", "\"BOM", "detected\"", ",", "!", "informationStream", ".", "hasBom", "(", ")", ")", ";", "assertEquals", "(", "\"Encoding\"", ",", "null", ",", "informationStream", ".", "getEncoding", "(", ")", ")", ";", "}", "public", "void", "testUTF8BOM", "(", ")", "throws", "Exception", "{", "InformationInputStream", "informationStream", "=", "new", "InformationInputStream", "(", "getStream", "(", "\"\"", ")", ")", ";", "Utils", ".", "copy", "(", "informationStream", ",", "new", "ByteArrayOutputStream", "(", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "informationStream", ".", "isShell", "(", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "informationStream", ".", "hasBom", "(", ")", ")", ";", "assertEquals", "(", "\"Encoding\"", ",", "\"UTF-8\"", ",", "informationStream", ".", "getEncoding", "(", ")", ")", ";", "}", "public", "void", "testUTF16BE", "(", ")", "throws", "Exception", "{", "InformationInputStream", "informationStream", "=", "new", "InformationInputStream", "(", "getStream", "(", "\"\"", ")", ")", ";", "Utils", ".", "copy", "(", "informationStream", ",", "new", "ByteArrayOutputStream", "(", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "informationStream", ".", "isShell", "(", ")", ")", ";", "assertTrue", "(", "\"BOM", "detected\"", ",", "!", "informationStream", ".", "hasBom", "(", ")", ")", ";", "assertEquals", "(", "\"Encoding\"", ",", "\"UTF-16BE\"", ",", "informationStream", ".", "getEncoding", "(", ")", ")", ";", "}", "public", "void", "testUTF16BEBOM", "(", ")", "throws", "Exception", "{", "InformationInputStream", "informationStream", "=", "new", "InformationInputStream", "(", "getStream", "(", "\"\"", ")", ")", ";", "Utils", ".", "copy", "(", "informationStream", ",", "new", "ByteArrayOutputStream", "(", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "informationStream", ".", "isShell", "(", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "informationStream", ".", "hasBom", "(", ")", ")", ";", "assertEquals", "(", "\"Encoding\"", ",", "\"UTF-16BE\"", ",", "informationStream", ".", "getEncoding", "(", ")", ")", ";", "}", "public", "void", "testUTF16LE", "(", ")", "throws", "Exception", "{", "InformationInputStream", "informationStream", "=", "new", "InformationInputStream", "(", "getStream", "(", "\"\"", ")", ")", ";", "Utils", ".", "copy", "(", "informationStream", ",", "new", "ByteArrayOutputStream", "(", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "informationStream", ".", "isShell", "(", ")", ")", ";", "assertTrue", "(", "\"BOM", "detected\"", ",", "!", "informationStream", ".", "hasBom", "(", ")", ")", ";", "assertEquals", "(", "\"Encoding\"", ",", "\"UTF-16LE\"", ",", "informationStream", ".", "getEncoding", "(", ")", ")", ";", "}", "public", "void", "testUTF16LEBOM", "(", ")", "throws", "Exception", "{", "InformationInputStream", "informationStream", "=", "new", "InformationInputStream", "(", "getStream", "(", "\"\"", ")", ")", ";", "Utils", ".", "copy", "(", "informationStream", ",", "new", "ByteArrayOutputStream", "(", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "informationStream", ".", "isShell", "(", ")", ")", ";", "assertTrue", "(", "\"\"", ",", "informationStream", ".", "hasBom", "(", ")", ")", ";", "assertEquals", "(", "\"Encoding\"", ",", "\"UTF-16LE\"", ",", "informationStream", ".", "getEncoding", "(", ")", ")", ";", "}", "}", "</s>" ]
918
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "utils", ";", "import", "java", ".", "io", ".", "ByteArrayInputStream", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "public", "class", "UtilsTestCase", "extends", "TestCase", "{", "public", "void", "testStripPath", "(", ")", "throws", "Exception", "{", "assertEquals", "(", "\"foo/bar\"", ",", "Utils", ".", "stripPath", "(", "0", ",", "\"foo/bar\"", ")", ")", ";", "assertEquals", "(", "\"bar\"", ",", "Utils", ".", "stripPath", "(", "1", ",", "\"foo/bar\"", ")", ")", ";", "assertEquals", "(", "\"bar/baz\"", ",", "Utils", ".", "stripPath", "(", "1", ",", "\"foo/bar/baz\"", ")", ")", ";", "assertEquals", "(", "\"baz\"", ",", "Utils", ".", "stripPath", "(", "2", ",", "\"foo/bar/baz\"", ")", ")", ";", "assertEquals", "(", "\"foo/\"", ",", "Utils", ".", "stripPath", "(", "0", ",", "\"foo/\"", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "Utils", ".", "stripPath", "(", "1", ",", "\"foo/\"", ")", ")", ";", "assertEquals", "(", "\"foo/\"", ",", "Utils", ".", "stripPath", "(", "2", ",", "\"foo/\"", ")", ")", ";", "}", "private", "String", "convert", "(", "String", "s", ")", "throws", "Exception", "{", "byte", "[", "]", "data", "=", "Utils", ".", "toUnixLineEndings", "(", "new", "ByteArrayInputStream", "(", "s", ".", "getBytes", "(", "\"UTF-8\"", ")", ")", ")", ";", "return", "new", "String", "(", "data", ",", "\"UTF-8\"", ")", ";", "}", "public", "void", "testNewlineConversionLF", "(", ")", "throws", "Exception", "{", "String", "expected", "=", "\"\"", ";", "String", "actual", "=", "convert", "(", "\"\"", ")", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "public", "void", "testNewlineConversionCRLF", "(", ")", "throws", "Exception", "{", "String", "expected", "=", "\"\"", ";", "String", "actual", "=", "convert", "(", "\"\"", ")", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "public", "void", "testNewlineConversionCR", "(", ")", "throws", "Exception", "{", "String", "expected", "=", "\"\"", ";", "String", "actual", "=", "convert", "(", "\"\"", ")", ";", "assertEquals", "(", "expected", ",", "actual", ")", ";", "}", "public", "void", "testReplaceVariables", "(", ")", "{", "Map", "<", "String", ",", "String", ">", "variables", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "variables", ".", "put", "(", "\"version\"", ",", "\"1.2.3\"", ")", ";", "variables", ".", "put", "(", "\"name\"", ",", "\"jdeb\"", ")", ";", "variables", ".", "put", "(", "\"url\"", ",", "\"\"", ")", ";", "VariableResolver", "resolver", "=", "new", "MapVariableResolver", "(", "variables", ")", ";", "String", "result", "=", "Utils", ".", "replaceVariables", "(", "resolver", ",", "\"\"", ",", "\"[[\"", ",", "\"]]\"", ")", ";", "assertEquals", "(", "\"\"", ",", "result", ")", ";", "result", "=", "Utils", ".", "replaceVariables", "(", "resolver", ",", "\"\"", ",", "\"[[\"", ",", "\"]]\"", ")", ";", "assertEquals", "(", "\"jdeb", "1.2.3\"", ",", "result", ")", ";", "result", "=", "Utils", ".", "replaceVariables", "(", "resolver", ",", "\"\"", ",", "\"[[\"", ",", "\"]]\"", ")", ";", "assertEquals", "(", "\"\"", ",", "result", ")", ";", "result", "=", "Utils", ".", "replaceVariables", "(", "resolver", ",", "\"\"", ",", "\"[[\"", ",", "\"]]\"", ")", ";", "assertEquals", "(", "\"\"", ",", "result", ")", ";", "}", "}", "</s>" ]
919
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "descriptors", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "changes", ".", "ChangeSet", ";", "public", "final", "class", "ChangesDescriptorTestCase", "extends", "TestCase", "{", "public", "void", "testToString", "(", ")", "throws", "Exception", "{", "final", "PackageDescriptor", "descriptor", "=", "new", "PackageDescriptor", "(", ")", ";", "descriptor", ".", "set", "(", "\"Package\"", ",", "\"test-package\"", ")", ";", "descriptor", ".", "set", "(", "\"Description\"", ",", "\"\"", ")", ";", "descriptor", ".", "set", "(", "\"Version\"", ",", "\"1.0\"", ")", ";", "final", "ChangesDescriptor", "changes", "=", "new", "ChangesDescriptor", "(", "descriptor", ",", "new", "ChangeSet", "[", "0", "]", ")", ";", "assertEquals", "(", "\"1.0\"", ",", "changes", ".", "get", "(", "\"Version\"", ")", ")", ";", "}", "}", "</s>" ]
920
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "descriptors", ";", "import", "java", ".", "io", ".", "ByteArrayInputStream", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "text", ".", "ParseException", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "utils", ".", "MapVariableResolver", ";", "public", "final", "class", "PackageDescriptorTestCase", "extends", "TestCase", "{", "public", "void", "testParse", "(", ")", "throws", "Exception", "{", "final", "InputStream", "is", "=", "new", "ByteArrayInputStream", "(", "(", "\"\"", "+", "\"\"", "+", "\"", "Value2.1n\"", "+", "\"", "Value2.2n\"", "+", "\"\"", ")", ".", "getBytes", "(", ")", ")", ";", "final", "PackageDescriptor", "d", "=", "new", "PackageDescriptor", "(", "is", ",", "null", ")", ";", "assertFalse", "(", "d", ".", "isValid", "(", ")", ")", ";", "assertEquals", "(", "\"key", "1\"", ",", "\"Value1\"", ",", "d", ".", "get", "(", "\"Key1\"", ")", ")", ";", "assertEquals", "(", "\"key", "2\"", ",", "\"\"", ",", "d", ".", "get", "(", "\"Key2\"", ")", ")", ";", "assertEquals", "(", "\"key", "3\"", ",", "\"Value3\"", ",", "d", ".", "get", "(", "\"Key3\"", ")", ")", ";", "}", "public", "void", "testToString", "(", ")", "throws", "Exception", "{", "PackageDescriptor", "descriptor", "=", "new", "PackageDescriptor", "(", ")", ";", "descriptor", ".", "set", "(", "\"Package\"", ",", "\"test-package\"", ")", ";", "descriptor", ".", "set", "(", "\"Description\"", ",", "\"\"", ")", ";", "descriptor", ".", "set", "(", "\"Version\"", ",", "\"1.0\"", ")", ";", "String", "s", "=", "descriptor", ".", "toString", "(", ")", ";", "PackageDescriptor", "descriptor2", "=", "new", "PackageDescriptor", "(", "new", "ByteArrayInputStream", "(", "s", ".", "getBytes", "(", ")", ")", ",", "null", ")", ";", "assertEquals", "(", "\"Package\"", ",", "descriptor", ".", "get", "(", "\"Package\"", ")", ",", "descriptor2", ".", "get", "(", "\"Package\"", ")", ")", ";", "assertEquals", "(", "\"Description\"", ",", "descriptor", ".", "get", "(", "\"Description\"", ")", ",", "descriptor2", ".", "get", "(", "\"Description\"", ")", ")", ";", "assertEquals", "(", "\"Version", "3\"", ",", "descriptor", ".", "get", "(", "\"Version\"", ")", ",", "descriptor2", ".", "get", "(", "\"Version\"", ")", ")", ";", "}", "public", "void", "testVariableSubstitution", "(", ")", "{", "final", "Map", "<", "String", ",", "String", ">", "map", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "map", ".", "put", "(", "\"VERSION\"", ",", "\"1.2\"", ")", ";", "map", ".", "put", "(", "\"MAINTAINER\"", ",", "\"\"", ")", ";", "final", "PackageDescriptor", "d", "=", "new", "PackageDescriptor", "(", "new", "MapVariableResolver", "(", "map", ")", ")", ";", "d", ".", "set", "(", "\"Version\"", ",", "\"[[VERSION]]\"", ")", ";", "d", ".", "set", "(", "\"Maintainer\"", ",", "\"\"", ")", ";", "d", ".", "set", "(", "\"NoResolve1\"", ",", "\"test[[test\"", ")", ";", "d", ".", "set", "(", "\"NoResolve2\"", ",", "\"[[test]]\"", ")", ";", "assertEquals", "(", "\"1.2\"", ",", "d", ".", "get", "(", "\"Version\"", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "d", ".", "get", "(", "\"Maintainer\"", ")", ")", ";", "assertEquals", "(", "\"test[[test\"", ",", "d", ".", "get", "(", "\"NoResolve1\"", ")", ")", ";", "assertEquals", "(", "\"[[test]]\"", ",", "d", ".", "get", "(", "\"NoResolve2\"", ")", ")", ";", "}", "public", "void", "testEmptyLines", "(", ")", "throws", "Exception", "{", "final", "InputStream", "is", "=", "new", "ByteArrayInputStream", "(", "(", "\"\"", "+", "\"\"", "+", "\"n\"", ")", ".", "getBytes", "(", ")", ")", ";", "try", "{", "new", "PackageDescriptor", "(", "is", ",", "null", ")", ";", "fail", "(", "\"\"", ")", ";", "}", "catch", "(", "ParseException", "e", ")", "{", "}", "}", "}", "</s>" ]
921
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "ar", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "ar", ".", "ArArchiveEntry", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "ar", ".", "ArArchiveInputStream", ";", "public", "final", "class", "ArInputStreamTestCase", "extends", "TestCase", "{", "public", "void", "testRead", "(", ")", "throws", "Exception", "{", "final", "File", "archive", "=", "new", "File", "(", "getClass", "(", ")", ".", "getResource", "(", "\"data.ar\"", ")", ".", "toURI", "(", ")", ")", ";", "final", "ArArchiveInputStream", "ar", "=", "new", "ArArchiveInputStream", "(", "new", "FileInputStream", "(", "archive", ")", ")", ";", "final", "ArArchiveEntry", "entry1", "=", "ar", ".", "getNextArEntry", "(", ")", ";", "assertEquals", "(", "\"data.tgz\"", ",", "entry1", ".", "getName", "(", ")", ")", ";", "assertEquals", "(", "148", ",", "entry1", ".", "getLength", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "entry1", ".", "getLength", "(", ")", ";", "i", "++", ")", "{", "ar", ".", "read", "(", ")", ";", "}", "final", "ArArchiveEntry", "entry2", "=", "ar", ".", "getNextArEntry", "(", ")", ";", "assertNull", "(", "entry2", ")", ";", "ar", ".", "close", "(", ")", ";", "}", "}", "</s>" ]
922
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "ar", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileOutputStream", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "ar", ".", "ArArchiveEntry", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "ar", ".", "ArArchiveOutputStream", ";", "public", "final", "class", "ArOutputStreamTestCase", "extends", "TestCase", "{", "public", "void", "testWrite", "(", ")", "throws", "Exception", "{", "final", "File", "out1", "=", "File", ".", "createTempFile", "(", "\"jdeb\"", ",", "\".ar\"", ")", ";", "final", "ArArchiveOutputStream", "os", "=", "new", "ArArchiveOutputStream", "(", "new", "FileOutputStream", "(", "out1", ")", ")", ";", "os", ".", "putArchiveEntry", "(", "new", "ArArchiveEntry", "(", "\"data\"", ",", "4", ")", ")", ";", "os", ".", "write", "(", "\"data\"", ".", "getBytes", "(", ")", ")", ";", "os", ".", "closeArchiveEntry", "(", ")", ";", "os", ".", "close", "(", ")", ";", "assertTrue", "(", "out1", ".", "delete", "(", ")", ")", ";", "}", "}", "</s>" ]
923
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "ar", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "public", "final", "class", "NonClosingInputStream", "extends", "InputStream", "{", "private", "final", "InputStream", "delegate", ";", "public", "NonClosingInputStream", "(", "final", "InputStream", "pDelegate", ")", "{", "delegate", "=", "pDelegate", ";", "}", "public", "int", "available", "(", ")", "throws", "IOException", "{", "return", "delegate", ".", "available", "(", ")", ";", "}", "public", "void", "close", "(", ")", "throws", "IOException", "{", "}", "public", "void", "mark", "(", "int", "readlimit", ")", "{", "delegate", ".", "mark", "(", "readlimit", ")", ";", "}", "public", "boolean", "markSupported", "(", ")", "{", "return", "delegate", ".", "markSupported", "(", ")", ";", "}", "public", "int", "read", "(", ")", "throws", "IOException", "{", "return", "delegate", ".", "read", "(", ")", ";", "}", "public", "int", "read", "(", "byte", "[", "]", "b", ",", "int", "off", ",", "int", "len", ")", "throws", "IOException", "{", "return", "delegate", ".", "read", "(", "b", ",", "off", ",", "len", ")", ";", "}", "public", "int", "read", "(", "byte", "[", "]", "b", ")", "throws", "IOException", "{", "return", "delegate", ".", "read", "(", "b", ")", ";", "}", "public", "void", "reset", "(", ")", "throws", "IOException", "{", "delegate", ".", "reset", "(", ")", ";", "}", "public", "long", "skip", "(", "long", "n", ")", "throws", "IOException", "{", "return", "delegate", ".", "skip", "(", "n", ")", ";", "}", "}", "</s>" ]
924
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "control", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "StringReader", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "util", ".", "ReaderInputStream", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "utils", ".", "MapVariableResolver", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "utils", ".", "VariableResolver", ";", "public", "class", "FilteredConfigurationFileTestCase", "extends", "TestCase", "{", "private", "VariableResolver", "variableResolver", ";", "private", "FilteredConfigurationFile", "placeHolder", ";", "protected", "void", "setUp", "(", ")", "throws", "Exception", "{", "Map", "<", "String", ",", "String", ">", "map", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "map", ".", "put", "(", "\"artifactId\"", ",", "\"jdeb\"", ")", ";", "map", ".", "put", "(", "\"myProperty1\"", ",", "\"custom1\"", ")", ";", "map", ".", "put", "(", "\"myProperty2\"", ",", "\"custom2\"", ")", ";", "variableResolver", "=", "new", "MapVariableResolver", "(", "map", ")", ";", "}", "public", "void", "testTokenSubstitution", "(", ")", "throws", "Exception", "{", "InputStream", "inputStream", "=", "new", "ReaderInputStream", "(", "new", "StringReader", "(", "\"\"", ")", ")", ";", "placeHolder", "=", "new", "FilteredConfigurationFile", "(", "\"\"", ",", "inputStream", ",", "variableResolver", ")", ";", "String", "actual", "=", "placeHolder", ".", "toString", "(", ")", ";", "assertEquals", "(", "\"\"", ",", "actual", ")", ";", "}", "public", "void", "testName", "(", ")", "throws", "Exception", "{", "InputStream", "inputStream", "=", "new", "ReaderInputStream", "(", "new", "StringReader", "(", "\"\"", ")", ")", ";", "placeHolder", "=", "new", "FilteredConfigurationFile", "(", "\"myName\"", ",", "inputStream", ",", "variableResolver", ")", ";", "assertEquals", "(", "\"myName\"", ",", "placeHolder", ".", "getName", "(", ")", ")", ";", "}", "}", "</s>" ]
925
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "ant", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "java", ".", "io", ".", "PrintStream", ";", "import", "java", ".", "util", ".", "zip", ".", "GZIPInputStream", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "ar", ".", "ArArchiveEntry", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "ar", ".", "ArArchiveInputStream", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "BuildException", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "DefaultLogger", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "Project", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "ProjectHelper", ";", "import", "org", ".", "apache", ".", "tools", ".", "bzip2", ".", "CBZip2InputStream", ";", "import", "org", ".", "apache", ".", "tools", ".", "tar", ".", "TarEntry", ";", "import", "org", ".", "apache", ".", "tools", ".", "tar", ".", "TarInputStream", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "ar", ".", "NonClosingInputStream", ";", "public", "final", "class", "DebAntTaskTestCase", "extends", "TestCase", "{", "private", "Project", "project", ";", "protected", "void", "setUp", "(", ")", "throws", "Exception", "{", "project", "=", "new", "Project", "(", ")", ";", "project", ".", "setCoreLoader", "(", "getClass", "(", ")", ".", "getClassLoader", "(", ")", ")", ";", "project", ".", "init", "(", ")", ";", "File", "buildFile", "=", "new", "File", "(", "\"\"", ")", ";", "project", ".", "setBaseDir", "(", "buildFile", ".", "getParentFile", "(", ")", ")", ";", "final", "ProjectHelper", "helper", "=", "ProjectHelper", ".", "getProjectHelper", "(", ")", ";", "helper", ".", "parse", "(", "project", ",", "buildFile", ")", ";", "File", "deb", "=", "new", "File", "(", "\"\"", ")", ";", "if", "(", "deb", ".", "exists", "(", ")", ")", "{", "assertTrue", "(", "\"\"", ",", "deb", ".", "delete", "(", ")", ")", ";", "}", "}", "public", "void", "testMissingControl", "(", ")", "{", "try", "{", "project", ".", "executeTarget", "(", "\"\"", ")", ";", "fail", "(", "\"\"", ")", ";", "}", "catch", "(", "BuildException", "e", ")", "{", "}", "}", "public", "void", "testInvalidControl", "(", ")", "{", "try", "{", "project", ".", "executeTarget", "(", "\"\"", ")", ";", "fail", "(", "\"\"", ")", ";", "}", "catch", "(", "BuildException", "e", ")", "{", "}", "}", "public", "void", "testMissingDestFile", "(", ")", "{", "try", "{", "project", ".", "executeTarget", "(", "\"\"", ")", ";", "fail", "(", "\"\"", ")", ";", "}", "catch", "(", "BuildException", "e", ")", "{", "}", "}", "public", "void", "testEmptyPackage", "(", ")", "{", "try", "{", "project", ".", "executeTarget", "(", "\"\"", ")", ";", "fail", "(", "\"\"", ")", ";", "}", "catch", "(", "BuildException", "e", ")", "{", "}", "}", "public", "void", "testPackageWithArchive", "(", ")", "{", "project", ".", "executeTarget", "(", "\"with-archive\"", ")", ";", "assertTrue", "(", "\"\"", ",", "new", "File", "(", "\"\"", ")", ".", "exists", "(", ")", ")", ";", "}", "public", "void", "testPackageWithMissingArchive", "(", ")", "{", "try", "{", "project", ".", "executeTarget", "(", "\"\"", ")", ";", "fail", "(", "\"\"", ")", ";", "}", "catch", "(", "BuildException", "e", ")", "{", "}", "}", "public", "void", "testPackageWithDirectory", "(", ")", "{", "project", ".", "executeTarget", "(", "\"\"", ")", ";", "assertTrue", "(", "\"\"", ",", "new", "File", "(", "\"\"", ")", ".", "exists", "(", ")", ")", ";", "}", "public", "void", "testPackageWithMissingDirectory", "(", ")", "{", "try", "{", "project", ".", "executeTarget", "(", "\"\"", ")", ";", "fail", "(", "\"\"", ")", ";", "}", "catch", "(", "BuildException", "e", ")", "{", "}", "}", "private", "void", "redirectOutput", "(", "OutputStream", "out", ")", "{", "DefaultLogger", "logger", "=", "new", "DefaultLogger", "(", ")", ";", "logger", ".", "setOutputPrintStream", "(", "new", "PrintStream", "(", "out", ")", ")", ";", "logger", ".", "setMessageOutputLevel", "(", "Project", ".", "MSG_INFO", ")", ";", "project", ".", "addBuildListener", "(", "logger", ")", ";", "}", "public", "void", "testVerboseEnabled", "(", ")", "{", "ByteArrayOutputStream", "out", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "redirectOutput", "(", "out", ")", ";", "project", ".", "executeTarget", "(", "\"\"", ")", ";", "assertTrue", "(", "out", ".", "toString", "(", ")", ".", "contains", "(", "\"Total", "size\"", ")", ")", ";", "}", "public", "void", "testVerboseDisabled", "(", ")", "{", "ByteArrayOutputStream", "out", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "redirectOutput", "(", "out", ")", ";", "project", ".", "executeTarget", "(", "\"\"", ")", ";", "assertTrue", "(", "!", "out", ".", "toString", "(", ")", ".", "contains", "(", "\"Total", "size\"", ")", ")", ";", "}", "public", "void", "testMissingDataType", "(", ")", "{", "try", "{", "project", ".", "executeTarget", "(", "\"\"", ")", ";", "fail", "(", "\"\"", ")", ";", "}", "catch", "(", "BuildException", "e", ")", "{", "}", "}", "public", "void", "testUnknownDataType", "(", ")", "{", "try", "{", "project", ".", "executeTarget", "(", "\"\"", ")", ";", "fail", "(", "\"\"", ")", ";", "}", "catch", "(", "BuildException", "e", ")", "{", "}", "}", "public", "void", "testFileSet", "(", ")", "{", "project", ".", "executeTarget", "(", "\"fileset\"", ")", ";", "assertTrue", "(", "\"\"", ",", "new", "File", "(", "\"\"", ")", ".", "exists", "(", ")", ")", ";", "}", "public", "void", "testTarFileSet", "(", ")", "throws", "Exception", "{", "project", ".", "executeTarget", "(", "\"tarfileset\"", ")", ";", "File", "deb", "=", "new", "File", "(", "\"\"", ")", ";", "assertTrue", "(", "\"\"", ",", "deb", ".", "exists", "(", ")", ")", ";", "ArArchiveInputStream", "in", "=", "new", "ArArchiveInputStream", "(", "new", "FileInputStream", "(", "deb", ")", ")", ";", "ArArchiveEntry", "entry", ";", "while", "(", "(", "entry", "=", "in", ".", "getNextArEntry", "(", ")", ")", "!=", "null", ")", "{", "if", "(", "entry", ".", "getName", "(", ")", ".", "equals", "(", "\"data.tar.gz\"", ")", ")", "{", "TarInputStream", "tar", "=", "new", "TarInputStream", "(", "new", "GZIPInputStream", "(", "new", "NonClosingInputStream", "(", "in", ")", ")", ")", ";", "TarEntry", "tarentry", ";", "while", "(", "(", "tarentry", "=", "tar", ".", "getNextEntry", "(", ")", ")", "!=", "null", ")", "{", "assertTrue", "(", "\"prefix\"", ",", "tarentry", ".", "getName", "(", ")", ".", "startsWith", "(", "\"./foo/\"", ")", ")", ";", "if", "(", "tarentry", ".", "isDirectory", "(", ")", ")", "{", "assertEquals", "(", "\"\"", "+", "tarentry", ".", "getName", "(", ")", "+", "\")\"", ",", "040700", ",", "tarentry", ".", "getMode", "(", ")", ")", ";", "}", "else", "{", "assertEquals", "(", "\"file", "mode", "(\"", "+", "tarentry", ".", "getName", "(", ")", "+", "\")\"", ",", "0100600", ",", "tarentry", ".", "getMode", "(", ")", ")", ";", "}", "assertEquals", "(", "\"user\"", ",", "\"ebourg\"", ",", "tarentry", ".", "getUserName", "(", ")", ")", ";", "assertEquals", "(", "\"group\"", ",", "\"ebourg\"", ",", "tarentry", ".", "getGroupName", "(", ")", ")", ";", "}", "tar", ".", "close", "(", ")", ";", "}", "else", "{", "long", "skip", "=", "entry", ".", "getLength", "(", ")", ";", "while", "(", "skip", ">", "0", ")", "{", "long", "skipped", "=", "in", ".", "skip", "(", "skip", ")", ";", "if", "(", "skipped", "==", "-", "1", ")", "{", "throw", "new", "IOException", "(", "\"\"", ")", ";", "}", "skip", "-=", "skipped", ";", "}", "}", "}", "in", ".", "close", "(", ")", ";", "}", "public", "void", "testUnkownCompression", "(", ")", "throws", "Exception", "{", "try", "{", "project", ".", "executeTarget", "(", "\"\"", ")", ";", "fail", "(", "\"\"", ")", ";", "}", "catch", "(", "BuildException", "e", ")", "{", "}", "}", "public", "void", "testBZip2Compression", "(", ")", "throws", "Exception", "{", "project", ".", "executeTarget", "(", "\"\"", ")", ";", "File", "deb", "=", "new", "File", "(", "\"\"", ")", ";", "assertTrue", "(", "\"\"", ",", "deb", ".", "exists", "(", ")", ")", ";", "boolean", "found", "=", "false", ";", "ArArchiveInputStream", "in", "=", "new", "ArArchiveInputStream", "(", "new", "FileInputStream", "(", "deb", ")", ")", ";", "ArArchiveEntry", "entry", ";", "while", "(", "(", "entry", "=", "in", ".", "getNextArEntry", "(", ")", ")", "!=", "null", ")", "{", "if", "(", "entry", ".", "getName", "(", ")", ".", "equals", "(", "\"data.tar.bz2\"", ")", ")", "{", "found", "=", "true", ";", "assertEquals", "(", "\"header", "0\"", ",", "(", "byte", ")", "'B'", ",", "in", ".", "read", "(", ")", ")", ";", "assertEquals", "(", "\"header", "1\"", ",", "(", "byte", ")", "'Z'", ",", "in", ".", "read", "(", ")", ")", ";", "TarInputStream", "tar", "=", "new", "TarInputStream", "(", "new", "CBZip2InputStream", "(", "in", ")", ")", ";", "while", "(", "(", "tar", ".", "getNextEntry", "(", ")", ")", "!=", "null", ")", "{", ";", "}", "tar", ".", "close", "(", ")", ";", "break", ";", "}", "else", "{", "long", "skip", "=", "entry", ".", "getLength", "(", ")", ";", "while", "(", "skip", ">", "0", ")", "{", "long", "skipped", "=", "in", ".", "skip", "(", "skip", ")", ";", "if", "(", "skipped", "==", "-", "1", ")", "{", "throw", "new", "IOException", "(", "\"\"", ")", ";", "}", "skip", "-=", "skipped", ";", "}", "}", "}", "in", ".", "close", "(", ")", ";", "assertTrue", "(", "\"\"", ",", "found", ")", ";", "}", "public", "void", "testNoCompression", "(", ")", "throws", "Exception", "{", "project", ".", "executeTarget", "(", "\"\"", ")", ";", "File", "deb", "=", "new", "File", "(", "\"\"", ")", ";", "assertTrue", "(", "\"\"", ",", "deb", ".", "exists", "(", ")", ")", ";", "boolean", "found", "=", "false", ";", "ArArchiveInputStream", "in", "=", "new", "ArArchiveInputStream", "(", "new", "FileInputStream", "(", "deb", ")", ")", ";", "ArArchiveEntry", "entry", ";", "while", "(", "(", "entry", "=", "in", ".", "getNextArEntry", "(", ")", ")", "!=", "null", ")", "{", "if", "(", "entry", ".", "getName", "(", ")", ".", "equals", "(", "\"data.tar\"", ")", ")", "{", "found", "=", "true", ";", "TarInputStream", "tar", "=", "new", "TarInputStream", "(", "new", "NonClosingInputStream", "(", "in", ")", ")", ";", "while", "(", "(", "tar", ".", "getNextEntry", "(", ")", ")", "!=", "null", ")", "{", ";", "}", "tar", ".", "close", "(", ")", ";", "}", "else", "{", "long", "skip", "=", "entry", ".", "getLength", "(", ")", ";", "while", "(", "skip", ">", "0", ")", "{", "long", "skipped", "=", "in", ".", "skip", "(", "skip", ")", ";", "if", "(", "skipped", "==", "-", "1", ")", "{", "throw", "new", "IOException", "(", "\"\"", ")", ";", "}", "skip", "-=", "skipped", ";", "}", "}", "}", "in", ".", "close", "(", ")", ";", "assertTrue", "(", "\"\"", ",", "found", ")", ";", "}", "}", "</s>" ]
926
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ";", "import", "java", ".", "io", ".", "ByteArrayInputStream", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "FileNotFoundException", ";", "import", "java", ".", "io", ".", "FileOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "java", ".", "math", ".", "BigInteger", ";", "import", "java", ".", "security", ".", "DigestOutputStream", ";", "import", "java", ".", "security", ".", "MessageDigest", ";", "import", "java", ".", "security", ".", "NoSuchAlgorithmException", ";", "import", "java", ".", "text", ".", "ParseException", ";", "import", "java", ".", "text", ".", "SimpleDateFormat", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "java", ".", "util", ".", "zip", ".", "GZIPOutputStream", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "ar", ".", "ArArchiveEntry", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "ar", ".", "ArArchiveOutputStream", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "tar", ".", "TarArchiveEntry", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "tar", ".", "TarArchiveOutputStream", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "compressors", ".", "CompressorException", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "compressors", ".", "CompressorStreamFactory", ";", "import", "org", ".", "apache", ".", "commons", ".", "io", ".", "output", ".", "NullOutputStream", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "DirectoryScanner", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "changes", ".", "ChangeSet", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "changes", ".", "ChangesProvider", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "control", ".", "FilteredConfigurationFile", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "descriptors", ".", "ChangesDescriptor", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "descriptors", ".", "PackageDescriptor", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "PermMapper", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "signing", ".", "SigningUtils", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "utils", ".", "InformationInputStream", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "utils", ".", "InformationOutputStream", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "utils", ".", "Utils", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "utils", ".", "VariableResolver", ";", "public", "class", "Processor", "{", "private", "static", "final", "Set", "<", "String", ">", "CONFIGURATION_FILENAMES", "=", "new", "HashSet", "<", "String", ">", "(", "Arrays", ".", "asList", "(", "new", "String", "[", "]", "{", "\"conffiles\"", ",", "\"preinst\"", ",", "\"postinst\"", ",", "\"prerm\"", ",", "\"postrm\"", "}", ")", ")", ";", "private", "final", "Console", "console", ";", "private", "final", "VariableResolver", "resolver", ";", "private", "List", "<", "FilteredConfigurationFile", ">", "configurationFiles", ";", "private", "static", "final", "class", "Total", "{", "private", "BigInteger", "count", "=", "BigInteger", ".", "valueOf", "(", "0", ")", ";", "public", "void", "add", "(", "long", "size", ")", "{", "count", "=", "count", ".", "add", "(", "BigInteger", ".", "valueOf", "(", "size", ")", ")", ";", "}", "public", "String", "toString", "(", ")", "{", "return", "\"\"", "+", "count", ";", "}", "}", "public", "Processor", "(", "final", "Console", "pConsole", ",", "final", "VariableResolver", "pResolver", ")", "{", "console", "=", "pConsole", ";", "resolver", "=", "pResolver", ";", "configurationFiles", "=", "new", "ArrayList", "<", "FilteredConfigurationFile", ">", "(", ")", ";", "}", "private", "void", "addTo", "(", "final", "ArArchiveOutputStream", "pOutput", ",", "final", "String", "pName", ",", "final", "String", "pContent", ")", "throws", "IOException", "{", "final", "byte", "[", "]", "content", "=", "pContent", ".", "getBytes", "(", ")", ";", "pOutput", ".", "putArchiveEntry", "(", "new", "ArArchiveEntry", "(", "pName", ",", "content", ".", "length", ")", ")", ";", "pOutput", ".", "write", "(", "content", ")", ";", "pOutput", ".", "closeArchiveEntry", "(", ")", ";", "}", "private", "void", "addTo", "(", "final", "ArArchiveOutputStream", "pOutput", ",", "final", "String", "pName", ",", "final", "File", "pContent", ")", "throws", "IOException", "{", "pOutput", ".", "putArchiveEntry", "(", "new", "ArArchiveEntry", "(", "pName", ",", "pContent", ".", "length", "(", ")", ")", ")", ";", "final", "InputStream", "input", "=", "new", "FileInputStream", "(", "pContent", ")", ";", "try", "{", "Utils", ".", "copy", "(", "input", ",", "pOutput", ")", ";", "}", "finally", "{", "input", ".", "close", "(", ")", ";", "}", "pOutput", ".", "closeArchiveEntry", "(", ")", ";", "}", "public", "PackageDescriptor", "createDeb", "(", "final", "File", "[", "]", "pControlFiles", ",", "final", "DataProducer", "[", "]", "pData", ",", "final", "File", "pOutput", ",", "String", "compression", ")", "throws", "PackagingException", "{", "File", "tempData", "=", "null", ";", "File", "tempControl", "=", "null", ";", "try", "{", "tempData", "=", "File", ".", "createTempFile", "(", "\"deb\"", ",", "\"data\"", ")", ";", "tempControl", "=", "File", ".", "createTempFile", "(", "\"deb\"", ",", "\"control\"", ")", ";", "console", ".", "info", "(", "\"\"", ")", ";", "final", "StringBuilder", "md5s", "=", "new", "StringBuilder", "(", ")", ";", "final", "BigInteger", "size", "=", "buildData", "(", "pData", ",", "tempData", ",", "md5s", ",", "compression", ")", ";", "console", ".", "info", "(", "\"\"", ")", ";", "final", "PackageDescriptor", "packageDescriptor", "=", "buildControl", "(", "pControlFiles", ",", "size", ",", "md5s", ",", "tempControl", ")", ";", "if", "(", "!", "packageDescriptor", ".", "isValid", "(", ")", ")", "{", "throw", "new", "PackagingException", "(", "\"\"", "+", "packageDescriptor", ".", "invalidKeys", "(", ")", "+", "\"\"", "+", "Arrays", ".", "toString", "(", "PackageDescriptor", ".", "mandatoryKeys", ")", "+", "\"\"", ")", ";", "}", "pOutput", ".", "getParentFile", "(", ")", ".", "mkdirs", "(", ")", ";", "final", "InformationOutputStream", "md5output", "=", "new", "InformationOutputStream", "(", "new", "FileOutputStream", "(", "pOutput", ")", ",", "MessageDigest", ".", "getInstance", "(", "\"MD5\"", ")", ")", ";", "final", "InformationOutputStream", "sha1output", "=", "new", "InformationOutputStream", "(", "md5output", ",", "MessageDigest", ".", "getInstance", "(", "\"SHA1\"", ")", ")", ";", "final", "InformationOutputStream", "sha256output", "=", "new", "InformationOutputStream", "(", "sha1output", ",", "MessageDigest", ".", "getInstance", "(", "\"SHA-256\"", ")", ")", ";", "final", "ArArchiveOutputStream", "ar", "=", "new", "ArArchiveOutputStream", "(", "sha256output", ")", ";", "addTo", "(", "ar", ",", "\"\"", ",", "\"2.0n\"", ")", ";", "addTo", "(", "ar", ",", "\"\"", ",", "tempControl", ")", ";", "addTo", "(", "ar", ",", "\"data.tar\"", "+", "getExtension", "(", "compression", ")", ",", "tempData", ")", ";", "ar", ".", "close", "(", ")", ";", "packageDescriptor", ".", "set", "(", "\"MD5\"", ",", "md5output", ".", "getHexDigest", "(", ")", ")", ";", "packageDescriptor", ".", "set", "(", "\"SHA1\"", ",", "sha1output", ".", "getHexDigest", "(", ")", ")", ";", "packageDescriptor", ".", "set", "(", "\"SHA256\"", ",", "sha256output", ".", "getHexDigest", "(", ")", ")", ";", "packageDescriptor", ".", "set", "(", "\"Size\"", ",", "\"\"", "+", "md5output", ".", "getSize", "(", ")", ")", ";", "packageDescriptor", ".", "set", "(", "\"File\"", ",", "pOutput", ".", "getName", "(", ")", ")", ";", "return", "packageDescriptor", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "PackagingException", "(", "\"\"", ",", "e", ")", ";", "}", "finally", "{", "if", "(", "tempData", "!=", "null", ")", "{", "if", "(", "!", "tempData", ".", "delete", "(", ")", ")", "{", "throw", "new", "PackagingException", "(", "\"\"", "+", "tempData", ")", ";", "}", "}", "if", "(", "tempControl", "!=", "null", ")", "{", "if", "(", "!", "tempControl", ".", "delete", "(", ")", ")", "{", "throw", "new", "PackagingException", "(", "\"\"", "+", "tempControl", ")", ";", "}", "}", "}", "}", "private", "String", "getExtension", "(", "final", "String", "pCompression", ")", "{", "if", "(", "\"gzip\"", ".", "equals", "(", "pCompression", ")", ")", "{", "return", "\".gz\"", ";", "}", "else", "if", "(", "\"bzip2\"", ".", "equals", "(", "pCompression", ")", ")", "{", "return", "\".bz2\"", ";", "}", "else", "{", "return", "\"\"", ";", "}", "}", "public", "ChangesDescriptor", "createChanges", "(", "final", "PackageDescriptor", "pPackageDescriptor", ",", "final", "ChangesProvider", "pChangesProvider", ",", "final", "InputStream", "pRing", ",", "final", "String", "pKey", ",", "final", "String", "pPassphrase", ",", "final", "OutputStream", "pOutput", ")", "throws", "IOException", ",", "PackagingException", "{", "final", "ChangeSet", "[", "]", "changeSets", "=", "pChangesProvider", ".", "getChangesSets", "(", ")", ";", "final", "ChangesDescriptor", "changesDescriptor", "=", "new", "ChangesDescriptor", "(", "pPackageDescriptor", ",", "changeSets", ")", ";", "changesDescriptor", ".", "set", "(", "\"Format\"", ",", "\"1.8\"", ")", ";", "if", "(", "changesDescriptor", ".", "get", "(", "\"Binary\"", ")", "==", "null", ")", "{", "changesDescriptor", ".", "set", "(", "\"Binary\"", ",", "changesDescriptor", ".", "get", "(", "\"Package\"", ")", ")", ";", "}", "if", "(", "changesDescriptor", ".", "get", "(", "\"Source\"", ")", "==", "null", ")", "{", "changesDescriptor", ".", "set", "(", "\"Source\"", ",", "changesDescriptor", ".", "get", "(", "\"Package\"", ")", ")", ";", "}", "final", "StringBuilder", "checksumsSha1", "=", "new", "StringBuilder", "(", "\"n\"", ")", ";", "checksumsSha1", ".", "append", "(", "'", "'", ")", ".", "append", "(", "changesDescriptor", ".", "get", "(", "\"SHA1\"", ")", ")", ";", "checksumsSha1", ".", "append", "(", "'", "'", ")", ".", "append", "(", "changesDescriptor", ".", "get", "(", "\"Size\"", ")", ")", ";", "checksumsSha1", ".", "append", "(", "'", "'", ")", ".", "append", "(", "changesDescriptor", ".", "get", "(", "\"File\"", ")", ")", ";", "changesDescriptor", ".", "set", "(", "\"\"", ",", "checksumsSha1", ".", "toString", "(", ")", ")", ";", "final", "StringBuilder", "checksumsSha256", "=", "new", "StringBuilder", "(", "\"n\"", ")", ";", "checksumsSha256", ".", "append", "(", "'", "'", ")", ".", "append", "(", "changesDescriptor", ".", "get", "(", "\"SHA256\"", ")", ")", ";", "checksumsSha256", ".", "append", "(", "'", "'", ")", ".", "append", "(", "changesDescriptor", ".", "get", "(", "\"Size\"", ")", ")", ";", "checksumsSha256", ".", "append", "(", "'", "'", ")", ".", "append", "(", "changesDescriptor", ".", "get", "(", "\"File\"", ")", ")", ";", "changesDescriptor", ".", "set", "(", "\"\"", ",", "checksumsSha256", ".", "toString", "(", ")", ")", ";", "final", "StringBuilder", "files", "=", "new", "StringBuilder", "(", "\"n\"", ")", ";", "files", ".", "append", "(", "'", "'", ")", ".", "append", "(", "changesDescriptor", ".", "get", "(", "\"MD5\"", ")", ")", ";", "files", ".", "append", "(", "'", "'", ")", ".", "append", "(", "changesDescriptor", ".", "get", "(", "\"Size\"", ")", ")", ";", "files", ".", "append", "(", "'", "'", ")", ".", "append", "(", "changesDescriptor", ".", "get", "(", "\"Section\"", ")", ")", ";", "files", ".", "append", "(", "'", "'", ")", ".", "append", "(", "changesDescriptor", ".", "get", "(", "\"Priority\"", ")", ")", ";", "files", ".", "append", "(", "'", "'", ")", ".", "append", "(", "changesDescriptor", ".", "get", "(", "\"File\"", ")", ")", ";", "changesDescriptor", ".", "set", "(", "\"Files\"", ",", "files", ".", "toString", "(", ")", ")", ";", "if", "(", "!", "changesDescriptor", ".", "isValid", "(", ")", ")", "{", "throw", "new", "PackagingException", "(", "\"\"", "+", "changesDescriptor", ".", "invalidKeys", "(", ")", "+", "\"\"", "+", "Arrays", ".", "toString", "(", "ChangesDescriptor", ".", "mandatoryKeys", ")", "+", "\"\"", ")", ";", "}", "final", "String", "changes", "=", "changesDescriptor", ".", "toString", "(", ")", ";", "final", "byte", "[", "]", "changesBytes", "=", "changes", ".", "getBytes", "(", "\"UTF-8\"", ")", ";", "if", "(", "pRing", "==", "null", "||", "pKey", "==", "null", "||", "pPassphrase", "==", "null", ")", "{", "pOutput", ".", "write", "(", "changesBytes", ")", ";", "pOutput", ".", "close", "(", ")", ";", "return", "changesDescriptor", ";", "}", "console", ".", "info", "(", "\"\"", "+", "pKey", ")", ";", "final", "InputStream", "input", "=", "new", "ByteArrayInputStream", "(", "changesBytes", ")", ";", "try", "{", "SigningUtils", ".", "clearSign", "(", "input", ",", "pRing", ",", "pKey", ",", "pPassphrase", ",", "pOutput", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "pOutput", ".", "close", "(", ")", ";", "return", "changesDescriptor", ";", "}", "private", "PackageDescriptor", "buildControl", "(", "final", "File", "[", "]", "pControlFiles", ",", "final", "BigInteger", "pDataSize", ",", "final", "StringBuilder", "pChecksums", ",", "final", "File", "pOutput", ")", "throws", "IOException", ",", "ParseException", "{", "final", "File", "dir", "=", "pOutput", ".", "getParentFile", "(", ")", ";", "if", "(", "dir", "!=", "null", "&&", "(", "!", "dir", ".", "exists", "(", ")", "||", "!", "dir", ".", "isDirectory", "(", ")", ")", ")", "{", "throw", "new", "IOException", "(", "\"\"", "+", "pOutput", ".", "getAbsolutePath", "(", ")", "+", "\"'\"", ")", ";", "}", "final", "TarArchiveOutputStream", "outputStream", "=", "new", "TarArchiveOutputStream", "(", "new", "GZIPOutputStream", "(", "new", "FileOutputStream", "(", "pOutput", ")", ")", ")", ";", "outputStream", ".", "setLongFileMode", "(", "TarArchiveOutputStream", ".", "LONGFILE_GNU", ")", ";", "PackageDescriptor", "packageDescriptor", "=", "null", ";", "for", "(", "File", "file", ":", "pControlFiles", ")", "{", "if", "(", "file", ".", "isDirectory", "(", ")", ")", "{", "boolean", "isDefaultExcludes", "=", "false", ";", "for", "(", "String", "pattern", ":", "DirectoryScanner", ".", "getDefaultExcludes", "(", ")", ")", "{", "isDefaultExcludes", "=", "DirectoryScanner", ".", "match", "(", "pattern", ",", "file", ".", "getAbsolutePath", "(", ")", ".", "replace", "(", "\"\\\\\"", ",", "\"/\"", ")", ")", ";", "if", "(", "isDefaultExcludes", ")", "{", "break", ";", "}", "}", "if", "(", "!", "isDefaultExcludes", ")", "{", "console", ".", "info", "(", "\"\"", "+", "file", "+", "\"\"", ")", ";", "}", "continue", ";", "}", "final", "TarArchiveEntry", "entry", "=", "new", "TarArchiveEntry", "(", "file", ")", ";", "final", "String", "name", "=", "file", ".", "getName", "(", ")", ";", "entry", ".", "setName", "(", "\"./\"", "+", "name", ")", ";", "entry", ".", "setNames", "(", "\"root\"", ",", "\"root\"", ")", ";", "entry", ".", "setMode", "(", "PermMapper", ".", "toMode", "(", "\"755\"", ")", ")", ";", "if", "(", "CONFIGURATION_FILENAMES", ".", "contains", "(", "name", ")", ")", "{", "FilteredConfigurationFile", "configurationFile", "=", "new", "FilteredConfigurationFile", "(", "file", ".", "getName", "(", ")", ",", "new", "FileInputStream", "(", "file", ")", ",", "resolver", ")", ";", "configurationFiles", ".", "add", "(", "configurationFile", ")", ";", "}", "else", "if", "(", "\"control\"", ".", "equals", "(", "name", ")", ")", "{", "packageDescriptor", "=", "new", "PackageDescriptor", "(", "new", "FileInputStream", "(", "file", ")", ",", "resolver", ")", ";", "if", "(", "packageDescriptor", ".", "get", "(", "\"Date\"", ")", "==", "null", ")", "{", "SimpleDateFormat", "fmt", "=", "new", "SimpleDateFormat", "(", "\"\"", ",", "Locale", ".", "ENGLISH", ")", ";", "packageDescriptor", ".", "set", "(", "\"Date\"", ",", "fmt", ".", "format", "(", "new", "Date", "(", ")", ")", ")", ";", "}", "if", "(", "packageDescriptor", ".", "get", "(", "\"Distribution\"", ")", "==", "null", ")", "{", "packageDescriptor", ".", "set", "(", "\"Distribution\"", ",", "\"unknown\"", ")", ";", "}", "if", "(", "packageDescriptor", ".", "get", "(", "\"Urgency\"", ")", "==", "null", ")", "{", "packageDescriptor", ".", "set", "(", "\"Urgency\"", ",", "\"low\"", ")", ";", "}", "packageDescriptor", ".", "set", "(", "\"\"", ",", "pDataSize", ".", "divide", "(", "BigInteger", ".", "valueOf", "(", "1024", ")", ")", ".", "toString", "(", ")", ")", ";", "final", "String", "debFullName", "=", "System", ".", "getenv", "(", "\"DEBFULLNAME\"", ")", ";", "final", "String", "debEmail", "=", "System", ".", "getenv", "(", "\"DEBEMAIL\"", ")", ";", "if", "(", "debFullName", "!=", "null", "&&", "debEmail", "!=", "null", ")", "{", "final", "String", "maintainer", "=", "debFullName", "+", "\"", "<\"", "+", "debEmail", "+", "\">\"", ";", "packageDescriptor", ".", "set", "(", "\"Maintainer\"", ",", "maintainer", ")", ";", "console", ".", "info", "(", "\"\"", "+", "maintainer", "+", "\"\"", ")", ";", "}", "}", "else", "{", "InformationInputStream", "infoStream", "=", "new", "InformationInputStream", "(", "new", "FileInputStream", "(", "file", ")", ")", ";", "Utils", ".", "copy", "(", "infoStream", ",", "NullOutputStream", ".", "NULL_OUTPUT_STREAM", ")", ";", "infoStream", ".", "close", "(", ")", ";", "InputStream", "in", "=", "new", "FileInputStream", "(", "file", ")", ";", "if", "(", "infoStream", ".", "isShell", "(", ")", "&&", "!", "infoStream", ".", "hasUnixLineEndings", "(", ")", ")", "{", "byte", "[", "]", "buf", "=", "Utils", ".", "toUnixLineEndings", "(", "in", ")", ";", "entry", ".", "setSize", "(", "buf", ".", "length", ")", ";", "in", "=", "new", "ByteArrayInputStream", "(", "buf", ")", ";", "}", "outputStream", ".", "putArchiveEntry", "(", "entry", ")", ";", "Utils", ".", "copy", "(", "in", ",", "outputStream", ")", ";", "outputStream", ".", "closeArchiveEntry", "(", ")", ";", "in", ".", "close", "(", ")", ";", "}", "}", "if", "(", "packageDescriptor", "==", "null", ")", "{", "throw", "new", "FileNotFoundException", "(", "\"\"", "+", "Arrays", ".", "toString", "(", "pControlFiles", ")", ")", ";", "}", "for", "(", "FilteredConfigurationFile", "configurationFile", ":", "configurationFiles", ")", "{", "addControlEntry", "(", "configurationFile", ".", "getName", "(", ")", ",", "configurationFile", ".", "toString", "(", ")", ",", "outputStream", ")", ";", "}", "addEntry", "(", "\"control\"", ",", "packageDescriptor", ".", "toString", "(", ")", ",", "outputStream", ")", ";", "addEntry", "(", "\"md5sums\"", ",", "pChecksums", ".", "toString", "(", ")", ",", "outputStream", ")", ";", "outputStream", ".", "close", "(", ")", ";", "return", "packageDescriptor", ";", "}", "private", "OutputStream", "compressedOutputStream", "(", "String", "pCompression", ",", "final", "OutputStream", "outputStream", ")", "throws", "CompressorException", "{", "if", "(", "\"none\"", ".", "equalsIgnoreCase", "(", "pCompression", ")", ")", "{", "return", "outputStream", ";", "}", "if", "(", "\"gzip\"", ".", "equals", "(", "pCompression", ")", ")", "{", "pCompression", "=", "\"gz\"", ";", "}", "return", "new", "CompressorStreamFactory", "(", ")", ".", "createCompressorOutputStream", "(", "pCompression", ",", "outputStream", ")", ";", "}", "BigInteger", "buildData", "(", "final", "DataProducer", "[", "]", "pData", ",", "final", "File", "pOutput", ",", "final", "StringBuilder", "pChecksums", ",", "String", "pCompression", ")", "throws", "NoSuchAlgorithmException", ",", "IOException", ",", "CompressorException", "{", "final", "File", "dir", "=", "pOutput", ".", "getParentFile", "(", ")", ";", "if", "(", "dir", "!=", "null", "&&", "(", "!", "dir", ".", "exists", "(", ")", "||", "!", "dir", ".", "isDirectory", "(", ")", ")", ")", "{", "throw", "new", "IOException", "(", "\"\"", "+", "pOutput", ".", "getAbsolutePath", "(", ")", "+", "\"'\"", ")", ";", "}", "final", "TarArchiveOutputStream", "tarOutputStream", "=", "new", "TarArchiveOutputStream", "(", "compressedOutputStream", "(", "pCompression", ",", "new", "FileOutputStream", "(", "pOutput", ")", ")", ")", ";", "tarOutputStream", ".", "setLongFileMode", "(", "TarArchiveOutputStream", ".", "LONGFILE_GNU", ")", ";", "final", "MessageDigest", "digest", "=", "MessageDigest", ".", "getInstance", "(", "\"MD5\"", ")", ";", "final", "Total", "dataSize", "=", "new", "Total", "(", ")", ";", "final", "List", "addedDirectories", "=", "new", "ArrayList", "(", ")", ";", "final", "DataConsumer", "receiver", "=", "new", "DataConsumer", "(", ")", "{", "public", "void", "onEachDir", "(", "String", "dirname", ",", "String", "linkname", ",", "String", "user", ",", "int", "uid", ",", "String", "group", ",", "int", "gid", ",", "int", "mode", ",", "long", "size", ")", "throws", "IOException", "{", "dirname", "=", "fixPath", "(", "dirname", ")", ";", "createParentDirectories", "(", "(", "new", "File", "(", "dirname", ")", ")", ".", "getParent", "(", ")", ",", "user", ",", "uid", ",", "group", ",", "gid", ")", ";", "createDirectory", "(", "dirname", ",", "user", ",", "uid", ",", "group", ",", "gid", ",", "mode", ",", "0", ")", ";", "console", ".", "info", "(", "\"dir:", "\"", "+", "dirname", ")", ";", "}", "public", "void", "onEachFile", "(", "InputStream", "inputStream", ",", "String", "filename", ",", "String", "linkname", ",", "String", "user", ",", "int", "uid", ",", "String", "group", ",", "int", "gid", ",", "int", "mode", ",", "long", "size", ")", "throws", "IOException", "{", "filename", "=", "fixPath", "(", "filename", ")", ";", "createParentDirectories", "(", "(", "new", "File", "(", "filename", ")", ")", ".", "getParent", "(", ")", ",", "user", ",", "uid", ",", "group", ",", "gid", ")", ";", "final", "TarArchiveEntry", "entry", "=", "new", "TarArchiveEntry", "(", "filename", ",", "true", ")", ";", "entry", ".", "setUserName", "(", "user", ")", ";", "entry", ".", "setUserId", "(", "uid", ")", ";", "entry", ".", "setGroupName", "(", "group", ")", ";", "entry", ".", "setGroupId", "(", "gid", ")", ";", "entry", ".", "setMode", "(", "mode", ")", ";", "entry", ".", "setSize", "(", "size", ")", ";", "tarOutputStream", ".", "putArchiveEntry", "(", "entry", ")", ";", "dataSize", ".", "add", "(", "size", ")", ";", "digest", ".", "reset", "(", ")", ";", "Utils", ".", "copy", "(", "inputStream", ",", "new", "DigestOutputStream", "(", "tarOutputStream", ",", "digest", ")", ")", ";", "final", "String", "md5", "=", "Utils", ".", "toHex", "(", "digest", ".", "digest", "(", ")", ")", ";", "tarOutputStream", ".", "closeArchiveEntry", "(", ")", ";", "console", ".", "info", "(", "\"file:\"", "+", "entry", ".", "getName", "(", ")", "+", "\"", "size:\"", "+", "entry", ".", "getSize", "(", ")", "+", "\"", "mode:\"", "+", "entry", ".", "getMode", "(", ")", "+", "\"", "linkname:\"", "+", "entry", ".", "getLinkName", "(", ")", "+", "\"", "username:\"", "+", "entry", ".", "getUserName", "(", ")", "+", "\"", "userid:\"", "+", "entry", ".", "getUserId", "(", ")", "+", "\"", "groupname:\"", "+", "entry", ".", "getGroupName", "(", ")", "+", "\"", "groupid:\"", "+", "entry", ".", "getGroupId", "(", ")", "+", "\"", "modtime:\"", "+", "entry", ".", "getModTime", "(", ")", "+", "\"", "md5:", "\"", "+", "md5", ")", ";", "pChecksums", ".", "append", "(", "md5", ")", ".", "append", "(", "\"", "\"", ")", ".", "append", "(", "entry", ".", "getName", "(", ")", ")", ".", "append", "(", "'\\n'", ")", ";", "}", "public", "void", "onEachLink", "(", "String", "path", ",", "String", "linkName", ",", "boolean", "symlink", ",", "String", "user", ",", "int", "uid", ",", "String", "group", ",", "int", "gid", ")", "throws", "IOException", "{", "path", "=", "fixPath", "(", "path", ")", ";", "createParentDirectories", "(", "(", "new", "File", "(", "path", ")", ")", ".", "getParent", "(", ")", ",", "user", ",", "uid", ",", "group", ",", "gid", ")", ";", "final", "TarArchiveEntry", "entry", "=", "new", "TarArchiveEntry", "(", "path", ",", "symlink", "?", "TarArchiveEntry", ".", "LF_SYMLINK", ":", "TarArchiveEntry", ".", "LF_LINK", ")", ";", "entry", ".", "setName", "(", "path", ")", ";", "entry", ".", "setLinkName", "(", "linkName", ")", ";", "tarOutputStream", ".", "putArchiveEntry", "(", "entry", ")", ";", "tarOutputStream", ".", "closeArchiveEntry", "(", ")", ";", "}", "private", "String", "fixPath", "(", "String", "path", ")", "{", "if", "(", "path", ".", "indexOf", "(", "'\\\\'", ")", ">", "-", "1", ")", "{", "path", "=", "path", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "}", "if", "(", "path", ".", "startsWith", "(", "\"/\"", ")", ")", "{", "path", "=", "\".\"", "+", "path", ";", "}", "else", "if", "(", "!", "path", ".", "startsWith", "(", "\"./\"", ")", ")", "{", "path", "=", "\"./\"", "+", "path", ";", "}", "return", "path", ";", "}", "private", "void", "createDirectory", "(", "String", "directory", ",", "String", "user", ",", "int", "uid", ",", "String", "group", ",", "int", "gid", ",", "int", "mode", ",", "long", "size", ")", "throws", "IOException", "{", "if", "(", "!", "directory", ".", "endsWith", "(", "\"/\"", ")", ")", "{", "directory", "+=", "\"/\"", ";", "}", "if", "(", "!", "addedDirectories", ".", "contains", "(", "directory", ")", ")", "{", "TarArchiveEntry", "entry", "=", "new", "TarArchiveEntry", "(", "directory", ",", "true", ")", ";", "entry", ".", "setUserName", "(", "user", ")", ";", "entry", ".", "setUserId", "(", "uid", ")", ";", "entry", ".", "setGroupName", "(", "group", ")", ";", "entry", ".", "setGroupId", "(", "gid", ")", ";", "entry", ".", "setMode", "(", "mode", ")", ";", "entry", ".", "setSize", "(", "size", ")", ";", "tarOutputStream", ".", "putArchiveEntry", "(", "entry", ")", ";", "tarOutputStream", ".", "closeArchiveEntry", "(", ")", ";", "addedDirectories", ".", "add", "(", "directory", ")", ";", "}", "}", "private", "void", "createParentDirectories", "(", "String", "dirname", ",", "String", "user", ",", "int", "uid", ",", "String", "group", ",", "int", "gid", ")", "throws", "IOException", "{", "if", "(", "dirname", "==", "null", ")", "{", "return", ";", "}", "String", "[", "]", "pathParts", "=", "dirname", ".", "split", "(", "\"\\\\/\"", ")", ";", "String", "parentDir", "=", "\"./\"", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "pathParts", ".", "length", ";", "i", "++", ")", "{", "parentDir", "+=", "pathParts", "[", "i", "]", "+", "\"/\"", ";", "int", "mode", "=", "TarArchiveEntry", ".", "DEFAULT_DIR_MODE", ";", "createDirectory", "(", "parentDir", ",", "user", ",", "uid", ",", "group", ",", "gid", ",", "mode", ",", "0", ")", ";", "}", "}", "}", ";", "try", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "pData", ".", "length", ";", "i", "++", ")", "{", "final", "DataProducer", "data", "=", "pData", "[", "i", "]", ";", "data", ".", "produce", "(", "receiver", ")", ";", "}", "}", "finally", "{", "tarOutputStream", ".", "close", "(", ")", ";", "}", "console", ".", "info", "(", "\"Total", "size:", "\"", "+", "dataSize", ")", ";", "return", "dataSize", ".", "count", ";", "}", "private", "static", "void", "addEntry", "(", "final", "String", "pName", ",", "final", "String", "pContent", ",", "final", "TarArchiveOutputStream", "pOutput", ")", "throws", "IOException", "{", "final", "byte", "[", "]", "data", "=", "pContent", ".", "getBytes", "(", "\"UTF-8\"", ")", ";", "final", "TarArchiveEntry", "entry", "=", "new", "TarArchiveEntry", "(", "\"./\"", "+", "pName", ",", "true", ")", ";", "entry", ".", "setSize", "(", "data", ".", "length", ")", ";", "entry", ".", "setNames", "(", "\"root\"", ",", "\"root\"", ")", ";", "pOutput", ".", "putArchiveEntry", "(", "entry", ")", ";", "pOutput", ".", "write", "(", "data", ")", ";", "pOutput", ".", "closeArchiveEntry", "(", ")", ";", "}", "private", "static", "void", "addControlEntry", "(", "final", "String", "pName", ",", "final", "String", "pContent", ",", "final", "TarArchiveOutputStream", "pOutput", ")", "throws", "IOException", "{", "final", "byte", "[", "]", "data", "=", "pContent", ".", "getBytes", "(", "\"UTF-8\"", ")", ";", "final", "TarArchiveEntry", "entry", "=", "new", "TarArchiveEntry", "(", "\"./\"", "+", "pName", ",", "true", ")", ";", "entry", ".", "setSize", "(", "data", ".", "length", ")", ";", "entry", ".", "setNames", "(", "\"root\"", ",", "\"root\"", ")", ";", "entry", ".", "setMode", "(", "PermMapper", ".", "toMode", "(", "\"755\"", ")", ")", ";", "pOutput", ".", "putArchiveEntry", "(", "entry", ")", ";", "pOutput", ".", "write", "(", "data", ")", ";", "pOutput", ".", "closeArchiveEntry", "(", ")", ";", "}", "}", "</s>" ]
927
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "ant", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileNotFoundException", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "types", ".", "PatternSet", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataConsumer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataProducer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "producers", ".", "DataProducerArchive", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "producers", ".", "DataProducerDirectory", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "producers", ".", "DataProducerFile", ";", "public", "final", "class", "Data", "extends", "PatternSet", "implements", "DataProducer", "{", "private", "final", "Collection", "<", "Mapper", ">", "mapperWrapper", "=", "new", "ArrayList", "<", "Mapper", ">", "(", ")", ";", "private", "File", "src", ";", "private", "String", "type", ";", "private", "String", "destinationName", ";", "public", "void", "setSrc", "(", "File", "src", ")", "{", "this", ".", "src", "=", "src", ";", "}", "public", "String", "getType", "(", ")", "{", "return", "type", ";", "}", "public", "void", "setType", "(", "String", "type", ")", "{", "this", ".", "type", "=", "type", ";", "}", "public", "void", "setDst", "(", "String", "destinationName", ")", "{", "this", ".", "destinationName", "=", "destinationName", ";", "}", "public", "void", "addMapper", "(", "Mapper", "mapper", ")", "{", "mapperWrapper", ".", "add", "(", "mapper", ")", ";", "}", "public", "void", "produce", "(", "final", "DataConsumer", "pReceiver", ")", "throws", "IOException", "{", "if", "(", "!", "src", ".", "exists", "(", ")", ")", "{", "throw", "new", "FileNotFoundException", "(", "\"\"", "+", "src", ")", ";", "}", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "Mapper", "[", "]", "mappers", "=", "new", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "Mapper", "[", "mapperWrapper", ".", "size", "(", ")", "]", ";", "final", "Iterator", "<", "Mapper", ">", "it", "=", "mapperWrapper", ".", "iterator", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "mappers", ".", "length", ";", "i", "++", ")", "{", "mappers", "[", "i", "]", "=", "it", ".", "next", "(", ")", ".", "createMapper", "(", ")", ";", "}", "if", "(", "\"file\"", ".", "equalsIgnoreCase", "(", "type", ")", ")", "{", "new", "DataProducerFile", "(", "src", ",", "destinationName", ",", "getIncludePatterns", "(", "getProject", "(", ")", ")", ",", "getExcludePatterns", "(", "getProject", "(", ")", ")", ",", "mappers", ")", ".", "produce", "(", "pReceiver", ")", ";", "}", "else", "if", "(", "\"archive\"", ".", "equalsIgnoreCase", "(", "type", ")", ")", "{", "new", "DataProducerArchive", "(", "src", ",", "getIncludePatterns", "(", "getProject", "(", ")", ")", ",", "getExcludePatterns", "(", "getProject", "(", ")", ")", ",", "mappers", ")", ".", "produce", "(", "pReceiver", ")", ";", "}", "else", "if", "(", "\"directory\"", ".", "equalsIgnoreCase", "(", "type", ")", ")", "{", "new", "DataProducerDirectory", "(", "src", ",", "getIncludePatterns", "(", "getProject", "(", ")", ")", ",", "getExcludePatterns", "(", "getProject", "(", ")", ")", ",", "mappers", ")", ".", "produce", "(", "pReceiver", ")", ";", "}", "}", "}", "</s>" ]
928
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "ant", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "Task", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "Console", ";", "public", "final", "class", "TaskConsole", "implements", "Console", "{", "private", "final", "Task", "task", ";", "private", "final", "boolean", "verbose", ";", "public", "TaskConsole", "(", "Task", "task", ",", "boolean", "verbose", ")", "{", "this", ".", "task", "=", "task", ";", "this", ".", "verbose", "=", "verbose", ";", "}", "public", "void", "info", "(", "String", "message", ")", "{", "if", "(", "verbose", ")", "{", "task", ".", "log", "(", "message", ")", ";", "}", "}", "public", "void", "warn", "(", "String", "message", ")", "{", "task", ".", "log", "(", "message", ")", ";", "}", "}", "</s>" ]
929
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "ant", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "FileOutputStream", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Arrays", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "BuildException", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "MatchingTask", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "Tar", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "types", ".", "FileSet", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataProducer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "Processor", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "changes", ".", "TextfileChangesProvider", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "descriptors", ".", "PackageDescriptor", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "producers", ".", "DataProducerFileSet", ";", "public", "class", "DebAntTask", "extends", "MatchingTask", "{", "private", "File", "deb", ";", "private", "File", "control", ";", "private", "File", "keyring", ";", "private", "String", "key", ";", "private", "String", "passphrase", ";", "private", "File", "changesIn", ";", "private", "File", "changesOut", ";", "private", "File", "changesSave", ";", "private", "String", "compression", "=", "\"gzip\"", ";", "private", "boolean", "verbose", ";", "private", "Collection", "<", "DataProducer", ">", "dataProducers", "=", "new", "ArrayList", "<", "DataProducer", ">", "(", ")", ";", "public", "void", "setDestfile", "(", "File", "deb", ")", "{", "this", ".", "deb", "=", "deb", ";", "}", "public", "void", "setControl", "(", "File", "control", ")", "{", "this", ".", "control", "=", "control", ";", "}", "public", "void", "setChangesIn", "(", "File", "changes", ")", "{", "this", ".", "changesIn", "=", "changes", ";", "}", "public", "void", "setChangesOut", "(", "File", "changes", ")", "{", "this", ".", "changesOut", "=", "changes", ";", "}", "public", "void", "setChangesSave", "(", "File", "changes", ")", "{", "this", ".", "changesSave", "=", "changes", ";", "}", "public", "void", "setKeyring", "(", "File", "keyring", ")", "{", "this", ".", "keyring", "=", "keyring", ";", "}", "public", "void", "setKey", "(", "String", "key", ")", "{", "this", ".", "key", "=", "key", ";", "}", "public", "void", "setPassphrase", "(", "String", "passphrase", ")", "{", "this", ".", "passphrase", "=", "passphrase", ";", "}", "public", "void", "setCompression", "(", "String", "compression", ")", "{", "this", ".", "compression", "=", "compression", ";", "}", "public", "void", "setVerbose", "(", "boolean", "verbose", ")", "{", "this", ".", "verbose", "=", "verbose", ";", "}", "public", "void", "addFileSet", "(", "FileSet", "fileset", ")", "{", "dataProducers", ".", "add", "(", "new", "DataProducerFileSet", "(", "fileset", ")", ")", ";", "}", "public", "void", "addTarFileSet", "(", "Tar", ".", "TarFileSet", "fileset", ")", "{", "dataProducers", ".", "add", "(", "new", "DataProducerFileSet", "(", "fileset", ")", ")", ";", "}", "public", "void", "addData", "(", "Data", "data", ")", "{", "dataProducers", ".", "add", "(", "data", ")", ";", "}", "private", "boolean", "isPossibleOutput", "(", "File", "file", ")", "{", "if", "(", "file", ".", "exists", "(", ")", ")", "{", "return", "file", ".", "isFile", "(", ")", "&&", "file", ".", "canWrite", "(", ")", ";", "}", "return", "true", ";", "}", "public", "void", "execute", "(", ")", "{", "if", "(", "control", "==", "null", "||", "!", "control", ".", "isDirectory", "(", ")", ")", "{", "throw", "new", "BuildException", "(", "\"\"", ")", ";", "}", "if", "(", "changesIn", "!=", "null", ")", "{", "if", "(", "!", "changesIn", ".", "isFile", "(", ")", "||", "!", "changesIn", ".", "canRead", "(", ")", ")", "{", "throw", "new", "BuildException", "(", "\"\"", "+", "changesIn", "+", "\"\"", ")", ";", "}", "if", "(", "changesOut", "==", "null", ")", "{", "throw", "new", "BuildException", "(", "\"\"", ")", ";", "}", "if", "(", "!", "isPossibleOutput", "(", "changesOut", ")", ")", "{", "throw", "new", "BuildException", "(", "\"\"", "+", "changesOut", ")", ";", "}", "if", "(", "changesSave", "!=", "null", "&&", "!", "isPossibleOutput", "(", "changesSave", ")", ")", "{", "throw", "new", "BuildException", "(", "\"\"", "+", "changesSave", ")", ";", "}", "}", "else", "{", "if", "(", "changesOut", "!=", "null", "||", "changesSave", "!=", "null", ")", "{", "throw", "new", "BuildException", "(", "\"\"", ")", ";", "}", "}", "if", "(", "!", "\"gzip\"", ".", "equals", "(", "compression", ")", "&&", "!", "\"bzip2\"", ".", "equals", "(", "compression", ")", "&&", "!", "\"none\"", ".", "equals", "(", "compression", ")", ")", "{", "throw", "new", "BuildException", "(", "\"\"", "+", "compression", "+", "\"\"", ")", ";", "}", "if", "(", "dataProducers", ".", "size", "(", ")", "==", "0", ")", "{", "throw", "new", "BuildException", "(", "\"\"", ")", ";", "}", "for", "(", "DataProducer", "dataProducer", ":", "dataProducers", ")", "{", "if", "(", "dataProducer", "instanceof", "Data", ")", "{", "Data", "data", "=", "(", "Data", ")", "dataProducer", ";", "if", "(", "data", ".", "getType", "(", ")", "==", "null", ")", "{", "throw", "new", "BuildException", "(", "\"\"", ")", ";", "}", "else", "if", "(", "!", "Arrays", ".", "asList", "(", "\"file\"", ",", "\"directory\"", ",", "\"archive\"", ")", ".", "contains", "(", "data", ".", "getType", "(", ")", ".", "toLowerCase", "(", ")", ")", ")", "{", "throw", "new", "BuildException", "(", "\"The", "type", "'\"", "+", "data", ".", "getType", "(", ")", "+", "\"\"", ")", ";", "}", "}", "}", "if", "(", "deb", "==", "null", ")", "{", "throw", "new", "BuildException", "(", "\"\"", ")", ";", "}", "final", "File", "[", "]", "controlFiles", "=", "control", ".", "listFiles", "(", ")", ";", "final", "DataProducer", "[", "]", "data", "=", "new", "DataProducer", "[", "dataProducers", ".", "size", "(", ")", "]", ";", "dataProducers", ".", "toArray", "(", "data", ")", ";", "final", "Processor", "processor", "=", "new", "Processor", "(", "new", "TaskConsole", "(", "this", ",", "verbose", ")", ",", "null", ")", ";", "final", "PackageDescriptor", "packageDescriptor", ";", "try", "{", "log", "(", "\"\"", "+", "deb", ")", ";", "packageDescriptor", "=", "processor", ".", "createDeb", "(", "controlFiles", ",", "data", ",", "deb", ",", "compression", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "throw", "new", "BuildException", "(", "\"\"", "+", "deb", ",", "e", ")", ";", "}", "final", "TextfileChangesProvider", "changesProvider", ";", "try", "{", "if", "(", "changesOut", "==", "null", ")", "{", "return", ";", "}", "log", "(", "\"\"", "+", "changesOut", ")", ";", "changesProvider", "=", "new", "TextfileChangesProvider", "(", "new", "FileInputStream", "(", "changesIn", ")", ",", "packageDescriptor", ")", ";", "processor", ".", "createChanges", "(", "packageDescriptor", ",", "changesProvider", ",", "(", "keyring", "!=", "null", ")", "?", "new", "FileInputStream", "(", "keyring", ")", ":", "null", ",", "key", ",", "passphrase", ",", "new", "FileOutputStream", "(", "changesOut", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "BuildException", "(", "\"\"", "+", "changesOut", ",", "e", ")", ";", "}", "try", "{", "if", "(", "changesSave", "==", "null", ")", "{", "return", ";", "}", "log", "(", "\"\"", "+", "changesSave", ")", ";", "changesProvider", ".", "save", "(", "new", "FileOutputStream", "(", "changesSave", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "BuildException", "(", "\"\"", "+", "changesSave", ",", "e", ")", ";", "}", "}", "}", "</s>" ]
930
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "ant", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "LsMapper", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "PermMapper", ";", "public", "final", "class", "Mapper", "{", "private", "String", "mapperType", "=", "\"perm\"", ";", "private", "File", "src", ";", "private", "String", "prefix", ";", "private", "int", "strip", ";", "private", "int", "uid", "=", "-", "1", ";", "private", "int", "gid", "=", "-", "1", ";", "private", "String", "user", ";", "private", "String", "group", ";", "private", "int", "fileMode", "=", "-", "1", ";", "private", "int", "dirMode", "=", "-", "1", ";", "public", "void", "setType", "(", "final", "String", "pType", ")", "{", "mapperType", "=", "pType", ";", "}", "public", "void", "setSrc", "(", "final", "File", "pSrc", ")", "{", "src", "=", "pSrc", ";", "}", "public", "void", "setPrefix", "(", "final", "String", "pPrefix", ")", "{", "prefix", "=", "pPrefix", ";", "}", "public", "void", "setStrip", "(", "final", "int", "pStrip", ")", "{", "strip", "=", "pStrip", ";", "}", "public", "void", "setUid", "(", "final", "int", "pUid", ")", "{", "uid", "=", "pUid", ";", "}", "public", "void", "setGid", "(", "final", "int", "pGid", ")", "{", "gid", "=", "pGid", ";", "}", "public", "void", "setUser", "(", "final", "String", "pUser", ")", "{", "user", "=", "pUser", ";", "}", "public", "void", "setGroup", "(", "final", "String", "pGroup", ")", "{", "group", "=", "pGroup", ";", "}", "public", "void", "setFileMode", "(", "final", "int", "pFileMode", ")", "{", "fileMode", "=", "pFileMode", ";", "}", "public", "void", "setDirMode", "(", "int", "pDirMode", ")", "{", "dirMode", "=", "pDirMode", ";", "}", "public", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "Mapper", "createMapper", "(", ")", "throws", "IOException", "{", "if", "(", "\"perm\"", ".", "equalsIgnoreCase", "(", "mapperType", ")", ")", "{", "return", "new", "PermMapper", "(", "uid", ",", "gid", ",", "user", ",", "group", ",", "fileMode", ",", "dirMode", ",", "strip", ",", "prefix", ")", ";", "}", "if", "(", "\"ls\"", ".", "equalsIgnoreCase", "(", "mapperType", ")", ")", "{", "try", "{", "return", "new", "LsMapper", "(", "new", "FileInputStream", "(", "src", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "throw", "new", "IOException", "(", "\"\"", "+", "mapperType", "+", "\"'\"", ")", ";", "}", "}", "</s>" ]
931
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "control", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "utils", ".", "Utils", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "utils", ".", "VariableResolver", ";", "public", "class", "FilteredConfigurationFile", "{", "private", "static", "String", "openToken", "=", "\"[[\"", ";", "private", "static", "String", "closeToken", "=", "\"]]\"", ";", "private", "List", "<", "String", ">", "lines", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "private", "String", "name", ";", "public", "FilteredConfigurationFile", "(", "String", "name", ",", "InputStream", "pInputStream", ",", "VariableResolver", "pResolver", ")", "throws", "IOException", "{", "this", ".", "name", "=", "name", ";", "parse", "(", "pInputStream", ",", "pResolver", ")", ";", "}", "public", "static", "void", "setOpenToken", "(", "final", "String", "pToken", ")", "{", "openToken", "=", "pToken", ";", "}", "public", "static", "void", "setCloseToken", "(", "final", "String", "pToken", ")", "{", "closeToken", "=", "pToken", ";", "}", "private", "void", "parse", "(", "InputStream", "pInputStream", ",", "VariableResolver", "pResolver", ")", "throws", "IOException", "{", "BufferedReader", "br", "=", "null", ";", "try", "{", "br", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "pInputStream", ")", ")", ";", "String", "line", ";", "while", "(", "(", "line", "=", "br", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "lines", ".", "add", "(", "Utils", ".", "replaceVariables", "(", "pResolver", ",", "line", ",", "openToken", ",", "closeToken", ")", ")", ";", "}", "}", "finally", "{", "if", "(", "br", "!=", "null", ")", "{", "br", ".", "close", "(", ")", ";", "}", "}", "}", "public", "String", "toString", "(", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "String", "line", ":", "lines", ")", "{", "builder", ".", "append", "(", "line", ")", ".", "append", "(", "'\\n'", ")", ";", "}", "return", "builder", ".", "toString", "(", ")", ";", "}", "public", "String", "getName", "(", ")", "{", "return", "name", ";", "}", "}", "</s>" ]
932
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "public", "interface", "DataConsumer", "{", "void", "onEachDir", "(", "String", "dirname", ",", "String", "linkname", ",", "String", "user", ",", "int", "uid", ",", "String", "group", ",", "int", "gid", ",", "int", "mode", ",", "long", "size", ")", "throws", "IOException", ";", "void", "onEachFile", "(", "InputStream", "input", ",", "String", "filename", ",", "String", "linkname", ",", "String", "user", ",", "int", "uid", ",", "String", "group", ",", "int", "gid", ",", "int", "mode", ",", "long", "size", ")", "throws", "IOException", ";", "void", "onEachLink", "(", "String", "path", ",", "String", "linkName", ",", "boolean", "symlink", ",", "String", "user", ",", "int", "uid", ",", "String", "group", ",", "int", "gid", ")", "throws", "IOException", ";", "}", "</s>" ]
933
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "maven", ";", "import", "java", ".", "io", ".", "File", ";", "import", "org", ".", "apache", ".", "maven", ".", "plugin", ".", "AbstractMojo", ";", "import", "org", ".", "apache", ".", "maven", ".", "project", ".", "MavenProject", ";", "public", "abstract", "class", "AbstractPluginMojo", "extends", "AbstractMojo", "{", "private", "MavenProject", "project", ";", "protected", "File", "buildDirectory", ";", "protected", "MavenProject", "getProject", "(", ")", "{", "if", "(", "project", ".", "getExecutionProject", "(", ")", "!=", "null", ")", "{", "return", "project", ".", "getExecutionProject", "(", ")", ";", "}", "return", "project", ";", "}", "}", "</s>" ]
934
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "maven", ";", "import", "org", ".", "apache", ".", "maven", ".", "plugin", ".", "logging", ".", "Log", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "Console", ";", "public", "final", "class", "MojoConsole", "implements", "Console", "{", "private", "final", "Log", "log", ";", "private", "final", "boolean", "verbose", ";", "public", "MojoConsole", "(", "Log", "log", ",", "boolean", "verbose", ")", "{", "this", ".", "log", "=", "log", ";", "this", ".", "verbose", "=", "verbose", ";", "}", "public", "void", "info", "(", "String", "s", ")", "{", "if", "(", "verbose", ")", "{", "log", ".", "info", "(", "s", ")", ";", "}", "}", "public", "void", "warn", "(", "String", "s", ")", "{", "log", ".", "warn", "(", "s", ")", ";", "}", "}", "</s>" ]
935
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "maven", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "LsMapper", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "NullMapper", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "PermMapper", ";", "public", "final", "class", "Mapper", "{", "private", "String", "type", ";", "private", "int", "uid", "=", "-", "1", ";", "private", "int", "gid", "=", "-", "1", ";", "private", "String", "user", ";", "private", "String", "group", ";", "private", "String", "filemode", ";", "private", "String", "dirmode", ";", "private", "String", "prefix", ";", "private", "int", "strip", ";", "private", "File", "src", ";", "public", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "Mapper", "createMapper", "(", ")", "throws", "IOException", "{", "if", "(", "\"ls\"", ".", "equalsIgnoreCase", "(", "type", ")", ")", "{", "try", "{", "return", "new", "LsMapper", "(", "new", "FileInputStream", "(", "src", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "if", "(", "\"perm\"", ".", "equalsIgnoreCase", "(", "type", ")", ")", "{", "return", "new", "PermMapper", "(", "uid", ",", "gid", ",", "user", ",", "group", ",", "filemode", ",", "dirmode", ",", "strip", ",", "prefix", ")", ";", "}", "return", "NullMapper", ".", "INSTANCE", ";", "}", "}", "</s>" ]
936
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "maven", ";", "import", "static", "org", ".", "vafer", ".", "jdeb", ".", "maven", ".", "MissingSourceBehavior", ".", "FAIL", ";", "import", "static", "org", ".", "vafer", ".", "jdeb", ".", "maven", ".", "MissingSourceBehavior", ".", "IGNORE", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileNotFoundException", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "StringTokenizer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataConsumer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataProducer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "producers", ".", "DataProducerArchive", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "producers", ".", "DataProducerDirectory", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "producers", ".", "DataProducerFile", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "producers", ".", "DataProducerLink", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "producers", ".", "DataProducerPathTemplate", ";", "public", "final", "class", "Data", "implements", "DataProducer", "{", "private", "File", "src", ";", "public", "void", "setSrc", "(", "File", "src", ")", "{", "this", ".", "src", "=", "src", ";", "}", "private", "String", "dst", ";", "public", "void", "setDst", "(", "String", "dst", ")", "{", "this", ".", "dst", "=", "dst", ";", "}", "private", "String", "type", ";", "public", "void", "setType", "(", "String", "type", ")", "{", "this", ".", "type", "=", "type", ";", "}", "private", "MissingSourceBehavior", "missingSrc", "=", "FAIL", ";", "public", "void", "setMissingSrc", "(", "String", "missingSrc", ")", "{", "MissingSourceBehavior", "value", "=", "MissingSourceBehavior", ".", "valueOf", "(", "missingSrc", ".", "trim", "(", ")", ".", "toUpperCase", "(", ")", ")", ";", "if", "(", "value", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Unknown", "\"", "+", "MissingSourceBehavior", ".", "class", ".", "getSimpleName", "(", ")", "+", "\":", "\"", "+", "missingSrc", ")", ";", "}", "this", ".", "missingSrc", "=", "value", ";", "}", "private", "String", "linkTarget", ";", "public", "void", "setLinkTarget", "(", "String", "linkTarget", ")", "{", "this", ".", "linkTarget", "=", "linkTarget", ";", "}", "private", "boolean", "symlink", ";", "public", "void", "setSymlink", "(", "boolean", "symlink", ")", "{", "this", ".", "symlink", "=", "symlink", ";", "}", "private", "String", "[", "]", "includePatterns", ";", "public", "void", "setIncludes", "(", "String", "includes", ")", "{", "includePatterns", "=", "splitPatterns", "(", "includes", ")", ";", "}", "private", "String", "[", "]", "excludePatterns", ";", "public", "void", "setExcludes", "(", "String", "excludes", ")", "{", "excludePatterns", "=", "splitPatterns", "(", "excludes", ")", ";", "}", "private", "Mapper", "mapper", ";", "private", "String", "[", "]", "paths", ";", "void", "setPaths", "(", "String", "[", "]", "paths", ")", "{", "this", ".", "paths", "=", "paths", ";", "}", "public", "String", "[", "]", "splitPatterns", "(", "String", "patterns", ")", "{", "String", "[", "]", "result", "=", "null", ";", "if", "(", "patterns", "!=", "null", "&&", "patterns", ".", "length", "(", ")", ">", "0", ")", "{", "List", "<", "String", ">", "tokens", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "StringTokenizer", "tok", "=", "new", "StringTokenizer", "(", "patterns", ",", "\",", "\"", ",", "false", ")", ";", "while", "(", "tok", ".", "hasMoreTokens", "(", ")", ")", "{", "tokens", ".", "add", "(", "tok", ".", "nextToken", "(", ")", ")", ";", "}", "result", "=", "tokens", ".", "toArray", "(", "new", "String", "[", "tokens", ".", "size", "(", ")", "]", ")", ";", "}", "return", "result", ";", "}", "public", "void", "produce", "(", "final", "DataConsumer", "pReceiver", ")", "throws", "IOException", "{", "if", "(", "src", "!=", "null", "&&", "!", "src", ".", "exists", "(", ")", ")", "{", "if", "(", "missingSrc", "==", "IGNORE", ")", "{", "return", ";", "}", "else", "{", "throw", "new", "FileNotFoundException", "(", "\"\"", "+", "src", ")", ";", "}", "}", "if", "(", "src", "==", "null", "&&", "(", "paths", "==", "null", "||", "paths", ".", "length", "==", "0", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"\"", ")", ";", "}", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "Mapper", "[", "]", "mappers", "=", "null", ";", "if", "(", "mapper", "!=", "null", ")", "{", "mappers", "=", "new", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "Mapper", "[", "]", "{", "mapper", ".", "createMapper", "(", ")", "}", ";", "}", "if", "(", "\"file\"", ".", "equalsIgnoreCase", "(", "type", ")", ")", "{", "new", "DataProducerFile", "(", "src", ",", "dst", ",", "includePatterns", ",", "excludePatterns", ",", "mappers", ")", ".", "produce", "(", "pReceiver", ")", ";", "return", ";", "}", "if", "(", "\"archive\"", ".", "equalsIgnoreCase", "(", "type", ")", ")", "{", "new", "DataProducerArchive", "(", "src", ",", "includePatterns", ",", "excludePatterns", ",", "mappers", ")", ".", "produce", "(", "pReceiver", ")", ";", "return", ";", "}", "if", "(", "\"directory\"", ".", "equalsIgnoreCase", "(", "type", ")", ")", "{", "new", "DataProducerDirectory", "(", "src", ",", "includePatterns", ",", "excludePatterns", ",", "mappers", ")", ".", "produce", "(", "pReceiver", ")", ";", "return", ";", "}", "if", "(", "\"link\"", ".", "equalsIgnoreCase", "(", "type", ")", ")", "{", "new", "DataProducerLink", "(", "src", ".", "getPath", "(", ")", ",", "linkTarget", ",", "symlink", ",", "includePatterns", ",", "excludePatterns", ",", "mappers", ")", ".", "produce", "(", "pReceiver", ")", ";", "return", ";", "}", "if", "(", "\"template\"", ".", "equalsIgnoreCase", "(", "type", ")", ")", "{", "new", "DataProducerPathTemplate", "(", "paths", ",", "includePatterns", ",", "excludePatterns", ",", "mappers", ")", ".", "produce", "(", "pReceiver", ")", ";", "return", ";", "}", "throw", "new", "IOException", "(", "\"\"", "+", "type", "+", "\"\"", "+", "src", ")", ";", "}", "}", "</s>" ]
937
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "maven", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "text", ".", "SimpleDateFormat", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "Collections", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "apache", ".", "maven", ".", "artifact", ".", "Artifact", ";", "import", "org", ".", "apache", ".", "maven", ".", "execution", ".", "MavenSession", ";", "import", "org", ".", "apache", ".", "maven", ".", "plugin", ".", "MojoExecutionException", ";", "import", "org", ".", "apache", ".", "maven", ".", "project", ".", "MavenProject", ";", "import", "org", ".", "apache", ".", "maven", ".", "project", ".", "MavenProjectHelper", ";", "import", "org", ".", "apache", ".", "tools", ".", "tar", ".", "TarEntry", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "Console", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataConsumer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataProducer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "PackagingException", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "descriptors", ".", "AbstractDescriptor", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "utils", ".", "MapVariableResolver", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "utils", ".", "Utils", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "utils", ".", "VariableResolver", ";", "public", "class", "DebMojo", "extends", "AbstractPluginMojo", "{", "private", "MavenProjectHelper", "projectHelper", ";", "private", "String", "deb", ";", "private", "String", "controlDir", ";", "private", "String", "changesIn", ";", "private", "String", "changesOut", ";", "private", "String", "changesSave", ";", "private", "String", "compression", ";", "private", "String", "attach", ";", "private", "String", "installDir", ";", "private", "String", "type", ";", "private", "File", "baseDir", ";", "private", "boolean", "submodules", ";", "private", "MavenSession", "session", ";", "private", "String", "classifier", ";", "private", "Data", "[", "]", "dataSet", ";", "private", "boolean", "timestamped", ";", "private", "boolean", "verbose", ";", "private", "String", "openReplaceToken", "=", "\"[[\"", ";", "private", "String", "closeReplaceToken", "=", "\"]]\"", ";", "private", "Collection", "<", "DataProducer", ">", "dataProducers", "=", "new", "ArrayList", "<", "DataProducer", ">", "(", ")", ";", "public", "void", "setOpenReplaceToken", "(", "String", "openReplaceToken", ")", "{", "this", ".", "openReplaceToken", "=", "openReplaceToken", ";", "AbstractDescriptor", ".", "setOpenToken", "(", "openReplaceToken", ")", ";", "}", "public", "void", "setCloseReplaceToken", "(", "String", "closeReplaceToken", ")", "{", "this", ".", "closeReplaceToken", "=", "closeReplaceToken", ";", "AbstractDescriptor", ".", "setCloseToken", "(", "closeReplaceToken", ")", ";", "}", "protected", "void", "setData", "(", "Data", "[", "]", "dataSet", ")", "{", "this", ".", "dataSet", "=", "dataSet", ";", "dataProducers", ".", "clear", "(", ")", ";", "if", "(", "dataSet", "!=", "null", ")", "{", "Collections", ".", "addAll", "(", "dataProducers", ",", "dataSet", ")", ";", "}", "}", "protected", "VariableResolver", "initializeVariableResolver", "(", "Map", "<", "String", ",", "String", ">", "variables", ")", "{", "(", "(", "Map", ")", "variables", ")", ".", "putAll", "(", "getProject", "(", ")", ".", "getProperties", "(", ")", ")", ";", "variables", ".", "put", "(", "\"name\"", ",", "getProject", "(", ")", ".", "getName", "(", ")", ")", ";", "variables", ".", "put", "(", "\"artifactId\"", ",", "getProject", "(", ")", ".", "getArtifactId", "(", ")", ")", ";", "variables", ".", "put", "(", "\"groupId\"", ",", "getProject", "(", ")", ".", "getGroupId", "(", ")", ")", ";", "variables", ".", "put", "(", "\"version\"", ",", "getProjectVersion", "(", ")", ")", ";", "variables", ".", "put", "(", "\"description\"", ",", "getProject", "(", ")", ".", "getDescription", "(", ")", ")", ";", "variables", ".", "put", "(", "\"extension\"", ",", "\"deb\"", ")", ";", "variables", ".", "put", "(", "\"baseDir\"", ",", "getProject", "(", ")", ".", "getBasedir", "(", ")", ".", "getAbsolutePath", "(", ")", ")", ";", "variables", ".", "put", "(", "\"buildDir\"", ",", "buildDirectory", ".", "getAbsolutePath", "(", ")", ")", ";", "variables", ".", "put", "(", "\"\"", ",", "getProject", "(", ")", ".", "getVersion", "(", ")", ")", ";", "variables", ".", "put", "(", "\"url\"", ",", "getProject", "(", ")", ".", "getUrl", "(", ")", ")", ";", "return", "new", "MapVariableResolver", "(", "variables", ")", ";", "}", "private", "String", "getProjectVersion", "(", ")", "{", "String", "version", "=", "getProject", "(", ")", ".", "getVersion", "(", ")", ".", "replace", "(", "'-'", ",", "'+'", ")", ";", "if", "(", "this", ".", "timestamped", "&&", "version", ".", "endsWith", "(", "\"+SNAPSHOT\"", ")", ")", "{", "Date", "buildStartTime", "=", "getProject", "(", ")", ".", "getProjectBuilderConfiguration", "(", ")", ".", "getBuildStartTime", "(", ")", ";", "version", "=", "version", ".", "substring", "(", "0", ",", "version", ".", "length", "(", ")", "-", "\"+SNAPSHOT\"", ".", "length", "(", ")", ")", ";", "version", "+=", "\"~\"", ";", "version", "+=", "new", "SimpleDateFormat", "(", "\"\"", ")", ".", "format", "(", "buildStartTime", ")", ";", "}", "return", "version", ";", "}", "private", "boolean", "isSubmodule", "(", ")", "{", "return", "!", "session", ".", "getExecutionRootDirectory", "(", ")", ".", "equalsIgnoreCase", "(", "baseDir", ".", "toString", "(", ")", ")", ";", "}", "private", "boolean", "hasMainArtifact", "(", ")", "{", "final", "MavenProject", "project", "=", "getProject", "(", ")", ";", "final", "Artifact", "artifact", "=", "project", ".", "getArtifact", "(", ")", ";", "return", "artifact", ".", "getFile", "(", ")", "!=", "null", "&&", "artifact", ".", "getFile", "(", ")", ".", "isFile", "(", ")", ";", "}", "public", "void", "execute", "(", ")", "throws", "MojoExecutionException", "{", "final", "MavenProject", "project", "=", "getProject", "(", ")", ";", "if", "(", "isSubmodule", "(", ")", "&&", "!", "submodules", ")", "{", "getLog", "(", ")", ".", "info", "(", "\"\"", ")", ";", "return", ";", "}", "setData", "(", "dataSet", ")", ";", "Console", "infoConsole", "=", "new", "MojoConsole", "(", "getLog", "(", ")", ",", "verbose", ")", ";", "final", "VariableResolver", "resolver", "=", "initializeVariableResolver", "(", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ")", ";", "final", "File", "debFile", "=", "new", "File", "(", "Utils", ".", "replaceVariables", "(", "resolver", ",", "deb", ",", "openReplaceToken", ",", "closeReplaceToken", ")", ")", ";", "final", "File", "controlDirFile", "=", "new", "File", "(", "Utils", ".", "replaceVariables", "(", "resolver", ",", "controlDir", ",", "openReplaceToken", ",", "closeReplaceToken", ")", ")", ";", "final", "File", "installDirFile", "=", "new", "File", "(", "Utils", ".", "replaceVariables", "(", "resolver", ",", "installDir", ",", "openReplaceToken", ",", "closeReplaceToken", ")", ")", ";", "final", "File", "changesInFile", "=", "new", "File", "(", "Utils", ".", "replaceVariables", "(", "resolver", ",", "changesIn", ",", "openReplaceToken", ",", "closeReplaceToken", ")", ")", ";", "final", "File", "changesOutFile", "=", "new", "File", "(", "Utils", ".", "replaceVariables", "(", "resolver", ",", "changesOut", ",", "openReplaceToken", ",", "closeReplaceToken", ")", ")", ";", "final", "File", "changesSaveFile", "=", "new", "File", "(", "Utils", ".", "replaceVariables", "(", "resolver", ",", "changesSave", ",", "openReplaceToken", ",", "closeReplaceToken", ")", ")", ";", "if", "(", "dataProducers", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "!", "hasMainArtifact", "(", ")", ")", "{", "final", "String", "packaging", "=", "project", ".", "getPackaging", "(", ")", ";", "if", "(", "\"pom\"", ".", "equalsIgnoreCase", "(", "packaging", ")", ")", "{", "getLog", "(", ")", ".", "warn", "(", "\"\"", ")", ";", "}", "else", "{", "throw", "new", "MojoExecutionException", "(", "\"\"", "+", "\"\"", ")", ";", "}", "}", "else", "{", "Set", "<", "Artifact", ">", "artifacts", "=", "new", "HashSet", "<", "Artifact", ">", "(", ")", ";", "artifacts", ".", "add", "(", "project", ".", "getArtifact", "(", ")", ")", ";", "for", "(", "Artifact", "artifact", ":", "(", "Set", "<", "Artifact", ">", ")", "project", ".", "getArtifacts", "(", ")", ")", "{", "artifacts", ".", "add", "(", "artifact", ")", ";", "}", "for", "(", "Artifact", "artifact", ":", "(", "List", "<", "Artifact", ">", ")", "project", ".", "getAttachedArtifacts", "(", ")", ")", "{", "artifacts", ".", "add", "(", "artifact", ")", ";", "}", "for", "(", "Artifact", "artifact", ":", "artifacts", ")", "{", "final", "File", "file", "=", "artifact", ".", "getFile", "(", ")", ";", "if", "(", "file", "!=", "null", ")", "{", "dataProducers", ".", "add", "(", "new", "DataProducer", "(", ")", "{", "public", "void", "produce", "(", "final", "DataConsumer", "receiver", ")", "{", "try", "{", "receiver", ".", "onEachFile", "(", "new", "FileInputStream", "(", "file", ")", ",", "new", "File", "(", "installDirFile", ",", "file", ".", "getName", "(", ")", ")", ".", "getAbsolutePath", "(", ")", ",", "\"\"", ",", "\"root\"", ",", "0", ",", "\"root\"", ",", "0", ",", "TarEntry", ".", "DEFAULT_FILE_MODE", ",", "file", ".", "length", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "getLog", "(", ")", ".", "error", "(", "e", ")", ";", "}", "}", "}", ")", ";", "}", "else", "{", "getLog", "(", ")", ".", "error", "(", "\"\"", "+", "artifact", ")", ";", "}", "}", "}", "}", "try", "{", "DebMaker", "debMaker", "=", "new", "DebMaker", "(", "infoConsole", ",", "debFile", ",", "controlDirFile", ",", "dataProducers", ",", "resolver", ")", ";", "if", "(", "changesInFile", ".", "exists", "(", ")", "&&", "changesInFile", ".", "canRead", "(", ")", ")", "{", "debMaker", ".", "setChangesIn", "(", "changesInFile", ")", ";", "debMaker", ".", "setChangesOut", "(", "changesOutFile", ")", ";", "debMaker", ".", "setChangesSave", "(", "changesSaveFile", ")", ";", "}", "debMaker", ".", "setCompression", "(", "compression", ")", ";", "debMaker", ".", "makeDeb", "(", ")", ";", "if", "(", "\"true\"", ".", "equalsIgnoreCase", "(", "attach", ")", ")", "{", "getLog", "(", ")", ".", "info", "(", "\"\"", "+", "debFile", ")", ";", "projectHelper", ".", "attachArtifact", "(", "project", ",", "type", ",", "classifier", ",", "debFile", ")", ";", "}", "}", "catch", "(", "PackagingException", "e", ")", "{", "getLog", "(", ")", ".", "error", "(", "\"\"", "+", "debFile", ",", "e", ")", ";", "throw", "new", "MojoExecutionException", "(", "\"\"", "+", "debFile", ",", "e", ")", ";", "}", "}", "}", "</s>" ]
938
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "maven", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "FileOutputStream", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "Console", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataProducer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "PackagingException", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "Processor", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "changes", ".", "TextfileChangesProvider", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "descriptors", ".", "PackageDescriptor", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "utils", ".", "VariableResolver", ";", "public", "class", "DebMaker", "{", "private", "Console", "console", ";", "private", "File", "deb", ";", "private", "File", "control", ";", "private", "File", "keyring", ";", "private", "String", "key", ";", "private", "String", "passphrase", ";", "private", "File", "changesIn", ";", "private", "File", "changesOut", ";", "private", "File", "changesSave", ";", "private", "String", "compression", "=", "\"gzip\"", ";", "private", "final", "VariableResolver", "variableResolver", ";", "private", "final", "Collection", "<", "DataProducer", ">", "dataProducers", ";", "public", "DebMaker", "(", "Console", "console", ",", "VariableResolver", "variableResolver", ")", "{", "this", "(", "console", ",", "null", ",", "null", ",", "null", ",", "variableResolver", ")", ";", "}", "public", "DebMaker", "(", "Console", "console", ",", "File", "deb", ",", "File", "controlDir", ",", "VariableResolver", "variableResolver", ")", "{", "this", "(", "console", ",", "deb", ",", "controlDir", ",", "null", ",", "variableResolver", ")", ";", "}", "public", "DebMaker", "(", "Console", "console", ",", "File", "deb", ",", "File", "controlDir", ",", "Collection", "<", "DataProducer", ">", "dataProducers", ",", "VariableResolver", "variableResolver", ")", "{", "this", ".", "console", "=", "console", ";", "this", ".", "deb", "=", "deb", ";", "this", ".", "control", "=", "controlDir", ";", "this", ".", "variableResolver", "=", "variableResolver", ";", "if", "(", "dataProducers", "!=", "null", ")", "{", "this", ".", "dataProducers", "=", "dataProducers", ";", "}", "else", "{", "this", ".", "dataProducers", "=", "new", "ArrayList", "<", "DataProducer", ">", "(", ")", ";", "}", "}", "public", "void", "setDeb", "(", "File", "deb", ")", "{", "this", ".", "deb", "=", "deb", ";", "}", "public", "void", "setControl", "(", "File", "control", ")", "{", "this", ".", "control", "=", "control", ";", "}", "public", "void", "setChangesIn", "(", "File", "changes", ")", "{", "this", ".", "changesIn", "=", "changes", ";", "}", "public", "void", "setChangesOut", "(", "File", "changes", ")", "{", "this", ".", "changesOut", "=", "changes", ";", "}", "public", "void", "setChangesSave", "(", "File", "changes", ")", "{", "this", ".", "changesSave", "=", "changes", ";", "}", "public", "void", "setKeyring", "(", "File", "keyring", ")", "{", "this", ".", "keyring", "=", "keyring", ";", "}", "public", "void", "setKey", "(", "String", "key", ")", "{", "this", ".", "key", "=", "key", ";", "}", "public", "void", "setPassphrase", "(", "String", "passphrase", ")", "{", "this", ".", "passphrase", "=", "passphrase", ";", "}", "public", "void", "setCompression", "(", "String", "compression", ")", "{", "this", ".", "compression", "=", "compression", ";", "}", "public", "void", "addData", "(", "File", "file", ")", "{", "final", "Data", "data", "=", "new", "Data", "(", ")", ";", "data", ".", "setSrc", "(", "file", ")", ";", "dataProducers", ".", "add", "(", "data", ")", ";", "}", "public", "void", "addData", "(", "Data", "data", ")", "{", "dataProducers", ".", "add", "(", "data", ")", ";", "}", "private", "boolean", "isPossibleOutput", "(", "File", "file", ")", "{", "if", "(", "file", ".", "exists", "(", ")", ")", "{", "return", "file", ".", "isFile", "(", ")", "&&", "file", ".", "canWrite", "(", ")", ";", "}", "return", "true", ";", "}", "public", "void", "makeDeb", "(", ")", "throws", "PackagingException", "{", "if", "(", "control", "==", "null", "||", "!", "control", ".", "isDirectory", "(", ")", ")", "{", "throw", "new", "PackagingException", "(", "\"\\\"\"", "+", "control", "+", "\"\"", ")", ";", "}", "if", "(", "changesIn", "!=", "null", ")", "{", "if", "(", "!", "changesIn", ".", "isFile", "(", ")", "||", "!", "changesIn", ".", "canRead", "(", ")", ")", "{", "throw", "new", "PackagingException", "(", "\"\"", "+", "changesIn", "+", "\"\"", ")", ";", "}", "if", "(", "changesOut", "==", "null", ")", "{", "throw", "new", "PackagingException", "(", "\"\"", ")", ";", "}", "if", "(", "!", "isPossibleOutput", "(", "changesOut", ")", ")", "{", "throw", "new", "PackagingException", "(", "\"\"", "+", "changesOut", ")", ";", "}", "if", "(", "changesSave", "!=", "null", "&&", "!", "isPossibleOutput", "(", "changesSave", ")", ")", "{", "throw", "new", "PackagingException", "(", "\"\"", "+", "changesSave", ")", ";", "}", "}", "else", "{", "if", "(", "changesOut", "!=", "null", "||", "changesSave", "!=", "null", ")", "{", "throw", "new", "PackagingException", "(", "\"\"", ")", ";", "}", "}", "if", "(", "!", "\"gzip\"", ".", "equals", "(", "compression", ")", "&&", "!", "\"bzip2\"", ".", "equals", "(", "compression", ")", "&&", "!", "\"none\"", ".", "equals", "(", "compression", ")", ")", "{", "throw", "new", "PackagingException", "(", "\"\"", "+", "compression", "+", "\"\"", ")", ";", "}", "if", "(", "deb", "==", "null", ")", "{", "throw", "new", "PackagingException", "(", "\"\"", ")", ";", "}", "final", "File", "[", "]", "controlFiles", "=", "control", ".", "listFiles", "(", ")", ";", "final", "DataProducer", "[", "]", "data", "=", "new", "DataProducer", "[", "dataProducers", ".", "size", "(", ")", "]", ";", "dataProducers", ".", "toArray", "(", "data", ")", ";", "final", "Processor", "processor", "=", "new", "Processor", "(", "console", ",", "variableResolver", ")", ";", "final", "PackageDescriptor", "packageDescriptor", ";", "try", "{", "console", ".", "info", "(", "\"\"", "+", "deb", ")", ";", "packageDescriptor", "=", "processor", ".", "createDeb", "(", "controlFiles", ",", "data", ",", "deb", ",", "compression", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "PackagingException", "(", "\"\"", "+", "deb", ",", "e", ")", ";", "}", "final", "TextfileChangesProvider", "changesProvider", ";", "try", "{", "if", "(", "changesOut", "==", "null", ")", "{", "return", ";", "}", "console", ".", "info", "(", "\"\"", "+", "changesOut", ")", ";", "changesProvider", "=", "new", "TextfileChangesProvider", "(", "new", "FileInputStream", "(", "changesIn", ")", ",", "packageDescriptor", ")", ";", "processor", ".", "createChanges", "(", "packageDescriptor", ",", "changesProvider", ",", "(", "keyring", "!=", "null", ")", "?", "new", "FileInputStream", "(", "keyring", ")", ":", "null", ",", "key", ",", "passphrase", ",", "new", "FileOutputStream", "(", "changesOut", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "PackagingException", "(", "\"\"", "+", "changesOut", ",", "e", ")", ";", "}", "try", "{", "if", "(", "changesSave", "==", "null", ")", "{", "return", ";", "}", "console", ".", "info", "(", "\"\"", "+", "changesSave", ")", ";", "changesProvider", ".", "save", "(", "new", "FileOutputStream", "(", "changesSave", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "PackagingException", "(", "\"\"", "+", "changesSave", ",", "e", ")", ";", "}", "}", "}", "</s>" ]
939
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "maven", ";", "public", "enum", "MissingSourceBehavior", "{", "IGNORE", ",", "FAIL", "}", "</s>" ]
940
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "signing", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "java", ".", "nio", ".", "charset", ".", "Charset", ";", "import", "java", ".", "security", ".", "GeneralSecurityException", ";", "import", "java", ".", "util", ".", "Iterator", ";", "import", "org", ".", "bouncycastle", ".", "bcpg", ".", "ArmoredOutputStream", ";", "import", "org", ".", "bouncycastle", ".", "bcpg", ".", "BCPGOutputStream", ";", "import", "org", ".", "bouncycastle", ".", "openpgp", ".", "PGPException", ";", "import", "org", ".", "bouncycastle", ".", "openpgp", ".", "PGPPrivateKey", ";", "import", "org", ".", "bouncycastle", ".", "openpgp", ".", "PGPSecretKey", ";", "import", "org", ".", "bouncycastle", ".", "openpgp", ".", "PGPSecretKeyRing", ";", "import", "org", ".", "bouncycastle", ".", "openpgp", ".", "PGPSecretKeyRingCollection", ";", "import", "org", ".", "bouncycastle", ".", "openpgp", ".", "PGPSignature", ";", "import", "org", ".", "bouncycastle", ".", "openpgp", ".", "PGPSignatureGenerator", ";", "import", "org", ".", "bouncycastle", ".", "openpgp", ".", "PGPUtil", ";", "import", "org", ".", "bouncycastle", ".", "openpgp", ".", "operator", ".", "bc", ".", "BcPBESecretKeyDecryptorBuilder", ";", "import", "org", ".", "bouncycastle", ".", "openpgp", ".", "operator", ".", "bc", ".", "BcPGPContentSignerBuilder", ";", "import", "org", ".", "bouncycastle", ".", "openpgp", ".", "operator", ".", "bc", ".", "BcPGPDigestCalculatorProvider", ";", "public", "final", "class", "SigningUtils", "{", "private", "static", "final", "byte", "[", "]", "EOL", "=", "\"rn\"", ".", "getBytes", "(", "Charset", ".", "forName", "(", "\"UTF-8\"", ")", ")", ";", "public", "static", "void", "clearSign", "(", "InputStream", "input", ",", "InputStream", "keyring", ",", "String", "keyId", ",", "String", "passphrase", ",", "OutputStream", "output", ")", "throws", "IOException", ",", "PGPException", ",", "GeneralSecurityException", "{", "PGPSecretKey", "secretKey", "=", "getSecretKey", "(", "keyring", ",", "keyId", ")", ";", "PGPPrivateKey", "privateKey", "=", "secretKey", ".", "extractPrivateKey", "(", "new", "BcPBESecretKeyDecryptorBuilder", "(", "new", "BcPGPDigestCalculatorProvider", "(", ")", ")", ".", "build", "(", "passphrase", ".", "toCharArray", "(", ")", ")", ")", ";", "int", "digest", "=", "PGPUtil", ".", "SHA1", ";", "PGPSignatureGenerator", "signatureGenerator", "=", "new", "PGPSignatureGenerator", "(", "new", "BcPGPContentSignerBuilder", "(", "secretKey", ".", "getPublicKey", "(", ")", ".", "getAlgorithm", "(", ")", ",", "digest", ")", ")", ";", "signatureGenerator", ".", "init", "(", "PGPSignature", ".", "CANONICAL_TEXT_DOCUMENT", ",", "privateKey", ")", ";", "ArmoredOutputStream", "armoredOutput", "=", "new", "ArmoredOutputStream", "(", "output", ")", ";", "armoredOutput", ".", "beginClearText", "(", "digest", ")", ";", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "input", ")", ")", ";", "String", "line", ";", "while", "(", "(", "line", "=", "reader", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "byte", "[", "]", "data", "=", "trim", "(", "line", ")", ".", "getBytes", "(", "\"UTF-8\"", ")", ";", "armoredOutput", ".", "write", "(", "data", ")", ";", "armoredOutput", ".", "write", "(", "EOL", ")", ";", "signatureGenerator", ".", "update", "(", "data", ")", ";", "signatureGenerator", ".", "update", "(", "EOL", ")", ";", "}", "armoredOutput", ".", "endClearText", "(", ")", ";", "PGPSignature", "signature", "=", "signatureGenerator", ".", "generate", "(", ")", ";", "signature", ".", "encode", "(", "new", "BCPGOutputStream", "(", "armoredOutput", ")", ")", ";", "armoredOutput", ".", "close", "(", ")", ";", "}", "private", "static", "PGPSecretKey", "getSecretKey", "(", "InputStream", "input", ",", "String", "keyId", ")", "throws", "IOException", ",", "PGPException", "{", "PGPSecretKeyRingCollection", "keyrings", "=", "new", "PGPSecretKeyRingCollection", "(", "PGPUtil", ".", "getDecoderStream", "(", "input", ")", ")", ";", "Iterator", "rIt", "=", "keyrings", ".", "getKeyRings", "(", ")", ";", "while", "(", "rIt", ".", "hasNext", "(", ")", ")", "{", "PGPSecretKeyRing", "kRing", "=", "(", "PGPSecretKeyRing", ")", "rIt", ".", "next", "(", ")", ";", "Iterator", "kIt", "=", "kRing", ".", "getSecretKeys", "(", ")", ";", "while", "(", "kIt", ".", "hasNext", "(", ")", ")", "{", "PGPSecretKey", "key", "=", "(", "PGPSecretKey", ")", "kIt", ".", "next", "(", ")", ";", "if", "(", "key", ".", "isSigningKey", "(", ")", "&&", "Long", ".", "toHexString", "(", "key", ".", "getKeyID", "(", ")", "&", "0xFFFFFFFFL", ")", ".", "equals", "(", "keyId", ".", "toLowerCase", "(", ")", ")", ")", "{", "return", "key", ";", "}", "}", "}", "return", "null", ";", "}", "private", "static", "String", "trim", "(", "String", "line", ")", "{", "char", "[", "]", "chars", "=", "line", ".", "toCharArray", "(", ")", ";", "int", "len", "=", "chars", ".", "length", ";", "while", "(", "len", ">", "0", ")", "{", "if", "(", "!", "Character", ".", "isWhitespace", "(", "chars", "[", "len", "-", "1", "]", ")", ")", "{", "break", ";", "}", "len", "--", ";", "}", "return", "line", ".", "substring", "(", "0", ",", "len", ")", ";", "}", "}", "</s>" ]
941
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ";", "public", "final", "class", "PackagingException", "extends", "Exception", "{", "private", "static", "final", "long", "serialVersionUID", "=", "1L", ";", "public", "PackagingException", "(", ")", "{", "super", "(", ")", ";", "}", "public", "PackagingException", "(", "String", "message", ",", "Throwable", "cause", ")", "{", "super", "(", "message", ",", "cause", ")", ";", "}", "public", "PackagingException", "(", "String", "message", ")", "{", "super", "(", "message", ")", ";", "}", "public", "PackagingException", "(", "Throwable", "cause", ")", "{", "super", "(", "cause", ")", ";", "}", "}", "</s>" ]
942
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ";", "import", "java", ".", "io", ".", "IOException", ";", "public", "interface", "DataProducer", "{", "void", "produce", "(", "DataConsumer", "receiver", ")", "throws", "IOException", ";", "}", "</s>" ]
943
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "changes", ";", "import", "java", ".", "text", ".", "DateFormat", ";", "import", "java", ".", "text", ".", "SimpleDateFormat", ";", "import", "java", ".", "util", ".", "Date", ";", "public", "final", "class", "ChangeSet", "{", "private", "final", "String", "packageName", ";", "private", "final", "String", "version", ";", "private", "final", "Date", "date", ";", "private", "final", "String", "distribution", ";", "private", "final", "String", "urgency", ";", "private", "final", "String", "changedBy", ";", "private", "final", "String", "[", "]", "changes", ";", "public", "ChangeSet", "(", "String", "pPackageName", ",", "String", "pVersion", ",", "Date", "pDate", ",", "String", "pDistribution", ",", "String", "pUrgency", ",", "String", "pChangedBy", ",", "final", "String", "[", "]", "pChanges", ")", "{", "changes", "=", "pChanges", ";", "packageName", "=", "pPackageName", ";", "version", "=", "pVersion", ";", "date", "=", "pDate", ";", "distribution", "=", "pDistribution", ";", "urgency", "=", "pUrgency", ";", "changedBy", "=", "pChangedBy", ";", "}", "public", "static", "DateFormat", "createDateForma", "(", ")", "{", "return", "new", "SimpleDateFormat", "(", "\"\"", ")", ";", "}", "public", "String", "getPackage", "(", ")", "{", "return", "packageName", ";", "}", "public", "String", "getVersion", "(", ")", "{", "return", "version", ";", "}", "public", "Date", "getDate", "(", ")", "{", "return", "date", ";", "}", "public", "String", "getDistribution", "(", ")", "{", "return", "distribution", ";", "}", "public", "String", "getUrgency", "(", ")", "{", "return", "urgency", ";", "}", "public", "String", "getChangedBy", "(", ")", "{", "return", "changedBy", ";", "}", "public", "String", "[", "]", "getChanges", "(", ")", "{", "return", "changes", ";", "}", "public", "String", "toString", "(", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"", "\"", ")", ".", "append", "(", "getPackage", "(", ")", ")", ".", "append", "(", "\"", "(\"", ")", ".", "append", "(", "getVersion", "(", ")", ")", ".", "append", "(", "\")", "\"", ")", ";", "sb", ".", "append", "(", "getDistribution", "(", ")", ")", ".", "append", "(", "\";", "urgency=\"", ")", ".", "append", "(", "getUrgency", "(", ")", ")", ";", "for", "(", "String", "change", ":", "changes", ")", "{", "sb", ".", "append", "(", "'\\n'", ")", ".", "append", "(", "\"", "*", "\"", ")", ".", "append", "(", "change", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
944
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "changes", ";", "public", "interface", "ChangesProvider", "{", "ChangeSet", "[", "]", "getChangesSets", "(", ")", ";", "}", "</s>" ]
945
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "changes", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "BufferedWriter", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "java", ".", "io", ".", "OutputStreamWriter", ";", "import", "java", ".", "text", ".", "DateFormat", ";", "import", "java", ".", "text", ".", "ParseException", ";", "import", "java", ".", "text", ".", "SimpleDateFormat", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Collection", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "descriptors", ".", "PackageDescriptor", ";", "public", "final", "class", "TextfileChangesProvider", "implements", "ChangesProvider", "{", "private", "final", "ChangeSet", "[", "]", "changeSets", ";", "public", "TextfileChangesProvider", "(", "final", "InputStream", "pInput", ",", "final", "PackageDescriptor", "pDescriptor", ")", "throws", "IOException", ",", "ParseException", "{", "final", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "pInput", ")", ")", ";", "final", "DateFormat", "tdf", "=", "new", "SimpleDateFormat", "(", "\"\"", ",", "Locale", ".", "ENGLISH", ")", ";", "final", "DateFormat", "sdf", "=", "ChangeSet", ".", "createDateForma", "(", ")", ";", "String", "packageName", "=", "pDescriptor", ".", "get", "(", "\"Package\"", ")", ";", "String", "version", "=", "pDescriptor", ".", "get", "(", "\"Version\"", ")", ";", "Date", "date", "=", "tdf", ".", "parse", "(", "pDescriptor", ".", "get", "(", "\"Date\"", ")", ")", ";", "String", "distribution", "=", "pDescriptor", ".", "get", "(", "\"Distribution\"", ")", ";", "String", "urgency", "=", "pDescriptor", ".", "get", "(", "\"Urgency\"", ")", ";", "String", "changedBy", "=", "pDescriptor", ".", "get", "(", "\"Maintainer\"", ")", ";", "Collection", "<", "String", ">", "changesColl", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "Collection", "<", "ChangeSet", ">", "changeSetColl", "=", "new", "ArrayList", "<", "ChangeSet", ">", "(", ")", ";", "while", "(", "true", ")", "{", "final", "String", "line", "=", "reader", ".", "readLine", "(", ")", ";", "if", "(", "line", "==", "null", ")", "{", "final", "String", "[", "]", "changes", "=", "changesColl", ".", "toArray", "(", "new", "String", "[", "changesColl", ".", "size", "(", ")", "]", ")", ";", "final", "ChangeSet", "changeSet", "=", "new", "ChangeSet", "(", "packageName", ",", "version", ",", "date", ",", "distribution", ",", "urgency", ",", "changedBy", ",", "changes", ")", ";", "changeSetColl", ".", "add", "(", "changeSet", ")", ";", "break", ";", "}", "if", "(", "line", ".", "startsWith", "(", "\"release", "\"", ")", ")", "{", "if", "(", "changesColl", ".", "size", "(", ")", ">", "0", ")", "{", "final", "String", "[", "]", "changes", "=", "changesColl", ".", "toArray", "(", "new", "String", "[", "changesColl", ".", "size", "(", ")", "]", ")", ";", "final", "ChangeSet", "changeSet", "=", "new", "ChangeSet", "(", "packageName", ",", "version", ",", "date", ",", "distribution", ",", "urgency", ",", "changedBy", ",", "changes", ")", ";", "changeSetColl", ".", "add", "(", "changeSet", ")", ";", "changesColl", ".", "clear", "(", ")", ";", "}", "final", "String", "[", "]", "tokens", "=", "line", ".", "substring", "(", "\"release", "\"", ".", "length", "(", ")", ")", ".", "split", "(", "\",\"", ")", ";", "for", "(", "String", "token", ":", "tokens", ")", "{", "final", "String", "[", "]", "lr", "=", "token", ".", "trim", "(", ")", ".", "split", "(", "\"=\"", ")", ";", "final", "String", "key", "=", "lr", "[", "0", "]", ";", "final", "String", "value", "=", "lr", "[", "1", "]", ";", "if", "(", "\"urgency\"", ".", "equals", "(", "key", ")", ")", "{", "urgency", "=", "value", ";", "}", "else", "if", "(", "\"by\"", ".", "equals", "(", "key", ")", ")", "{", "changedBy", "=", "value", ";", "}", "else", "if", "(", "\"date\"", ".", "equals", "(", "key", ")", ")", "{", "date", "=", "sdf", ".", "parse", "(", "value", ")", ";", "}", "else", "if", "(", "\"version\"", ".", "equals", "(", "key", ")", ")", "{", "version", "=", "value", ";", "}", "else", "if", "(", "\"distribution\"", ".", "equals", "(", "key", ")", ")", "{", "distribution", "=", "value", ";", "}", "}", "continue", ";", "}", "if", "(", "line", ".", "startsWith", "(", "\"", "*", "\"", ")", ")", "{", "changesColl", ".", "add", "(", "line", ".", "substring", "(", "\"", "*", "\"", ".", "length", "(", ")", ")", ")", ";", "continue", ";", "}", "throw", "new", "ParseException", "(", "\"\"", "+", "line", "+", "\"]\"", ",", "0", ")", ";", "}", "reader", ".", "close", "(", ")", ";", "changeSets", "=", "changeSetColl", ".", "toArray", "(", "new", "ChangeSet", "[", "changeSetColl", ".", "size", "(", ")", "]", ")", ";", "}", "public", "void", "save", "(", "final", "OutputStream", "pOutput", ")", "throws", "IOException", "{", "final", "BufferedWriter", "writer", "=", "new", "BufferedWriter", "(", "new", "OutputStreamWriter", "(", "pOutput", ")", ")", ";", "final", "DateFormat", "df", "=", "ChangeSet", ".", "createDateForma", "(", ")", ";", "for", "(", "ChangeSet", "changeSet", ":", "changeSets", ")", "{", "writer", ".", "write", "(", "\"release", "\"", ")", ";", "writer", ".", "write", "(", "\"date=\"", "+", "df", ".", "format", "(", "changeSet", ".", "getDate", "(", ")", ")", "+", "\",\"", ")", ";", "writer", ".", "write", "(", "\"version=\"", "+", "changeSet", ".", "getVersion", "(", ")", "+", "\",\"", ")", ";", "writer", ".", "write", "(", "\"urgency=\"", "+", "changeSet", ".", "getUrgency", "(", ")", "+", "\",\"", ")", ";", "writer", ".", "write", "(", "\"by=\"", "+", "changeSet", ".", "getChangedBy", "(", ")", "+", "\",\"", ")", ";", "writer", ".", "write", "(", "\"\"", "+", "changeSet", ".", "getDistribution", "(", ")", ")", ";", "writer", ".", "write", "(", "\"n\"", ")", ";", "for", "(", "String", "change", ":", "changeSet", ".", "getChanges", "(", ")", ")", "{", "writer", ".", "write", "(", "\"", "*", "\"", ")", ";", "writer", ".", "write", "(", "change", ")", ";", "writer", ".", "write", "(", "\"n\"", ")", ";", "}", "}", "writer", ".", "close", "(", ")", ";", "}", "public", "ChangeSet", "[", "]", "getChangesSets", "(", ")", "{", "return", "changeSets", ";", "}", "}", "</s>" ]
946
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "producers", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "tar", ".", "TarArchiveEntry", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataConsumer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataProducer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "Mapper", ";", "public", "class", "DataProducerPathTemplate", "extends", "AbstractDataProducer", "implements", "DataProducer", "{", "private", "final", "String", "[", "]", "literalPaths", ";", "public", "DataProducerPathTemplate", "(", "String", "[", "]", "pLiteralPaths", ",", "String", "[", "]", "pIncludes", ",", "String", "[", "]", "pExcludes", ",", "Mapper", "[", "]", "pMapper", ")", "{", "super", "(", "pIncludes", ",", "pExcludes", ",", "pMapper", ")", ";", "literalPaths", "=", "pLiteralPaths", ";", "}", "public", "void", "produce", "(", "DataConsumer", "pReceiver", ")", "throws", "IOException", "{", "for", "(", "String", "literalPath", ":", "literalPaths", ")", "{", "TarArchiveEntry", "entry", "=", "new", "TarArchiveEntry", "(", "literalPath", ",", "true", ")", ";", "entry", ".", "setUserId", "(", "0", ")", ";", "entry", ".", "setUserName", "(", "\"root\"", ")", ";", "entry", ".", "setGroupId", "(", "0", ")", ";", "entry", ".", "setGroupName", "(", "\"root\"", ")", ";", "entry", ".", "setMode", "(", "TarArchiveEntry", ".", "DEFAULT_DIR_MODE", ")", ";", "entry", "=", "map", "(", "entry", ")", ";", "entry", ".", "setSize", "(", "0", ")", ";", "pReceiver", ".", "onEachDir", "(", "entry", ".", "getName", "(", ")", ",", "entry", ".", "getLinkName", "(", ")", ",", "entry", ".", "getUserName", "(", ")", ",", "entry", ".", "getUserId", "(", ")", ",", "entry", ".", "getGroupName", "(", ")", ",", "entry", ".", "getGroupId", "(", ")", ",", "entry", ".", "getMode", "(", ")", ",", "entry", ".", "getSize", "(", ")", ")", ";", "}", "}", "}", "</s>" ]
947
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "producers", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "tar", ".", "TarArchiveEntry", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "types", ".", "selectors", ".", "SelectorUtils", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataProducer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "Mapper", ";", "public", "abstract", "class", "AbstractDataProducer", "implements", "DataProducer", "{", "private", "final", "String", "[", "]", "includes", ";", "private", "final", "String", "[", "]", "excludes", ";", "private", "final", "Mapper", "[", "]", "mappers", ";", "public", "AbstractDataProducer", "(", "final", "String", "[", "]", "pIncludes", ",", "final", "String", "[", "]", "pExcludes", ",", "final", "Mapper", "[", "]", "pMapper", ")", "{", "excludes", "=", "(", "pExcludes", "!=", "null", ")", "?", "pExcludes", ":", "new", "String", "[", "0", "]", ";", "includes", "=", "(", "pIncludes", "!=", "null", ")", "?", "pIncludes", ":", "new", "String", "[", "]", "{", "\"**\"", "}", ";", "mappers", "=", "(", "pMapper", "!=", "null", ")", "?", "pMapper", ":", "new", "Mapper", "[", "0", "]", ";", "}", "public", "boolean", "isIncluded", "(", "final", "String", "pName", ")", "{", "if", "(", "!", "isIncluded", "(", "pName", ",", "includes", ")", ")", "{", "return", "false", ";", "}", "if", "(", "isExcluded", "(", "pName", ",", "excludes", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}", "private", "boolean", "isIncluded", "(", "String", "name", ",", "String", "[", "]", "includes", ")", "{", "for", "(", "String", "include", ":", "includes", ")", "{", "if", "(", "SelectorUtils", ".", "matchPath", "(", "include", ",", "name", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "private", "boolean", "isExcluded", "(", "String", "name", ",", "String", "[", "]", "excludes", ")", "{", "for", "(", "String", "exclude", ":", "excludes", ")", "{", "if", "(", "SelectorUtils", ".", "matchPath", "(", "exclude", ",", "name", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "public", "TarArchiveEntry", "map", "(", "final", "TarArchiveEntry", "pEntry", ")", "{", "TarArchiveEntry", "entry", "=", "pEntry", ";", "for", "(", "Mapper", "mapper", ":", "mappers", ")", "{", "entry", "=", "mapper", ".", "map", "(", "entry", ")", ";", "}", "return", "entry", ";", "}", "}", "</s>" ]
948
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "producers", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "tar", ".", "TarArchiveEntry", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataConsumer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataProducer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "Mapper", ";", "public", "final", "class", "DataProducerFile", "extends", "AbstractDataProducer", "implements", "DataProducer", "{", "private", "final", "File", "file", ";", "private", "final", "String", "destinationName", ";", "public", "DataProducerFile", "(", "final", "File", "pFile", ",", "String", "pDestinationName", ",", "String", "[", "]", "pIncludes", ",", "String", "[", "]", "pExcludes", ",", "Mapper", "[", "]", "pMapper", ")", "{", "super", "(", "pIncludes", ",", "pExcludes", ",", "pMapper", ")", ";", "file", "=", "pFile", ";", "destinationName", "=", "pDestinationName", ";", "}", "public", "void", "produce", "(", "final", "DataConsumer", "pReceiver", ")", "throws", "IOException", "{", "String", "fileName", ";", "if", "(", "destinationName", "!=", "null", "&&", "destinationName", ".", "trim", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "fileName", "=", "destinationName", ".", "trim", "(", ")", ";", "}", "else", "{", "fileName", "=", "file", ".", "getName", "(", ")", ";", "}", "TarArchiveEntry", "entry", "=", "new", "TarArchiveEntry", "(", "fileName", ",", "true", ")", ";", "entry", ".", "setUserId", "(", "0", ")", ";", "entry", ".", "setUserName", "(", "\"root\"", ")", ";", "entry", ".", "setGroupId", "(", "0", ")", ";", "entry", ".", "setGroupName", "(", "\"root\"", ")", ";", "entry", ".", "setMode", "(", "TarArchiveEntry", ".", "DEFAULT_FILE_MODE", ")", ";", "entry", "=", "map", "(", "entry", ")", ";", "entry", ".", "setSize", "(", "file", ".", "length", "(", ")", ")", ";", "final", "InputStream", "inputStream", "=", "new", "FileInputStream", "(", "file", ")", ";", "try", "{", "pReceiver", ".", "onEachFile", "(", "inputStream", ",", "entry", ".", "getName", "(", ")", ",", "entry", ".", "getLinkName", "(", ")", ",", "entry", ".", "getUserName", "(", ")", ",", "entry", ".", "getUserId", "(", ")", ",", "entry", ".", "getGroupName", "(", ")", ",", "entry", ".", "getGroupId", "(", ")", ",", "entry", ".", "getMode", "(", ")", ",", "entry", ".", "getSize", "(", ")", ")", ";", "}", "finally", "{", "inputStream", ".", "close", "(", ")", ";", "}", "}", "}", "</s>" ]
949
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "producers", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "tar", ".", "TarArchiveEntry", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "DirectoryScanner", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataConsumer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataProducer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "Mapper", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "utils", ".", "Utils", ";", "public", "final", "class", "DataProducerDirectory", "extends", "AbstractDataProducer", "implements", "DataProducer", "{", "private", "final", "DirectoryScanner", "scanner", "=", "new", "DirectoryScanner", "(", ")", ";", "public", "DataProducerDirectory", "(", "final", "File", "pDir", ",", "final", "String", "[", "]", "pIncludes", ",", "final", "String", "[", "]", "pExcludes", ",", "final", "Mapper", "[", "]", "pMappers", ")", "{", "super", "(", "pIncludes", ",", "pExcludes", ",", "pMappers", ")", ";", "scanner", ".", "setBasedir", "(", "pDir", ")", ";", "scanner", ".", "setIncludes", "(", "pIncludes", ")", ";", "scanner", ".", "setExcludes", "(", "pExcludes", ")", ";", "scanner", ".", "setCaseSensitive", "(", "true", ")", ";", "scanner", ".", "setFollowSymlinks", "(", "true", ")", ";", "}", "public", "void", "produce", "(", "final", "DataConsumer", "pReceiver", ")", "throws", "IOException", "{", "scanner", ".", "scan", "(", ")", ";", "final", "File", "baseDir", "=", "scanner", ".", "getBasedir", "(", ")", ";", "for", "(", "String", "dir", ":", "scanner", ".", "getIncludedDirectories", "(", ")", ")", "{", "final", "File", "file", "=", "new", "File", "(", "baseDir", ",", "dir", ")", ";", "String", "dirname", "=", "getFilename", "(", "baseDir", ",", "file", ")", ";", "if", "(", "\"\"", ".", "equals", "(", "dirname", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "isIncluded", "(", "dirname", ")", ")", "{", "continue", ";", "}", "if", "(", "'/'", "!=", "File", ".", "separatorChar", ")", "{", "dirname", "=", "dirname", ".", "replace", "(", "File", ".", "separatorChar", ",", "'/'", ")", ";", "}", "if", "(", "!", "dirname", ".", "endsWith", "(", "\"/\"", ")", ")", "{", "dirname", "+=", "\"/\"", ";", "}", "TarArchiveEntry", "entry", "=", "new", "TarArchiveEntry", "(", "dirname", ",", "true", ")", ";", "entry", ".", "setUserId", "(", "0", ")", ";", "entry", ".", "setUserName", "(", "\"root\"", ")", ";", "entry", ".", "setGroupId", "(", "0", ")", ";", "entry", ".", "setGroupName", "(", "\"root\"", ")", ";", "entry", ".", "setMode", "(", "TarArchiveEntry", ".", "DEFAULT_DIR_MODE", ")", ";", "entry", "=", "map", "(", "entry", ")", ";", "entry", ".", "setSize", "(", "0", ")", ";", "pReceiver", ".", "onEachDir", "(", "entry", ".", "getName", "(", ")", ",", "entry", ".", "getLinkName", "(", ")", ",", "entry", ".", "getUserName", "(", ")", ",", "entry", ".", "getUserId", "(", ")", ",", "entry", ".", "getGroupName", "(", ")", ",", "entry", ".", "getGroupId", "(", ")", ",", "entry", ".", "getMode", "(", ")", ",", "entry", ".", "getSize", "(", ")", ")", ";", "}", "for", "(", "String", "f", ":", "scanner", ".", "getIncludedFiles", "(", ")", ")", "{", "final", "File", "file", "=", "new", "File", "(", "baseDir", ",", "f", ")", ";", "String", "filename", "=", "getFilename", "(", "baseDir", ",", "file", ")", ";", "if", "(", "!", "isIncluded", "(", "filename", ")", ")", "{", "continue", ";", "}", "if", "(", "'/'", "!=", "File", ".", "separatorChar", ")", "{", "filename", "=", "filename", ".", "replace", "(", "File", ".", "separatorChar", ",", "'/'", ")", ";", "}", "TarArchiveEntry", "entry", "=", "new", "TarArchiveEntry", "(", "filename", ",", "true", ")", ";", "entry", ".", "setUserId", "(", "0", ")", ";", "entry", ".", "setUserName", "(", "\"root\"", ")", ";", "entry", ".", "setGroupId", "(", "0", ")", ";", "entry", ".", "setGroupName", "(", "\"root\"", ")", ";", "entry", ".", "setMode", "(", "TarArchiveEntry", ".", "DEFAULT_FILE_MODE", ")", ";", "entry", "=", "map", "(", "entry", ")", ";", "entry", ".", "setSize", "(", "file", ".", "length", "(", ")", ")", ";", "final", "InputStream", "inputStream", "=", "new", "FileInputStream", "(", "file", ")", ";", "try", "{", "pReceiver", ".", "onEachFile", "(", "inputStream", ",", "entry", ".", "getName", "(", ")", ",", "entry", ".", "getLinkName", "(", ")", ",", "entry", ".", "getUserName", "(", ")", ",", "entry", ".", "getUserId", "(", ")", ",", "entry", ".", "getGroupName", "(", ")", ",", "entry", ".", "getGroupId", "(", ")", ",", "entry", ".", "getMode", "(", ")", ",", "entry", ".", "getSize", "(", ")", ")", ";", "}", "finally", "{", "inputStream", ".", "close", "(", ")", ";", "}", "}", "}", "private", "String", "getFilename", "(", "File", "root", ",", "File", "file", ")", "{", "final", "String", "relativeFilename", "=", "file", ".", "getAbsolutePath", "(", ")", ".", "substring", "(", "root", ".", "getAbsolutePath", "(", ")", ".", "length", "(", ")", ")", ";", "return", "Utils", ".", "stripLeadingSlash", "(", "relativeFilename", ")", ";", "}", "}", "</s>" ]
950
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "producers", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "DirectoryScanner", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "taskdefs", ".", "Tar", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "types", ".", "FileSet", ";", "import", "org", ".", "apache", ".", "tools", ".", "tar", ".", "TarEntry", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataConsumer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataProducer", ";", "public", "final", "class", "DataProducerFileSet", "implements", "DataProducer", "{", "private", "final", "FileSet", "fileset", ";", "public", "DataProducerFileSet", "(", "final", "FileSet", "fileset", ")", "{", "this", ".", "fileset", "=", "fileset", ";", "}", "public", "void", "produce", "(", "final", "DataConsumer", "pReceiver", ")", "throws", "IOException", "{", "String", "user", "=", "\"root\"", ";", "int", "uid", "=", "0", ";", "String", "group", "=", "\"root\"", ";", "int", "gid", "=", "0", ";", "int", "filemode", "=", "TarEntry", ".", "DEFAULT_FILE_MODE", ";", "int", "dirmode", "=", "TarEntry", ".", "DEFAULT_DIR_MODE", ";", "String", "prefix", "=", "\"\"", ";", "if", "(", "fileset", "instanceof", "Tar", ".", "TarFileSet", ")", "{", "Tar", ".", "TarFileSet", "tarfileset", "=", "(", "Tar", ".", "TarFileSet", ")", "fileset", ";", "user", "=", "tarfileset", ".", "getUserName", "(", ")", ";", "uid", "=", "tarfileset", ".", "getUid", "(", ")", ";", "group", "=", "tarfileset", ".", "getGroup", "(", ")", ";", "gid", "=", "tarfileset", ".", "getGid", "(", ")", ";", "filemode", "=", "tarfileset", ".", "getMode", "(", ")", ";", "dirmode", "=", "tarfileset", ".", "getDirMode", "(", "tarfileset", ".", "getProject", "(", ")", ")", ";", "prefix", "=", "tarfileset", ".", "getPrefix", "(", "tarfileset", ".", "getProject", "(", ")", ")", ";", "}", "final", "DirectoryScanner", "scanner", "=", "fileset", ".", "getDirectoryScanner", "(", "fileset", ".", "getProject", "(", ")", ")", ";", "scanner", ".", "scan", "(", ")", ";", "final", "File", "basedir", "=", "scanner", ".", "getBasedir", "(", ")", ";", "for", "(", "String", "directory", ":", "scanner", ".", "getIncludedDirectories", "(", ")", ")", "{", "String", "name", "=", "directory", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "pReceiver", ".", "onEachDir", "(", "prefix", "+", "\"/\"", "+", "name", ",", "null", ",", "user", ",", "uid", ",", "group", ",", "gid", ",", "dirmode", ",", "0", ")", ";", "}", "for", "(", "String", "filename", ":", "scanner", ".", "getIncludedFiles", "(", ")", ")", "{", "final", "String", "name", "=", "filename", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ";", "final", "File", "file", "=", "new", "File", "(", "basedir", ",", "name", ")", ";", "final", "InputStream", "inputStream", "=", "new", "FileInputStream", "(", "file", ")", ";", "try", "{", "pReceiver", ".", "onEachFile", "(", "inputStream", ",", "prefix", "+", "\"/\"", "+", "name", ",", "null", ",", "user", ",", "uid", ",", "group", ",", "gid", ",", "filemode", ",", "file", ".", "length", "(", ")", ")", ";", "}", "finally", "{", "inputStream", ".", "close", "(", ")", ";", "}", "}", "}", "}", "</s>" ]
951
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "producers", ";", "import", "java", ".", "io", ".", "BufferedInputStream", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "ArchiveEntry", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "ArchiveException", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "ArchiveInputStream", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "ArchiveStreamFactory", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "tar", ".", "TarArchiveEntry", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "tar", ".", "TarArchiveInputStream", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "zip", ".", "ZipArchiveEntry", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "zip", ".", "ZipArchiveInputStream", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "compressors", ".", "CompressorException", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "compressors", ".", "CompressorInputStream", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "compressors", ".", "CompressorStreamFactory", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataConsumer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataProducer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "Mapper", ";", "public", "final", "class", "DataProducerArchive", "extends", "AbstractDataProducer", "implements", "DataProducer", "{", "private", "final", "File", "archive", ";", "public", "DataProducerArchive", "(", "final", "File", "pArchive", ",", "final", "String", "[", "]", "pIncludes", ",", "final", "String", "[", "]", "pExcludes", ",", "final", "Mapper", "[", "]", "pMappers", ")", "{", "super", "(", "pIncludes", ",", "pExcludes", ",", "pMappers", ")", ";", "archive", "=", "pArchive", ";", "}", "public", "void", "produce", "(", "final", "DataConsumer", "pReceiver", ")", "throws", "IOException", "{", "InputStream", "is", "=", "new", "BufferedInputStream", "(", "new", "FileInputStream", "(", "archive", ")", ")", ";", "CompressorInputStream", "compressorInputStream", "=", "null", ";", "try", "{", "compressorInputStream", "=", "new", "CompressorStreamFactory", "(", ")", ".", "createCompressorInputStream", "(", "is", ")", ";", "}", "catch", "(", "CompressorException", "e", ")", "{", "}", "if", "(", "compressorInputStream", "!=", "null", ")", "{", "is", "=", "new", "BufferedInputStream", "(", "compressorInputStream", ")", ";", "}", "ArchiveInputStream", "archiveInputStream", "=", "null", ";", "try", "{", "archiveInputStream", "=", "new", "ArchiveStreamFactory", "(", ")", ".", "createArchiveInputStream", "(", "is", ")", ";", "}", "catch", "(", "ArchiveException", "e", ")", "{", "throw", "new", "IOException", "(", "\"\"", "+", "archive", ",", "e", ")", ";", "}", "EntryConverter", "converter", "=", "null", ";", "if", "(", "archiveInputStream", "instanceof", "TarArchiveInputStream", ")", "{", "converter", "=", "new", "EntryConverter", "(", ")", "{", "public", "TarArchiveEntry", "convert", "(", "ArchiveEntry", "entry", ")", "{", "TarArchiveEntry", "src", "=", "(", "TarArchiveEntry", ")", "entry", ";", "TarArchiveEntry", "dst", "=", "new", "TarArchiveEntry", "(", "src", ".", "getName", "(", ")", ",", "true", ")", ";", "dst", ".", "setSize", "(", "src", ".", "getSize", "(", ")", ")", ";", "dst", ".", "setGroupName", "(", "src", ".", "getGroupName", "(", ")", ")", ";", "dst", ".", "setGroupId", "(", "src", ".", "getGroupId", "(", ")", ")", ";", "dst", ".", "setUserId", "(", "src", ".", "getUserId", "(", ")", ")", ";", "dst", ".", "setMode", "(", "src", ".", "getMode", "(", ")", ")", ";", "dst", ".", "setModTime", "(", "src", ".", "getModTime", "(", ")", ")", ";", "return", "dst", ";", "}", "}", ";", "}", "else", "if", "(", "archiveInputStream", "instanceof", "ZipArchiveInputStream", ")", "{", "converter", "=", "new", "EntryConverter", "(", ")", "{", "public", "TarArchiveEntry", "convert", "(", "ArchiveEntry", "entry", ")", "{", "ZipArchiveEntry", "src", "=", "(", "ZipArchiveEntry", ")", "entry", ";", "TarArchiveEntry", "dst", "=", "new", "TarArchiveEntry", "(", "src", ".", "getName", "(", ")", ",", "true", ")", ";", "dst", ".", "setSize", "(", "src", ".", "getSize", "(", ")", ")", ";", "dst", ".", "setMode", "(", "src", ".", "getUnixMode", "(", ")", ")", ";", "dst", ".", "setModTime", "(", "src", ".", "getTime", "(", ")", ")", ";", "return", "dst", ";", "}", "}", ";", "}", "else", "{", "throw", "new", "IOException", "(", "\"\"", "+", "archive", ")", ";", "}", "try", "{", "while", "(", "true", ")", "{", "ArchiveEntry", "archiveEntry", "=", "archiveInputStream", ".", "getNextEntry", "(", ")", ";", "if", "(", "archiveEntry", "==", "null", ")", "{", "break", ";", "}", "if", "(", "!", "isIncluded", "(", "archiveEntry", ".", "getName", "(", ")", ")", ")", "{", "continue", ";", "}", "TarArchiveEntry", "entry", "=", "converter", ".", "convert", "(", "archiveEntry", ")", ";", "entry", "=", "map", "(", "entry", ")", ";", "if", "(", "entry", ".", "isDirectory", "(", ")", ")", "{", "pReceiver", ".", "onEachDir", "(", "entry", ".", "getName", "(", ")", ",", "entry", ".", "getLinkName", "(", ")", ",", "entry", ".", "getUserName", "(", ")", ",", "entry", ".", "getUserId", "(", ")", ",", "entry", ".", "getGroupName", "(", ")", ",", "entry", ".", "getGroupId", "(", ")", ",", "entry", ".", "getMode", "(", ")", ",", "entry", ".", "getSize", "(", ")", ")", ";", "continue", ";", "}", "pReceiver", ".", "onEachFile", "(", "archiveInputStream", ",", "entry", ".", "getName", "(", ")", ",", "entry", ".", "getLinkName", "(", ")", ",", "entry", ".", "getUserName", "(", ")", ",", "entry", ".", "getUserId", "(", ")", ",", "entry", ".", "getGroupName", "(", ")", ",", "entry", ".", "getGroupId", "(", ")", ",", "entry", ".", "getMode", "(", ")", ",", "entry", ".", "getSize", "(", ")", ")", ";", "}", "}", "finally", "{", "if", "(", "archiveInputStream", "!=", "null", ")", "{", "archiveInputStream", ".", "close", "(", ")", ";", "}", "}", "}", "private", "interface", "EntryConverter", "{", "public", "TarArchiveEntry", "convert", "(", "ArchiveEntry", "entry", ")", ";", "}", "}", "</s>" ]
952
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "producers", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataConsumer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "DataProducer", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ".", "Mapper", ";", "public", "final", "class", "DataProducerLink", "extends", "AbstractDataProducer", "implements", "DataProducer", "{", "private", "final", "String", "path", ";", "private", "final", "String", "linkName", ";", "private", "final", "boolean", "symlink", ";", "public", "DataProducerLink", "(", "final", "String", "name", ",", "final", "String", "linkName", ",", "final", "boolean", "symlink", ",", "String", "[", "]", "pIncludes", ",", "String", "[", "]", "pExcludes", ",", "Mapper", "[", "]", "pMapper", ")", "{", "super", "(", "pIncludes", ",", "pExcludes", ",", "pMapper", ")", ";", "this", ".", "path", "=", "name", ";", "this", ".", "symlink", "=", "symlink", ";", "this", ".", "linkName", "=", "linkName", ";", "}", "public", "void", "produce", "(", "final", "DataConsumer", "pReceiver", ")", "throws", "IOException", "{", "pReceiver", ".", "onEachLink", "(", "path", ",", "linkName", ",", "symlink", ",", "\"root\"", ",", "0", ",", "\"root\"", ",", "0", ")", ";", "}", "}", "</s>" ]
953
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "descriptors", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "changes", ".", "ChangeSet", ";", "public", "final", "class", "ChangesDescriptor", "extends", "AbstractDescriptor", "{", "private", "final", "static", "String", "[", "]", "keys", "=", "{", "\"Format\"", ",", "\"Date\"", ",", "\"Source\"", ",", "\"Binary\"", ",", "\"Architecture\"", ",", "\"Version\"", ",", "\"Distribution\"", ",", "\"Urgency\"", ",", "\"Maintainer\"", ",", "\"Changed-By\"", ",", "\"Description\"", ",", "\"Changes\"", ",", "\"Closes\"", ",", "\"\"", ",", "\"\"", ",", "\"Files\"", "}", ";", "public", "final", "static", "String", "[", "]", "mandatoryKeys", "=", "{", "\"Format\"", ",", "\"Date\"", ",", "\"Source\"", ",", "\"Binary\"", ",", "\"Architecture\"", ",", "\"Version\"", ",", "\"Distribution\"", ",", "\"Urgency\"", ",", "\"Maintainer\"", ",", "\"Description\"", ",", "\"Changes\"", ",", "\"\"", ",", "\"\"", ",", "\"Files\"", "}", ";", "private", "final", "ChangeSet", "[", "]", "changeSets", ";", "public", "ChangesDescriptor", "(", "final", "AbstractDescriptor", "pDescriptor", ",", "final", "ChangeSet", "[", "]", "pChangeSets", ")", "{", "super", "(", "pDescriptor", ")", ";", "changeSets", "=", "pChangeSets", ";", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "changeSets", ".", "length", ">", "0", ")", "{", "final", "ChangeSet", "lastestChangeSet", "=", "changeSets", "[", "0", "]", ";", "set", "(", "\"Urgency\"", ",", "lastestChangeSet", ".", "getUrgency", "(", ")", ")", ";", "set", "(", "\"Changed-By\"", ",", "lastestChangeSet", ".", "getChangedBy", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "1", ";", "i", "++", ")", "{", "final", "ChangeSet", "changeSet", "=", "changeSets", "[", "i", "]", ";", "sb", ".", "append", "(", "changeSet", ".", "toString", "(", ")", ")", ";", "}", "}", "set", "(", "\"Changes\"", ",", "sb", ".", "toString", "(", ")", ")", ";", "}", "public", "String", "[", "]", "getMandatoryKeys", "(", ")", "{", "return", "mandatoryKeys", ";", "}", "public", "String", "toString", "(", ")", "{", "return", "toString", "(", "keys", ")", ";", "}", "}", "</s>" ]
954
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "descriptors", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "io", ".", "StringReader", ";", "import", "java", ".", "text", ".", "ParseException", ";", "import", "java", ".", "util", ".", "HashSet", ";", "import", "java", ".", "util", ".", "LinkedHashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "Set", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "utils", ".", "Utils", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "utils", ".", "VariableResolver", ";", "public", "abstract", "class", "AbstractDescriptor", "{", "protected", "final", "Map", "<", "String", ",", "String", ">", "values", "=", "new", "LinkedHashMap", "<", "String", ",", "String", ">", "(", ")", ";", "protected", "final", "VariableResolver", "resolver", ";", "private", "static", "String", "openToken", "=", "\"[[\"", ";", "private", "static", "String", "closeToken", "=", "\"]]\"", ";", "public", "AbstractDescriptor", "(", "final", "VariableResolver", "pResolver", ")", "{", "resolver", "=", "pResolver", ";", "}", "public", "AbstractDescriptor", "(", "final", "AbstractDescriptor", "pDescriptor", ")", "{", "this", "(", "pDescriptor", ".", "resolver", ")", ";", "values", ".", "putAll", "(", "pDescriptor", ".", "values", ")", ";", "}", "public", "static", "void", "setOpenToken", "(", "final", "String", "pToken", ")", "{", "openToken", "=", "pToken", ";", "}", "public", "static", "void", "setCloseToken", "(", "final", "String", "pToken", ")", "{", "closeToken", "=", "pToken", ";", "}", "protected", "void", "parse", "(", "final", "InputStream", "pInput", ")", "throws", "IOException", ",", "ParseException", "{", "final", "BufferedReader", "br", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "pInput", ")", ")", ";", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", ")", ";", "String", "key", "=", "null", ";", "int", "linenr", "=", "0", ";", "while", "(", "true", ")", "{", "final", "String", "line", "=", "br", ".", "readLine", "(", ")", ";", "if", "(", "line", "==", "null", ")", "{", "if", "(", "buffer", ".", "length", "(", ")", ">", "0", ")", "{", "set", "(", "key", ",", "buffer", ".", "toString", "(", ")", ")", ";", "buffer", "=", "null", ";", "}", "break", ";", "}", "linenr", "++", ";", "if", "(", "line", ".", "length", "(", ")", "==", "0", ")", "{", "throw", "new", "ParseException", "(", "\"Empty", "line\"", ",", "linenr", ")", ";", "}", "final", "char", "first", "=", "line", ".", "charAt", "(", "0", ")", ";", "if", "(", "Character", ".", "isLetter", "(", "first", ")", ")", "{", "if", "(", "buffer", ".", "length", "(", ")", ">", "0", ")", "{", "set", "(", "key", ",", "buffer", ".", "toString", "(", ")", ")", ";", "buffer", "=", "new", "StringBuilder", "(", ")", ";", "}", "final", "int", "i", "=", "line", ".", "indexOf", "(", "':'", ")", ";", "if", "(", "i", "<", "0", ")", "{", "throw", "new", "ParseException", "(", "\"\"", ",", "linenr", ")", ";", "}", "key", "=", "line", ".", "substring", "(", "0", ",", "i", ")", ";", "buffer", ".", "append", "(", "line", ".", "substring", "(", "i", "+", "1", ")", ".", "trim", "(", ")", ")", ";", "continue", ";", "}", "buffer", ".", "append", "(", "'\\n'", ")", ".", "append", "(", "line", ".", "substring", "(", "1", ")", ")", ";", "}", "br", ".", "close", "(", ")", ";", "}", "public", "void", "set", "(", "final", "String", "pKey", ",", "final", "String", "pValue", ")", "{", "String", "value", "=", "Utils", ".", "replaceVariables", "(", "resolver", ",", "pValue", ",", "openToken", ",", "closeToken", ")", ";", "if", "(", "\"\"", ".", "equals", "(", "value", ")", ")", "{", "value", "=", "null", ";", "}", "values", ".", "put", "(", "pKey", ",", "value", ")", ";", "}", "public", "String", "get", "(", "String", "key", ")", "{", "return", "values", ".", "get", "(", "key", ")", ";", "}", "public", "abstract", "String", "[", "]", "getMandatoryKeys", "(", ")", ";", "public", "boolean", "isValid", "(", ")", "{", "return", "invalidKeys", "(", ")", ".", "size", "(", ")", "==", "0", ";", "}", "public", "Set", "<", "String", ">", "invalidKeys", "(", ")", "{", "final", "Set", "<", "String", ">", "invalid", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "for", "(", "String", "aMk", ":", "getMandatoryKeys", "(", ")", ")", "{", "if", "(", "get", "(", "aMk", ")", "==", "null", ")", "{", "invalid", ".", "add", "(", "aMk", ")", ";", "}", "}", "return", "invalid", ";", "}", "public", "String", "toString", "(", "final", "String", "[", "]", "keys", ")", "{", "StringBuilder", "s", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "String", "key", ":", "keys", ")", "{", "String", "value", "=", "values", ".", "get", "(", "key", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "s", ".", "append", "(", "key", ")", ".", "append", "(", "\":\"", ")", ";", "try", "{", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "StringReader", "(", "value", ")", ")", ";", "String", "line", ";", "while", "(", "(", "line", "=", "reader", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "if", "(", "line", ".", "length", "(", ")", "!=", "0", "&&", "!", "Character", ".", "isWhitespace", "(", "line", ".", "charAt", "(", "0", ")", ")", ")", "{", "s", ".", "append", "(", "'", "'", ")", ";", "}", "s", ".", "append", "(", "line", ")", ".", "append", "(", "'\\n'", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}", "}", "return", "s", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
955
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "descriptors", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "text", ".", "ParseException", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "utils", ".", "VariableResolver", ";", "public", "final", "class", "PackageDescriptor", "extends", "AbstractDescriptor", "{", "private", "final", "static", "String", "[", "]", "keys", "=", "{", "\"Package\"", ",", "\"Source\"", ",", "\"Version\"", ",", "\"Section\"", ",", "\"Priority\"", ",", "\"Architecture\"", ",", "\"Essential\"", ",", "\"Depends\"", ",", "\"Pre-Depends\"", ",", "\"Recommends\"", ",", "\"Suggests\"", ",", "\"Breaks\"", ",", "\"Enhances\"", ",", "\"Conflicts\"", ",", "\"Provides\"", ",", "\"Replaces\"", ",", "\"\"", ",", "\"Maintainer\"", ",", "\"Description\"", ",", "\"Homepage\"", ",", "}", ";", "public", "final", "static", "String", "[", "]", "mandatoryKeys", "=", "{", "\"Package\"", ",", "\"Version\"", ",", "\"Section\"", ",", "\"Priority\"", ",", "\"Architecture\"", ",", "\"Maintainer\"", ",", "\"Description\"", "}", ";", "public", "PackageDescriptor", "(", ")", "{", "this", "(", "null", ")", ";", "}", "public", "PackageDescriptor", "(", "final", "VariableResolver", "pResolver", ")", "{", "super", "(", "pResolver", ")", ";", "}", "public", "PackageDescriptor", "(", "final", "InputStream", "pInput", ",", "final", "VariableResolver", "pResolver", ")", "throws", "IOException", ",", "ParseException", "{", "this", "(", "pResolver", ")", ";", "parse", "(", "pInput", ")", ";", "}", "public", "String", "[", "]", "getMandatoryKeys", "(", ")", "{", "return", "mandatoryKeys", ";", "}", "public", "String", "toString", "(", ")", "{", "return", "toString", "(", "keys", ")", ";", "}", "}", "</s>" ]
956
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "tar", ".", "TarArchiveEntry", ";", "public", "final", "class", "NullMapper", "implements", "Mapper", "{", "public", "static", "final", "Mapper", "INSTANCE", "=", "new", "NullMapper", "(", ")", ";", "private", "NullMapper", "(", ")", "{", "}", "public", "TarArchiveEntry", "map", "(", "final", "TarArchiveEntry", "pEntry", ")", "{", "return", "pEntry", ";", "}", "}", "</s>" ]
957
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "tar", ".", "TarArchiveEntry", ";", "public", "interface", "Mapper", "{", "public", "TarArchiveEntry", "map", "(", "final", "TarArchiveEntry", "entry", ")", ";", "}", "</s>" ]
958
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "tar", ".", "TarArchiveEntry", ";", "import", "org", ".", "vafer", ".", "jdeb", ".", "utils", ".", "Utils", ";", "public", "final", "class", "PermMapper", "implements", "Mapper", "{", "private", "final", "int", "strip", ";", "private", "final", "String", "prefix", ";", "private", "int", "uid", "=", "-", "1", ";", "private", "int", "gid", "=", "-", "1", ";", "private", "String", "user", ";", "private", "String", "group", ";", "private", "int", "fileMode", "=", "-", "1", ";", "private", "int", "dirMode", "=", "-", "1", ";", "public", "static", "int", "toMode", "(", "String", "modeString", ")", "{", "int", "mode", "=", "-", "1", ";", "if", "(", "modeString", "!=", "null", "&&", "modeString", ".", "length", "(", ")", ">", "0", ")", "{", "mode", "=", "Integer", ".", "parseInt", "(", "modeString", ",", "8", ")", ";", "}", "return", "mode", ";", "}", "public", "PermMapper", "(", "int", "uid", ",", "int", "gid", ",", "String", "user", ",", "String", "group", ",", "int", "fileMode", ",", "int", "dirMode", ",", "int", "strip", ",", "String", "prefix", ")", "{", "this", ".", "strip", "=", "strip", ";", "this", ".", "prefix", "=", "(", "prefix", "==", "null", ")", "?", "\"\"", ":", "prefix", ";", "this", ".", "uid", "=", "uid", ";", "this", ".", "gid", "=", "gid", ";", "this", ".", "user", "=", "user", ";", "this", ".", "group", "=", "group", ";", "this", ".", "fileMode", "=", "fileMode", ";", "this", ".", "dirMode", "=", "dirMode", ";", "}", "public", "PermMapper", "(", "int", "uid", ",", "int", "gid", ",", "String", "user", ",", "String", "group", ",", "String", "fileMode", ",", "String", "dirMode", ",", "int", "strip", ",", "String", "prefix", ")", "{", "this", "(", "uid", ",", "gid", ",", "user", ",", "group", ",", "toMode", "(", "fileMode", ")", ",", "toMode", "(", "dirMode", ")", ",", "strip", ",", "prefix", ")", ";", "}", "public", "TarArchiveEntry", "map", "(", "final", "TarArchiveEntry", "entry", ")", "{", "final", "String", "name", "=", "entry", ".", "getName", "(", ")", ";", "final", "TarArchiveEntry", "newEntry", "=", "new", "TarArchiveEntry", "(", "prefix", "+", "'/'", "+", "Utils", ".", "stripPath", "(", "strip", ",", "name", ")", ",", "true", ")", ";", "if", "(", "uid", ">", "-", "1", ")", "{", "newEntry", ".", "setUserId", "(", "uid", ")", ";", "}", "else", "{", "newEntry", ".", "setUserId", "(", "entry", ".", "getUserId", "(", ")", ")", ";", "}", "if", "(", "gid", ">", "-", "1", ")", "{", "newEntry", ".", "setGroupId", "(", "gid", ")", ";", "}", "else", "{", "newEntry", ".", "setGroupId", "(", "entry", ".", "getGroupId", "(", ")", ")", ";", "}", "if", "(", "user", "!=", "null", ")", "{", "newEntry", ".", "setUserName", "(", "user", ")", ";", "}", "else", "{", "newEntry", ".", "setUserName", "(", "entry", ".", "getUserName", "(", ")", ")", ";", "}", "if", "(", "group", "!=", "null", ")", "{", "newEntry", ".", "setGroupName", "(", "group", ")", ";", "}", "else", "{", "newEntry", ".", "setGroupName", "(", "entry", ".", "getGroupName", "(", ")", ")", ";", "}", "if", "(", "newEntry", ".", "isDirectory", "(", ")", ")", "{", "if", "(", "dirMode", ">", "-", "1", ")", "{", "newEntry", ".", "setMode", "(", "dirMode", ")", ";", "}", "else", "{", "newEntry", ".", "setMode", "(", "entry", ".", "getMode", "(", ")", ")", ";", "}", "}", "else", "{", "if", "(", "fileMode", ">", "-", "1", ")", "{", "newEntry", ".", "setMode", "(", "fileMode", ")", ";", "}", "else", "{", "newEntry", ".", "setMode", "(", "entry", ".", "getMode", "(", ")", ")", ";", "}", "}", "newEntry", ".", "setSize", "(", "entry", ".", "getSize", "(", ")", ")", ";", "return", "newEntry", ";", "}", "}", "</s>" ]
959
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "mapping", ";", "import", "java", ".", "io", ".", "BufferedReader", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "java", ".", "util", ".", "regex", ".", "Matcher", ";", "import", "java", ".", "util", ".", "regex", ".", "Pattern", ";", "import", "org", ".", "apache", ".", "commons", ".", "compress", ".", "archivers", ".", "tar", ".", "TarArchiveEntry", ";", "public", "final", "class", "LsMapper", "implements", "Mapper", "{", "private", "final", "Map", "mapping", ";", "public", "final", "static", "class", "ParseError", "extends", "Exception", "{", "private", "static", "final", "long", "serialVersionUID", "=", "1L", ";", "public", "ParseError", "(", ")", "{", "super", "(", ")", ";", "}", "public", "ParseError", "(", "String", "message", ",", "Throwable", "cause", ")", "{", "super", "(", "message", ",", "cause", ")", ";", "}", "public", "ParseError", "(", "String", "message", ")", "{", "super", "(", "message", ")", ";", "}", "public", "ParseError", "(", "Throwable", "cause", ")", "{", "super", "(", "cause", ")", ";", "}", "}", ";", "public", "LsMapper", "(", "final", "InputStream", "pInput", ")", "throws", "IOException", ",", "ParseError", "{", "mapping", "=", "parse", "(", "pInput", ")", ";", "}", "final", "private", "Pattern", "basePattern", "=", "Pattern", ".", "compile", "(", "\"^\\\\./(.*):$\"", ")", ";", "final", "private", "Pattern", "totalPattern", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "final", "private", "Pattern", "dirPattern", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "final", "private", "Pattern", "filePattern", "=", "Pattern", ".", "compile", "(", "\"\"", ")", ";", "final", "private", "Pattern", "newlinePattern", "=", "Pattern", ".", "compile", "(", "\"$\"", ")", ";", "private", "String", "readBase", "(", "final", "BufferedReader", "reader", ")", "throws", "IOException", ",", "ParseError", "{", "final", "String", "line", "=", "reader", ".", "readLine", "(", ")", ";", "if", "(", "line", "==", "null", ")", "{", "return", "null", ";", "}", "final", "Matcher", "matcher", "=", "basePattern", ".", "matcher", "(", "line", ")", ";", "if", "(", "!", "matcher", ".", "matches", "(", ")", ")", "{", "throw", "new", "ParseError", "(", "\"\"", "+", "line", "+", "\"\\\"\"", ")", ";", "}", "return", "matcher", ".", "group", "(", "1", ")", ";", "}", "private", "String", "readTotal", "(", "final", "BufferedReader", "reader", ")", "throws", "IOException", ",", "ParseError", "{", "final", "String", "line", "=", "reader", ".", "readLine", "(", ")", ";", "final", "Matcher", "matcher", "=", "totalPattern", ".", "matcher", "(", "line", ")", ";", "if", "(", "!", "matcher", ".", "matches", "(", ")", ")", "{", "throw", "new", "ParseError", "(", "\"\"", "+", "line", "+", "\"\\\"\"", ")", ";", "}", "return", "matcher", ".", "group", "(", "1", ")", ";", "}", "private", "TarArchiveEntry", "readDir", "(", "final", "BufferedReader", "reader", ",", "final", "String", "base", ")", "throws", "IOException", ",", "ParseError", "{", "final", "String", "current", "=", "reader", ".", "readLine", "(", ")", ";", "final", "Matcher", "currentMatcher", "=", "dirPattern", ".", "matcher", "(", "current", ")", ";", "if", "(", "!", "currentMatcher", ".", "matches", "(", ")", ")", "{", "throw", "new", "ParseError", "(", "\"\"", "+", "current", "+", "\"\\\"\"", ")", ";", "}", "final", "String", "parent", "=", "reader", ".", "readLine", "(", ")", ";", "final", "Matcher", "parentMatcher", "=", "dirPattern", ".", "matcher", "(", "parent", ")", ";", "if", "(", "!", "parentMatcher", ".", "matches", "(", ")", ")", "{", "throw", "new", "ParseError", "(", "\"\"", "+", "parent", "+", "\"\\\"\"", ")", ";", "}", "final", "TarArchiveEntry", "entry", "=", "new", "TarArchiveEntry", "(", "base", ",", "true", ")", ";", "entry", ".", "setMode", "(", "convertModeFromString", "(", "currentMatcher", ".", "group", "(", "1", ")", ")", ")", ";", "entry", ".", "setUserName", "(", "currentMatcher", ".", "group", "(", "3", ")", ")", ";", "entry", ".", "setGroupName", "(", "currentMatcher", ".", "group", "(", "4", ")", ")", ";", "return", "entry", ";", "}", "private", "int", "convertModeFromString", "(", "final", "String", "mode", ")", "{", "final", "char", "[", "]", "m", "=", "mode", ".", "toCharArray", "(", ")", ";", "int", "sum", "=", "0", ";", "int", "bit", "=", "1", ";", "for", "(", "int", "i", "=", "m", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "m", "[", "i", "]", "!=", "'-'", ")", "{", "sum", "+=", "bit", ";", "}", "bit", "+=", "bit", ";", "}", "return", "sum", ";", "}", "private", "TarArchiveEntry", "readFile", "(", "final", "BufferedReader", "reader", ",", "final", "String", "base", ")", "throws", "IOException", ",", "ParseError", "{", "while", "(", "true", ")", "{", "final", "String", "line", "=", "reader", ".", "readLine", "(", ")", ";", "if", "(", "line", "==", "null", ")", "{", "return", "null", ";", "}", "final", "Matcher", "currentMatcher", "=", "filePattern", ".", "matcher", "(", "line", ")", ";", "if", "(", "!", "currentMatcher", ".", "matches", "(", ")", ")", "{", "final", "Matcher", "newlineMatcher", "=", "newlinePattern", ".", "matcher", "(", "line", ")", ";", "if", "(", "newlineMatcher", ".", "matches", "(", ")", ")", "{", "return", "null", ";", "}", "throw", "new", "ParseError", "(", "\"\"", "+", "line", "+", "\"\\\"\"", ")", ";", "}", "final", "String", "type", "=", "currentMatcher", ".", "group", "(", "1", ")", ";", "if", "(", "type", ".", "startsWith", "(", "\"-\"", ")", ")", "{", "final", "TarArchiveEntry", "entry", "=", "new", "TarArchiveEntry", "(", "base", "+", "\"/\"", "+", "currentMatcher", ".", "group", "(", "8", ")", ",", "true", ")", ";", "entry", ".", "setMode", "(", "convertModeFromString", "(", "currentMatcher", ".", "group", "(", "2", ")", ")", ")", ";", "entry", ".", "setUserName", "(", "currentMatcher", ".", "group", "(", "4", ")", ")", ";", "entry", ".", "setGroupName", "(", "currentMatcher", ".", "group", "(", "5", ")", ")", ";", "return", "entry", ";", "}", "}", "}", "private", "Map", "parse", "(", "final", "InputStream", "pInput", ")", "throws", "IOException", ",", "ParseError", "{", "final", "Map", "mapping", "=", "new", "HashMap", "(", ")", ";", "final", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "pInput", ")", ")", ";", "boolean", "first", "=", "true", ";", "while", "(", "true", ")", "{", "final", "String", "base", ";", "if", "(", "first", ")", "{", "base", "=", "\"\"", ";", "first", "=", "false", ";", "}", "else", "{", "base", "=", "readBase", "(", "reader", ")", ";", "if", "(", "base", "==", "null", ")", "{", "break", ";", "}", "}", "readTotal", "(", "reader", ")", ";", "final", "TarArchiveEntry", "dir", "=", "readDir", "(", "reader", ",", "base", ")", ";", "mapping", ".", "put", "(", "dir", ".", "getName", "(", ")", ",", "dir", ")", ";", "while", "(", "true", ")", "{", "final", "TarArchiveEntry", "file", "=", "readFile", "(", "reader", ",", "base", ")", ";", "if", "(", "file", "==", "null", ")", "{", "break", ";", "}", "mapping", ".", "put", "(", "file", ".", "getName", "(", ")", ",", "file", ")", ";", "}", "}", "return", "mapping", ";", "}", "public", "TarArchiveEntry", "map", "(", "final", "TarArchiveEntry", "pEntry", ")", "{", "final", "TarArchiveEntry", "entry", "=", "(", "TarArchiveEntry", ")", "mapping", ".", "get", "(", "pEntry", ".", "getName", "(", ")", ")", ";", "if", "(", "entry", "!=", "null", ")", "{", "final", "TarArchiveEntry", "newEntry", "=", "new", "TarArchiveEntry", "(", "entry", ".", "getName", "(", ")", ",", "true", ")", ";", "newEntry", ".", "setUserId", "(", "entry", ".", "getUserId", "(", ")", ")", ";", "newEntry", ".", "setGroupId", "(", "entry", ".", "getGroupId", "(", ")", ")", ";", "newEntry", ".", "setUserName", "(", "entry", ".", "getUserName", "(", ")", ")", ";", "newEntry", ".", "setGroupName", "(", "entry", ".", "getGroupName", "(", ")", ")", ";", "newEntry", ".", "setMode", "(", "entry", ".", "getMode", "(", ")", ")", ";", "newEntry", ".", "setSize", "(", "entry", ".", "getSize", "(", ")", ")", ";", "return", "newEntry", ";", "}", "return", "pEntry", ";", "}", "}", "</s>" ]
960
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ";", "public", "interface", "Console", "{", "void", "info", "(", "String", "s", ")", ";", "void", "warn", "(", "String", "s", ")", ";", "}", "</s>" ]
961
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "utils", ";", "import", "java", ".", "util", ".", "Map", ";", "public", "final", "class", "MapVariableResolver", "implements", "VariableResolver", "{", "private", "final", "Map", "<", "String", ",", "String", ">", "map", ";", "public", "MapVariableResolver", "(", "Map", "<", "String", ",", "String", ">", "map", ")", "{", "this", ".", "map", "=", "map", ";", "}", "public", "String", "get", "(", "String", "key", ")", "{", "return", "map", ".", "get", "(", "key", ")", ";", "}", "}", "</s>" ]
962
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "utils", ";", "import", "java", ".", "io", ".", "FilterInputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "util", ".", "HashMap", ";", "import", "java", ".", "util", ".", "Map", ";", "public", "final", "class", "InformationInputStream", "extends", "FilterInputStream", "{", "private", "long", "i", ";", "private", "long", "ascii", ";", "private", "long", "nonascii", ";", "private", "long", "cr", ";", "private", "long", "lf", ";", "private", "long", "zero", ";", "private", "final", "Map", "<", "BOM", ",", "Integer", ">", "bomPositions", "=", "new", "HashMap", "<", "BOM", ",", "Integer", ">", "(", ")", ";", "private", "final", "Map", "<", "Shell", ",", "Integer", ">", "shellPositions", "=", "new", "HashMap", "<", "Shell", ",", "Integer", ">", "(", ")", ";", "private", "enum", "BOM", "{", "NONE", "(", "null", ")", ",", "UTF8", "(", "\"UTF-8\"", ",", "0xEF", ",", "0xBB", ",", "0xBF", ")", ",", "UTF16LE", "(", "\"UTF-16LE\"", ",", "0xFF", ",", "0xFE", ")", ",", "UTF16BE", "(", "\"UTF-16BE\"", ",", "0xFE", ",", "0xFF", ")", ";", "int", "[", "]", "sequence", ";", "String", "encoding", ";", "private", "BOM", "(", "String", "encoding", ",", "int", "...", "sequence", ")", "{", "this", ".", "encoding", "=", "encoding", ";", "this", ".", "sequence", "=", "sequence", ";", "}", "}", "private", "enum", "Shell", "{", "NONE", ",", "ASCII", "(", "0x23", ",", "0x21", ")", ",", "UTF16BE", "(", "0x00", ",", "0x23", ",", "0x00", ",", "0x21", ")", ",", "UTF16LE", "(", "0x23", ",", "0x00", ",", "0x21", ",", "0x00", ")", ";", "int", "[", "]", "header", ";", "private", "Shell", "(", "int", "...", "header", ")", "{", "this", ".", "header", "=", "header", ";", "}", "}", "private", "BOM", "bom", "=", "BOM", ".", "NONE", ";", "private", "Shell", "shell", "=", "Shell", ".", "NONE", ";", "public", "InformationInputStream", "(", "InputStream", "in", ")", "{", "super", "(", "in", ")", ";", "}", "public", "boolean", "hasBom", "(", ")", "{", "return", "bom", "!=", "BOM", ".", "NONE", ";", "}", "public", "boolean", "isShell", "(", ")", "{", "return", "shell", "!=", "Shell", ".", "NONE", ";", "}", "public", "boolean", "hasUnixLineEndings", "(", ")", "{", "return", "cr", "==", "0", ";", "}", "public", "String", "getEncoding", "(", ")", "{", "String", "encoding", "=", "bom", ".", "encoding", ";", "if", "(", "encoding", "==", "null", ")", "{", "if", "(", "shell", "==", "Shell", ".", "UTF16BE", ")", "{", "encoding", "=", "BOM", ".", "UTF16BE", ".", "encoding", ";", "}", "else", "if", "(", "shell", "==", "Shell", ".", "UTF16LE", ")", "{", "encoding", "=", "BOM", ".", "UTF16LE", ".", "encoding", ";", "}", "}", "return", "encoding", ";", "}", "private", "void", "add", "(", "int", "c", ")", "{", "if", "(", "i", "<", "10", ")", "{", "if", "(", "shell", "==", "Shell", ".", "NONE", ")", "{", "for", "(", "Shell", "shell", ":", "Shell", ".", "values", "(", ")", ")", "{", "int", "position", "=", "shellPositions", ".", "containsKey", "(", "shell", ")", "?", "shellPositions", ".", "get", "(", "shell", ")", ":", "0", ";", "if", "(", "position", "<", "shell", ".", "header", ".", "length", ")", "{", "if", "(", "c", "==", "shell", ".", "header", "[", "position", "]", ")", "{", "shellPositions", ".", "put", "(", "shell", ",", "position", "+", "1", ")", ";", "}", "else", "{", "shellPositions", ".", "put", "(", "shell", ",", "0", ")", ";", "}", "}", "else", "{", "this", ".", "shell", "=", "shell", ";", "}", "}", "}", "if", "(", "bom", "==", "BOM", ".", "NONE", ")", "{", "for", "(", "BOM", "bom", ":", "BOM", ".", "values", "(", ")", ")", "{", "int", "position", "=", "bomPositions", ".", "containsKey", "(", "bom", ")", "?", "bomPositions", ".", "get", "(", "bom", ")", ":", "0", ";", "if", "(", "position", "<", "bom", ".", "sequence", ".", "length", ")", "{", "if", "(", "c", "==", "bom", ".", "sequence", "[", "position", "]", "&&", "position", "==", "i", ")", "{", "bomPositions", ".", "put", "(", "bom", ",", "position", "+", "1", ")", ";", "}", "else", "{", "bomPositions", ".", "put", "(", "bom", ",", "0", ")", ";", "}", "}", "else", "{", "this", ".", "bom", "=", "bom", ";", "}", "}", "}", "}", "i", "++", ";", "if", "(", "c", "==", "'\\n'", ")", "{", "lf", "++", ";", "return", ";", "}", "if", "(", "c", "==", "'\\r'", ")", "{", "cr", "++", ";", "return", ";", "}", "if", "(", "c", ">=", "'", "'", "&&", "c", "<=", "'~'", ")", "{", "ascii", "++", ";", "return", ";", "}", "if", "(", "c", "==", "0", ")", "{", "zero", "++", ";", "return", ";", "}", "nonascii", "++", ";", "}", "public", "int", "read", "(", ")", "throws", "IOException", "{", "int", "b", "=", "super", ".", "read", "(", ")", ";", "if", "(", "b", "!=", "-", "1", ")", "{", "add", "(", "b", "&", "0xFF", ")", ";", "}", "return", "b", ";", "}", "public", "int", "read", "(", "byte", "[", "]", "b", ",", "int", "off", ",", "int", "len", ")", "throws", "IOException", "{", "int", "length", "=", "super", ".", "read", "(", "b", ",", "off", ",", "len", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "add", "(", "b", "[", "off", "+", "i", "]", "&", "0xFF", ")", ";", "}", "return", "length", ";", "}", "public", "String", "toString", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "\"{\"", ")", ";", "sb", ".", "append", "(", "\"total=\"", ")", ".", "append", "(", "i", ")", ";", "sb", ".", "append", "(", "\",noascii=\"", ")", ".", "append", "(", "nonascii", ")", ";", "sb", ".", "append", "(", "\",ascii=\"", ")", ".", "append", "(", "ascii", ")", ";", "sb", ".", "append", "(", "\",cr=\"", ")", ".", "append", "(", "cr", ")", ";", "sb", ".", "append", "(", "\",lf=\"", ")", ".", "append", "(", "lf", ")", ";", "sb", ".", "append", "(", "\",zero=\"", ")", ".", "append", "(", "zero", ")", ";", "sb", ".", "append", "(", "\"}\"", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
963
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "utils", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "java", ".", "security", ".", "DigestOutputStream", ";", "import", "java", ".", "security", ".", "MessageDigest", ";", "public", "class", "InformationOutputStream", "extends", "DigestOutputStream", "{", "private", "final", "MessageDigest", "digest", ";", "private", "long", "size", ";", "public", "InformationOutputStream", "(", "OutputStream", "pStream", ",", "MessageDigest", "pDigest", ")", "{", "super", "(", "pStream", ",", "pDigest", ")", ";", "digest", "=", "pDigest", ";", "size", "=", "0", ";", "}", "public", "String", "getHexDigest", "(", ")", "{", "return", "Utils", ".", "toHex", "(", "digest", ".", "digest", "(", ")", ")", ";", "}", "public", "void", "write", "(", "byte", "[", "]", "b", ",", "int", "off", ",", "int", "len", ")", "throws", "IOException", "{", "super", ".", "write", "(", "b", ",", "off", ",", "len", ")", ";", "size", "+=", "len", ";", "}", "public", "void", "write", "(", "int", "b", ")", "throws", "IOException", "{", "super", ".", "write", "(", "b", ")", ";", "size", "++", ";", "}", "public", "long", "getSize", "(", ")", "{", "return", "size", ";", "}", "}", "</s>" ]
964
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "utils", ";", "public", "interface", "VariableResolver", "{", "public", "String", "get", "(", "final", "String", "pKey", ")", ";", "}", "</s>" ]
965
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "utils", ";", "import", "java", ".", "io", ".", "ByteArrayOutputStream", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "InputStreamReader", ";", "import", "java", ".", "io", ".", "OutputStream", ";", "import", "java", ".", "text", ".", "ParseException", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "filters", ".", "FixCrLfFilter", ";", "import", "org", ".", "apache", ".", "tools", ".", "ant", ".", "util", ".", "ReaderInputStream", ";", "public", "final", "class", "Utils", "{", "public", "static", "int", "copy", "(", "final", "InputStream", "pInput", ",", "final", "OutputStream", "pOutput", ")", "throws", "IOException", "{", "final", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "2048", "]", ";", "int", "count", "=", "0", ";", "int", "n", ";", "while", "(", "-", "1", "!=", "(", "n", "=", "pInput", ".", "read", "(", "buffer", ")", ")", ")", "{", "pOutput", ".", "write", "(", "buffer", ",", "0", ",", "n", ")", ";", "count", "+=", "n", ";", "}", "return", "count", ";", "}", "public", "static", "String", "toHex", "(", "final", "byte", "[", "]", "bytes", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "byte", "b", ":", "bytes", ")", "{", "sb", ".", "append", "(", "Integer", ".", "toHexString", "(", "(", "b", ">>", "4", ")", "&", "0x0f", ")", ")", ";", "sb", ".", "append", "(", "Integer", ".", "toHexString", "(", "b", "&", "0x0f", ")", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}", "public", "static", "String", "stripPath", "(", "final", "int", "p", ",", "final", "String", "s", ")", "{", "if", "(", "p", "<=", "0", ")", "{", "return", "s", ";", "}", "int", "x", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "p", ";", "i", "++", ")", "{", "x", "=", "s", ".", "indexOf", "(", "'/'", ",", "x", "+", "1", ")", ";", "if", "(", "x", "<", "0", ")", "{", "return", "s", ";", "}", "}", "return", "s", ".", "substring", "(", "x", "+", "1", ")", ";", "}", "public", "static", "String", "stripLeadingSlash", "(", "final", "String", "s", ")", "{", "if", "(", "s", "==", "null", ")", "{", "return", "s", ";", "}", "if", "(", "s", ".", "length", "(", ")", "==", "0", ")", "{", "return", "s", ";", "}", "if", "(", "s", ".", "charAt", "(", "0", ")", "==", "'/'", ")", "{", "return", "s", ".", "substring", "(", "1", ")", ";", "}", "return", "s", ";", "}", "public", "static", "String", "replaceVariables", "(", "final", "VariableResolver", "pResolver", ",", "final", "String", "pExpression", ",", "final", "String", "pOpen", ",", "final", "String", "pClose", ")", "{", "final", "char", "[", "]", "open", "=", "pOpen", ".", "toCharArray", "(", ")", ";", "final", "char", "[", "]", "close", "=", "pClose", ".", "toCharArray", "(", ")", ";", "final", "StringBuilder", "out", "=", "new", "StringBuilder", "(", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "char", "[", "]", "watch", "=", "open", ";", "int", "w", "=", "0", ";", "for", "(", "char", "c", ":", "pExpression", ".", "toCharArray", "(", ")", ")", "{", "if", "(", "c", "==", "watch", "[", "w", "]", ")", "{", "w", "++", ";", "if", "(", "watch", ".", "length", "==", "w", ")", "{", "if", "(", "watch", "==", "open", ")", "{", "out", ".", "append", "(", "sb", ")", ";", "sb", "=", "new", "StringBuilder", "(", ")", ";", "watch", "=", "close", ";", "}", "else", "{", "final", "String", "variable", "=", "pResolver", ".", "get", "(", "sb", ".", "toString", "(", ")", ")", ";", "if", "(", "variable", "!=", "null", ")", "{", "out", ".", "append", "(", "variable", ")", ";", "}", "else", "{", "out", ".", "append", "(", "pOpen", ")", ";", "out", ".", "append", "(", "sb", ")", ";", "out", ".", "append", "(", "pClose", ")", ";", "}", "sb", "=", "new", "StringBuilder", "(", ")", ";", "watch", "=", "open", ";", "}", "w", "=", "0", ";", "}", "}", "else", "{", "if", "(", "w", ">", "0", ")", "{", "sb", ".", "append", "(", "watch", ",", "0", ",", "w", ")", ";", "}", "sb", ".", "append", "(", "c", ")", ";", "w", "=", "0", ";", "}", "}", "if", "(", "watch", "==", "close", ")", "{", "out", ".", "append", "(", "open", ")", ";", "}", "out", ".", "append", "(", "sb", ")", ";", "return", "out", ".", "toString", "(", ")", ";", "}", "public", "static", "byte", "[", "]", "toUnixLineEndings", "(", "InputStream", "input", ")", "throws", "IOException", "{", "String", "encoding", "=", "\"ISO-8859-1\"", ";", "FixCrLfFilter", "filter", "=", "new", "FixCrLfFilter", "(", "new", "InputStreamReader", "(", "input", ",", "encoding", ")", ")", ";", "filter", ".", "setEol", "(", "FixCrLfFilter", ".", "CrLf", ".", "newInstance", "(", "\"unix\"", ")", ")", ";", "ByteArrayOutputStream", "filteredFile", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "Utils", ".", "copy", "(", "new", "ReaderInputStream", "(", "filter", ",", "encoding", ")", ",", "filteredFile", ")", ";", "return", "filteredFile", ".", "toByteArray", "(", ")", ";", "}", "}", "</s>" ]
966
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "examples", ";", "public", "class", "Main", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "}", "</s>" ]
967
[ "<s>", "package", "org", ".", "vafer", ".", "jdeb", ".", "examples", ";", "public", "class", "Main", "{", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "System", ".", "out", ".", "println", "(", "\"\"", ")", ";", "}", "}", "</s>" ]
968
[ "<s>", "package", "com", ".", "svashishtha", ".", "dom", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "StringTokenizer", ";", "import", "org", ".", "apache", ".", "xerces", ".", "dom", ".", "DocumentImpl", ";", "import", "org", ".", "w3c", ".", "dom", ".", "Attr", ";", "import", "org", ".", "w3c", ".", "dom", ".", "Document", ";", "import", "org", ".", "w3c", ".", "dom", ".", "Element", ";", "import", "org", ".", "w3c", ".", "dom", ".", "Node", ";", "import", "org", ".", "w3c", ".", "dom", ".", "NodeList", ";", "public", "final", "class", "DomEditor", "{", "private", "DomEditor", "(", ")", "{", "super", "(", ")", ";", "}", "public", "static", "void", "addAttributeToElement", "(", "Document", "doc", ",", "Element", "projectElement", ",", "String", "attributeName", ",", "String", "attributeValue", ")", "{", "Attr", "xmlnsAttr", "=", "doc", ".", "createAttribute", "(", "attributeName", ")", ";", "xmlnsAttr", ".", "setValue", "(", "attributeValue", ")", ";", "projectElement", ".", "setAttributeNode", "(", "xmlnsAttr", ")", ";", "}", "public", "static", "void", "replaceTagValue", "(", "Document", "doc", ",", "String", "tagName", ",", "String", "tagValue", ")", "{", "NodeList", "nodeList", "=", "doc", ".", "getElementsByTagName", "(", "tagName", ")", ";", "int", "j", "=", "nodeList", ".", "getLength", "(", ")", ";", "Node", "node", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "j", ";", "i", "++", ")", "{", "Node", "newNode", "=", "doc", ".", "createTextNode", "(", "tagValue", ")", ";", "node", "=", "nodeList", ".", "item", "(", "i", ")", ";", "if", "(", "node", ".", "getFirstChild", "(", ")", "!=", "null", ")", "{", "node", ".", "replaceChild", "(", "newNode", ",", "node", ".", "getFirstChild", "(", ")", ")", ";", "}", "else", "{", "node", ".", "appendChild", "(", "newNode", ")", ";", "}", "}", "}", "public", "static", "Element", "insertNewTagBelow", "(", "Document", "d", ",", "String", "appendTo", ",", "String", "tagName", ",", "String", "tagValue", ")", "{", "Node", "element", "=", "d", ".", "getElementsByTagName", "(", "appendTo", ")", ".", "item", "(", "0", ")", ";", "if", "(", "element", "==", "null", ")", "{", "element", "=", "d", ".", "createElement", "(", "appendTo", ")", ";", "}", "Element", "newElement", "=", "d", ".", "createElement", "(", "tagName", ")", ";", "element", ".", "appendChild", "(", "newElement", ")", ";", "newElement", ".", "appendChild", "(", "d", ".", "createTextNode", "(", "tagValue", ")", ")", ";", "return", "newElement", ";", "}", "public", "static", "Element", "insertTagValue", "(", "Document", "doc", ",", "String", "tagName", ",", "String", "tagValue", ")", "{", "Element", "element", "=", "doc", ".", "createElement", "(", "tagName", ")", ";", "doc", ".", "getDocumentElement", "(", ")", ".", "appendChild", "(", "element", ")", ";", "if", "(", "tagValue", "!=", "null", ")", "{", "element", ".", "appendChild", "(", "doc", ".", "createTextNode", "(", "tagValue", ")", ")", ";", "}", "return", "element", ";", "}", "public", "static", "Element", "insertTagInElement", "(", "Document", "document", ",", "Element", "elementToAppend", ",", "String", "tagName", ",", "String", "tagValue", ")", "{", "Element", "newElement", "=", "document", ".", "createElement", "(", "tagName", ")", ";", "elementToAppend", ".", "appendChild", "(", "newElement", ")", ";", "newElement", ".", "appendChild", "(", "document", ".", "createTextNode", "(", "tagValue", ")", ")", ";", "return", "newElement", ";", "}", "public", "static", "void", "insertOrUpdateTagValue", "(", "Document", "doc", ",", "String", "tagName", ",", "String", "tagValue", ")", "{", "if", "(", "DomEditor", ".", "checkTagExists", "(", "doc", ",", "tagName", ")", ")", "{", "DomEditor", ".", "replaceTagValue", "(", "doc", ",", "tagName", ",", "tagValue", ")", ";", "}", "else", "{", "DomEditor", ".", "insertTagValue", "(", "doc", ",", "tagName", ",", "tagValue", ")", ";", "}", "}", "public", "static", "String", "getTagValue", "(", "Element", "element", ",", "String", "tagName", ")", "{", "if", "(", "element", "==", "null", ")", "{", "return", "null", ";", "}", "NodeList", "nodes", "=", "element", ".", "getElementsByTagName", "(", "tagName", ")", ";", "if", "(", "nodes", "==", "null", "||", "nodes", ".", "getLength", "(", ")", "<=", "0", ")", "{", "return", "null", ";", "}", "return", "getTagValueOfFirstChild", "(", "nodes", ".", "item", "(", "0", ")", ")", ";", "}", "public", "static", "List", "<", "String", ">", "getTagValues", "(", "Element", "element", ",", "String", "tagName", ")", "{", "List", "<", "String", ">", "tagValues", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "List", "<", "Element", ">", "elements", "=", "getElements", "(", "tagName", ",", "element", ")", ";", "for", "(", "Element", "resultElement", ":", "elements", ")", "{", "tagValues", ".", "add", "(", "getTagValue", "(", "resultElement", ",", "tagName", ")", ")", ";", "}", "return", "tagValues", ";", "}", "public", "static", "List", "<", "String", ">", "getTagValues", "(", "Document", "document", ",", "String", "tagName", ")", "{", "Element", "element", "=", "document", ".", "getDocumentElement", "(", ")", ";", "return", "getTagValues", "(", "element", ",", "tagName", ")", ";", "}", "public", "static", "Document", "getDocument", "(", "Element", "element", ")", "{", "Document", "doc", "=", "new", "DocumentImpl", "(", ")", ";", "Node", "node", "=", "(", "(", "DocumentImpl", ")", "doc", ")", ".", "importNode", "(", "element", ",", "true", ")", ";", "doc", ".", "appendChild", "(", "node", ")", ";", "return", "doc", ";", "}", "public", "static", "String", "getNodeValue", "(", "String", "key", ",", "Document", "doc", ")", "{", "return", "getNodeValue", "(", "key", ",", "doc", ".", "getDocumentElement", "(", ")", ")", ";", "}", "public", "static", "String", "getNodeValue", "(", "String", "key", ",", "Element", "contentElement", ")", "{", "String", "value", "=", "\"\"", ";", "StringTokenizer", "tokenizer", "=", "new", "StringTokenizer", "(", "key", ",", "\".\"", ",", "false", ")", ";", "NodeList", "nodes", "=", "null", ";", "while", "(", "tokenizer", ".", "hasMoreTokens", "(", ")", ")", "{", "String", "tagName", "=", "tokenizer", ".", "nextToken", "(", ")", ";", "nodes", "=", "contentElement", ".", "getElementsByTagName", "(", "tagName", ")", ";", "contentElement", "=", "locateElement", "(", "nodes", ")", ";", "if", "(", "contentElement", "==", "null", ")", "return", "null", ";", "}", "value", "=", "getTagValue", "(", "contentElement", ")", ";", "return", "value", ";", "}", "public", "static", "String", "getTagValue", "(", "Node", "node", ")", "{", "NodeList", "childNodeList", "=", "node", ".", "getChildNodes", "(", ")", ";", "String", "value", "=", "null", ";", "if", "(", "childNodeList", "==", "null", ")", "value", "=", "\"\"", ";", "else", "{", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "childNodeList", ".", "getLength", "(", ")", ";", "j", "++", ")", "{", "buffer", ".", "append", "(", "childNodeList", ".", "item", "(", "j", ")", ".", "getNodeValue", "(", ")", ")", ";", "}", "value", "=", "buffer", ".", "toString", "(", ")", ";", "}", "return", "value", ";", "}", "private", "static", "Element", "locateElement", "(", "NodeList", "nodes", ")", "{", "if", "(", "nodes", "==", "null", ")", "return", "null", ";", "int", "len", "=", "nodes", ".", "getLength", "(", ")", ";", "if", "(", "len", "==", "0", ")", "return", "null", ";", "Element", "elt", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "Node", "n", "=", "nodes", ".", "item", "(", "i", ")", ";", "if", "(", "n", ".", "getNodeType", "(", ")", "==", "Node", ".", "ELEMENT_NODE", ")", "{", "elt", "=", "(", "Element", ")", "n", ";", "}", "else", "{", "continue", ";", "}", "}", "return", "elt", ";", "}", "public", "static", "String", "getTagValueOfFirstChild", "(", "Node", "node", ")", "{", "NodeList", "childNodeList", "=", "node", ".", "getChildNodes", "(", ")", ";", "String", "value", ";", "if", "(", "childNodeList", "==", "null", ")", "{", "value", "=", "\"\"", ";", "}", "else", "{", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "childNodeList", ".", "getLength", "(", ")", ";", "j", "++", ")", "{", "buffer", ".", "append", "(", "childNodeList", ".", "item", "(", "j", ")", ".", "getNodeValue", "(", ")", ")", ";", "}", "value", "=", "buffer", ".", "toString", "(", ")", ";", "}", "return", "value", ";", "}", "public", "static", "void", "deleteTag", "(", "Document", "doc", ",", "String", "tagName", ")", "{", "NodeList", "nodeList", "=", "doc", ".", "getElementsByTagName", "(", "tagName", ")", ";", "int", "j", "=", "nodeList", ".", "getLength", "(", ")", ";", "Node", "node", ";", "Node", "parentNode", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "j", ";", "i", "++", ")", "{", "node", "=", "nodeList", ".", "item", "(", "i", ")", ";", "parentNode", "=", "node", ".", "getParentNode", "(", ")", ";", "parentNode", ".", "removeChild", "(", "node", ")", ";", "}", "}", "public", "static", "List", "<", "Element", ">", "getElements", "(", "String", "tagName", ",", "Element", "input", ")", "{", "NodeList", "nodes", "=", "input", ".", "getElementsByTagName", "(", "tagName", ")", ";", "int", "len", "=", "nodes", ".", "getLength", "(", ")", ";", "List", "<", "Element", ">", "elt", "=", "new", "ArrayList", "<", "Element", ">", "(", "len", ")", ";", "Node", "node", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "{", "node", "=", "nodes", ".", "item", "(", "i", ")", ";", "if", "(", "node", ".", "getNodeType", "(", ")", "==", "Node", ".", "ELEMENT_NODE", ")", "{", "elt", ".", "add", "(", "(", "Element", ")", "node", ")", ";", "}", "}", "return", "elt", ";", "}", "public", "static", "boolean", "checkTagExists", "(", "Document", "doc", ",", "String", "tagname", ")", "{", "boolean", "retVal", "=", "true", ";", "NodeList", "nodes", "=", "doc", ".", "getElementsByTagName", "(", "tagname", ")", ";", "if", "(", "(", "nodes", "==", "null", ")", "||", "(", "nodes", ".", "getLength", "(", ")", "==", "0", ")", ")", "{", "retVal", "=", "false", ";", "}", "return", "retVal", ";", "}", "public", "static", "void", "insertCDATASection", "(", "Document", "doc", ",", "String", "tagName", ",", "String", "tagValue", ")", "{", "NodeList", "nodeList", "=", "doc", ".", "getElementsByTagName", "(", "tagName", ")", ";", "if", "(", "nodeList", "==", "null", ")", "return", ";", "int", "j", "=", "nodeList", ".", "getLength", "(", ")", ";", "Node", "node", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "j", ";", "i", "++", ")", "{", "node", "=", "nodeList", ".", "item", "(", "i", ")", ";", "node", ".", "appendChild", "(", "doc", ".", "createCDATASection", "(", "tagValue", ")", ")", ";", "}", "}", "}", "</s>" ]
969
[ "<s>", "package", "com", ".", "svashishtha", ".", "dom", ";", "import", "java", ".", "io", ".", "StringWriter", ";", "import", "javax", ".", "xml", ".", "transform", ".", "Transformer", ";", "import", "javax", ".", "xml", ".", "transform", ".", "TransformerFactory", ";", "import", "javax", ".", "xml", ".", "transform", ".", "dom", ".", "DOMSource", ";", "import", "javax", ".", "xml", ".", "transform", ".", "stream", ".", "StreamResult", ";", "import", "org", ".", "w3c", ".", "dom", ".", "Document", ";", "public", "class", "DomToString", "{", "private", "DomToString", "(", ")", "{", "}", "public", "static", "String", "getStringFromDocument", "(", "Document", "doc", ")", "{", "DOMSource", "domSource", "=", "new", "DOMSource", "(", "doc", ")", ";", "StringWriter", "writer", "=", "new", "StringWriter", "(", ")", ";", "StreamResult", "result", "=", "new", "StreamResult", "(", "writer", ")", ";", "TransformerFactory", "tf", "=", "TransformerFactory", ".", "newInstance", "(", ")", ";", "Transformer", "transformer", ";", "try", "{", "transformer", "=", "tf", ".", "newTransformer", "(", ")", ";", "transformer", ".", "transform", "(", "domSource", ",", "result", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "return", "writer", ".", "toString", "(", ")", ";", "}", "}", "</s>" ]
970
[ "<s>", "package", "com", ".", "svashishtha", ".", "dom", ";", "import", "java", ".", "util", ".", "Map", ";", "import", "javax", ".", "xml", ".", "parsers", ".", "DocumentBuilderFactory", ";", "import", "javax", ".", "xml", ".", "parsers", ".", "ParserConfigurationException", ";", "import", "javax", ".", "xml", ".", "transform", ".", "TransformerException", ";", "import", "org", ".", "w3c", ".", "dom", ".", "Document", ";", "import", "org", ".", "w3c", ".", "dom", ".", "Element", ";", "public", "class", "MapToDom", "{", "private", "static", "final", "DocumentBuilderFactory", "DOCUMENT_BUILDER_FACTORY", "=", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ";", "private", "MapToDom", "(", ")", "{", "}", "public", "static", "<", "K", ",", "V", ">", "String", "mapToXml", "(", "Map", "<", "K", ",", "V", ">", "map", ",", "String", "rootName", ",", "String", "childName", ",", "String", "keyName", ",", "String", "valueName", ")", "throws", "TransformerException", ",", "ParserConfigurationException", "{", "Document", "document", "=", "DOCUMENT_BUILDER_FACTORY", ".", "newDocumentBuilder", "(", ")", ".", "newDocument", "(", ")", ";", "Element", "root", "=", "document", ".", "createElement", "(", "rootName", ")", ";", "document", ".", "appendChild", "(", "root", ")", ";", "for", "(", "Map", ".", "Entry", "<", "K", ",", "V", ">", "errorCodeReport", ":", "map", ".", "entrySet", "(", ")", ")", "{", "Element", "s", "=", "document", ".", "createElement", "(", "childName", ")", ";", "root", ".", "appendChild", "(", "s", ")", ";", "s", ".", "setAttribute", "(", "keyName", ",", "errorCodeReport", ".", "getKey", "(", ")", ".", "toString", "(", ")", ")", ";", "s", ".", "setAttribute", "(", "valueName", ",", "errorCodeReport", ".", "getValue", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "return", "DomToString", ".", "getStringFromDocument", "(", "document", ")", ";", "}", "}", "</s>" ]
971
[ "<s>", "package", "com", ".", "svashishtha", ".", "dom", ".", "io", ";", "import", "java", ".", "io", ".", "File", ";", "import", "javax", ".", "xml", ".", "transform", ".", "OutputKeys", ";", "import", "javax", ".", "xml", ".", "transform", ".", "Result", ";", "import", "javax", ".", "xml", ".", "transform", ".", "Source", ";", "import", "javax", ".", "xml", ".", "transform", ".", "Transformer", ";", "import", "javax", ".", "xml", ".", "transform", ".", "TransformerConfigurationException", ";", "import", "javax", ".", "xml", ".", "transform", ".", "TransformerException", ";", "import", "javax", ".", "xml", ".", "transform", ".", "TransformerFactory", ";", "import", "javax", ".", "xml", ".", "transform", ".", "TransformerFactoryConfigurationError", ";", "import", "javax", ".", "xml", ".", "transform", ".", "dom", ".", "DOMSource", ";", "import", "javax", ".", "xml", ".", "transform", ".", "stream", ".", "StreamResult", ";", "import", "org", ".", "w3c", ".", "dom", ".", "Document", ";", "public", "class", "PrettyPrinter", "{", "private", "PrettyPrinter", "(", ")", "{", "}", "public", "static", "void", "printToConsole", "(", "Document", "document", ")", "{", "TransformerFactory", "tfactory", "=", "TransformerFactory", ".", "newInstance", "(", ")", ";", "Transformer", "serializer", ";", "try", "{", "serializer", "=", "tfactory", ".", "newTransformer", "(", ")", ";", "serializer", ".", "setOutputProperty", "(", "OutputKeys", ".", "INDENT", ",", "\"yes\"", ")", ";", "serializer", ".", "setOutputProperty", "(", "\"\"", ",", "\"2\"", ")", ";", "serializer", ".", "transform", "(", "new", "DOMSource", "(", "document", ")", ",", "new", "StreamResult", "(", "System", ".", "out", ")", ")", ";", "}", "catch", "(", "TransformerException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}", "public", "static", "void", "printToFile", "(", "Document", "document", ",", "File", "directoryToWriteTo", ",", "String", "fileName", ")", "{", "Source", "source", "=", "new", "DOMSource", "(", "document", ")", ";", "File", "file", "=", "new", "File", "(", "directoryToWriteTo", ",", "fileName", ")", ";", "Result", "result", "=", "new", "StreamResult", "(", "file", ")", ";", "try", "{", "Transformer", "transformer", "=", "TransformerFactory", ".", "newInstance", "(", ")", ".", "newTransformer", "(", ")", ";", "transformer", ".", "setOutputProperty", "(", "OutputKeys", ".", "INDENT", ",", "\"yes\"", ")", ";", "transformer", ".", "setOutputProperty", "(", "\"\"", ",", "\"2\"", ")", ";", "transformer", ".", "transform", "(", "source", ",", "result", ")", ";", "}", "catch", "(", "TransformerConfigurationException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "catch", "(", "TransformerFactoryConfigurationError", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "catch", "(", "TransformerException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}", "}", "</s>" ]
972
[ "<s>", "package", "com", ".", "svashishtha", ".", "dom", ";", "import", "java", ".", "io", ".", "ByteArrayInputStream", ";", "import", "java", ".", "io", ".", "File", ";", "import", "java", ".", "io", ".", "FileInputStream", ";", "import", "java", ".", "io", ".", "FileNotFoundException", ";", "import", "java", ".", "io", ".", "IOException", ";", "import", "java", ".", "io", ".", "InputStream", ";", "import", "java", ".", "io", ".", "StringReader", ";", "import", "javax", ".", "xml", ".", "parsers", ".", "DocumentBuilder", ";", "import", "javax", ".", "xml", ".", "parsers", ".", "DocumentBuilderFactory", ";", "import", "javax", ".", "xml", ".", "parsers", ".", "ParserConfigurationException", ";", "import", "org", ".", "apache", ".", "commons", ".", "io", ".", "IOUtils", ";", "import", "org", ".", "apache", ".", "xerces", ".", "parsers", ".", "DOMParser", ";", "import", "org", ".", "w3c", ".", "dom", ".", "Document", ";", "import", "org", ".", "xml", ".", "sax", ".", "InputSource", ";", "import", "org", ".", "xml", ".", "sax", ".", "SAXException", ";", "public", "class", "DomParser", "{", "private", "DomParser", "(", ")", "{", "}", "public", "static", "Document", "getDocument", "(", "File", "xmlFile", ")", "{", "DocumentBuilderFactory", "dbfac", "=", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ";", "try", "{", "DocumentBuilder", "docBuilder", "=", "dbfac", ".", "newDocumentBuilder", "(", ")", ";", "return", "docBuilder", ".", "parse", "(", "xmlFile", ")", ";", "}", "catch", "(", "ParserConfigurationException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "catch", "(", "SAXException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}", "public", "static", "Document", "getDocument", "(", "String", "xmlString", ")", "{", "DocumentBuilderFactory", "factory", "=", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ";", "try", "{", "DocumentBuilder", "builder", "=", "factory", ".", "newDocumentBuilder", "(", ")", ";", "InputSource", "is", "=", "new", "InputSource", "(", "new", "StringReader", "(", "xmlString", ")", ")", ";", "return", "builder", ".", "parse", "(", "is", ")", ";", "}", "catch", "(", "ParserConfigurationException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "catch", "(", "SAXException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}", "public", "static", "Document", "parse", "(", "InputStream", "in", ")", "{", "Document", "document", "=", "null", ";", "if", "(", "in", "==", "null", ")", "return", "null", ";", "DOMParser", "parser", "=", "new", "DOMParser", "(", ")", ";", "try", "{", "parser", ".", "parse", "(", "new", "InputSource", "(", "in", ")", ")", ";", "}", "catch", "(", "SAXException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "document", "=", "parser", ".", "getDocument", "(", ")", ";", "return", "document", ";", "}", "public", "static", "Document", "parseXmlWithRelativeFilePath", "(", "String", "relativeXmlPath", ")", "{", "InputStream", "stream", "=", "DomParser", ".", "class", ".", "getClassLoader", "(", ")", ".", "getResourceAsStream", "(", "relativeXmlPath", ")", ";", "try", "{", "return", "parse", "(", "stream", ")", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "stream", ")", ";", "}", "}", "public", "static", "Document", "parseXmlWithAbsFilePath", "(", "String", "absoluteFilePath", ")", "{", "InputStream", "stream", "=", "null", ";", "try", "{", "stream", "=", "new", "FileInputStream", "(", "absoluteFilePath", ")", ";", "return", "parse", "(", "stream", ")", ";", "}", "catch", "(", "FileNotFoundException", "fnfEx", ")", "{", "throw", "new", "IllegalArgumentException", "(", "fnfEx", ")", ";", "}", "finally", "{", "if", "(", "stream", "!=", "null", ")", "{", "IOUtils", ".", "closeQuietly", "(", "stream", ")", ";", "}", "}", "}", "public", "static", "Document", "parseXmlString", "(", "String", "xmlString", ")", "{", "InputStream", "stream", "=", "new", "ByteArrayInputStream", "(", "xmlString", ".", "getBytes", "(", ")", ")", ";", "try", "{", "return", "parse", "(", "stream", ")", ";", "}", "finally", "{", "IOUtils", ".", "closeQuietly", "(", "stream", ")", ";", "}", "}", "}", "</s>" ]
973
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "calendar", ";", "import", "java", ".", "awt", ".", "event", ".", "ActionEvent", ";", "import", "java", ".", "awt", ".", "event", ".", "ActionListener", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "public", "class", "YearComboBoxTest", "extends", "TestCase", "{", "private", "final", "Date", "february2002", "=", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2002-02-01\"", ")", ";", "public", "void", "testUserSelect", "(", ")", "{", "YearComboBox", "yearcombobox", "=", "new", "YearComboBox", "(", ")", ";", "CalendarModel", "calendarModel", "=", "new", "CalendarModel", "(", "Locale", ".", "FRENCH", ",", "february2002", ")", ";", "yearcombobox", ".", "setCalendarModel", "(", "calendarModel", ")", ";", "yearcombobox", ".", "setSelectedItem", "(", "\"2004\"", ")", ";", "assertEquals", "(", "500", ",", "yearcombobox", ".", "getModel", "(", ")", ".", "getSize", "(", ")", ")", ";", "assertEquals", "(", "7", ",", "yearcombobox", ".", "getSelectedIndex", "(", ")", ")", ";", "assertEquals", "(", "\"1997\"", ",", "yearcombobox", ".", "getItemAt", "(", "0", ")", ")", ";", "assertEquals", "(", "\"1998\"", ",", "yearcombobox", ".", "getItemAt", "(", "1", ")", ")", ";", "assertEquals", "(", "\"1999\"", ",", "yearcombobox", ".", "getItemAt", "(", "2", ")", ")", ";", "assertEquals", "(", "\"2000\"", ",", "yearcombobox", ".", "getItemAt", "(", "3", ")", ")", ";", "assertEquals", "(", "\"2001\"", ",", "yearcombobox", ".", "getItemAt", "(", "4", ")", ")", ";", "assertEquals", "(", "\"2002\"", ",", "yearcombobox", ".", "getItemAt", "(", "5", ")", ")", ";", "assertEquals", "(", "\"2003\"", ",", "yearcombobox", ".", "getItemAt", "(", "6", ")", ")", ";", "assertEquals", "(", "\"2004\"", ",", "yearcombobox", ".", "getItemAt", "(", "7", ")", ")", ";", "assertEquals", "(", "\"2005\"", ",", "yearcombobox", ".", "getItemAt", "(", "8", ")", ")", ";", "assertEquals", "(", "\"2006\"", ",", "yearcombobox", ".", "getItemAt", "(", "9", ")", ")", ";", "}", "public", "void", "test_setByUser", "(", ")", "{", "YearComboBox", "yearcombobox", "=", "new", "YearComboBox", "(", ")", ";", "CalendarModel", "calendarModel", "=", "new", "CalendarModel", "(", "Locale", ".", "FRENCH", ",", "february2002", ")", ";", "yearcombobox", ".", "setCalendarModel", "(", "calendarModel", ")", ";", "yearcombobox", ".", "setSelectedItem", "(", "\"1999\"", ")", ";", "assertEquals", "(", "500", ",", "yearcombobox", ".", "getModel", "(", ")", ".", "getSize", "(", ")", ")", ";", "assertEquals", "(", "2", ",", "yearcombobox", ".", "getSelectedIndex", "(", ")", ")", ";", "assertEquals", "(", "\"1999\"", ",", "yearcombobox", ".", "getItemAt", "(", "2", ")", ")", ";", "}", "public", "void", "test_setByUser_nullValue", "(", ")", "{", "final", "YearComboBox", "yearcombobox", "=", "new", "YearComboBox", "(", ")", ";", "final", "CalendarModel", "calendarModel", "=", "new", "CalendarModel", "(", "Locale", ".", "FRENCH", ",", "february2002", ")", ";", "yearcombobox", ".", "setCalendarModel", "(", "calendarModel", ")", ";", "yearcombobox", ".", "setUserListener", "(", "new", "ActionListener", "(", ")", "{", "public", "void", "actionPerformed", "(", "ActionEvent", "event", ")", "{", "try", "{", "calendarModel", ".", "setYear", "(", "Integer", ".", "parseInt", "(", "(", "String", ")", "yearcombobox", ".", "getSelectedItem", "(", ")", ")", ")", ";", "}", "catch", "(", "NumberFormatException", "ex", ")", "{", "calendarModel", ".", "setYear", "(", "calendarModel", ".", "getYear", "(", ")", ")", ";", "}", "}", "}", ")", ";", "yearcombobox", ".", "setSelectedItem", "(", "\"\"", ")", ";", "assertEquals", "(", "500", ",", "yearcombobox", ".", "getModel", "(", ")", ".", "getSize", "(", ")", ")", ";", "assertEquals", "(", "5", ",", "yearcombobox", ".", "getSelectedIndex", "(", ")", ")", ";", "assertEquals", "(", "\"2002\"", ",", "yearcombobox", ".", "getItemAt", "(", "5", ")", ")", ";", "}", "public", "void", "test_setCalendarModel", "(", ")", "{", "YearComboBox", "yearcombobox", "=", "new", "YearComboBox", "(", ")", ";", "CalendarModel", "calendarModel", "=", "new", "CalendarModel", "(", "Locale", ".", "FRENCH", ",", "february2002", ")", ";", "yearcombobox", ".", "setCalendarModel", "(", "calendarModel", ")", ";", "assertEquals", "(", "500", ",", "yearcombobox", ".", "getModel", "(", ")", ".", "getSize", "(", ")", ")", ";", "assertEquals", "(", "5", ",", "yearcombobox", ".", "getSelectedIndex", "(", ")", ")", ";", "assertEquals", "(", "\"2000\"", ",", "yearcombobox", ".", "getItemAt", "(", "3", ")", ")", ";", "assertEquals", "(", "\"2001\"", ",", "yearcombobox", ".", "getItemAt", "(", "4", ")", ")", ";", "assertEquals", "(", "\"2002\"", ",", "yearcombobox", ".", "getItemAt", "(", "5", ")", ")", ";", "assertEquals", "(", "\"2003\"", ",", "yearcombobox", ".", "getItemAt", "(", "6", ")", ")", ";", "assertEquals", "(", "\"2004\"", ",", "yearcombobox", ".", "getItemAt", "(", "7", ")", ")", ";", "}", "protected", "void", "setUp", "(", ")", "{", "}", "protected", "void", "tearDown", "(", ")", "{", "}", "}", "</s>" ]
974
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "calendar", ";", "import", "net", ".", "codjo", ".", "test", ".", "common", ".", "LogString", ";", "class", "DateSelectionListenerMock", "implements", "DateSelectionListener", "{", "private", "LogString", "logString", ";", "DateSelectionListenerMock", "(", "LogString", "logString", ")", "{", "this", ".", "logString", "=", "logString", ";", "}", "public", "void", "selectionChanged", "(", ")", "{", "logString", ".", "call", "(", "\"\"", ")", ";", "}", "}", "</s>" ]
975
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "calendar", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "public", "class", "DateHandlerTest", "extends", "TestCase", "{", "public", "void", "test_message", "(", ")", "throws", "Exception", "{", "DateHandler", "root", "=", "newHandlerFalse", "(", ")", ";", "root", ".", "setSuccessor", "(", "newHandlerTrue", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "root", ".", "message", "(", "new", "Date", "(", ")", ")", ")", ";", "}", "public", "void", "test_isWeekEnd", "(", ")", "throws", "Exception", "{", "DateHandler", "handler", "=", "newHandlerTrue", "(", ")", ";", "assertTrue", "(", "\"samedi\"", ",", "handler", ".", "isWeekEnd", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2004-03-06\"", ")", ")", ")", ";", "assertTrue", "(", "\"dimanche\"", ",", "handler", ".", "isWeekEnd", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2004-03-07\"", ")", ")", ")", ";", "assertFalse", "(", "\"vendredi\"", ",", "handler", ".", "isWeekEnd", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2004-03-05\"", ")", ")", ")", ";", "}", "public", "void", "test_isSameDate", "(", ")", "throws", "Exception", "{", "DateHandler", "handler", "=", "newHandlerTrue", "(", ")", ";", "final", "java", ".", "sql", ".", "Date", "differentDate", "=", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2004-03-05\"", ")", ";", "final", "java", ".", "sql", ".", "Date", "dateNoTime", "=", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2004-03-06\"", ")", ";", "Date", "dateWithTime", "=", "java", ".", "sql", ".", "Timestamp", ".", "valueOf", "(", "\"\"", ")", ";", "assertTrue", "(", "\"identique\"", ",", "handler", ".", "isSameDate", "(", "dateNoTime", ",", "dateNoTime", ")", ")", ";", "assertTrue", "(", "\"heure", "dif\"", ",", "handler", ".", "isSameDate", "(", "dateNoTime", ",", "dateWithTime", ")", ")", ";", "assertTrue", "(", "\"heure", "dif\"", ",", "handler", ".", "isSameDate", "(", "dateWithTime", ",", "dateNoTime", ")", ")", ";", "assertFalse", "(", "\"\"", ",", "handler", ".", "isSameDate", "(", "dateNoTime", ",", "differentDate", ")", ")", ";", "}", "private", "DateHandler", "newHandlerTrue", "(", ")", "{", "return", "new", "DateHandler", "(", ")", "{", "protected", "boolean", "handle", "(", "Date", "input", ")", "{", "return", "true", ";", "}", "protected", "String", "handleMessage", "(", "Date", "input", ")", "{", "return", "\"\"", ";", "}", "}", ";", "}", "private", "DateHandler", "newHandlerFalse", "(", ")", "{", "return", "new", "DateHandler", "(", ")", "{", "protected", "boolean", "handle", "(", "Date", "input", ")", "{", "return", "false", ";", "}", "protected", "String", "handleMessage", "(", "Date", "input", ")", "{", "return", "\"\"", ";", "}", "}", ";", "}", "}", "</s>" ]
976
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "calendar", ";", "import", "java", ".", "awt", ".", "Color", ";", "import", "java", ".", "awt", ".", "event", ".", "WindowAdapter", ";", "import", "java", ".", "awt", ".", "event", ".", "WindowEvent", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "javax", ".", "swing", ".", "JFrame", ";", "import", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "util", ".", "GuiUtil", ";", "import", "net", ".", "codjo", ".", "test", ".", "common", ".", "LogString", ";", "import", "org", ".", "uispec4j", ".", "UISpecTestCase", ";", "public", "class", "JCalendarYearTest", "extends", "UISpecTestCase", "{", "private", "static", "final", "Color", "BLACK", "=", "GuiUtil", ".", "DEFAULT_BLACK_COLOR", ";", "private", "static", "final", "Color", "HOLIDAY_COLOR", "=", "JCalendarYear", ".", "HOLIDAY_FOREGROUND", ";", "public", "void", "test_nominal", "(", ")", "throws", "Exception", "{", "JCalendarYear", "calendarYear", "=", "new", "JCalendarYear", "(", ")", ";", "org", ".", "uispec4j", ".", "Panel", "gui", "=", "new", "org", ".", "uispec4j", ".", "Panel", "(", "calendarYear", ")", ";", "calendarYear", ".", "setYear", "(", "\"2012\"", ")", ";", "calendarYear", ".", "setLocale", "(", "Locale", ".", "ENGLISH", ")", ";", "assertTrue", "(", "gui", ".", "getTextBox", "(", "\"MonthLabel_0\"", ")", ".", "textEquals", "(", "\"January", "2012\"", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTextBox", "(", "\"MonthLabel_1\"", ")", ".", "textEquals", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTextBox", "(", "\"MonthLabel_2\"", ")", ".", "textEquals", "(", "\"March", "2012\"", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTextBox", "(", "\"MonthLabel_3\"", ")", ".", "textEquals", "(", "\"April", "2012\"", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTextBox", "(", "\"MonthLabel_4\"", ")", ".", "textEquals", "(", "\"May", "2012\"", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTextBox", "(", "\"MonthLabel_5\"", ")", ".", "textEquals", "(", "\"June", "2012\"", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTextBox", "(", "\"MonthLabel_6\"", ")", ".", "textEquals", "(", "\"July", "2012\"", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTextBox", "(", "\"MonthLabel_7\"", ")", ".", "textEquals", "(", "\"August", "2012\"", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTextBox", "(", "\"MonthLabel_8\"", ")", ".", "textEquals", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTextBox", "(", "\"MonthLabel_9\"", ")", ".", "textEquals", "(", "\"October", "2012\"", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTextBox", "(", "\"\"", ")", ".", "textEquals", "(", "\"\"", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTextBox", "(", "\"\"", ")", ".", "textEquals", "(", "\"\"", ")", ")", ";", "}", "public", "void", "test_holidays", "(", ")", "throws", "Exception", "{", "JCalendarYear", "calendarYear", "=", "new", "JCalendarYear", "(", ")", ";", "calendarYear", ".", "setYear", "(", "\"2012\"", ")", ";", "calendarYear", ".", "setLocale", "(", "Locale", ".", "FRENCH", ")", ";", "List", "<", "Date", ">", "holidays", "=", "new", "ArrayList", "<", "Date", ">", "(", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-01-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-01-05\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-02-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-03-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-04-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-05-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-06-04\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-07-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-08-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-09-04\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-10-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-11-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-12-04\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-01-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-09-04\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2011-01-03\"", ")", ")", ";", "calendarYear", ".", "setHolidays", "(", "holidays", ")", ";", "org", ".", "uispec4j", ".", "Panel", "gui", "=", "new", "org", ".", "uispec4j", ".", "Panel", "(", "calendarYear", ")", ";", "assertFalse", "(", "gui", ".", "getTable", "(", "\"Calendar_0\"", ")", ".", "isEnabled", "(", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_0\"", ")", ".", "rowEquals", "(", "0", ",", "new", "Object", "[", "]", "{", "\"26\"", ",", "\"27\"", ",", "\"28\"", ",", "\"29\"", ",", "\"30\"", ",", "\"31\"", ",", "\"1\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_0\"", ")", ".", "rowEquals", "(", "1", ",", "new", "Object", "[", "]", "{", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", ",", "\"6\"", ",", "\"7\"", ",", "\"8\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_0\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "lightGray", "}", ",", "{", "HOLIDAY_COLOR", ",", "BLACK", ",", "BLACK", ",", "HOLIDAY_COLOR", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertFalse", "(", "gui", ".", "getTable", "(", "\"Calendar_1\"", ")", ".", "isEnabled", "(", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_1\"", ")", ".", "rowEquals", "(", "0", ",", "new", "Object", "[", "]", "{", "\"30\"", ",", "\"31\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_1\"", ")", ".", "rowEquals", "(", "1", ",", "new", "Object", "[", "]", "{", "\"6\"", ",", "\"7\"", ",", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", ",", "\"12\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_1\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "BLACK", ",", "HOLIDAY_COLOR", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertFalse", "(", "gui", ".", "getTable", "(", "\"Calendar_2\"", ")", ".", "isEnabled", "(", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_2\"", ")", ".", "rowEquals", "(", "0", ",", "new", "Object", "[", "]", "{", "\"27\"", ",", "\"28\"", ",", "\"29\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_2\"", ")", ".", "rowEquals", "(", "1", ",", "new", "Object", "[", "]", "{", "\"5\"", ",", "\"6\"", ",", "\"7\"", ",", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_2\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "BLACK", ",", "HOLIDAY_COLOR", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertFalse", "(", "gui", ".", "getTable", "(", "\"Calendar_3\"", ")", ".", "isEnabled", "(", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_3\"", ")", ".", "rowEquals", "(", "0", ",", "new", "Object", "[", "]", "{", "\"26\"", ",", "\"27\"", ",", "\"28\"", ",", "\"29\"", ",", "\"30\"", ",", "\"31\"", ",", "\"1\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_3\"", ")", ".", "rowEquals", "(", "1", ",", "new", "Object", "[", "]", "{", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", ",", "\"6\"", ",", "\"7\"", ",", "\"8\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_3\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "lightGray", "}", ",", "{", "HOLIDAY_COLOR", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertFalse", "(", "gui", ".", "getTable", "(", "\"Calendar_4\"", ")", ".", "isEnabled", "(", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_4\"", ")", ".", "rowEquals", "(", "0", ",", "new", "Object", "[", "]", "{", "\"30\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", ",", "\"6\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_4\"", ")", ".", "rowEquals", "(", "1", ",", "new", "Object", "[", "]", "{", "\"7\"", ",", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", ",", "\"12\"", ",", "\"13\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_4\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "BLACK", ",", "HOLIDAY_COLOR", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertFalse", "(", "gui", ".", "getTable", "(", "\"Calendar_5\"", ")", ".", "isEnabled", "(", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_5\"", ")", ".", "rowEquals", "(", "0", ",", "new", "Object", "[", "]", "{", "\"28\"", ",", "\"29\"", ",", "\"30\"", ",", "\"31\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_5\"", ")", ".", "rowEquals", "(", "1", ",", "new", "Object", "[", "]", "{", "\"4\"", ",", "\"5\"", ",", "\"6\"", ",", "\"7\"", ",", "\"8\"", ",", "\"9\"", ",", "\"10\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_5\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "HOLIDAY_COLOR", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertFalse", "(", "gui", ".", "getTable", "(", "\"Calendar_6\"", ")", ".", "isEnabled", "(", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_6\"", ")", ".", "rowEquals", "(", "0", ",", "new", "Object", "[", "]", "{", "\"25\"", ",", "\"26\"", ",", "\"27\"", ",", "\"28\"", ",", "\"29\"", ",", "\"30\"", ",", "\"1\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_6\"", ")", ".", "rowEquals", "(", "1", ",", "new", "Object", "[", "]", "{", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", ",", "\"6\"", ",", "\"7\"", ",", "\"8\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_6\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "lightGray", "}", ",", "{", "HOLIDAY_COLOR", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertFalse", "(", "gui", ".", "getTable", "(", "\"Calendar_7\"", ")", ".", "isEnabled", "(", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_7\"", ")", ".", "rowEquals", "(", "0", ",", "new", "Object", "[", "]", "{", "\"30\"", ",", "\"31\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_7\"", ")", ".", "rowEquals", "(", "1", ",", "new", "Object", "[", "]", "{", "\"6\"", ",", "\"7\"", ",", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", ",", "\"12\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_7\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "BLACK", ",", "HOLIDAY_COLOR", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertFalse", "(", "gui", ".", "getTable", "(", "\"Calendar_8\"", ")", ".", "isEnabled", "(", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_8\"", ")", ".", "rowEquals", "(", "0", ",", "new", "Object", "[", "]", "{", "\"27\"", ",", "\"28\"", ",", "\"29\"", ",", "\"30\"", ",", "\"31\"", ",", "\"1\"", ",", "\"2\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_8\"", ")", ".", "rowEquals", "(", "1", ",", "new", "Object", "[", "]", "{", "\"3\"", ",", "\"4\"", ",", "\"5\"", ",", "\"6\"", ",", "\"7\"", ",", "\"8\"", ",", "\"9\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_8\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "HOLIDAY_COLOR", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertFalse", "(", "gui", ".", "getTable", "(", "\"Calendar_9\"", ")", ".", "isEnabled", "(", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_9\"", ")", ".", "rowEquals", "(", "0", ",", "new", "Object", "[", "]", "{", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", ",", "\"6\"", ",", "\"7\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_9\"", ")", ".", "rowEquals", "(", "1", ",", "new", "Object", "[", "]", "{", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", ",", "\"12\"", ",", "\"13\"", ",", "\"14\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_9\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "BLACK", ",", "HOLIDAY_COLOR", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertFalse", "(", "gui", ".", "getTable", "(", "\"Calendar_10\"", ")", ".", "isEnabled", "(", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_10\"", ")", ".", "rowEquals", "(", "0", ",", "new", "Object", "[", "]", "{", "\"29\"", ",", "\"30\"", ",", "\"31\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_10\"", ")", ".", "rowEquals", "(", "1", ",", "new", "Object", "[", "]", "{", "\"5\"", ",", "\"6\"", ",", "\"7\"", ",", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_10\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "BLACK", ",", "HOLIDAY_COLOR", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertFalse", "(", "gui", ".", "getTable", "(", "\"Calendar_11\"", ")", ".", "isEnabled", "(", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_11\"", ")", ".", "rowEquals", "(", "0", ",", "new", "Object", "[", "]", "{", "\"26\"", ",", "\"27\"", ",", "\"28\"", ",", "\"29\"", ",", "\"30\"", ",", "\"1\"", ",", "\"2\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_11\"", ")", ".", "rowEquals", "(", "1", ",", "new", "Object", "[", "]", "{", "\"3\"", ",", "\"4\"", ",", "\"5\"", ",", "\"6\"", ",", "\"7\"", ",", "\"8\"", ",", "\"9\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_11\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "HOLIDAY_COLOR", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "}", "public", "void", "test_dateHighlighter", "(", ")", "throws", "Exception", "{", "JCalendarYear", "calendarYear", "=", "new", "JCalendarYear", "(", ")", ";", "calendarYear", ".", "setYear", "(", "\"2012\"", ")", ";", "calendarYear", ".", "setLocale", "(", "Locale", ".", "FRENCH", ")", ";", "final", "List", "<", "Date", ">", "highlightDates", "=", "new", "ArrayList", "<", "Date", ">", "(", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-01-02\"", ")", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-01-05\"", ")", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-02-02\"", ")", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-03-02\"", ")", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-04-02\"", ")", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-05-02\"", ")", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-06-04\"", ")", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-07-02\"", ")", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-08-02\"", ")", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-09-04\"", ")", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-10-02\"", ")", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-11-02\"", ")", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-12-04\"", ")", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-01-02\"", ")", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-09-04\"", ")", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2011-01-03\"", ")", ")", ";", "calendarYear", ".", "setDateHighlighter", "(", "new", "DateHighlighter", "(", ")", "{", "public", "boolean", "highlight", "(", "Date", "date", ")", "{", "return", "highlightDates", ".", "contains", "(", "date", ")", ";", "}", "public", "Color", "getHighlightForeground", "(", ")", "{", "return", "Color", ".", "BLUE", ";", "}", "public", "Color", "getHighlightBackground", "(", ")", "{", "return", "Color", ".", "GREEN", ";", "}", "}", ")", ";", "org", ".", "uispec4j", ".", "Panel", "gui", "=", "new", "org", ".", "uispec4j", ".", "Panel", "(", "calendarYear", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_0\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "lightGray", "}", ",", "{", "Color", ".", "BLUE", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "BLUE", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_1\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "BLACK", ",", "Color", ".", "BLUE", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_2\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "BLACK", ",", "Color", ".", "BLUE", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_3\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "lightGray", "}", ",", "{", "Color", ".", "BLUE", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_4\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "BLACK", ",", "Color", ".", "BLUE", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_5\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "Color", ".", "BLUE", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_6\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "lightGray", "}", ",", "{", "Color", ".", "BLUE", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_7\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "BLACK", ",", "Color", ".", "BLUE", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_8\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "Color", ".", "BLUE", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_9\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "BLACK", ",", "Color", ".", "BLUE", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_10\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "BLACK", ",", "Color", ".", "BLUE", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_11\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "Color", ".", "BLUE", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "}", "public", "void", "test_erroneousDates", "(", ")", "throws", "Exception", "{", "JCalendarYear", "calendarYear", "=", "new", "JCalendarYear", "(", ")", ";", "calendarYear", ".", "setYear", "(", "\"1600\"", ")", ";", "calendarYear", ".", "setLocale", "(", "Locale", ".", "FRENCH", ")", ";", "calendarYear", ".", "setHolidays", "(", "null", ")", ";", "List", "<", "Date", ">", "holidays", "=", "new", "ArrayList", "<", "Date", ">", "(", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-01-02\"", ")", ")", ";", "holidays", ".", "add", "(", "null", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-01-04\"", ")", ")", ";", "try", "{", "calendarYear", ".", "setHolidays", "(", "holidays", ")", ";", "fail", "(", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "assertEquals", "(", "\"\"", ",", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "public", "void", "test_editionMode", "(", ")", "{", "JCalendarYear", "calendarYear", "=", "new", "JCalendarYear", "(", ")", ";", "calendarYear", ".", "setEditionMode", "(", "true", ")", ";", "calendarYear", ".", "setYear", "(", "\"2012\"", ")", ";", "calendarYear", ".", "setLocale", "(", "Locale", ".", "FRENCH", ")", ";", "org", ".", "uispec4j", ".", "Panel", "gui", "=", "new", "org", ".", "uispec4j", ".", "Panel", "(", "calendarYear", ")", ";", "List", "<", "Date", ">", "holidays", "=", "new", "ArrayList", "<", "Date", ">", "(", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-01-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-01-05\"", ")", ")", ";", "calendarYear", ".", "setHolidays", "(", "holidays", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_0\"", ")", ".", "rowEquals", "(", "0", ",", "new", "Object", "[", "]", "{", "\"26\"", ",", "\"27\"", ",", "\"28\"", ",", "\"29\"", ",", "\"30\"", ",", "\"31\"", ",", "\"1\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_0\"", ")", ".", "rowEquals", "(", "1", ",", "new", "Object", "[", "]", "{", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", ",", "\"6\"", ",", "\"7\"", ",", "\"8\"", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_0\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "lightGray", "}", ",", "{", "HOLIDAY_COLOR", ",", "BLACK", ",", "BLACK", ",", "HOLIDAY_COLOR", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_0\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_1\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_2\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_3\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_4\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_5\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_6\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_7\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_8\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_9\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_10\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_11\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_11\"", ")", ".", "click", "(", "3", ",", "3", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_11\"", ")", ".", "click", "(", "4", ",", "2", ")", ";", "assertSelectedDates", "(", "new", "String", "[", "]", "{", "\"2012-01-02\"", ",", "\"2012-01-05\"", ",", "\"2012-01-12\"", ",", "\"2012-02-16\"", ",", "\"2012-03-15\"", ",", "\"2012-04-12\"", ",", "\"2012-05-17\"", ",", "\"2012-06-14\"", ",", "\"2012-07-12\"", ",", "\"2012-08-16\"", ",", "\"2012-09-13\"", ",", "\"2012-10-18\"", ",", "\"2012-11-15\"", ",", "\"2012-12-13\"", ",", "\"2012-12-20\"", ",", "\"2012-12-26\"", "}", ",", "calendarYear", ")", ";", "holidays", ".", "clear", "(", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-02-23\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-03-24\"", ")", ")", ";", "calendarYear", ".", "setHolidays", "(", "holidays", ")", ";", "assertSelectedDates", "(", "new", "String", "[", "]", "{", "\"2012-02-23\"", ",", "\"2012-03-24\"", "}", ",", "calendarYear", ")", ";", "holidays", ".", "clear", "(", ")", ";", "calendarYear", ".", "setHolidays", "(", "holidays", ")", ";", "assertSelectedDates", "(", "new", "String", "[", "0", "]", ",", "calendarYear", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-02-23\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-03-24\"", ")", ")", ";", "calendarYear", ".", "setHolidays", "(", "holidays", ")", ";", "assertSelectedDates", "(", "new", "String", "[", "]", "{", "\"2012-02-23\"", ",", "\"2012-03-24\"", "}", ",", "calendarYear", ")", ";", "holidays", ".", "clear", "(", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-05-10\"", ")", ")", ";", "calendarYear", ".", "setHolidays", "(", "holidays", ")", ";", "assertSelectedDates", "(", "new", "String", "[", "]", "{", "\"2012-05-10\"", "}", ",", "calendarYear", ")", ";", "calendarYear", ".", "setHolidays", "(", "null", ")", ";", "assertSelectedDates", "(", "new", "String", "[", "0", "]", ",", "calendarYear", ")", ";", "}", "public", "void", "test_dateSelectionListener", "(", ")", "{", "LogString", "logString", "=", "new", "LogString", "(", ")", ";", "JCalendarYear", "calendarYear", "=", "new", "JCalendarYear", "(", ")", ";", "calendarYear", ".", "setEditionMode", "(", "true", ")", ";", "calendarYear", ".", "setYear", "(", "\"2012\"", ")", ";", "calendarYear", ".", "setLocale", "(", "Locale", ".", "FRENCH", ")", ";", "calendarYear", ".", "addDateSelectionListener", "(", "new", "DateSelectionListenerMock", "(", "logString", ")", ")", ";", "org", ".", "uispec4j", ".", "Panel", "gui", "=", "new", "org", ".", "uispec4j", ".", "Panel", "(", "calendarYear", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_0\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_1\"", ")", ".", "click", "(", "0", ",", "0", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_1\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_2\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_3\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "logString", ".", "clear", "(", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_4\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_5\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_6\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_7\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "logString", ".", "clear", "(", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_8\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_9\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_10\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_11\"", ")", ".", "click", "(", "2", ",", "3", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "logString", ".", "clear", "(", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_11\"", ")", ".", "click", "(", "3", ",", "3", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "gui", ".", "getTable", "(", "\"Calendar_11\"", ")", ".", "click", "(", "4", ",", "2", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "}", "private", "void", "assertSelectedDates", "(", "String", "[", "]", "expectedDates", ",", "JCalendarYear", "calendarYear", ")", "{", "List", "<", "Date", ">", "dates", "=", "new", "ArrayList", "<", "Date", ">", "(", ")", ";", "for", "(", "String", "date", ":", "expectedDates", ")", "{", "dates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "date", ")", ")", ";", "}", "assertEquals", "(", "dates", ",", "calendarYear", ".", "getSelectedDates", "(", ")", ")", ";", "}", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "JCalendarYear", "calendarYear", "=", "new", "JCalendarYear", "(", ")", ";", "calendarYear", ".", "setYear", "(", "\"2012\"", ")", ";", "calendarYear", ".", "setLocale", "(", "Locale", ".", "FRENCH", ")", ";", "List", "<", "Date", ">", "holidays", "=", "new", "ArrayList", "<", "Date", ">", "(", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-01-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-02-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-03-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-04-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-05-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-06-04\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-07-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-08-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-09-04\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-10-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-11-02\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-12-04\"", ")", ")", ";", "calendarYear", ".", "setHolidays", "(", "holidays", ")", ";", "JFrame", "frame", "=", "new", "JFrame", "(", "\"\"", ")", ";", "frame", ".", "getContentPane", "(", ")", ".", "add", "(", "calendarYear", ")", ";", "frame", ".", "pack", "(", ")", ";", "frame", ".", "setVisible", "(", "true", ")", ";", "frame", ".", "addWindowListener", "(", "new", "WindowAdapter", "(", ")", "{", "public", "void", "windowClosing", "(", "WindowEvent", "evt", ")", "{", "System", ".", "exit", "(", "0", ")", ";", "}", "}", ")", ";", "}", "}", "</s>" ]
977
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "calendar", ";", "import", "java", ".", "awt", ".", "Color", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Calendar", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "java", ".", "util", ".", "List", ";", "import", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "util", ".", "GuiUtil", ";", "import", "net", ".", "codjo", ".", "test", ".", "common", ".", "LogString", ";", "import", "org", ".", "uispec4j", ".", "UISpecTestCase", ";", "public", "class", "JCalendarMonthViewTest", "extends", "UISpecTestCase", "{", "private", "static", "final", "Color", "BLACK", "=", "GuiUtil", ".", "DEFAULT_BLACK_COLOR", ";", "private", "static", "final", "Color", "NOTVALID_COLOR", "=", "DefaultCalendarRenderer", ".", "DEFAULT_NOT_VALID_FOREGROUND", ";", "public", "void", "test_nominal", "(", ")", "throws", "Exception", "{", "JCalendarMonthView", "calendar", "=", "new", "JCalendarMonthView", "(", ")", ";", "calendar", ".", "setMonth", "(", "Calendar", ".", "FEBRUARY", ",", "\"2012\"", ")", ";", "org", ".", "uispec4j", ".", "Panel", "gui", "=", "new", "org", ".", "uispec4j", ".", "Panel", "(", "calendar", ")", ";", "assertTrue", "(", "gui", ".", "getTextBox", "(", "\"MonthLabel_1\"", ")", ".", "textEquals", "(", "\"Fvrier", "2012\"", ")", ")", ";", "assertFalse", "(", "gui", ".", "getComboBox", "(", "\"MonthCombo\"", ")", ".", "isVisible", "(", ")", ")", ";", "assertFalse", "(", "gui", ".", "getComboBox", "(", "\"YearCombo\"", ")", ".", "isVisible", "(", ")", ")", ";", "assertFalse", "(", "gui", ".", "getTextBox", "(", "\"HelpLabel\"", ")", ".", "isVisible", "(", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", ")", ".", "isEnabled", "(", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", ")", ".", "contentEquals", "(", "new", "String", "[", "]", "{", "\"lun.\"", ",", "\"mar.\"", ",", "\"mer.\"", ",", "\"jeu.\"", ",", "\"ven.\"", ",", "\"sam.\"", ",", "\"dim.\"", "}", ",", "new", "String", "[", "]", "[", "]", "{", "{", "\"30\"", ",", "\"31\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", "}", ",", "{", "\"6\"", ",", "\"7\"", ",", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", ",", "\"12\"", "}", ",", "{", "\"13\"", ",", "\"14\"", ",", "\"15\"", ",", "\"16\"", ",", "\"17\"", ",", "\"18\"", ",", "\"19\"", "}", ",", "{", "\"20\"", ",", "\"21\"", ",", "\"22\"", ",", "\"23\"", ",", "\"24\"", ",", "\"25\"", ",", "\"26\"", "}", ",", "{", "\"27\"", ",", "\"28\"", ",", "\"29\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", "}", ",", "{", "\"5\"", ",", "\"6\"", ",", "\"7\"", ",", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", "}", ",", "}", ")", ")", ";", "}", "public", "void", "test_disableSelection", "(", ")", "throws", "Exception", "{", "JCalendarMonthView", "calendar", "=", "new", "JCalendarMonthView", "(", ")", ";", "calendar", ".", "setMonth", "(", "Calendar", ".", "FEBRUARY", ",", "\"2012\"", ")", ";", "calendar", ".", "enableSelection", "(", "false", ")", ";", "org", ".", "uispec4j", ".", "Panel", "gui", "=", "new", "org", ".", "uispec4j", ".", "Panel", "(", "calendar", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", ")", ".", "contentEquals", "(", "new", "String", "[", "]", "{", "\"lun.\"", ",", "\"mar.\"", ",", "\"mer.\"", ",", "\"jeu.\"", ",", "\"ven.\"", ",", "\"sam.\"", ",", "\"dim.\"", "}", ",", "new", "String", "[", "]", "[", "]", "{", "{", "\"30\"", ",", "\"31\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", "}", ",", "{", "\"6\"", ",", "\"7\"", ",", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", ",", "\"12\"", "}", ",", "{", "\"13\"", ",", "\"14\"", ",", "\"15\"", ",", "\"16\"", ",", "\"17\"", ",", "\"18\"", ",", "\"19\"", "}", ",", "{", "\"20\"", ",", "\"21\"", ",", "\"22\"", ",", "\"23\"", ",", "\"24\"", ",", "\"25\"", ",", "\"26\"", "}", ",", "{", "\"27\"", ",", "\"28\"", ",", "\"29\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", "}", ",", "{", "\"5\"", ",", "\"6\"", ",", "\"7\"", ",", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", "}", ",", "}", ")", ")", ";", "assertFalse", "(", "gui", ".", "getTable", "(", ")", ".", "isEnabled", "(", ")", ")", ";", "gui", ".", "getTable", "(", ")", ".", "click", "(", "1", ",", "2", ")", ";", "assertSelectedDates", "(", "new", "String", "[", "0", "]", ",", "calendar", ")", ";", "}", "public", "void", "test_editMonthView", "(", ")", "{", "JCalendarMonthView", "calendar", "=", "new", "JCalendarMonthView", "(", ")", ";", "calendar", ".", "setMonth", "(", "Calendar", ".", "FEBRUARY", ",", "\"2012\"", ")", ";", "org", ".", "uispec4j", ".", "Panel", "gui", "=", "new", "org", ".", "uispec4j", ".", "Panel", "(", "calendar", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", ")", ".", "contentEquals", "(", "new", "String", "[", "]", "{", "\"lun.\"", ",", "\"mar.\"", ",", "\"mer.\"", ",", "\"jeu.\"", ",", "\"ven.\"", ",", "\"sam.\"", ",", "\"dim.\"", "}", ",", "new", "String", "[", "]", "[", "]", "{", "{", "\"30\"", ",", "\"31\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", "}", ",", "{", "\"6\"", ",", "\"7\"", ",", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", ",", "\"12\"", "}", ",", "{", "\"13\"", ",", "\"14\"", ",", "\"15\"", ",", "\"16\"", ",", "\"17\"", ",", "\"18\"", ",", "\"19\"", "}", ",", "{", "\"20\"", ",", "\"21\"", ",", "\"22\"", ",", "\"23\"", ",", "\"24\"", ",", "\"25\"", ",", "\"26\"", "}", ",", "{", "\"27\"", ",", "\"28\"", ",", "\"29\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", "}", ",", "{", "\"5\"", ",", "\"6\"", ",", "\"7\"", ",", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", "}", ",", "}", ")", ")", ";", "List", "<", "Date", ">", "holidays", "=", "new", "ArrayList", "<", "Date", ">", "(", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-02-23\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-02-24\"", ")", ")", ";", "calendar", ".", "setHolidays", "(", "holidays", ")", ";", "assertSelectedDates", "(", "new", "String", "[", "]", "{", "\"2012-02-23\"", ",", "\"2012-02-24\"", "}", ",", "calendar", ")", ";", "gui", ".", "getTable", "(", ")", ".", "click", "(", "0", ",", "0", ")", ";", "assertSelectedDates", "(", "new", "String", "[", "]", "{", "\"2012-02-23\"", ",", "\"2012-02-24\"", "}", ",", "calendar", ")", ";", "gui", ".", "getTable", "(", ")", ".", "click", "(", "1", ",", "2", ")", ";", "assertSelectedDates", "(", "new", "String", "[", "]", "{", "\"2012-02-23\"", ",", "\"2012-02-24\"", ",", "\"2012-02-08\"", "}", ",", "calendar", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_1\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "NOTVALID_COLOR", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "NOTVALID_COLOR", ",", "NOTVALID_COLOR", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "gui", ".", "getTable", "(", ")", ".", "click", "(", "2", ",", "3", ")", ";", "assertSelectedDates", "(", "new", "String", "[", "]", "{", "\"2012-02-23\"", ",", "\"2012-02-24\"", ",", "\"2012-02-08\"", ",", "\"2012-02-16\"", "}", ",", "calendar", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_1\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "NOTVALID_COLOR", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "NOTVALID_COLOR", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "NOTVALID_COLOR", ",", "NOTVALID_COLOR", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "gui", ".", "getTable", "(", ")", ".", "click", "(", "1", ",", "2", ")", ";", "assertSelectedDates", "(", "new", "String", "[", "]", "{", "\"2012-02-23\"", ",", "\"2012-02-24\"", ",", "\"2012-02-16\"", "}", ",", "calendar", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_1\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "NOTVALID_COLOR", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "NOTVALID_COLOR", ",", "NOTVALID_COLOR", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "}", "public", "void", "test_setHolidays", "(", ")", "throws", "Exception", "{", "JCalendarMonthView", "calendar", "=", "new", "JCalendarMonthView", "(", ")", ";", "calendar", ".", "setMonth", "(", "Calendar", ".", "FEBRUARY", ",", "\"2012\"", ")", ";", "org", ".", "uispec4j", ".", "Panel", "gui", "=", "new", "org", ".", "uispec4j", ".", "Panel", "(", "calendar", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", ")", ".", "contentEquals", "(", "new", "String", "[", "]", "{", "\"lun.\"", ",", "\"mar.\"", ",", "\"mer.\"", ",", "\"jeu.\"", ",", "\"ven.\"", ",", "\"sam.\"", ",", "\"dim.\"", "}", ",", "new", "String", "[", "]", "[", "]", "{", "{", "\"30\"", ",", "\"31\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", "}", ",", "{", "\"6\"", ",", "\"7\"", ",", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", ",", "\"12\"", "}", ",", "{", "\"13\"", ",", "\"14\"", ",", "\"15\"", ",", "\"16\"", ",", "\"17\"", ",", "\"18\"", ",", "\"19\"", "}", ",", "{", "\"20\"", ",", "\"21\"", ",", "\"22\"", ",", "\"23\"", ",", "\"24\"", ",", "\"25\"", ",", "\"26\"", "}", ",", "{", "\"27\"", ",", "\"28\"", ",", "\"29\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", "}", ",", "{", "\"5\"", ",", "\"6\"", ",", "\"7\"", ",", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", "}", ",", "}", ")", ")", ";", "List", "<", "Date", ">", "holidays", "=", "new", "ArrayList", "<", "Date", ">", "(", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-02-23\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-02-24\"", ")", ")", ";", "calendar", ".", "setHolidays", "(", "holidays", ")", ";", "assertSelectedDates", "(", "new", "String", "[", "]", "{", "\"2012-02-23\"", ",", "\"2012-02-24\"", "}", ",", "calendar", ")", ";", "holidays", ".", "clear", "(", ")", ";", "calendar", ".", "setHolidays", "(", "holidays", ")", ";", "assertSelectedDates", "(", "new", "String", "[", "0", "]", ",", "calendar", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-02-23\"", ")", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-02-24\"", ")", ")", ";", "calendar", ".", "setHolidays", "(", "holidays", ")", ";", "assertSelectedDates", "(", "new", "String", "[", "]", "{", "\"2012-02-23\"", ",", "\"2012-02-24\"", "}", ",", "calendar", ")", ";", "holidays", ".", "clear", "(", ")", ";", "holidays", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-05-10\"", ")", ")", ";", "calendar", ".", "setHolidays", "(", "holidays", ")", ";", "assertSelectedDates", "(", "new", "String", "[", "]", "{", "\"2012-05-10\"", "}", ",", "calendar", ")", ";", "calendar", ".", "setHolidays", "(", "null", ")", ";", "assertSelectedDates", "(", "new", "String", "[", "0", "]", ",", "calendar", ")", ";", "}", "public", "void", "test_setDateHighlighter", "(", ")", "throws", "Exception", "{", "JCalendarMonthView", "calendar", "=", "new", "JCalendarMonthView", "(", ")", ";", "calendar", ".", "setMonth", "(", "Calendar", ".", "FEBRUARY", ",", "\"2012\"", ")", ";", "org", ".", "uispec4j", ".", "Panel", "gui", "=", "new", "org", ".", "uispec4j", ".", "Panel", "(", "calendar", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", ")", ".", "contentEquals", "(", "new", "String", "[", "]", "{", "\"lun.\"", ",", "\"mar.\"", ",", "\"mer.\"", ",", "\"jeu.\"", ",", "\"ven.\"", ",", "\"sam.\"", ",", "\"dim.\"", "}", ",", "new", "String", "[", "]", "[", "]", "{", "{", "\"30\"", ",", "\"31\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", "}", ",", "{", "\"6\"", ",", "\"7\"", ",", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", ",", "\"12\"", "}", ",", "{", "\"13\"", ",", "\"14\"", ",", "\"15\"", ",", "\"16\"", ",", "\"17\"", ",", "\"18\"", ",", "\"19\"", "}", ",", "{", "\"20\"", ",", "\"21\"", ",", "\"22\"", ",", "\"23\"", ",", "\"24\"", ",", "\"25\"", ",", "\"26\"", "}", ",", "{", "\"27\"", ",", "\"28\"", ",", "\"29\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", "}", ",", "{", "\"5\"", ",", "\"6\"", ",", "\"7\"", ",", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", "}", ",", "}", ")", ")", ";", "final", "List", "<", "Date", ">", "highlightDates", "=", "new", "ArrayList", "<", "Date", ">", "(", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-02-23\"", ")", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-02-24\"", ")", ")", ";", "calendar", ".", "setDateHighlighter", "(", "new", "DateHighlighter", "(", ")", "{", "public", "boolean", "highlight", "(", "Date", "date", ")", "{", "return", "highlightDates", ".", "contains", "(", "date", ")", ";", "}", "public", "Color", "getHighlightForeground", "(", ")", "{", "return", "Color", ".", "BLUE", ";", "}", "public", "Color", "getHighlightBackground", "(", ")", "{", "return", "Color", ".", "GREEN", ";", "}", "}", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_1\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "BLUE", ",", "Color", ".", "BLUE", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_1\"", ")", ".", "backgroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "GREEN", ",", "Color", ".", "GREEN", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "highlightDates", ".", "clear", "(", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-02-16\"", ")", ")", ";", "highlightDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2012-02-17\"", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_1\"", ")", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "BLUE", ",", "Color", ".", "BLUE", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "BLACK", ",", "BLACK", ",", "BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "gui", ".", "getTable", "(", "\"Calendar_1\"", ")", ".", "backgroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "GREEN", ",", "Color", ".", "GREEN", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "}", "public", "void", "test_monthListener", "(", ")", "{", "LogString", "logString", "=", "new", "LogString", "(", ")", ";", "JCalendarMonthView", "calendar", "=", "new", "JCalendarMonthView", "(", ")", ";", "calendar", ".", "setMonth", "(", "Calendar", ".", "FEBRUARY", ",", "\"2012\"", ")", ";", "calendar", ".", "addDateSelectionListener", "(", "new", "DateSelectionListenerMock", "(", "logString", ")", ")", ";", "org", ".", "uispec4j", ".", "Panel", "gui", "=", "new", "org", ".", "uispec4j", ".", "Panel", "(", "calendar", ")", ";", "gui", ".", "getTable", "(", ")", ".", "click", "(", "0", ",", "0", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "gui", ".", "getTable", "(", ")", ".", "click", "(", "1", ",", "0", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "gui", ".", "getTable", "(", ")", ".", "click", "(", "1", ",", "0", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "gui", ".", "getTable", "(", ")", ".", "click", "(", "2", ",", "5", ")", ";", "assertEquals", "(", "\"\"", ",", "logString", ".", "getContent", "(", ")", ")", ";", "}", "private", "void", "assertSelectedDates", "(", "String", "[", "]", "expectedDates", ",", "JCalendarMonthView", "calendar", ")", "{", "List", "<", "Date", ">", "dates", "=", "new", "ArrayList", "<", "Date", ">", "(", ")", ";", "for", "(", "String", "date", ":", "expectedDates", ")", "{", "dates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "date", ")", ")", ";", "}", "assertEquals", "(", "dates", ",", "calendar", ".", "getSelectedDates", "(", ")", ")", ";", "}", "}", "</s>" ]
978
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "calendar", ";", "import", "java", ".", "awt", ".", "Color", ";", "import", "java", ".", "awt", ".", "Font", ";", "import", "java", ".", "awt", ".", "event", ".", "WindowAdapter", ";", "import", "java", ".", "awt", ".", "event", ".", "WindowEvent", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "java", ".", "util", ".", "List", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "javax", ".", "swing", ".", "BorderFactory", ";", "import", "javax", ".", "swing", ".", "JFrame", ";", "import", "javax", ".", "swing", ".", "JLabel", ";", "import", "javax", ".", "swing", ".", "JTable", ";", "import", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "util", ".", "TableUtil", ";", "import", "org", ".", "uispec4j", ".", "Table", ";", "import", "org", ".", "uispec4j", ".", "UISpecTestCase", ";", "public", "class", "DefaultCalendarRendererTest", "extends", "UISpecTestCase", "{", "private", "static", "final", "Color", "DEFAULT_BLACK", "=", "new", "JLabel", "(", ")", ".", "getForeground", "(", ")", ";", "private", "DefaultCalendarRenderer", "renderer", ";", "private", "JTable", "tableOfDates", ";", "public", "void", "test_default", "(", ")", "throws", "Exception", "{", "Table", "theTable", "=", "new", "Table", "(", "tableOfDates", ")", ";", "assertTrue", "(", "theTable", ".", "contentEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", ",", "\"6\"", ",", "\"7\"", "}", ",", "{", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", ",", "\"12\"", ",", "\"13\"", ",", "\"14\"", "}", ",", "{", "\"15\"", ",", "\"16\"", ",", "\"17\"", ",", "\"18\"", ",", "\"19\"", ",", "\"20\"", ",", "\"21\"", "}", ",", "{", "\"22\"", ",", "\"23\"", ",", "\"24\"", ",", "\"25\"", ",", "\"26\"", ",", "\"27\"", ",", "\"28\"", "}", ",", "{", "\"29\"", ",", "\"30\"", ",", "\"31\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "theTable", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "renderer", ".", "setWeekEndColor", "(", "Color", ".", "RED", ")", ";", "assertTrue", "(", "theTable", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "RED", ",", "Color", ".", "RED", "}", ",", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "RED", ",", "Color", ".", "RED", "}", ",", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "RED", ",", "Color", ".", "RED", "}", ",", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "RED", ",", "Color", ".", "RED", "}", ",", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "}", "public", "void", "test_defaultRootHandler", "(", ")", "throws", "Exception", "{", "renderer", "=", "new", "DefaultCalendarRenderer", "(", ")", ";", "assertTrue", "(", "renderer", ".", "getRootDateHandler", "(", ")", ".", "selectable", "(", "new", "Date", "(", ")", ")", ")", ";", "}", "public", "void", "test_setValidDate", "(", ")", "throws", "Exception", "{", "final", "List", "<", "Date", ">", "validDates", "=", "new", "ArrayList", "<", "Date", ">", "(", ")", ";", "validDates", ".", "add", "(", "newDate", "(", "\"2004-03-01\"", ")", ")", ";", "validDates", ".", "add", "(", "newDate", "(", "\"2004-03-02\"", ")", ")", ";", "renderer", ".", "setValidDate", "(", "validDates", ")", ";", "Table", "theTable", "=", "new", "Table", "(", "tableOfDates", ")", ";", "assertTrue", "(", "theTable", ".", "contentEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", ",", "\"6\"", ",", "\"7\"", "}", ",", "{", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", ",", "\"12\"", ",", "\"13\"", ",", "\"14\"", "}", ",", "{", "\"15\"", ",", "\"16\"", ",", "\"17\"", ",", "\"18\"", ",", "\"19\"", ",", "\"20\"", ",", "\"21\"", "}", ",", "{", "\"22\"", ",", "\"23\"", ",", "\"24\"", ",", "\"25\"", ",", "\"26\"", ",", "\"27\"", ",", "\"28\"", "}", ",", "{", "\"29\"", ",", "\"30\"", ",", "\"31\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "theTable", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "renderer", ".", "setNotValidForeground", "(", "Color", ".", "RED", ")", ";", "assertTrue", "(", "theTable", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", "}", ",", "{", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", "}", ",", "{", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", "}", ",", "{", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", "}", ",", "{", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "}", "public", "void", "test_setNoValidDate", "(", ")", "throws", "Exception", "{", "final", "List", "<", "Date", ">", "noValidDates", "=", "new", "ArrayList", "<", "Date", ">", "(", ")", ";", "noValidDates", ".", "add", "(", "newDate", "(", "\"2004-03-01\"", ")", ")", ";", "noValidDates", ".", "add", "(", "newDate", "(", "\"2004-03-02\"", ")", ")", ";", "renderer", ".", "setNoValidDate", "(", "noValidDates", ")", ";", "Table", "theTable", "=", "new", "Table", "(", "tableOfDates", ")", ";", "assertTrue", "(", "theTable", ".", "contentEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", ",", "\"6\"", ",", "\"7\"", "}", ",", "{", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", ",", "\"12\"", ",", "\"13\"", ",", "\"14\"", "}", ",", "{", "\"15\"", ",", "\"16\"", ",", "\"17\"", ",", "\"18\"", ",", "\"19\"", ",", "\"20\"", ",", "\"21\"", "}", ",", "{", "\"22\"", ",", "\"23\"", ",", "\"24\"", ",", "\"25\"", ",", "\"26\"", ",", "\"27\"", ",", "\"28\"", "}", ",", "{", "\"29\"", ",", "\"30\"", ",", "\"31\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "theTable", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "renderer", ".", "setNotValidForeground", "(", "Color", ".", "RED", ")", ";", "assertTrue", "(", "theTable", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "RED", ",", "Color", ".", "RED", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "}", "public", "void", "test_highlightDates", "(", ")", "throws", "Exception", "{", "final", "List", "<", "Date", ">", "validDates", "=", "new", "ArrayList", "<", "Date", ">", "(", ")", ";", "validDates", ".", "add", "(", "newDate", "(", "\"2004-03-01\"", ")", ")", ";", "validDates", ".", "add", "(", "newDate", "(", "\"2004-03-02\"", ")", ")", ";", "renderer", ".", "setValidDate", "(", "validDates", ")", ";", "Table", "theTable", "=", "new", "Table", "(", "tableOfDates", ")", ";", "assertTrue", "(", "theTable", ".", "contentEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", ",", "\"6\"", ",", "\"7\"", "}", ",", "{", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", ",", "\"12\"", ",", "\"13\"", ",", "\"14\"", "}", ",", "{", "\"15\"", ",", "\"16\"", ",", "\"17\"", ",", "\"18\"", ",", "\"19\"", ",", "\"20\"", ",", "\"21\"", "}", ",", "{", "\"22\"", ",", "\"23\"", ",", "\"24\"", ",", "\"25\"", ",", "\"26\"", ",", "\"27\"", ",", "\"28\"", "}", ",", "{", "\"29\"", ",", "\"30\"", ",", "\"31\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "theTable", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "DEFAULT_BLACK", ",", "DEFAULT_BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "theTable", ".", "backgroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "final", "List", "<", "Date", ">", "datesToHighlight", "=", "new", "ArrayList", "<", "Date", ">", "(", ")", ";", "datesToHighlight", ".", "add", "(", "newDate", "(", "\"2004-03-01\"", ")", ")", ";", "datesToHighlight", ".", "add", "(", "newDate", "(", "\"2004-03-06\"", ")", ")", ";", "datesToHighlight", ".", "add", "(", "newDate", "(", "\"2004-03-18\"", ")", ")", ";", "datesToHighlight", ".", "add", "(", "newDate", "(", "\"2004-04-02\"", ")", ")", ";", "renderer", ".", "setDateHighlighter", "(", "new", "DateHighlighter", "(", ")", "{", "public", "boolean", "highlight", "(", "Date", "date", ")", "{", "return", "datesToHighlight", ".", "contains", "(", "date", ")", ";", "}", "public", "Color", "getHighlightForeground", "(", ")", "{", "return", "Color", ".", "BLUE", ";", "}", "public", "Color", "getHighlightBackground", "(", ")", "{", "return", "Color", ".", "GREEN", ";", "}", "}", ")", ";", "assertTrue", "(", "theTable", ".", "foregroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "BLUE", ",", "DEFAULT_BLACK", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "BLUE", ",", "Color", ".", "lightGray", "}", ",", "{", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "BLUE", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", "}", ",", "{", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "lightGray", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "assertTrue", "(", "theTable", ".", "backgroundEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "Color", ".", "GREEN", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "GREEN", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "GREEN", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "{", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", ",", "Color", ".", "WHITE", "}", ",", "}", ")", ")", ";", "}", "public", "void", "test_tooltipOnSpecificDates", "(", ")", "throws", "Exception", "{", "Table", "theTable", "=", "new", "Table", "(", "tableOfDates", ")", ";", "assertTrue", "(", "theTable", ".", "contentEquals", "(", "new", "Object", "[", "]", "[", "]", "{", "{", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", ",", "\"5\"", ",", "\"6\"", ",", "\"7\"", "}", ",", "{", "\"8\"", ",", "\"9\"", ",", "\"10\"", ",", "\"11\"", ",", "\"12\"", ",", "\"13\"", ",", "\"14\"", "}", ",", "{", "\"15\"", ",", "\"16\"", ",", "\"17\"", ",", "\"18\"", ",", "\"19\"", ",", "\"20\"", ",", "\"21\"", "}", ",", "{", "\"22\"", ",", "\"23\"", ",", "\"24\"", ",", "\"25\"", ",", "\"26\"", ",", "\"27\"", ",", "\"28\"", "}", ",", "{", "\"29\"", ",", "\"30\"", ",", "\"31\"", ",", "\"1\"", ",", "\"2\"", ",", "\"3\"", ",", "\"4\"", "}", ",", "}", ")", ")", ";", "assertEquals", "(", "null", ",", "(", "(", "JLabel", ")", "TableUtil", ".", "getRenderedComponentAt", "(", "tableOfDates", ",", "1", ",", "4", ")", ")", ".", "getToolTipText", "(", ")", ")", ";", "assertEquals", "(", "null", ",", "(", "(", "JLabel", ")", "TableUtil", ".", "getRenderedComponentAt", "(", "tableOfDates", ",", "3", ",", "2", ")", ")", ".", "getToolTipText", "(", ")", ")", ";", "assertEquals", "(", "null", ",", "(", "(", "JLabel", ")", "TableUtil", ".", "getRenderedComponentAt", "(", "tableOfDates", ",", "3", ",", "3", ")", ")", ".", "getToolTipText", "(", ")", ")", ";", "renderer", ".", "setTooltipForDate", "(", "newDate", "(", "\"2004-03-12\"", ")", ",", "\"ravioli\"", ")", ";", "renderer", ".", "setTooltipForDate", "(", "newDate", "(", "\"2004-03-24\"", ")", ",", "\"\"", ")", ";", "assertEquals", "(", "\"ravioli\"", ",", "(", "(", "JLabel", ")", "TableUtil", ".", "getRenderedComponentAt", "(", "tableOfDates", ",", "1", ",", "4", ")", ")", ".", "getToolTipText", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "(", "(", "JLabel", ")", "TableUtil", ".", "getRenderedComponentAt", "(", "tableOfDates", ",", "3", ",", "2", ")", ")", ".", "getToolTipText", "(", ")", ")", ";", "assertEquals", "(", "null", ",", "(", "(", "JLabel", ")", "TableUtil", ".", "getRenderedComponentAt", "(", "tableOfDates", ",", "3", ",", "3", ")", ")", ".", "getToolTipText", "(", ")", ")", ";", "renderer", ".", "removeAllTooltips", "(", ")", ";", "assertEquals", "(", "null", ",", "(", "(", "JLabel", ")", "TableUtil", ".", "getRenderedComponentAt", "(", "tableOfDates", ",", "1", ",", "4", ")", ")", ".", "getToolTipText", "(", ")", ")", ";", "assertEquals", "(", "null", ",", "(", "(", "JLabel", ")", "TableUtil", ".", "getRenderedComponentAt", "(", "tableOfDates", ",", "3", ",", "2", ")", ")", ".", "getToolTipText", "(", ")", ")", ";", "assertEquals", "(", "null", ",", "(", "(", "JLabel", ")", "TableUtil", ".", "getRenderedComponentAt", "(", "tableOfDates", ",", "3", ",", "3", ")", ")", ".", "getToolTipText", "(", ")", ")", ";", "}", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "JCalendarMonthView", "jcal", "=", "new", "JCalendarMonthView", "(", ")", ";", "jcal", ".", "setMonth", "(", "0", ",", "\"2012\"", ")", ";", "jcal", ".", "setSelectedDate", "(", "new", "Date", "(", "System", ".", "currentTimeMillis", "(", ")", ")", ")", ";", "final", "DateHandler", "handler", "=", "new", "DateHandler", "(", ")", "{", "public", "boolean", "handle", "(", "java", ".", "util", ".", "Date", "input", ")", "{", "return", "input", ".", "compareTo", "(", "new", "java", ".", "util", ".", "Date", "(", ")", ")", "<", "0", ";", "}", "protected", "JLabel", "handleRenderer", "(", "java", ".", "util", ".", "Date", "input", ",", "JLabel", "renderer", ")", "{", "if", "(", "isWeekEnd", "(", "input", ")", ")", "{", "renderer", ".", "setForeground", "(", "Color", ".", "gray", ")", ";", "final", "Font", "font", "=", "renderer", ".", "getFont", "(", ")", ";", "renderer", ".", "setFont", "(", "font", ".", "deriveFont", "(", "Font", ".", "BOLD", ")", ".", "deriveFont", "(", "Font", ".", "ITALIC", ")", ")", ";", "}", "else", "{", "renderer", ".", "setForeground", "(", "Color", ".", "green", ")", ";", "renderer", ".", "setBackground", "(", "Color", ".", "red", ")", ";", "renderer", ".", "setBorder", "(", "BorderFactory", ".", "createLineBorder", "(", "Color", ".", "green", ")", ")", ";", "}", "return", "renderer", ";", "}", "}", ";", "handler", ".", "setSuccessor", "(", "jcal", ".", "getDateHandler", "(", ")", ")", ";", "jcal", ".", "setDateHandler", "(", "handler", ")", ";", "JFrame", "frame", "=", "new", "JFrame", "(", "\"\"", ")", ";", "frame", ".", "getContentPane", "(", ")", ".", "add", "(", "jcal", ")", ";", "frame", ".", "pack", "(", ")", ";", "frame", ".", "setVisible", "(", "true", ")", ";", "frame", ".", "addWindowListener", "(", "new", "WindowAdapter", "(", ")", "{", "public", "void", "windowClosing", "(", "WindowEvent", "evt", ")", "{", "System", ".", "exit", "(", "0", ")", ";", "}", "}", ")", ";", "}", "@", "Override", "protected", "void", "setUp", "(", ")", "throws", "Exception", "{", "renderer", "=", "new", "DefaultCalendarRenderer", "(", ")", ";", "tableOfDates", "=", "new", "JTable", "(", ")", ";", "tableOfDates", ".", "setDefaultRenderer", "(", "Date", ".", "class", ",", "renderer", ")", ";", "tableOfDates", ".", "setModel", "(", "new", "CalendarModel", "(", "Locale", ".", "FRANCE", ",", "java", ".", "sql", ".", "Timestamp", ".", "valueOf", "(", "\"\"", ")", ")", ")", ";", "}", "private", "static", "Date", "newDate", "(", "String", "dateStr", ")", "{", "return", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "dateStr", ")", ";", "}", "}", "</s>" ]
979
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "calendar", ";", "import", "net", ".", "codjo", ".", "test", ".", "release", ".", "task", ".", "gui", ".", "GuiConfigurationException", ";", "import", "net", ".", "codjo", ".", "test", ".", "release", ".", "task", ".", "gui", ".", "SetCalendarStep", ";", "import", "net", ".", "codjo", ".", "test", ".", "release", ".", "task", ".", "gui", ".", "metainfo", ".", "SetCalendarDescriptor", ";", "import", "java", ".", "awt", ".", "Component", ";", "import", "java", ".", "text", ".", "ParseException", ";", "import", "java", ".", "text", ".", "SimpleDateFormat", ";", "import", "java", ".", "util", ".", "Date", ";", "public", "class", "JCalendarTestBehavior", "implements", "SetCalendarDescriptor", "{", "private", "String", "pattern", "=", "\"yyyy-MM-dd\"", ";", "public", "void", "setCalendar", "(", "Component", "comp", ",", "SetCalendarStep", "step", ")", "{", "if", "(", "comp", "==", "null", "||", "!", "(", "comp", "instanceof", "JCalendar", ")", ")", "{", "throw", "new", "GuiConfigurationException", "(", "\"\"", ")", ";", "}", "try", "{", "(", "(", "JCalendar", ")", "comp", ")", ".", "setSelectedDate", "(", "getDate", "(", "step", ".", "getValue", "(", ")", ")", ")", ";", "}", "catch", "(", "ParseException", "e", ")", "{", "String", "message", "=", "\"\"", "+", "pattern", ";", "throw", "new", "GuiConfigurationException", "(", "message", ",", "e", ")", ";", "}", "}", "private", "Date", "getDate", "(", "String", "value", ")", "throws", "ParseException", "{", "SimpleDateFormat", "dateFormat", "=", "new", "SimpleDateFormat", "(", "pattern", ")", ";", "return", "dateFormat", ".", "parse", "(", "value", ")", ";", "}", "}", "</s>" ]
980
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "calendar", ";", "import", "java", ".", "awt", ".", "event", ".", "ActionEvent", ";", "import", "java", ".", "awt", ".", "event", ".", "ActionListener", ";", "import", "java", ".", "util", ".", "Calendar", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertEquals", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "MonthComboBoxTest", "{", "private", "final", "Date", "february2002", "=", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2002-02-01\"", ")", ";", "@", "Test", "public", "void", "testCalendarModelChange", "(", ")", "{", "MonthComboBox", "monthcombobox", "=", "new", "MonthComboBox", "(", ")", ";", "CalendarModel", "calendarModel1", "=", "new", "CalendarModel", "(", "Locale", ".", "FRENCH", ",", "february2002", ")", ";", "monthcombobox", ".", "setCalendarModel", "(", "calendarModel1", ")", ";", "calendarModel1", ".", "setMonth", "(", "Calendar", ".", "JANUARY", ")", ";", "assertEquals", "(", "Calendar", ".", "JANUARY", ",", "monthcombobox", ".", "getSelectedIndex", "(", ")", ")", ";", "assertEquals", "(", "\"janvier\"", ",", "monthcombobox", ".", "getSelectedItem", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testComboBoxChange", "(", ")", "{", "JCalendar", "cal", "=", "new", "JCalendar", "(", ")", ";", "MonthComboBox", "monthcombobox", "=", "cal", ".", "getMonthComboBox", "(", ")", ";", "monthcombobox", ".", "getCalendarModel", "(", ")", ".", "setDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2008-08-08\"", ")", ")", ";", "monthcombobox", ".", "setSelectedIndex", "(", "Calendar", ".", "JANUARY", ")", ";", "assertEquals", "(", "Calendar", ".", "JANUARY", ",", "monthcombobox", ".", "getSelectedIndex", "(", ")", ")", ";", "assertEquals", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2008-01-01\"", ")", ",", "cal", ".", "getSelectedDate", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "testComboBoxChangeOnJanuary31", "(", ")", "{", "final", "MonthComboBox", "comboBox", "=", "new", "MonthComboBox", "(", ")", ";", "final", "CalendarModel", "model", "=", "new", "CalendarModel", "(", "Locale", ".", "FRENCH", ",", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2005-01-31\"", ")", ")", ";", "comboBox", ".", "setUserListener", "(", "new", "ActionListener", "(", ")", "{", "public", "void", "actionPerformed", "(", "ActionEvent", "event", ")", "{", "model", ".", "setMonth", "(", "comboBox", ".", "getSelectedIndex", "(", ")", ")", ";", "}", "}", ")", ";", "comboBox", ".", "setCalendarModel", "(", "model", ")", ";", "comboBox", ".", "setSelectedIndex", "(", "Calendar", ".", "APRIL", ")", ";", "assertEquals", "(", "Calendar", ".", "APRIL", ",", "comboBox", ".", "getSelectedIndex", "(", ")", ")", ";", "assertEquals", "(", "Calendar", ".", "APRIL", ",", "comboBox", ".", "getCalendarModel", "(", ")", ".", "getMonth", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "test_setCalendarModel_ENGLISH", "(", ")", "{", "MonthComboBox", "monthcombobox", "=", "new", "MonthComboBox", "(", ")", ";", "CalendarModel", "calendarModel1", "=", "new", "CalendarModel", "(", "Locale", ".", "ENGLISH", ",", "february2002", ")", ";", "monthcombobox", ".", "setCalendarModel", "(", "calendarModel1", ")", ";", "assertEquals", "(", "13", ",", "monthcombobox", ".", "getModel", "(", ")", ".", "getSize", "(", ")", ")", ";", "assertEquals", "(", "Calendar", ".", "FEBRUARY", ",", "monthcombobox", ".", "getSelectedIndex", "(", ")", ")", ";", "assertEquals", "(", "\"February\"", ",", "monthcombobox", ".", "getSelectedItem", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "test_setCalendarModel_FRENCH", "(", ")", "{", "MonthComboBox", "monthcombobox", "=", "new", "MonthComboBox", "(", ")", ";", "assertEquals", "(", "0", ",", "monthcombobox", ".", "getModel", "(", ")", ".", "getSize", "(", ")", ")", ";", "CalendarModel", "calendarModel1", "=", "new", "CalendarModel", "(", "Locale", ".", "FRENCH", ",", "february2002", ")", ";", "monthcombobox", ".", "setCalendarModel", "(", "calendarModel1", ")", ";", "assertEquals", "(", "13", ",", "monthcombobox", ".", "getModel", "(", ")", ".", "getSize", "(", ")", ")", ";", "assertEquals", "(", "Calendar", ".", "FEBRUARY", ",", "monthcombobox", ".", "getSelectedIndex", "(", ")", ")", ";", "assertEquals", "(", "\"fvrier\"", ",", "monthcombobox", ".", "getSelectedItem", "(", ")", ")", ";", "}", "}", "</s>" ]
981
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "calendar", ";", "import", "static", "net", ".", "codjo", ".", "test", ".", "common", ".", "matcher", ".", "JUnitMatchers", ".", "*", ";", "import", "net", ".", "codjo", ".", "test", ".", "release", ".", "task", ".", "gui", ".", "GuiConfigurationException", ";", "import", "net", ".", "codjo", ".", "test", ".", "release", ".", "task", ".", "gui", ".", "SetCalendarStep", ";", "import", "java", ".", "text", ".", "SimpleDateFormat", ";", "import", "javax", ".", "swing", ".", "JTextField", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "JCalendarTestBehaviorTest", "{", "@", "Test", "(", "expected", "=", "GuiConfigurationException", ".", "class", ")", "public", "void", "test_badArgument", "(", ")", "throws", "Exception", "{", "JCalendarTestBehavior", "behavior", "=", "new", "JCalendarTestBehavior", "(", ")", ";", "behavior", ".", "setCalendar", "(", "new", "JTextField", "(", ")", ",", "new", "SetCalendarStep", "(", ")", ")", ";", "}", "@", "Test", "public", "void", "test_nominal", "(", ")", "throws", "Exception", "{", "JCalendarTestBehavior", "behavior", "=", "new", "JCalendarTestBehavior", "(", ")", ";", "JCalendar", "jCalendar", "=", "new", "JCalendar", "(", ")", ";", "final", "String", "strDate", "=", "\"2009-10-10\"", ";", "SetCalendarStep", "valueStep", "=", "new", "SetCalendarStep", "(", ")", "{", "@", "Override", "public", "String", "getValue", "(", ")", "{", "return", "strDate", ";", "}", "}", ";", "behavior", ".", "setCalendar", "(", "jCalendar", ",", "valueStep", ")", ";", "assertThat", "(", "jCalendar", ".", "getSelectedDate", "(", ")", ",", "equalTo", "(", "new", "SimpleDateFormat", "(", "\"yyyy-MM-dd\"", ")", ".", "parse", "(", "strDate", ")", ")", ")", ";", "}", "@", "Test", "(", "expected", "=", "GuiConfigurationException", ".", "class", ")", "public", "void", "test_badDate", "(", ")", "throws", "Exception", "{", "JCalendarTestBehavior", "behavior", "=", "new", "JCalendarTestBehavior", "(", ")", ";", "JCalendar", "jCalendar", "=", "new", "JCalendar", "(", ")", ";", "final", "String", "strDate", "=", "\"10/10/2009\"", ";", "SetCalendarStep", "valueStep", "=", "new", "SetCalendarStep", "(", ")", "{", "@", "Override", "public", "String", "getValue", "(", ")", "{", "return", "strDate", ";", "}", "}", ";", "behavior", ".", "setCalendar", "(", "jCalendar", ",", "valueStep", ")", ";", "assertThat", "(", "jCalendar", ".", "getSelectedDate", "(", ")", ",", "equalTo", "(", "new", "SimpleDateFormat", "(", "\"dd/MM/yyyy\"", ")", ".", "parse", "(", "strDate", ")", ")", ")", ";", "}", "}", "</s>" ]
982
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "calendar", ";", "import", "java", ".", "util", ".", "Calendar", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "public", "class", "CalendarModelTest", "extends", "TestCase", "{", "private", "final", "Date", "april2002", "=", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2002-04-01\"", ")", ";", "private", "final", "Date", "february2002", "=", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2002-02-01\"", ")", ";", "private", "final", "Date", "march2000", "=", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2000-03-01\"", ")", ";", "private", "final", "Date", "march2002", "=", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2002-03-01\"", ")", ";", "private", "final", "Date", "october2002", "=", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2002-10-01\"", ")", ";", "public", "void", "test_getColumnName", "(", ")", "{", "CalendarModel", "calendarmodel", "=", "new", "CalendarModel", "(", "Locale", ".", "FRANCE", ")", ";", "assertEquals", "(", "\"lun.\"", ",", "calendarmodel", ".", "getColumnName", "(", "0", ")", ")", ";", "assertEquals", "(", "\"dim.\"", ",", "calendarmodel", ".", "getColumnName", "(", "6", ")", ")", ";", "}", "public", "void", "test_getColumnName_ENGLISH", "(", ")", "{", "CalendarModel", "calendarmodel", "=", "new", "CalendarModel", "(", "Locale", ".", "ENGLISH", ")", ";", "assertEquals", "(", "\"Sun\"", ",", "calendarmodel", ".", "getColumnName", "(", "0", ")", ")", ";", "assertEquals", "(", "\"Sat\"", ",", "calendarmodel", ".", "getColumnName", "(", "6", ")", ")", ";", "}", "public", "void", "test_getDayIndex", "(", ")", "{", "CalendarModel", "calendarmodel", "=", "new", "CalendarModel", "(", "Locale", ".", "FRANCE", ")", ";", "int", "inc", "=", "0", ";", "assertEquals", "(", "\"MONDAY\"", ",", "Calendar", ".", "MONDAY", ",", "calendarmodel", ".", "getDayOfWeekFromIndex", "(", "inc", "++", ")", ")", ";", "assertEquals", "(", "\"TUESDAY\"", ",", "Calendar", ".", "TUESDAY", ",", "calendarmodel", ".", "getDayOfWeekFromIndex", "(", "inc", "++", ")", ")", ";", "assertEquals", "(", "\"WEDNESDAY\"", ",", "Calendar", ".", "WEDNESDAY", ",", "calendarmodel", ".", "getDayOfWeekFromIndex", "(", "inc", "++", ")", ")", ";", "assertEquals", "(", "\"THURSDAY\"", ",", "Calendar", ".", "THURSDAY", ",", "calendarmodel", ".", "getDayOfWeekFromIndex", "(", "inc", "++", ")", ")", ";", "assertEquals", "(", "\"FRIDAY\"", ",", "Calendar", ".", "FRIDAY", ",", "calendarmodel", ".", "getDayOfWeekFromIndex", "(", "inc", "++", ")", ")", ";", "assertEquals", "(", "\"SATURDAY\"", ",", "Calendar", ".", "SATURDAY", ",", "calendarmodel", ".", "getDayOfWeekFromIndex", "(", "inc", "++", ")", ")", ";", "assertEquals", "(", "\"SUNDAY\"", ",", "Calendar", ".", "SUNDAY", ",", "calendarmodel", ".", "getDayOfWeekFromIndex", "(", "inc", ")", ")", ";", "}", "public", "void", "test_getDayIndex_ENGLISH", "(", ")", "{", "CalendarModel", "calendarmodel", "=", "new", "CalendarModel", "(", "Locale", ".", "ENGLISH", ")", ";", "assertEquals", "(", "\"SUNDAY\"", ",", "Calendar", ".", "SUNDAY", ",", "calendarmodel", ".", "getDayOfWeekFromIndex", "(", "0", ")", ")", ";", "}", "public", "void", "test_getRowCount", "(", ")", "{", "CalendarModel", "calendarmodel", "=", "new", "CalendarModel", "(", "Locale", ".", "FRANCE", ",", "february2002", ")", ";", "assertEquals", "(", "5", ",", "calendarmodel", ".", "getRowCount", "(", ")", ")", ";", "}", "public", "void", "test_getRowCount_March2002_FRANCE", "(", ")", "{", "CalendarModel", "calendarmodel", "=", "new", "CalendarModel", "(", "Locale", ".", "FRANCE", ",", "march2002", ")", ";", "assertEquals", "(", "5", ",", "calendarmodel", ".", "getRowCount", "(", ")", ")", ";", "}", "public", "void", "test_getRowCount_March2000_ENGLISH", "(", ")", "{", "CalendarModel", "calendarmodel", "=", "new", "CalendarModel", "(", "Locale", ".", "ENGLISH", ",", "march2000", ")", ";", "assertEquals", "(", "5", ",", "calendarmodel", ".", "getRowCount", "(", ")", ")", ";", "}", "public", "void", "test_getValueAt", "(", ")", "{", "CalendarModel", "calendarmodel", "=", "new", "CalendarModel", "(", "Locale", ".", "FRANCE", ",", "february2002", ")", ";", "assertEquals", "(", "february2002", ",", "calendarmodel", ".", "getValueAt", "(", "0", ",", "4", ")", ")", ";", "}", "public", "void", "test_getValueAt_ENGLISH", "(", ")", "{", "CalendarModel", "calendarmodel", "=", "new", "CalendarModel", "(", "Locale", ".", "ENGLISH", ",", "february2002", ")", ";", "assertEquals", "(", "february2002", ",", "calendarmodel", ".", "getValueAt", "(", "0", ",", "5", ")", ")", ";", "}", "public", "void", "test_getValueAt_april", "(", ")", "{", "CalendarModel", "calendarmodel", "=", "new", "CalendarModel", "(", "Locale", ".", "FRANCE", ",", "april2002", ")", ";", "assertEquals", "(", "april2002", ",", "calendarmodel", ".", "getValueAt", "(", "0", ",", "0", ")", ")", ";", "}", "public", "void", "test_getValueAt_october", "(", ")", "{", "CalendarModel", "calendarmodel", "=", "new", "CalendarModel", "(", "Locale", ".", "FRANCE", ",", "october2002", ")", ";", "assertEquals", "(", "october2002", ",", "calendarmodel", ".", "getValueAt", "(", "0", ",", "1", ")", ")", ";", "}", "public", "void", "test_setDate_Bug", "(", ")", "{", "CalendarModel", "calendarmodel", "=", "new", "CalendarModel", "(", ")", ";", "final", "java", ".", "sql", ".", "Date", "aDate", "=", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2003-12-03\"", ")", ";", "calendarmodel", ".", "setDate", "(", "aDate", ")", ";", "assertEquals", "(", "aDate", ",", "calendarmodel", ".", "getDate", "(", ")", ")", ";", "}", "public", "void", "test_setDate__noTime", "(", ")", "{", "CalendarModel", "calendarmodel", "=", "new", "CalendarModel", "(", ")", ";", "final", "java", ".", "sql", ".", "Date", "aDate", "=", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2003-12-03\"", ")", ";", "final", "Date", "aDateWithTime", "=", "java", ".", "sql", ".", "Timestamp", ".", "valueOf", "(", "\"\"", ")", ";", "calendarmodel", ".", "setDate", "(", "aDateWithTime", ")", ";", "assertEquals", "(", "aDate", ",", "calendarmodel", ".", "getDate", "(", ")", ")", ";", "}", "}", "</s>" ]
983
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "date", ";", "import", "static", "net", ".", "codjo", ".", "test", ".", "common", ".", "matcher", ".", "JUnitMatchers", ".", "*", ";", "import", "javax", ".", "swing", ".", "JFrame", ";", "import", "org", ".", "junit", ".", "Before", ";", "import", "org", ".", "junit", ".", "Test", ";", "import", "org", ".", "uispec4j", ".", "Key", ";", "import", "org", ".", "uispec4j", ".", "TextBox", ";", "public", "class", "PopupDateFieldTest", "{", "private", "PopupDateField", "popupDateField", ";", "private", "TextBox", "popupDateFieldTest", ";", "@", "Test", "public", "void", "testBUG", "(", ")", "throws", "Exception", "{", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "d2", ")", ";", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "d5", ")", ";", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "SLASH", ")", ";", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "d1", ")", ";", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "d2", ")", ";", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "SLASH", ")", ";", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "d1", ")", ";", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "d9", ")", ";", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "d9", ")", ";", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "d9", ")", ";", "assertThat", "(", "popupDateFieldTest", ".", "getText", "(", ")", ",", "equalTo", "(", "\"25/12/1999\"", ")", ")", ";", "}", "@", "Test", "public", "void", "test_getDate", "(", ")", "throws", "Exception", "{", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "d2", ")", ";", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "d5", ")", ";", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "SLASH", ")", ";", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "d1", ")", ";", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "d2", ")", ";", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "SLASH", ")", ";", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "d2", ")", ";", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "d0", ")", ";", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "d0", ")", ";", "popupDateFieldTest", ".", "pressKey", "(", "Key", ".", "d1", ")", ";", "assertThat", "(", "new", "java", ".", "sql", ".", "Date", "(", "popupDateField", ".", "getDate", "(", ")", ".", "getTime", "(", ")", ")", ",", "equalTo", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2001-12-25\"", ")", ")", ")", ";", "}", "@", "Test", "public", "void", "test_setDate", "(", ")", "throws", "InterruptedException", "{", "popupDateField", ".", "setDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2001-12-25\"", ")", ")", ";", "Thread", ".", "sleep", "(", "250", ")", ";", "assertThat", "(", "popupDateFieldTest", ".", "getText", "(", ")", ",", "equalTo", "(", "\"25/12/2001\"", ")", ")", ";", "}", "@", "Test", "public", "void", "test_setDate_monthAndDayAutoCompletion", "(", ")", "throws", "InterruptedException", "{", "popupDateField", ".", "setDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2001-1-2\"", ")", ")", ";", "Thread", ".", "sleep", "(", "250", ")", ";", "assertThat", "(", "popupDateFieldTest", ".", "getText", "(", ")", ",", "equalTo", "(", "\"02/01/2001\"", ")", ")", ";", "}", "@", "Test", "public", "void", "test_setDate_null", "(", ")", "throws", "InterruptedException", "{", "popupDateField", ".", "setDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2001-12-25\"", ")", ")", ";", "Thread", ".", "sleep", "(", "250", ")", ";", "popupDateField", ".", "setDate", "(", "null", ")", ";", "Thread", ".", "sleep", "(", "250", ")", ";", "assertThat", "(", "popupDateFieldTest", ".", "getText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "}", "@", "Before", "public", "void", "setUp", "(", ")", "throws", "Exception", "{", "popupDateField", "=", "new", "PopupDateField", "(", ")", ";", "popupDateFieldTest", "=", "new", "TextBox", "(", "popupDateField", ".", "getDateTextField", "(", ")", ")", ";", "JFrame", "window", "=", "new", "JFrame", "(", ")", ";", "window", ".", "getContentPane", "(", ")", ".", "add", "(", "popupDateField", ")", ";", "}", "}", "</s>" ]
984
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "date", ";", "import", "org", ".", "uispec4j", ".", "Key", ";", "import", "org", ".", "uispec4j", ".", "TextBox", ";", "import", "org", ".", "uispec4j", ".", "UISpecTestCase", ";", "public", "class", "PeriodFieldTest", "extends", "UISpecTestCase", "{", "private", "PeriodField", "periodField", ";", "public", "void", "test_init", "(", ")", "throws", "Exception", "{", "assertEquals", "(", "\"PeriodField\"", ",", "periodField", ".", "getName", "(", ")", ")", ";", "}", "public", "void", "test_periodValid", "(", ")", "throws", "Exception", "{", "periodField", ".", "setText", "(", "\"2007\"", ")", ";", "assertFalse", "(", "periodField", ".", "isCorrect", "(", ")", ")", ";", "periodField", ".", "setText", "(", "\"200701\"", ")", ";", "assertTrue", "(", "periodField", ".", "isCorrect", "(", ")", ")", ";", "}", "public", "void", "test_onlyPeriodString", "(", ")", "throws", "Exception", "{", "periodField", ".", "setText", "(", "\"****\"", ")", ";", "assertFalse", "(", "periodField", ".", "isCorrect", "(", ")", ")", ";", "periodField", ".", "setText", "(", "\"wrong", "period\"", ")", ";", "assertFalse", "(", "periodField", ".", "isCorrect", "(", ")", ")", ";", "}", "public", "void", "test_maxLength", "(", ")", "throws", "Exception", "{", "TextBox", "periodTestField", "=", "new", "TextBox", "(", "new", "PeriodField", "(", "true", ")", ")", ";", "periodTestField", ".", "pressKey", "(", "Key", ".", "d2", ")", ";", "periodTestField", ".", "pressKey", "(", "Key", ".", "d0", ")", ";", "periodTestField", ".", "pressKey", "(", "Key", ".", "d0", ")", ";", "periodTestField", ".", "pressKey", "(", "Key", ".", "d8", ")", ";", "periodTestField", ".", "pressKey", "(", "Key", ".", "d0", ")", ";", "periodTestField", ".", "pressKey", "(", "Key", ".", "d4", ")", ";", "assertTrue", "(", "periodTestField", ".", "textEquals", "(", "\"200804\"", ")", ")", ";", "periodTestField", ".", "pressKey", "(", "Key", ".", "d1", ")", ";", "periodTestField", ".", "pressKey", "(", "Key", ".", "d2", ")", ";", "assertTrue", "(", "periodTestField", ".", "textEquals", "(", "\"200804\"", ")", ")", ";", "}", "@", "Override", "protected", "void", "setUp", "(", ")", "throws", "Exception", "{", "super", ".", "setUp", "(", ")", ";", "periodField", "=", "new", "PeriodField", "(", ")", ";", "}", "}", "</s>" ]
985
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "date", ";", "import", "java", ".", "sql", ".", "Timestamp", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "public", "class", "TimestampDateFieldTest", "extends", "TestCase", "{", "public", "void", "test_setDate", "(", ")", "throws", "Exception", "{", "TimestampDateField", "comp", "=", "new", "TimestampDateField", "(", ")", ";", "Timestamp", "date", "=", "Timestamp", ".", "valueOf", "(", "\"\"", ")", ";", "comp", ".", "setDate", "(", "date", ")", ";", "assertEquals", "(", "\"\"", ",", "comp", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "comp", ".", "getDate", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "public", "void", "test_setEnable", "(", ")", "throws", "Exception", "{", "TimestampDateField", "comp", "=", "new", "TimestampDateField", "(", ")", ";", "assertTrue", "(", "!", "comp", ".", "isEditable", "(", ")", ")", ";", "comp", ".", "setEditable", "(", "true", ")", ";", "assertTrue", "(", "!", "comp", ".", "isEditable", "(", ")", ")", ";", "}", "public", "void", "test_setText", "(", ")", "throws", "Exception", "{", "TimestampDateField", "comp", "=", "new", "TimestampDateField", "(", ")", ";", "Timestamp", "date", "=", "Timestamp", ".", "valueOf", "(", "\"\"", ")", ";", "comp", ".", "setDate", "(", "date", ")", ";", "assertEquals", "(", "\"\"", ",", "comp", ".", "getText", "(", ")", ")", ";", "comp", ".", "setText", "(", "\"toto\"", ")", ";", "assertEquals", "(", "\"\"", ",", "comp", ".", "getText", "(", ")", ")", ";", "}", "protected", "void", "setUp", "(", ")", "{", "}", "protected", "void", "tearDown", "(", ")", "{", "}", "}", "</s>" ]
986
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "date", ";", "import", "static", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "date", ".", "AbstractDateField", ".", "BAD_DATE", ";", "import", "java", ".", "util", ".", "ArrayList", ";", "import", "java", ".", "util", ".", "Calendar", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "java", ".", "util", ".", "List", ";", "import", "junit", ".", "extensions", ".", "jfcunit", ".", "JFCTestCase", ";", "public", "class", "RestrictedDateFieldTest", "extends", "JFCTestCase", "{", "public", "void", "test_invalidDates", "(", ")", "throws", "Exception", "{", "List", "<", "Date", ">", "invalidDates", "=", "new", "ArrayList", "<", "Date", ">", "(", ")", ";", "invalidDates", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2001-12-25\"", ")", ")", ";", "RestrictedDateField", "dateField", "=", "new", "RestrictedDateField", "(", "true", ",", "true", ",", "invalidDates", ")", ";", "java", ".", "sql", ".", "Date", "newDate", "=", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2001-12-24\"", ")", ";", "dateField", ".", "setDate", "(", "newDate", ")", ";", "flushAWT", "(", ")", ";", "assertEquals", "(", "newDate", ",", "new", "java", ".", "sql", ".", "Date", "(", "dateField", ".", "buildDateValueFromGUI", "(", ")", ".", "getTime", "(", ")", ")", ")", ";", "newDate", "=", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2001-12-25\"", ")", ";", "dateField", ".", "setDate", "(", "newDate", ")", ";", "flushAWT", "(", ")", ";", "assertEquals", "(", "BAD_DATE", ",", "dateField", ".", "buildDateValueFromGUI", "(", ")", ")", ";", "}", "public", "void", "test_allowWeekEnds", "(", ")", "throws", "Exception", "{", "RestrictedDateField", "dateField", "=", "new", "RestrictedDateField", "(", "true", ",", "false", ")", ";", "java", ".", "sql", ".", "Date", "newDate", "=", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2009-07-24\"", ")", ";", "dateField", ".", "setDate", "(", "newDate", ")", ";", "flushAWT", "(", ")", ";", "assertEquals", "(", "newDate", ",", "new", "java", ".", "sql", ".", "Date", "(", "dateField", ".", "buildDateValueFromGUI", "(", ")", ".", "getTime", "(", ")", ")", ")", ";", "newDate", "=", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2009-07-25\"", ")", ";", "dateField", ".", "setDate", "(", "newDate", ")", ";", "flushAWT", "(", ")", ";", "assertEquals", "(", "BAD_DATE", ",", "dateField", ".", "buildDateValueFromGUI", "(", ")", ")", ";", "newDate", "=", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2009-07-26\"", ")", ";", "dateField", ".", "setDate", "(", "newDate", ")", ";", "flushAWT", "(", ")", ";", "assertEquals", "(", "BAD_DATE", ",", "dateField", ".", "buildDateValueFromGUI", "(", ")", ")", ";", "}", "public", "void", "test_allowPastDate", "(", ")", "throws", "Exception", "{", "RestrictedDateField", "dateField", "=", "new", "RestrictedDateField", "(", "true", ",", "true", ")", ";", "Calendar", "calendar", "=", "Calendar", ".", "getInstance", "(", ")", ";", "java", ".", "sql", ".", "Date", "todayDate", "=", "getSQLDateFromCalendar", "(", "calendar", ")", ";", "dateField", ".", "setDate", "(", "todayDate", ")", ";", "flushAWT", "(", ")", ";", "assertEquals", "(", "todayDate", ",", "dateField", ".", "buildDateValueFromGUI", "(", ")", ")", ";", "calendar", ".", "add", "(", "Calendar", ".", "DAY_OF_MONTH", ",", "-", "1", ")", ";", "java", ".", "sql", ".", "Date", "yesterday", "=", "getSQLDateFromCalendar", "(", "calendar", ")", ";", "dateField", ".", "setDate", "(", "yesterday", ")", ";", "flushAWT", "(", ")", ";", "assertEquals", "(", "yesterday", ",", "dateField", ".", "buildDateValueFromGUI", "(", ")", ")", ";", "calendar", ".", "add", "(", "Calendar", ".", "DAY_OF_MONTH", ",", "2", ")", ";", "java", ".", "sql", ".", "Date", "tomorrow", "=", "getSQLDateFromCalendar", "(", "calendar", ")", ";", "dateField", ".", "setDate", "(", "tomorrow", ")", ";", "flushAWT", "(", ")", ";", "assertEquals", "(", "tomorrow", ",", "dateField", ".", "buildDateValueFromGUI", "(", ")", ")", ";", "}", "public", "void", "test_noAllowPastDate", "(", ")", "throws", "Exception", "{", "RestrictedDateField", "dateField", "=", "new", "RestrictedDateField", "(", "false", ",", "true", ")", ";", "Calendar", "calendar", "=", "Calendar", ".", "getInstance", "(", ")", ";", "java", ".", "sql", ".", "Date", "today", "=", "getSQLDateFromCalendar", "(", "calendar", ")", ";", "dateField", ".", "setDate", "(", "today", ")", ";", "flushAWT", "(", ")", ";", "assertEquals", "(", "today", ",", "dateField", ".", "buildDateValueFromGUI", "(", ")", ")", ";", "calendar", ".", "add", "(", "Calendar", ".", "DAY_OF_MONTH", ",", "-", "1", ")", ";", "java", ".", "sql", ".", "Date", "yesterday", "=", "getSQLDateFromCalendar", "(", "calendar", ")", ";", "dateField", ".", "setDate", "(", "yesterday", ")", ";", "flushAWT", "(", ")", ";", "assertEquals", "(", "BAD_DATE", ",", "dateField", ".", "buildDateValueFromGUI", "(", ")", ")", ";", "calendar", ".", "add", "(", "Calendar", ".", "DAY_OF_MONTH", ",", "2", ")", ";", "java", ".", "sql", ".", "Date", "tomorrow", "=", "getSQLDateFromCalendar", "(", "calendar", ")", ";", "dateField", ".", "setDate", "(", "tomorrow", ")", ";", "flushAWT", "(", ")", ";", "assertEquals", "(", "tomorrow", ",", "dateField", ".", "buildDateValueFromGUI", "(", ")", ")", ";", "java", ".", "sql", ".", "Date", "maxPastDate", "=", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2009-06-30\"", ")", ";", "dateField", ".", "setMaxDateRange", "(", "maxPastDate", ")", ";", "dateField", ".", "setDate", "(", "maxPastDate", ")", ";", "flushAWT", "(", ")", ";", "assertEquals", "(", "BAD_DATE", ",", "dateField", ".", "buildDateValueFromGUI", "(", ")", ")", ";", "dateField", ".", "setDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2009-06-29\"", ")", ")", ";", "flushAWT", "(", ")", ";", "assertEquals", "(", "BAD_DATE", ",", "dateField", ".", "buildDateValueFromGUI", "(", ")", ")", ";", "java", ".", "sql", ".", "Date", "firstDayJuly", "=", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2009-07-01\"", ")", ";", "dateField", ".", "setDate", "(", "firstDayJuly", ")", ";", "flushAWT", "(", ")", ";", "assertEquals", "(", "BAD_DATE", ",", "dateField", ".", "buildDateValueFromGUI", "(", ")", ")", ";", "dateField", ".", "setAllowPastDate", "(", "true", ")", ";", "assertEquals", "(", "firstDayJuly", ",", "dateField", ".", "buildDateValueFromGUI", "(", ")", ")", ";", "}", "public", "void", "test_clearExcludedDateRanges", "(", ")", "throws", "Exception", "{", "RestrictedDateField", "field", "=", "new", "RestrictedDateField", "(", ")", ";", "field", ".", "addExcludedDateRange", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2009-01-01\"", ")", ",", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2010-01-01\"", ")", ")", ";", "assertEquals", "(", "field", ".", "getExcludedDateRanges", "(", ")", ".", "size", "(", ")", ",", "1", ")", ";", "field", ".", "clearExcludedDateRanges", "(", ")", ";", "assertEquals", "(", "field", ".", "getExcludedDateRanges", "(", ")", ".", "size", "(", ")", ",", "0", ")", ";", "field", ".", "addExcludedDateRange", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2009-01-01\"", ")", ",", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2010-01-01\"", ")", ")", ";", "assertEquals", "(", "field", ".", "getExcludedDateRanges", "(", ")", ".", "size", "(", ")", ",", "1", ")", ";", "}", "public", "void", "test_isInvalidDate", "(", ")", "{", "RestrictedDateField", "field", "=", "new", "RestrictedDateField", "(", ")", ";", "List", "<", "Date", ">", "list", "=", "new", "ArrayList", "<", "Date", ">", "(", ")", ";", "list", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2009-01-01\"", ")", ")", ";", "list", ".", "add", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2010-01-01\"", ")", ")", ";", "field", ".", "setInvalidDate", "(", "list", ")", ";", "assertEquals", "(", "field", ".", "isInvalidDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2009-06-01\"", ")", ")", ",", "false", ")", ";", "assertEquals", "(", "field", ".", "isInvalidDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2009-01-01\"", ")", ")", ",", "true", ")", ";", "assertEquals", "(", "field", ".", "isInvalidDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2010-01-01\"", ")", ")", ",", "true", ")", ";", "assertEquals", "(", "field", ".", "isInvalidDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2011-06-01\"", ")", ")", ",", "false", ")", ";", "assertEquals", "(", "field", ".", "isInvalidDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2008-06-01\"", ")", ")", ",", "false", ")", ";", "assertEquals", "(", "field", ".", "isInvalidDate", "(", "RestrictedDateField", ".", "MAX_DATE", ")", ",", "false", ")", ";", "assertEquals", "(", "field", ".", "isInvalidDate", "(", "RestrictedDateField", ".", "MIN_DATE", ")", ",", "false", ")", ";", "}", "public", "void", "test_isOutOfRangeDate", "(", ")", "{", "RestrictedDateField", "field", "=", "new", "RestrictedDateField", "(", ")", ";", "field", ".", "addExcludedDateRange", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2009-01-01\"", ")", ",", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2010-01-01\"", ")", ")", ";", "assertEquals", "(", "field", ".", "containsExcludedDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2009-06-01\"", ")", ")", ",", "true", ")", ";", "assertEquals", "(", "field", ".", "containsExcludedDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2009-01-01\"", ")", ")", ",", "true", ")", ";", "assertEquals", "(", "field", ".", "containsExcludedDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2010-01-01\"", ")", ")", ",", "true", ")", ";", "assertEquals", "(", "field", ".", "containsExcludedDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2011-06-01\"", ")", ")", ",", "false", ")", ";", "assertEquals", "(", "field", ".", "containsExcludedDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2008-06-01\"", ")", ")", ",", "false", ")", ";", "assertEquals", "(", "field", ".", "containsExcludedDate", "(", "RestrictedDateField", ".", "MAX_DATE", ")", ",", "false", ")", ";", "assertEquals", "(", "field", ".", "containsExcludedDate", "(", "RestrictedDateField", ".", "MIN_DATE", ")", ",", "false", ")", ";", "}", "public", "void", "test_isOutOfRangeDateWithMinDate", "(", ")", "{", "RestrictedDateField", "field", "=", "new", "RestrictedDateField", "(", ")", ";", "field", ".", "setMaxDateRange", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2009-01-01\"", ")", ")", ";", "assertEquals", "(", "field", ".", "containsExcludedDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2008-06-01\"", ")", ")", ",", "true", ")", ";", "assertEquals", "(", "field", ".", "containsExcludedDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2009-01-01\"", ")", ")", ",", "true", ")", ";", "assertEquals", "(", "field", ".", "containsExcludedDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2010-01-01\"", ")", ")", ",", "false", ")", ";", "assertEquals", "(", "field", ".", "containsExcludedDate", "(", "RestrictedDateField", ".", "MAX_DATE", ")", ",", "false", ")", ";", "assertEquals", "(", "field", ".", "containsExcludedDate", "(", "RestrictedDateField", ".", "MIN_DATE", ")", ",", "true", ")", ";", "}", "private", "java", ".", "sql", ".", "Date", "getSQLDateFromCalendar", "(", "Calendar", "calendar", ")", "{", "int", "year", "=", "calendar", ".", "get", "(", "Calendar", ".", "YEAR", ")", ";", "int", "month", "=", "calendar", ".", "get", "(", "Calendar", ".", "MONTH", ")", "+", "1", ";", "int", "day", "=", "calendar", ".", "get", "(", "Calendar", ".", "DAY_OF_MONTH", ")", ";", "return", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "year", "+", "\"-\"", "+", "(", "month", "<", "10", "?", "\"0\"", ":", "\"\"", ")", "+", "month", "+", "\"-\"", "+", "(", "day", "<", "10", "?", "\"0\"", ":", "\"\"", ")", "+", "day", ")", ";", "}", "}", "</s>" ]
987
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "date", ";", "import", "javax", ".", "swing", ".", "JFrame", ";", "import", "javax", ".", "swing", ".", "JLabel", ";", "import", "net", ".", "codjo", ".", "i18n", ".", "common", ".", "Language", ";", "import", "net", ".", "codjo", ".", "i18n", ".", "common", ".", "TranslationManager", ";", "import", "net", ".", "codjo", ".", "i18n", ".", "gui", ".", "TranslationNotifier", ";", "import", "net", ".", "codjo", ".", "test", ".", "common", ".", "DateUtil", ";", "import", "org", ".", "uispec4j", ".", "TextBox", ";", "import", "org", ".", "uispec4j", ".", "Trigger", ";", "import", "org", ".", "uispec4j", ".", "UISpecTestCase", ";", "import", "org", ".", "uispec4j", ".", "Window", ";", "import", "org", ".", "uispec4j", ".", "interception", ".", "WindowHandler", ";", "import", "org", ".", "uispec4j", ".", "interception", ".", "WindowInterceptor", ";", "import", "static", "org", ".", "hamcrest", ".", "core", ".", "IsEqual", ".", "equalTo", ";", "import", "static", "org", ".", "hamcrest", ".", "core", ".", "IsNull", ".", "nullValue", ";", "import", "static", "org", ".", "junit", ".", "Assert", ".", "assertThat", ";", "public", "class", "InternationalizableDateFieldTest", "extends", "UISpecTestCase", "{", "@", "Override", "protected", "void", "setUp", "(", ")", "throws", "Exception", "{", "super", ".", "setUp", "(", ")", ";", "}", "@", "Override", "protected", "void", "tearDown", "(", ")", "throws", "Exception", "{", "super", ".", "tearDown", "(", ")", ";", "}", "public", "void", "testUpdateTranslation", "(", ")", "throws", "Exception", "{", "TranslationManager", "translationManager", "=", "new", "TranslationManager", "(", ")", ";", "TranslationNotifier", "translationNotifier", "=", "new", "TranslationNotifier", "(", "Language", ".", "FR", ",", "translationManager", ")", ";", "translationNotifier", ".", "setLanguage", "(", "Language", ".", "FR", ")", ";", "final", "JFrame", "frame", "=", "new", "JFrame", "(", "\"DateField\"", ")", ";", "final", "DateField", "dateField", "=", "new", "DateField", "(", ")", ";", "frame", ".", "setContentPane", "(", "dateField", ")", ";", "dateField", ".", "setDate", "(", "DateUtil", ".", "createDate", "(", "\"1998-01-05\"", ")", ")", ";", "InternationalizableDateField", "i18nDateField", "=", "new", "InternationalizableDateField", "(", "dateField", ",", "translationNotifier", ",", "translationManager", ")", ";", "translationNotifier", ".", "addInternationalizableComponent", "(", "i18nDateField", ")", ";", "assertThat", "(", "i18nDateField", ".", "getComponent", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertThat", "(", "dateField", ".", "getCalendarButton", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertThat", "(", "dateField", ".", "getDayField", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertThat", "(", "dateField", ".", "getSlashlabelA", "(", ")", ".", "getToolTipText", "(", ")", ",", "nullValue", "(", ")", ")", ";", "assertThat", "(", "dateField", ".", "getMonthField", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertThat", "(", "dateField", ".", "getSlashlabelB", "(", ")", ".", "getToolTipText", "(", ")", ",", "nullValue", "(", ")", ")", ";", "assertThat", "(", "dateField", ".", "getYearField", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "final", "Window", "mainWindow", "=", "WindowInterceptor", ".", "run", "(", "new", "Trigger", "(", ")", "{", "public", "void", "run", "(", ")", "throws", "Exception", "{", "frame", ".", "setVisible", "(", "true", ")", ";", "}", "}", ")", ";", "assertPopupCalendar", "(", "mainWindow", ",", "\"\"", ")", ";", "translationNotifier", ".", "setLanguage", "(", "Language", ".", "EN", ")", ";", "assertThat", "(", "i18nDateField", ".", "getComponent", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertThat", "(", "dateField", ".", "getCalendarButton", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertThat", "(", "dateField", ".", "getDayField", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertThat", "(", "dateField", ".", "getSlashlabelA", "(", ")", ".", "getToolTipText", "(", ")", ",", "nullValue", "(", ")", ")", ";", "assertThat", "(", "dateField", ".", "getMonthField", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertThat", "(", "dateField", ".", "getSlashlabelB", "(", ")", ".", "getToolTipText", "(", ")", ",", "nullValue", "(", ")", ")", ";", "assertThat", "(", "dateField", ".", "getYearField", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertPopupCalendar", "(", "mainWindow", ",", "\"\"", ")", ";", "translationNotifier", ".", "setLanguage", "(", "Language", ".", "FR", ")", ";", "assertThat", "(", "i18nDateField", ".", "getComponent", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertThat", "(", "dateField", ".", "getCalendarButton", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertThat", "(", "dateField", ".", "getDayField", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertThat", "(", "dateField", ".", "getSlashlabelA", "(", ")", ".", "getToolTipText", "(", ")", ",", "nullValue", "(", ")", ")", ";", "assertThat", "(", "dateField", ".", "getMonthField", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertThat", "(", "dateField", ".", "getSlashlabelB", "(", ")", ".", "getToolTipText", "(", ")", ",", "nullValue", "(", ")", ")", ";", "assertThat", "(", "dateField", ".", "getYearField", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertPopupCalendar", "(", "mainWindow", ",", "\"\"", ")", ";", "}", "private", "void", "assertPopupCalendar", "(", "final", "Window", "mainWindow", ",", "final", "String", "dateHelpLabel", ")", "{", "WindowInterceptor", ".", "init", "(", "new", "Trigger", "(", ")", "{", "public", "void", "run", "(", ")", "throws", "Exception", "{", "mainWindow", ".", "getButton", "(", ")", ".", "click", "(", ")", ";", "}", "}", ")", ".", "process", "(", "new", "WindowHandler", "(", ")", "{", "@", "Override", "public", "Trigger", "process", "(", "final", "Window", "window", ")", "throws", "Exception", "{", "TextBox", "helpLabelTextBox", "=", "window", ".", "getTextBox", "(", "\"HelpLabel\"", ")", ";", "JLabel", "helpLabel", "=", "(", "JLabel", ")", "helpLabelTextBox", ".", "getAwtComponent", "(", ")", ";", "assertThat", "(", "helpLabel", ".", "getText", "(", ")", ",", "equalTo", "(", "dateHelpLabel", ")", ")", ";", "return", "window", ".", "getButton", "(", "\"Calendar.OK\"", ")", ".", "triggerClick", "(", ")", ";", "}", "}", ")", ".", "run", "(", ")", ";", "}", "public", "void", "testPopupUpdateTranslation", "(", ")", "throws", "Exception", "{", "TranslationManager", "translationManager", "=", "new", "TranslationManager", "(", ")", ";", "TranslationNotifier", "translationNotifier", "=", "new", "TranslationNotifier", "(", "Language", ".", "FR", ",", "translationManager", ")", ";", "translationNotifier", ".", "setLanguage", "(", "Language", ".", "FR", ")", ";", "PopupDateField", "dateField", "=", "new", "PopupDateField", "(", ")", ";", "dateField", ".", "setDate", "(", "DateUtil", ".", "createDate", "(", "\"1998-01-05\"", ")", ")", ";", "InternationalizableDateField", "i18nDateField", "=", "new", "InternationalizableDateField", "(", "dateField", ",", "translationNotifier", ",", "translationManager", ")", ";", "translationNotifier", ".", "addInternationalizableComponent", "(", "i18nDateField", ")", ";", "assertThat", "(", "i18nDateField", ".", "getComponent", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertThat", "(", "dateField", ".", "getCalendarButton", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertThat", "(", "dateField", ".", "getDateTextField", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "translationNotifier", ".", "setLanguage", "(", "Language", ".", "EN", ")", ";", "assertThat", "(", "i18nDateField", ".", "getComponent", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertThat", "(", "dateField", ".", "getCalendarButton", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertThat", "(", "dateField", ".", "getDateTextField", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "translationNotifier", ".", "setLanguage", "(", "Language", ".", "FR", ")", ";", "assertThat", "(", "i18nDateField", ".", "getComponent", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertThat", "(", "dateField", ".", "getCalendarButton", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "assertThat", "(", "dateField", ".", "getDateTextField", "(", ")", ".", "getToolTipText", "(", ")", ",", "equalTo", "(", "\"\"", ")", ")", ";", "}", "}", "</s>" ]
988
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "date", ";", "import", "static", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "date", ".", "RestrictedDateField", ".", "MAX_DATE", ";", "import", "static", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "date", ".", "RestrictedDateField", ".", "MIN_DATE", ";", "import", "static", "net", ".", "codjo", ".", "test", ".", "common", ".", "matcher", ".", "JUnitMatchers", ".", "*", ";", "import", "java", ".", "text", ".", "ParseException", ";", "import", "java", ".", "text", ".", "SimpleDateFormat", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "org", ".", "junit", ".", "Test", ";", "public", "class", "DateRangeTest", "{", "@", "Test", "public", "void", "test_maxValue", "(", ")", "throws", "Exception", "{", "DateRange", "dateRange", "=", "new", "DateRange", "(", "MIN_DATE", ",", "convertIntoDate", "(", "\"15/06/2010\"", ")", ")", ";", "assertThat", "(", "dateRange", ".", "contains", "(", "convertIntoDate", "(", "\"15/06/1976\"", ")", ")", ",", "equalTo", "(", "true", ")", ")", ";", "assertThat", "(", "dateRange", ".", "contains", "(", "convertIntoDate", "(", "\"01/12/0001\"", ")", ")", ",", "equalTo", "(", "true", ")", ")", ";", "assertThat", "(", "dateRange", ".", "contains", "(", "convertIntoDate", "(", "\"01/12/2011\"", ")", ")", ",", "equalTo", "(", "false", ")", ")", ";", "assertThat", "(", "dateRange", ".", "contains", "(", "convertIntoDate", "(", "\"15/06/2010\"", ")", ")", ",", "equalTo", "(", "true", ")", ")", ";", "}", "@", "Test", "public", "void", "test_minValue", "(", ")", "throws", "Exception", "{", "DateRange", "dateRange", "=", "new", "DateRange", "(", "convertIntoDate", "(", "\"15/06/2008\"", ")", ",", "MAX_DATE", ")", ";", "assertThat", "(", "dateRange", ".", "contains", "(", "convertIntoDate", "(", "\"15/06/1976\"", ")", ")", ",", "equalTo", "(", "false", ")", ")", ";", "assertThat", "(", "dateRange", ".", "contains", "(", "convertIntoDate", "(", "\"01/12/0001\"", ")", ")", ",", "equalTo", "(", "false", ")", ")", ";", "assertThat", "(", "dateRange", ".", "contains", "(", "convertIntoDate", "(", "\"01/12/2011\"", ")", ")", ",", "equalTo", "(", "true", ")", ")", ";", "assertThat", "(", "dateRange", ".", "contains", "(", "convertIntoDate", "(", "\"15/06/2010\"", ")", ")", ",", "equalTo", "(", "true", ")", ")", ";", "assertThat", "(", "dateRange", ".", "contains", "(", "convertIntoDate", "(", "\"15/06/2008\"", ")", ")", ",", "equalTo", "(", "true", ")", ")", ";", "}", "private", "static", "Date", "convertIntoDate", "(", "String", "dateValue", ")", "throws", "ParseException", "{", "return", "new", "SimpleDateFormat", "(", "\"dd/MM/yyyy\"", ")", ".", "parse", "(", "dateValue", ")", ";", "}", "}", "</s>" ]
989
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "date", ";", "import", "net", ".", "codjo", ".", "test", ".", "common", ".", "DateUtil", ";", "import", "net", ".", "codjo", ".", "test", ".", "release", ".", "task", ".", "gui", ".", "SetValueStep", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "public", "class", "DateFieldTestBehaviorTest", "extends", "TestCase", "{", "private", "DateFieldTestBehavior", "behavior", ";", "public", "void", "test_dateFieldSetValue", "(", ")", "throws", "Exception", "{", "SetValueStep", "step", "=", "new", "SetValueStep", "(", ")", ";", "step", ".", "setValue", "(", "\"2006-08-06\"", ")", ";", "DateField", "dateField", "=", "new", "DateField", "(", ")", ";", "behavior", ".", "setValue", "(", "dateField", ",", "step", ")", ";", "assertEquals", "(", "DateUtil", ".", "createDate", "(", "\"2006-08-06\"", ")", ",", "dateField", ".", "getDate", "(", ")", ")", ";", "}", "@", "Override", "protected", "void", "setUp", "(", ")", "{", "behavior", "=", "new", "DateFieldTestBehavior", "(", ")", ";", "}", "}", "</s>" ]
990
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "date", ";", "import", "net", ".", "codjo", ".", "test", ".", "common", ".", "LogString", ";", "import", "static", "net", ".", "codjo", ".", "test", ".", "common", ".", "matcher", ".", "JUnitMatchers", ".", "*", ";", "import", "java", ".", "awt", ".", "Point", ";", "import", "java", ".", "awt", ".", "event", ".", "ActionEvent", ";", "import", "java", ".", "awt", ".", "event", ".", "ActionListener", ";", "import", "java", ".", "awt", ".", "event", ".", "FocusEvent", ";", "import", "java", ".", "text", ".", "ParseException", ";", "import", "java", ".", "text", ".", "SimpleDateFormat", ";", "import", "java", ".", "util", ".", "Calendar", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "javax", ".", "swing", ".", "JButton", ";", "import", "javax", ".", "swing", ".", "JComponent", ";", "import", "javax", ".", "swing", ".", "JFrame", ";", "import", "javax", ".", "swing", ".", "JTextField", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "mock", ";", "import", "static", "org", ".", "mockito", ".", "Mockito", ".", "when", ";", "import", "org", ".", "uispec4j", ".", "Button", ";", "import", "org", ".", "uispec4j", ".", "Key", ";", "import", "org", ".", "uispec4j", ".", "Panel", ";", "import", "org", ".", "uispec4j", ".", "TextBox", ";", "import", "org", ".", "uispec4j", ".", "Trigger", ";", "import", "org", ".", "uispec4j", ".", "UISpecTestCase", ";", "import", "org", ".", "uispec4j", ".", "Window", ";", "import", "org", ".", "uispec4j", ".", "interception", ".", "WindowHandler", ";", "import", "org", ".", "uispec4j", ".", "interception", ".", "WindowInterceptor", ";", "public", "class", "DateFieldTest", "extends", "UISpecTestCase", "{", "private", "DateField", "dateField", ";", "private", "TextBox", "dayFieldTest", ";", "private", "TextBox", "monthFieldTest", ";", "private", "TextBox", "yearFieldTest", ";", "private", "LogString", "log", "=", "new", "LogString", "(", ")", ";", "public", "void", "testBUG", "(", ")", "throws", "Exception", "{", "dayFieldTest", ".", "pressKey", "(", "Key", ".", "d2", ")", ";", "dayFieldTest", ".", "pressKey", "(", "Key", ".", "d5", ")", ";", "monthFieldTest", ".", "pressKey", "(", "Key", ".", "d1", ")", ";", "monthFieldTest", ".", "pressKey", "(", "Key", ".", "d2", ")", ";", "yearFieldTest", ".", "pressKey", "(", "Key", ".", "d1", ")", ";", "yearFieldTest", ".", "pressKey", "(", "Key", ".", "d9", ")", ";", "yearFieldTest", ".", "pressKey", "(", "Key", ".", "d9", ")", ";", "yearFieldTest", ".", "pressKey", "(", "Key", ".", "d9", ")", ";", "assertEquals", "(", "\"25\"", ",", "dayFieldTest", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "\"12\"", ",", "monthFieldTest", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "\"1999\"", ",", "yearFieldTest", ".", "getText", "(", ")", ")", ";", "}", "public", "void", "test_getDate", "(", ")", "throws", "Exception", "{", "dayFieldTest", ".", "pressKey", "(", "Key", ".", "d2", ")", ";", "dayFieldTest", ".", "pressKey", "(", "Key", ".", "d5", ")", ";", "monthFieldTest", ".", "pressKey", "(", "Key", ".", "d1", ")", ";", "monthFieldTest", ".", "pressKey", "(", "Key", ".", "d2", ")", ";", "yearFieldTest", ".", "pressKey", "(", "Key", ".", "d2", ")", ";", "yearFieldTest", ".", "pressKey", "(", "Key", ".", "d0", ")", ";", "yearFieldTest", ".", "pressKey", "(", "Key", ".", "d0", ")", ";", "yearFieldTest", ".", "pressKey", "(", "Key", ".", "d1", ")", ";", "assertEquals", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2001-12-25\"", ")", ",", "dateField", ".", "getDate", "(", ")", ")", ";", "}", "public", "void", "test_setDate", "(", ")", "throws", "InterruptedException", "{", "dateField", ".", "setDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2001-12-25\"", ")", ")", ";", "assertTrue", "(", "dayFieldTest", ".", "textEquals", "(", "\"25\"", ")", ")", ";", "assertTrue", "(", "monthFieldTest", ".", "textEquals", "(", "\"12\"", ")", ")", ";", "assertTrue", "(", "yearFieldTest", ".", "textEquals", "(", "\"2001\"", ")", ")", ";", "}", "public", "void", "test_setDate_monthAndDayAutoCompletion", "(", ")", "{", "dateField", ".", "setDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2001-1-2\"", ")", ")", ";", "assertTrue", "(", "dayFieldTest", ".", "textEquals", "(", "\"02\"", ")", ")", ";", "assertTrue", "(", "monthFieldTest", ".", "textEquals", "(", "\"01\"", ")", ")", ";", "assertTrue", "(", "yearFieldTest", ".", "textEquals", "(", "\"2001\"", ")", ")", ";", "}", "public", "void", "test_setDate_null", "(", ")", "{", "dateField", ".", "setDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2001-12-25\"", ")", ")", ";", "dateField", ".", "setDate", "(", "null", ")", ";", "assertTrue", "(", "dayFieldTest", ".", "textIsEmpty", "(", ")", ")", ";", "assertTrue", "(", "monthFieldTest", ".", "textIsEmpty", "(", ")", ")", ";", "assertTrue", "(", "yearFieldTest", ".", "textIsEmpty", "(", ")", ")", ";", "}", "public", "void", "test_calendar_not_visible", "(", ")", "{", "dateField", "=", "new", "DateField", "(", "false", ")", ";", "Panel", "panel", "=", "new", "Panel", "(", "dateField", ")", ";", "Button", "calendarButton", "=", "panel", ".", "getButton", "(", ")", ";", "assertFalse", "(", "calendarButton", ".", "isVisible", "(", ")", ")", ";", "}", "public", "void", "test_setDateWithNullValueNotAuthorized", "(", ")", "{", "dateField", ".", "setNullDateValueAuthorized", "(", "false", ")", ";", "dateField", ".", "setDate", "(", "java", ".", "sql", ".", "Date", ".", "valueOf", "(", "\"2001-12-25\"", ")", ")", ";", "dateField", ".", "setDate", "(", "null", ")", ";", "assertTrue", "(", "dayFieldTest", ".", "textEquals", "(", "\"25\"", ")", ")", ";", "assertTrue", "(", "monthFieldTest", ".", "textEquals", "(", "\"12\"", ")", ")", ";", "assertTrue", "(", "yearFieldTest", ".", "textEquals", "(", "\"2001\"", ")", ")", ";", "}", "public", "void", "test_calendar_defaultDateIsRecorded", "(", ")", "{", "initializeDateField", "(", "new", "DateField", "(", "true", ",", "null", ",", "new", "JButtonThatMockGetLocationOnScreen", "(", ")", ")", ")", ";", "assertTrue", "(", "dayFieldTest", ".", "textIsEmpty", "(", ")", ")", ";", "assertTrue", "(", "monthFieldTest", ".", "textIsEmpty", "(", ")", ")", ";", "assertTrue", "(", "yearFieldTest", ".", "textIsEmpty", "(", ")", ")", ";", "WindowInterceptor", ".", "init", "(", "new", "Trigger", "(", ")", "{", "public", "void", "run", "(", ")", "throws", "Exception", "{", "Button", "calendarButton", "=", "new", "Button", "(", "dateField", ".", "getCalendarButton", "(", ")", ")", ";", "calendarButton", ".", "click", "(", ")", ";", "}", "}", ")", ".", "process", "(", "new", "WindowHandler", "(", ")", "{", "@", "Override", "public", "Trigger", "process", "(", "Window", "window", ")", "throws", "Exception", "{", "return", "window", ".", "getButton", "(", "\"OK\"", ")", ".", "triggerClick", "(", ")", ";", "}", "}", ")", ".", "run", "(", ")", ";", "Calendar", "cal", "=", "Calendar", ".", "getInstance", "(", ")", ";", "assertTrue", "(", "dayFieldTest", ".", "textEquals", "(", "getIntAsString", "(", "cal", ".", "get", "(", "Calendar", ".", "DAY_OF_MONTH", ")", ")", ")", ")", ";", "assertTrue", "(", "monthFieldTest", ".", "textEquals", "(", "getIntAsString", "(", "cal", ".", "get", "(", "Calendar", ".", "MONTH", ")", "+", "1", ")", ")", ")", ";", "assertTrue", "(", "yearFieldTest", ".", "textEquals", "(", "\"\"", "+", "cal", ".", "get", "(", "Calendar", ".", "YEAR", ")", ")", ")", ";", "}", "public", "void", "test_hasLostFocus", "(", ")", "throws", "Exception", "{", "DateField", ".", "DateFieldGlobalFocusValidator", "dateValidator", "=", "dateField", ".", "new", "DateFieldGlobalFocusValidator", "(", ")", ";", "FocusEvent", "focusEvent", "=", "mock", "(", "FocusEvent", ".", "class", ")", ";", "when", "(", "focusEvent", ".", "getOppositeComponent", "(", ")", ")", ".", "thenReturn", "(", "dateField", ".", "getMonthField", "(", ")", ")", ";", "assertThat", "(", "dateValidator", ".", "hasGloballyLostFocus", "(", "focusEvent", ")", ",", "equalTo", "(", "false", ")", ")", ";", "when", "(", "focusEvent", ".", "getOppositeComponent", "(", ")", ")", ".", "thenReturn", "(", "dateField", ".", "getDayField", "(", ")", ")", ";", "assertThat", "(", "dateValidator", ".", "hasGloballyLostFocus", "(", "focusEvent", ")", ",", "equalTo", "(", "false", ")", ")", ";", "when", "(", "focusEvent", ".", "getOppositeComponent", "(", ")", ")", ".", "thenReturn", "(", "dateField", ".", "getYearField", "(", ")", ")", ";", "assertThat", "(", "dateValidator", ".", "hasGloballyLostFocus", "(", "focusEvent", ")", ",", "equalTo", "(", "false", ")", ")", ";", "when", "(", "focusEvent", ".", "getOppositeComponent", "(", ")", ")", ".", "thenReturn", "(", "new", "JTextField", "(", ")", ")", ";", "assertThat", "(", "dateValidator", ".", "hasGloballyLostFocus", "(", "focusEvent", ")", ",", "equalTo", "(", "true", ")", ")", ";", "}", "public", "void", "test_setDate_likeBefore", "(", ")", "throws", "ParseException", "{", "DateField", ".", "DateFieldGlobalFocusValidator", "globalFocusValidator", "=", "dateField", ".", "new", "DateFieldGlobalFocusValidator", "(", ")", ";", "dateField", ".", "addFocusListener", "(", "globalFocusValidator", ")", ";", "dayFieldTest", ".", "pressKey", "(", "Key", ".", "d2", ")", ";", "dayFieldTest", ".", "pressKey", "(", "Key", ".", "d5", ")", ";", "monthFieldTest", ".", "pressKey", "(", "Key", ".", "d1", ")", ";", "monthFieldTest", ".", "pressKey", "(", "Key", ".", "d2", ")", ";", "yearFieldTest", ".", "pressKey", "(", "Key", ".", "d2", ")", ";", "yearFieldTest", ".", "pressKey", "(", "Key", ".", "d0", ")", ";", "yearFieldTest", ".", "pressKey", "(", "Key", ".", "d0", ")", ";", "yearFieldTest", ".", "pressKey", "(", "Key", ".", "d1", ")", ";", "assertFalse", "(", "dateField", ".", "getDate", "(", ")", "==", "null", ")", ";", "Date", "expectedDate", "=", "convertInDate", "(", "\"25/12/2001\"", ")", ";", "assertTrue", "(", "expectedDate", ".", "equals", "(", "dateField", ".", "getDate", "(", ")", ")", ")", ";", "}", "public", "void", "test_enabledFields", "(", ")", "throws", "Exception", "{", "dateField", ".", "setEnabled", "(", "true", ",", "false", ")", ";", "assertEquals", "(", "false", ",", "dateField", ".", "getCalendarButton", "(", ")", ".", "isEnabled", "(", ")", ")", ";", "assertEquals", "(", "true", ",", "dateField", ".", "getDayField", "(", ")", ".", "isEnabled", "(", ")", ")", ";", "assertEquals", "(", "true", ",", "dateField", ".", "getMonthField", "(", ")", ".", "isEnabled", "(", ")", ")", ";", "assertEquals", "(", "true", ",", "dateField", ".", "getYearField", "(", ")", ".", "isEnabled", "(", ")", ")", ";", "dateField", ".", "setEnabled", "(", "false", ",", "true", ")", ";", "assertEquals", "(", "true", ",", "dateField", ".", "getCalendarButton", "(", ")", ".", "isEnabled", "(", ")", ")", ";", "assertEquals", "(", "false", ",", "dateField", ".", "getDayField", "(", ")", ".", "isEnabled", "(", ")", ")", ";", "assertEquals", "(", "false", ",", "dateField", ".", "getMonthField", "(", ")", ".", "isEnabled", "(", ")", ")", ";", "assertEquals", "(", "false", ",", "dateField", ".", "getYearField", "(", ")", ".", "isEnabled", "(", ")", ")", ";", "}", "public", "void", "test_actionListener", "(", ")", "throws", "Exception", "{", "dateField", ".", "setDate", "(", "new", "Date", "(", ")", ")", ";", "ActionListener", "actionListener", "=", "new", "ActionListener", "(", ")", "{", "public", "void", "actionPerformed", "(", "ActionEvent", "e", ")", "{", "log", ".", "call", "(", "\"\"", ",", "(", "(", "JComponent", ")", "e", ".", "getSource", "(", ")", ")", ".", "getName", "(", ")", ")", ";", "}", "}", ";", "dateField", ".", "addActionListener", "(", "actionListener", ")", ";", "(", "(", "JTextField", ")", "dayFieldTest", ".", "getAwtComponent", "(", ")", ")", ".", "postActionEvent", "(", ")", ";", "log", ".", "assertAndClear", "(", "\"\"", ")", ";", "(", "(", "JTextField", ")", "monthFieldTest", ".", "getAwtComponent", "(", ")", ")", ".", "postActionEvent", "(", ")", ";", "log", ".", "assertAndClear", "(", "\"\"", ")", ";", "(", "(", "JTextField", ")", "yearFieldTest", ".", "getAwtComponent", "(", ")", ")", ".", "postActionEvent", "(", ")", ";", "log", ".", "assertAndClear", "(", "\"\"", ")", ";", "dateField", ".", "setDate", "(", "null", ")", ";", "log", ".", "assertAndClear", "(", "\"\"", ")", ";", "dateField", ".", "removeActionListener", "(", "actionListener", ")", ";", "(", "(", "JTextField", ")", "dayFieldTest", ".", "getAwtComponent", "(", ")", ")", ".", "postActionEvent", "(", ")", ";", "(", "(", "JTextField", ")", "monthFieldTest", ".", "getAwtComponent", "(", ")", ")", ".", "postActionEvent", "(", ")", ";", "(", "(", "JTextField", ")", "yearFieldTest", ".", "getAwtComponent", "(", ")", ")", ".", "postActionEvent", "(", ")", ";", "dateField", ".", "setDate", "(", "null", ")", ";", "log", ".", "assertContent", "(", "\"\"", ")", ";", "}", "private", "static", "Date", "convertInDate", "(", "String", "value", ")", "throws", "ParseException", "{", "return", "new", "SimpleDateFormat", "(", "\"dd/MM/yyyy\"", ")", ".", "parse", "(", "value", ")", ";", "}", "private", "String", "getIntAsString", "(", "int", "number", ")", "{", "if", "(", "number", ">=", "10", ")", "{", "return", "\"\"", "+", "number", ";", "}", "else", "{", "return", "\"0\"", "+", "number", ";", "}", "}", "@", "Override", "protected", "void", "setUp", "(", ")", "throws", "Exception", "{", "super", ".", "setUp", "(", ")", ";", "initializeDateField", "(", "new", "DateField", "(", ")", ")", ";", "}", "private", "void", "initializeDateField", "(", "DateField", "field", ")", "{", "this", ".", "dateField", "=", "field", ";", "this", ".", "dateField", ".", "setDisplayingDayOfWeek", "(", "true", ")", ";", "dayFieldTest", "=", "new", "TextBox", "(", "this", ".", "dateField", ".", "getDayField", "(", ")", ")", ";", "monthFieldTest", "=", "new", "TextBox", "(", "this", ".", "dateField", ".", "getMonthField", "(", ")", ")", ";", "yearFieldTest", "=", "new", "TextBox", "(", "this", ".", "dateField", ".", "getYearField", "(", ")", ")", ";", "JFrame", "window", "=", "new", "JFrame", "(", ")", ";", "window", ".", "getContentPane", "(", ")", ".", "add", "(", "this", ".", "dateField", ")", ";", "}", "private", "static", "class", "JButtonThatMockGetLocationOnScreen", "extends", "JButton", "{", "@", "Override", "public", "Point", "getLocationOnScreen", "(", ")", "{", "return", "new", "Point", "(", "40", ",", "50", ")", ";", "}", "}", "}", "</s>" ]
991
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "date", ";", "import", "net", ".", "codjo", ".", "test", ".", "common", ".", "DateUtil", ";", "import", "net", ".", "codjo", ".", "test", ".", "release", ".", "task", ".", "gui", ".", "GuiConfigurationException", ";", "import", "net", ".", "codjo", ".", "test", ".", "release", ".", "task", ".", "gui", ".", "SetValueStep", ";", "import", "net", ".", "codjo", ".", "test", ".", "release", ".", "task", ".", "gui", ".", "metainfo", ".", "SetValueDescriptor", ";", "import", "java", ".", "awt", ".", "Component", ";", "import", "java", ".", "text", ".", "ParseException", ";", "import", "java", ".", "util", ".", "Date", ";", "public", "class", "DateFieldTestBehavior", "implements", "SetValueDescriptor", "{", "public", "void", "setValue", "(", "Component", "comp", ",", "SetValueStep", "step", ")", "{", "String", "value", "=", "step", ".", "getValue", "(", ")", ";", "try", "{", "Date", "date", "=", "DateUtil", ".", "createDate", "(", "value", ")", ";", "comp", ".", "requestFocusInWindow", "(", ")", ";", "(", "(", "DateField", ")", "comp", ")", ".", "setDate", "(", "date", ")", ";", "}", "catch", "(", "ParseException", "e", ")", "{", "throw", "new", "GuiConfigurationException", "(", "value", "+", "\"\"", ")", ";", "}", "}", "}", "</s>" ]
992
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "date", ";", "import", "java", ".", "awt", ".", "Point", ";", "import", "java", ".", "util", ".", "Calendar", ";", "import", "java", ".", "util", ".", "Date", ";", "import", "java", ".", "util", ".", "GregorianCalendar", ";", "import", "javax", ".", "swing", ".", "JButton", ";", "import", "javax", ".", "swing", ".", "JFrame", ";", "import", "org", ".", "uispec4j", ".", "Button", ";", "import", "org", ".", "uispec4j", ".", "TextBox", ";", "import", "org", ".", "uispec4j", ".", "Trigger", ";", "import", "org", ".", "uispec4j", ".", "UISpecTestCase", ";", "import", "org", ".", "uispec4j", ".", "Window", ";", "import", "org", ".", "uispec4j", ".", "interception", ".", "WindowHandler", ";", "import", "org", ".", "uispec4j", ".", "interception", ".", "WindowInterceptor", ";", "public", "class", "NoNullDateFieldTest", "extends", "UISpecTestCase", "{", "private", "static", "final", "Date", "NO_NULL", "=", "new", "GregorianCalendar", "(", "9999", ",", "GregorianCalendar", ".", "DECEMBER", ",", "31", ")", ".", "getTime", "(", ")", ";", "private", "NoNullDateField", "dateField", ";", "private", "TextBox", "dayFieldTest", ";", "private", "TextBox", "monthFieldTest", ";", "private", "TextBox", "yearFieldTest", ";", "public", "void", "test_noNull", "(", ")", "{", "assertTrue", "(", "dayFieldTest", ".", "textIsEmpty", "(", ")", ")", ";", "assertTrue", "(", "monthFieldTest", ".", "textIsEmpty", "(", ")", ")", ";", "assertTrue", "(", "yearFieldTest", ".", "textIsEmpty", "(", ")", ")", ";", "}", "public", "void", "test_notNullDate", "(", ")", "{", "dateField", ".", "setDate", "(", "null", ")", ";", "assertNotNull", "(", "dateField", ".", "getDate", "(", ")", ")", ";", "}", "public", "void", "test_noNullAfterSetDate", "(", ")", "{", "dateField", ".", "setDate", "(", "NO_NULL", ")", ";", "assertTrue", "(", "dayFieldTest", ".", "textIsEmpty", "(", ")", ")", ";", "assertTrue", "(", "monthFieldTest", ".", "textIsEmpty", "(", ")", ")", ";", "assertTrue", "(", "yearFieldTest", ".", "textIsEmpty", "(", ")", ")", ";", "dateField", ".", "setDate", "(", "null", ")", ";", "assertTrue", "(", "dayFieldTest", ".", "textIsEmpty", "(", ")", ")", ";", "assertTrue", "(", "monthFieldTest", ".", "textIsEmpty", "(", ")", ")", ";", "assertTrue", "(", "yearFieldTest", ".", "textIsEmpty", "(", ")", ")", ";", "Date", "birthday", "=", "new", "GregorianCalendar", "(", "1976", ",", "GregorianCalendar", ".", "DECEMBER", ",", "10", ")", ".", "getTime", "(", ")", ";", "dateField", ".", "setDate", "(", "birthday", ")", ";", "assertTrue", "(", "dayFieldTest", ".", "textEquals", "(", "\"10\"", ")", ")", ";", "assertTrue", "(", "monthFieldTest", ".", "textEquals", "(", "\"12\"", ")", ")", ";", "assertTrue", "(", "yearFieldTest", ".", "textEquals", "(", "\"1976\"", ")", ")", ";", "}", "public", "void", "test_openCalendarWithNoNull", "(", ")", "throws", "Exception", "{", "initializeDateField", "(", "new", "NoNullDateField", "(", "true", ",", "new", "JButtonThatMockGetLocationOnScreen", "(", ")", ")", ")", ";", "WindowInterceptor", ".", "init", "(", "new", "Trigger", "(", ")", "{", "public", "void", "run", "(", ")", "throws", "Exception", "{", "Button", "calendarButton", "=", "new", "Button", "(", "dateField", ".", "getCalendarButton", "(", ")", ")", ";", "calendarButton", ".", "click", "(", ")", ";", "}", "}", ")", ".", "process", "(", "new", "WindowHandler", "(", ")", "{", "@", "Override", "public", "Trigger", "process", "(", "Window", "window", ")", "throws", "Exception", "{", "return", "window", ".", "getButton", "(", "\"OK\"", ")", ".", "triggerClick", "(", ")", ";", "}", "}", ")", ".", "run", "(", ")", ";", "GregorianCalendar", "calendar", "=", "new", "GregorianCalendar", "(", ")", ";", "calendar", ".", "set", "(", "Calendar", ".", "MINUTE", ",", "0", ")", ";", "calendar", ".", "set", "(", "Calendar", ".", "SECOND", ",", "0", ")", ";", "calendar", ".", "set", "(", "Calendar", ".", "HOUR_OF_DAY", ",", "0", ")", ";", "calendar", ".", "set", "(", "Calendar", ".", "MILLISECOND", ",", "0", ")", ";", "assertEquals", "(", "calendar", ".", "getTime", "(", ")", ",", "dateField", ".", "getDate", "(", ")", ")", ";", "}", "public", "void", "test_setNoNullDate", "(", ")", "throws", "Exception", "{", "Date", "infiniteDate", "=", "new", "GregorianCalendar", "(", "8888", ",", "Calendar", ".", "FEBRUARY", ",", "5", ")", ".", "getTime", "(", ")", ";", "dateField", ".", "setNoNullDate", "(", "infiniteDate", ")", ";", "dateField", ".", "setDate", "(", "infiniteDate", ")", ";", "assertTrue", "(", "dayFieldTest", ".", "textIsEmpty", "(", ")", ")", ";", "assertTrue", "(", "monthFieldTest", ".", "textIsEmpty", "(", ")", ")", ";", "assertTrue", "(", "yearFieldTest", ".", "textIsEmpty", "(", ")", ")", ";", "}", "@", "Override", "protected", "void", "setUp", "(", ")", "throws", "Exception", "{", "super", ".", "setUp", "(", ")", ";", "initializeDateField", "(", "new", "NoNullDateField", "(", ")", ")", ";", "}", "private", "void", "initializeDateField", "(", "NoNullDateField", "dateField", ")", "{", "this", ".", "dateField", "=", "dateField", ";", "dateField", ".", "setDate", "(", "NO_NULL", ")", ";", "this", ".", "dateField", ".", "setName", "(", "\"dateField\"", ")", ";", "this", ".", "dateField", ".", "setDisplayingDayOfWeek", "(", "true", ")", ";", "dayFieldTest", "=", "new", "TextBox", "(", "this", ".", "dateField", ".", "getDayField", "(", ")", ")", ";", "monthFieldTest", "=", "new", "TextBox", "(", "this", ".", "dateField", ".", "getMonthField", "(", ")", ")", ";", "yearFieldTest", "=", "new", "TextBox", "(", "this", ".", "dateField", ".", "getYearField", "(", ")", ")", ";", "JFrame", "window", "=", "new", "JFrame", "(", ")", ";", "window", ".", "getContentPane", "(", ")", ".", "add", "(", "this", ".", "dateField", ")", ";", "}", "@", "Override", "protected", "void", "tearDown", "(", ")", "throws", "Exception", "{", "super", ".", "tearDown", "(", ")", ";", "}", "private", "static", "class", "JButtonThatMockGetLocationOnScreen", "extends", "JButton", "{", "@", "Override", "public", "Point", "getLocationOnScreen", "(", ")", "{", "return", "new", "Point", "(", "40", ",", "50", ")", ";", "}", "}", "}", "</s>" ]
993
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "number", ";", "import", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "AbstractJFCTestCase", ";", "import", "java", ".", "awt", ".", "BorderLayout", ";", "import", "java", ".", "awt", ".", "Color", ";", "import", "java", ".", "awt", ".", "FlowLayout", ";", "import", "java", ".", "awt", ".", "Font", ";", "import", "java", ".", "awt", ".", "event", ".", "ActionEvent", ";", "import", "java", ".", "awt", ".", "event", ".", "ActionListener", ";", "import", "java", ".", "awt", ".", "event", ".", "KeyEvent", ";", "import", "java", ".", "awt", ".", "event", ".", "WindowAdapter", ";", "import", "java", ".", "awt", ".", "event", ".", "WindowEvent", ";", "import", "java", ".", "beans", ".", "PropertyChangeEvent", ";", "import", "java", ".", "beans", ".", "PropertyChangeListener", ";", "import", "java", ".", "math", ".", "BigDecimal", ";", "import", "java", ".", "text", ".", "DecimalFormat", ";", "import", "java", ".", "text", ".", "DecimalFormatSymbols", ";", "import", "java", ".", "util", ".", "Locale", ";", "import", "javax", ".", "swing", ".", "BorderFactory", ";", "import", "javax", ".", "swing", ".", "JButton", ";", "import", "javax", ".", "swing", ".", "JFrame", ";", "import", "javax", ".", "swing", ".", "JLabel", ";", "import", "javax", ".", "swing", ".", "JTextField", ";", "import", "javax", ".", "swing", ".", "UIManager", ";", "import", "junit", ".", "extensions", ".", "jfcunit", ".", "JFCTestHelper", ";", "import", "junit", ".", "extensions", ".", "jfcunit", ".", "TestHelper", ";", "import", "junit", ".", "extensions", ".", "jfcunit", ".", "eventdata", ".", "KeyEventData", ";", "import", "junit", ".", "extensions", ".", "jfcunit", ".", "eventdata", ".", "StringEventData", ";", "public", "class", "NumberFieldTest", "extends", "AbstractJFCTestCase", "{", "private", "static", "final", "String", "TOOLTIP_HEADER", "=", "\"\"", ";", "private", "JFrame", "window", "=", "null", ";", "private", "NumberField", "field", ";", "private", "MockPropertyChangeListener", "mockPropChangeListener", ";", "private", "JTextField", "otherField", ";", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "JFrame", "wnd", "=", "new", "JFrame", "(", "\"\"", ")", ";", "final", "NumberField", "fld", "=", "new", "NumberField", "(", ")", ";", "fld", ".", "setApplyRendererInEditMode", "(", "true", ")", ";", "fld", ".", "setMaximumFractionDigits", "(", "3", ")", ";", "fld", ".", "setMaximumIntegerDigits", "(", "2", ")", ";", "fld", ".", "setMinValue", "(", "-", "2", ")", ";", "fld", ".", "setMaxValue", "(", "120000", ")", ";", "fld", ".", "setColumns", "(", "10", ")", ";", "fld", ".", "setRenderer", "(", "new", "NumberFieldRenderer", "(", "new", "DecimalFormat", "(", "\"\"", ")", ",", "fld", ".", "getFont", "(", ")", ".", "deriveFont", "(", "Font", ".", "ITALIC", ")", ",", "Color", ".", "lightGray", ",", "Color", ".", "blue", ",", "BorderFactory", ".", "createRaisedBevelBorder", "(", ")", ")", ")", ";", "wnd", ".", "getContentPane", "(", ")", ".", "setLayout", "(", "new", "FlowLayout", "(", "FlowLayout", ".", "CENTER", ",", "5", ",", "5", ")", ")", ";", "wnd", ".", "getContentPane", "(", ")", ".", "add", "(", "new", "JLabel", "(", "\"un", "label\"", ")", ")", ";", "wnd", ".", "getContentPane", "(", ")", ".", "add", "(", "fld", ")", ";", "wnd", ".", "getContentPane", "(", ")", ".", "add", "(", "new", "JLabel", "(", "\"\"", ")", ")", ";", "wnd", ".", "getContentPane", "(", ")", ".", "add", "(", "new", "JTextField", "(", "\"\"", ")", ")", ";", "NumberField", "field2", "=", "new", "NumberField", "(", ")", ";", "field2", ".", "setNumber", "(", "1234.56", ")", ";", "field2", ".", "setThousandsSeparatorOnRenderer", "(", "'", "'", ")", ";", "field2", ".", "setEditable", "(", "false", ")", ";", "wnd", ".", "getContentPane", "(", ")", ".", "add", "(", "new", "JLabel", "(", "\"\"", ")", ")", ";", "wnd", ".", "getContentPane", "(", ")", ".", "add", "(", "field2", ")", ";", "wnd", ".", "setSize", "(", "400", ",", "150", ")", ";", "wnd", ".", "setVisible", "(", "true", ")", ";", "wnd", ".", "addWindowListener", "(", "new", "WindowAdapter", "(", ")", "{", "@", "Override", "public", "void", "windowClosing", "(", "WindowEvent", "evt", ")", "{", "System", ".", "exit", "(", "0", ")", ";", "}", "}", ")", ";", "JButton", "button", "=", "new", "JButton", "(", ")", ";", "button", ".", "setText", "(", "\"BIP\"", ")", ";", "button", ".", "addActionListener", "(", "new", "ActionListener", "(", ")", "{", "public", "void", "actionPerformed", "(", "ActionEvent", "e", ")", "{", "fld", ".", "setNumber", "(", "12", ")", ";", "}", "}", ")", ";", "wnd", ".", "getContentPane", "(", ")", ".", "add", "(", "button", ")", ";", "wnd", ".", "pack", "(", ")", ";", "}", "public", "void", "test_event_PropertyChangeListener", "(", ")", "{", "field", ".", "addPropertyChangeListener", "(", "NumberField", ".", "NUMBER_PROPERTY", ",", "mockPropChangeListener", ")", ";", "field", ".", "setText", "(", "\"1123.5\"", ")", ";", "assertEquals", "(", "1", ",", "mockPropChangeListener", ".", "propChangeCalledTimes", ")", ";", "assertEquals", "(", "NumberField", ".", "NUMBER_PROPERTY", ",", "mockPropChangeListener", ".", "lastReceivedEvent", ".", "getPropertyName", "(", ")", ")", ";", "assertEquals", "(", "null", ",", "mockPropChangeListener", ".", "lastReceivedEvent", ".", "getOldValue", "(", ")", ")", ";", "assertEquals", "(", "\"1123.5\"", ",", "mockPropChangeListener", ".", "lastReceivedEvent", ".", "getNewValue", "(", ")", ".", "toString", "(", ")", ")", ";", "field", ".", "setNumber", "(", "new", "BigDecimal", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "2", ",", "mockPropChangeListener", ".", "propChangeCalledTimes", ")", ";", "field", ".", "setNumber", "(", "new", "BigDecimal", "(", "\"-3.5\"", ")", ")", ";", "assertEquals", "(", "3", ",", "mockPropChangeListener", ".", "propChangeCalledTimes", ")", ";", "}", "public", "void", "test_event_PropertyChangeListener_badinput", "(", ")", "{", "field", ".", "addPropertyChangeListener", "(", "NumberField", ".", "NUMBER_PROPERTY", ",", "mockPropChangeListener", ")", ";", "field", ".", "setMinValue", "(", "2", ")", ";", "field", ".", "setText", "(", "\"1\"", ")", ";", "assertEquals", "(", "\"1\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "0", ",", "mockPropChangeListener", ".", "propChangeCalledTimes", ")", ";", "field", ".", "setCaretPosition", "(", "1", ")", ";", "getHelper", "(", ")", ".", "sendString", "(", "new", "StringEventData", "(", "this", ",", "field", ",", "\"4\"", ")", ")", ";", "assertEquals", "(", "\"14\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "1", ",", "mockPropChangeListener", ".", "propChangeCalledTimes", ")", ";", "assertEquals", "(", "NumberField", ".", "NUMBER_PROPERTY", ",", "mockPropChangeListener", ".", "lastReceivedEvent", ".", "getPropertyName", "(", ")", ")", ";", "assertEquals", "(", "null", ",", "mockPropChangeListener", ".", "lastReceivedEvent", ".", "getOldValue", "(", ")", ")", ";", "assertEquals", "(", "\"14\"", ",", "mockPropChangeListener", ".", "lastReceivedEvent", ".", "getNewValue", "(", ")", ".", "toString", "(", ")", ")", ";", "getHelper", "(", ")", ".", "sendKeyAction", "(", "new", "KeyEventData", "(", "this", ",", "field", ",", "KeyEvent", ".", "VK_BACK_SPACE", ")", ")", ";", "assertEquals", "(", "\"1\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "2", ",", "mockPropChangeListener", ".", "propChangeCalledTimes", ")", ";", "assertEquals", "(", "NumberField", ".", "NUMBER_PROPERTY", ",", "mockPropChangeListener", ".", "lastReceivedEvent", ".", "getPropertyName", "(", ")", ")", ";", "assertEquals", "(", "\"14\"", ",", "mockPropChangeListener", ".", "lastReceivedEvent", ".", "getOldValue", "(", ")", ".", "toString", "(", ")", ")", ";", "assertEquals", "(", "null", ",", "mockPropChangeListener", ".", "lastReceivedEvent", ".", "getNewValue", "(", ")", ")", ";", "}", "public", "void", "test_gui_beginWithDot", "(", ")", "{", "getHelper", "(", ")", ".", "sendString", "(", "new", "StringEventData", "(", "this", ",", "field", ",", "\".\"", ")", ")", ";", "assertEquals", "(", "\"0.\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "\"0\"", ",", "field", ".", "getNumber", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "public", "void", "test_gui_maxFractionDigit", "(", ")", "{", "field", ".", "setMaximumFractionDigits", "(", "2", ")", ";", "field", ".", "setForeground", "(", "Color", ".", "blue", ")", ";", "field", ".", "setToolTipText", "(", "\"prevTooltip\"", ")", ";", "getHelper", "(", ")", ".", "sendString", "(", "new", "StringEventData", "(", "this", ",", "field", ",", "\"1.23\"", ")", ")", ";", "assertEquals", "(", "\"1.23\"", ",", "field", ".", "getNumber", "(", ")", ".", "toString", "(", ")", ")", ";", "getHelper", "(", ")", ".", "sendString", "(", "new", "StringEventData", "(", "this", ",", "field", ",", "\"4\"", ")", ")", ";", "assertEquals", "(", "\"1.234\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "null", ",", "field", ".", "getNumber", "(", ")", ")", ";", "assertEquals", "(", "TOOLTIP_HEADER", "+", "\"\"", ",", "field", ".", "getToolTipText", "(", ")", ")", ";", "assertEquals", "(", "Color", ".", "red", ",", "field", ".", "getForeground", "(", ")", ")", ";", "getHelper", "(", ")", ".", "sendKeyAction", "(", "new", "KeyEventData", "(", "this", ",", "field", ",", "KeyEvent", ".", "VK_BACK_SPACE", ")", ")", ";", "awtSleep", "(", ")", ";", "assertEquals", "(", "\"1.23\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "\"1.23\"", ",", "field", ".", "getNumber", "(", ")", ".", "toString", "(", ")", ")", ";", "assertEquals", "(", "\"prevTooltip\"", ",", "field", ".", "getToolTipText", "(", ")", ")", ";", "assertEquals", "(", "Color", ".", "blue", ",", "field", ".", "getForeground", "(", ")", ")", ";", "}", "public", "void", "test_gui_maxDigits_updateColor", "(", ")", "{", "field", ".", "setMaximumIntegerDigits", "(", "3", ")", ";", "field", ".", "setForeground", "(", "Color", ".", "blue", ")", ";", "field", ".", "setToolTipText", "(", "\"prevTooltip\"", ")", ";", "assertOverflow", "(", "\"4567\"", ")", ";", "assertEquals", "(", "null", ",", "field", ".", "getNumber", "(", ")", ")", ";", "assertEquals", "(", "TOOLTIP_HEADER", "+", "\"\"", ",", "field", ".", "getToolTipText", "(", ")", ")", ";", "getHelper", "(", ")", ".", "sendKeyAction", "(", "new", "KeyEventData", "(", "this", ",", "field", ",", "KeyEvent", ".", "VK_BACK_SPACE", ")", ")", ";", "awtSleep", "(", ")", ";", "assertEquals", "(", "\"456\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "\"prevTooltip\"", ",", "field", ".", "getToolTipText", "(", ")", ")", ";", "assertEquals", "(", "Color", ".", "blue", ",", "field", ".", "getForeground", "(", ")", ")", ";", "}", "public", "void", "test_gui_maxDigits_overflow", "(", ")", "throws", "Exception", "{", "field", ".", "setMaximumIntegerDigits", "(", "3", ")", ";", "field", ".", "setForeground", "(", "Color", ".", "blue", ")", ";", "assertOverflow", "(", "\"1234\"", ")", ";", "assertEquals", "(", "null", ",", "field", ".", "getNumber", "(", ")", ")", ";", "assertEquals", "(", "TOOLTIP_HEADER", "+", "\"\"", ",", "field", ".", "getToolTipText", "(", ")", ")", ";", "assertNotOverflow", "(", "\"123\"", ")", ";", "assertNotOverflow", "(", "\"123.23\"", ")", ";", "assertNotOverflow", "(", "\"-123.23\"", ")", ";", "assertNotOverflow", "(", "\"-123\"", ")", ";", "assertNotOverflow", "(", "\"-123.0\"", ")", ";", "assertOverflow", "(", "\"1234\"", ")", ";", "assertOverflow", "(", "\"1234.23\"", ")", ";", "assertOverflow", "(", "\"-1234.23\"", ")", ";", "assertOverflow", "(", "\"-1234\"", ")", ";", "}", "public", "void", "test_gui_color_after_set_number", "(", ")", "throws", "Exception", "{", "field", ".", "setMaximumIntegerDigits", "(", "3", ")", ";", "field", ".", "setForeground", "(", "Color", ".", "blue", ")", ";", "assertOverflow", "(", "\"1234\"", ")", ";", "transferFocus", "(", "field", ")", ";", "assertTrue", "(", "field", ".", "hasError", "(", ")", ")", ";", "field", ".", "setNumber", "(", "12", ")", ";", "assertNotOverflow", "(", "\"123\"", ")", ";", "}", "public", "void", "test_has_error", "(", ")", "throws", "Exception", "{", "field", ".", "setMaximumIntegerDigits", "(", "3", ")", ";", "field", ".", "setForeground", "(", "Color", ".", "blue", ")", ";", "assertOverflow", "(", "\"1234\"", ")", ";", "assertTrue", "(", "field", ".", "hasError", "(", ")", ")", ";", "assertNotNull", "(", "field", ".", "getErrorMessage", "(", ")", ")", ";", "assertNotOverflow", "(", "\"12\"", ")", ";", "assertFalse", "(", "field", ".", "hasError", "(", ")", ")", ";", "assertNull", "(", "field", ".", "getErrorMessage", "(", ")", ")", ";", "}", "private", "void", "assertNotOverflow", "(", "String", "number", ")", "{", "field", ".", "setNumber", "(", "null", ")", ";", "getHelper", "(", ")", ".", "sendString", "(", "new", "StringEventData", "(", "this", ",", "field", ",", "number", ")", ")", ";", "assertEquals", "(", "Color", ".", "blue", ",", "field", ".", "getForeground", "(", ")", ")", ";", "}", "private", "void", "assertOverflow", "(", "String", "number", ")", "{", "field", ".", "setNumber", "(", "null", ")", ";", "getHelper", "(", ")", ".", "sendString", "(", "new", "StringEventData", "(", "this", ",", "field", ",", "number", ")", ")", ";", "assertEquals", "(", "Color", ".", "red", ",", "field", ".", "getForeground", "(", ")", ")", ";", "}", "public", "void", "test_gui_maxValue", "(", ")", "{", "field", ".", "setMaxValue", "(", "2", ")", ";", "getHelper", "(", ")", ".", "sendString", "(", "new", "StringEventData", "(", "this", ",", "field", ",", "\"1.23\"", ")", ")", ";", "assertEquals", "(", "\"1.23\"", ",", "field", ".", "getNumber", "(", ")", ".", "toString", "(", ")", ")", ";", "field", ".", "setCaretPosition", "(", "1", ")", ";", "getHelper", "(", ")", ".", "sendString", "(", "new", "StringEventData", "(", "this", ",", "field", ",", "\"4\"", ")", ")", ";", "assertEquals", "(", "\"14.23\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "null", ",", "field", ".", "getNumber", "(", ")", ")", ";", "assertEquals", "(", "TOOLTIP_HEADER", "+", "\"\"", ",", "field", ".", "getToolTipText", "(", ")", ")", ";", "assertEquals", "(", "Color", ".", "red", ",", "field", ".", "getForeground", "(", ")", ")", ";", "getHelper", "(", ")", ".", "sendKeyAction", "(", "new", "KeyEventData", "(", "this", ",", "field", ",", "KeyEvent", ".", "VK_BACK_SPACE", ")", ")", ";", "assertEquals", "(", "\"1.23\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "\"1.23\"", ",", "field", ".", "getNumber", "(", ")", ".", "toString", "(", ")", ")", ";", "assertEquals", "(", "null", ",", "field", ".", "getToolTipText", "(", ")", ")", ";", "assertEquals", "(", "UIManager", ".", "getColor", "(", "\"\"", ")", ",", "field", ".", "getForeground", "(", ")", ")", ";", "}", "public", "void", "test_gui_minValue", "(", ")", "throws", "Exception", "{", "field", ".", "setMinValue", "(", "2", ")", ";", "getHelper", "(", ")", ".", "sendString", "(", "new", "StringEventData", "(", "this", ",", "field", ",", "\"1.23\"", ")", ")", ";", "assertEquals", "(", "\"1.23\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "null", ",", "field", ".", "getNumber", "(", ")", ")", ";", "assertEquals", "(", "TOOLTIP_HEADER", "+", "\"\"", ",", "field", ".", "getToolTipText", "(", ")", ")", ";", "assertEquals", "(", "Color", ".", "red", ",", "field", ".", "getForeground", "(", ")", ")", ";", "field", ".", "setCaretPosition", "(", "1", ")", ";", "getHelper", "(", ")", ".", "sendString", "(", "new", "StringEventData", "(", "this", ",", "field", ",", "\"4\"", ")", ")", ";", "assertEquals", "(", "\"14.23\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "\"14.23\"", ",", "field", ".", "getNumber", "(", ")", ".", "toString", "(", ")", ")", ";", "assertEquals", "(", "null", ",", "field", ".", "getToolTipText", "(", ")", ")", ";", "assertEquals", "(", "UIManager", ".", "getColor", "(", "\"\"", ")", ",", "field", ".", "getForeground", "(", ")", ")", ";", "}", "public", "void", "test_gui_numberOnly", "(", ")", "{", "getHelper", "(", ")", ".", "sendString", "(", "new", "StringEventData", "(", "this", ",", "field", ",", "\"1235.5\"", ")", ")", ";", "assertEquals", "(", "\"1235.5\"", ",", "field", ".", "getText", "(", ")", ")", ";", "getHelper", "(", ")", ".", "sendString", "(", "new", "StringEventData", "(", "this", ",", "field", ",", "\"bobo\"", ")", ")", ";", "assertEquals", "(", "\"1235.5\"", ",", "field", ".", "getText", "(", ")", ")", ";", "}", "public", "void", "test_gui_setNumber_null", "(", ")", "{", "field", ".", "setText", "(", "\"1\"", ")", ";", "field", ".", "setCaretPosition", "(", "1", ")", ";", "assertEquals", "(", "1", ",", "field", ".", "getCaretPosition", "(", ")", ")", ";", "getHelper", "(", ")", ".", "sendKeyAction", "(", "new", "KeyEventData", "(", "this", ",", "field", ",", "KeyEvent", ".", "VK_BACK_SPACE", ")", ")", ";", "assertEquals", "(", "null", ",", "field", ".", "getNumber", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "field", ".", "getText", "(", ")", ")", ";", "}", "public", "void", "test_rendererAndEdition", "(", ")", "throws", "Exception", "{", "Color", "previousBackground", "=", "field", ".", "getBackground", "(", ")", ";", "Color", "previousForeground", "=", "field", ".", "getForeground", "(", ")", ";", "Font", "previousFont", "=", "field", ".", "getFont", "(", ")", ";", "field", ".", "setRenderer", "(", "createPsychedelicRenderer", "(", ")", ")", ";", "setFocus", "(", "field", ")", ";", "field", ".", "setNumber", "(", "new", "Integer", "(", "\"1234\"", ")", ")", ";", "assertEquals", "(", "\"1234\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertFieldDisplayProperties", "(", "previousFont", ",", "previousForeground", ",", "previousBackground", ")", ";", "setFocus", "(", "otherField", ")", ";", "setFocus", "(", "field", ")", ";", "assertEquals", "(", "\"1234\"", ",", "field", ".", "getText", "(", ")", ")", ";", "}", "public", "void", "test_rendererAndDisplay", "(", ")", "throws", "Exception", "{", "final", "NumberFieldRenderer", "psychedelicRenderer", "=", "createPsychedelicRenderer", "(", ")", ";", "field", ".", "setRenderer", "(", "psychedelicRenderer", ")", ";", "editFieldAndMoveFocus", "(", "\"1234\"", ")", ";", "assertEquals", "(", "\"1.234,00\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertFieldDisplayPropertiesSameAs", "(", "psychedelicRenderer", ")", ";", "}", "public", "void", "test_applyRendererInEditMode", "(", ")", "throws", "Exception", "{", "field", ".", "setRenderer", "(", "new", "NumberFieldRenderer", "(", "new", "DecimalFormat", "(", "\"##0.###\"", ",", "new", "DecimalFormatSymbols", "(", "Locale", ".", "ENGLISH", ")", ")", ")", ")", ";", "field", ".", "setApplyRendererInEditMode", "(", "false", ")", ";", "editFieldAndMoveFocus", "(", "\"1234.1500000\"", ")", ";", "assertEquals", "(", "\"1234.15\"", ",", "field", ".", "getText", "(", ")", ")", ";", "setFocus", "(", "field", ")", ";", "assertEquals", "(", "\"1234.1500000\"", ",", "field", ".", "getText", "(", ")", ")", ";", "field", ".", "setApplyRendererInEditMode", "(", "true", ")", ";", "editFieldAndMoveFocus", "(", "\"2659.120000\"", ")", ";", "assertEquals", "(", "\"2659.12\"", ",", "field", ".", "getText", "(", ")", ")", ";", "setFocus", "(", "field", ")", ";", "assertEquals", "(", "\"2659.12\"", ",", "field", ".", "getText", "(", ")", ")", ";", "}", "public", "void", "test_noEditModeIfNotEditable", "(", ")", "throws", "Exception", "{", "field", ".", "setRenderer", "(", "new", "NumberFieldRenderer", "(", "new", "DecimalFormat", "(", "\"##0.###\"", ",", "new", "DecimalFormatSymbols", "(", "Locale", ".", "ENGLISH", ")", ")", ")", ")", ";", "editFieldAndMoveFocus", "(", "\"1234.1500000\"", ")", ";", "field", ".", "setEditable", "(", "false", ")", ";", "assertEquals", "(", "\"1234.15\"", ",", "field", ".", "getText", "(", ")", ")", ";", "setFocus", "(", "field", ")", ";", "assertEquals", "(", "\"1234.15\"", ",", "field", ".", "getText", "(", ")", ")", ";", "}", "public", "void", "test_setThousandsSeparatorOnRenderer", "(", ")", "{", "editFieldAndMoveFocus", "(", "\"1234\"", ")", ";", "assertEquals", "(", "\"1234\"", ",", "field", ".", "getText", "(", ")", ")", ";", "field", ".", "setThousandsSeparatorOnRenderer", "(", "'#'", ")", ";", "editFieldAndMoveFocus", "(", "\"1234\"", ")", ";", "assertEquals", "(", "\"1#234,00\"", ",", "field", ".", "getText", "(", ")", ")", ";", "final", "NumberFieldRenderer", "psychedelicRenderer", "=", "createPsychedelicRenderer", "(", ")", ";", "field", ".", "setRenderer", "(", "psychedelicRenderer", ")", ";", "editFieldAndMoveFocus", "(", "\"1234\"", ")", ";", "assertEquals", "(", "\"1.234,00\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertFieldDisplayPropertiesSameAs", "(", "psychedelicRenderer", ")", ";", "field", ".", "setThousandsSeparatorOnRenderer", "(", "'", "'", ")", ";", "editFieldAndMoveFocus", "(", "\"1234\"", ")", ";", "assertEquals", "(", "\"1", "234,00\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertFieldDisplayPropertiesSameAs", "(", "psychedelicRenderer", ")", ";", "}", "public", "void", "test_setSeparatorsOnRenderer", "(", ")", "{", "editFieldAndMoveFocus", "(", "\"1234\"", ")", ";", "assertEquals", "(", "\"1234\"", ",", "field", ".", "getText", "(", ")", ")", ";", "field", ".", "setSeparatorsOnRenderer", "(", "'#'", ",", "'*'", ")", ";", "editFieldAndMoveFocus", "(", "\"1234\"", ")", ";", "assertEquals", "(", "\"1#234*00\"", ",", "field", ".", "getText", "(", ")", ")", ";", "final", "NumberFieldRenderer", "psychedelicRenderer", "=", "createPsychedelicRenderer", "(", ")", ";", "field", ".", "setRenderer", "(", "psychedelicRenderer", ")", ";", "editFieldAndMoveFocus", "(", "\"1234\"", ")", ";", "assertEquals", "(", "\"1.234,00\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertFieldDisplayPropertiesSameAs", "(", "psychedelicRenderer", ")", ";", "field", ".", "setSeparatorsOnRenderer", "(", "'#'", ",", "'*'", ")", ";", "editFieldAndMoveFocus", "(", "\"1234\"", ")", ";", "assertEquals", "(", "\"1#234*00\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertFieldDisplayPropertiesSameAs", "(", "psychedelicRenderer", ")", ";", "field", ".", "setThousandsSeparatorOnRenderer", "(", "'-'", ")", ";", "editFieldAndMoveFocus", "(", "\"1234\"", ")", ";", "assertEquals", "(", "\"1-234*00\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertFieldDisplayPropertiesSameAs", "(", "psychedelicRenderer", ")", ";", "}", "public", "void", "test_applyDecimalFormat", "(", ")", "throws", "Exception", "{", "field", ".", "applyDecimalFormat", "(", "\"#,##0.00\"", ")", ";", "editFieldAndMoveFocus", "(", "\"1234.465\"", ")", ";", "assertEquals", "(", "\"1", "234.46\"", ",", "field", ".", "getText", "(", ")", ")", ";", "field", ".", "applyDecimalFormat", "(", "\"#,##0.00\"", ",", "':'", ",", "','", ")", ";", "editFieldAndMoveFocus", "(", "\"1234.465\"", ")", ";", "assertEquals", "(", "\"1:234,46\"", ",", "field", ".", "getText", "(", ")", ")", ";", "}", "private", "void", "editFieldAndMoveFocus", "(", "String", "newValue", ")", "{", "setFocus", "(", "field", ")", ";", "field", ".", "setNumber", "(", "new", "BigDecimal", "(", "newValue", ")", ")", ";", "setFocus", "(", "otherField", ")", ";", "}", "private", "void", "assertFieldDisplayProperties", "(", "Font", "expectedFont", ",", "Color", "expectedForeground", ",", "Color", "expectedBackground", ")", "{", "assertEquals", "(", "expectedBackground", ",", "field", ".", "getBackground", "(", ")", ")", ";", "assertEquals", "(", "expectedFont", ",", "field", ".", "getFont", "(", ")", ")", ";", "assertEquals", "(", "expectedForeground", ",", "field", ".", "getForeground", "(", ")", ")", ";", "}", "private", "void", "assertFieldDisplayPropertiesSameAs", "(", "NumberFieldRenderer", "expectedRender", ")", "{", "assertFieldDisplayProperties", "(", "expectedRender", ".", "getFont", "(", ")", ",", "expectedRender", ".", "getForeground", "(", ")", ",", "expectedRender", ".", "getBackground", "(", ")", ")", ";", "}", "public", "void", "test_prg_forceEditionMode", "(", ")", "{", "Color", "prevbackground", "=", "field", ".", "getBackground", "(", ")", ";", "Color", "prevforeground", "=", "field", ".", "getForeground", "(", ")", ";", "Font", "prevfont", "=", "field", ".", "getFont", "(", ")", ";", "field", ".", "setRenderer", "(", "createPsychedelicRenderer", "(", ")", ")", ";", "field", ".", "forceEditionMode", "(", "true", ")", ";", "setFocus", "(", "field", ")", ";", "field", ".", "setNumber", "(", "new", "Integer", "(", "\"1234\"", ")", ")", ";", "assertEquals", "(", "\"1234\"", ",", "field", ".", "getText", "(", ")", ")", ";", "setFocus", "(", "otherField", ")", ";", "assertEquals", "(", "\"1234\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "prevbackground", ",", "field", ".", "getBackground", "(", ")", ")", ";", "assertEquals", "(", "prevfont", ",", "field", ".", "getFont", "(", ")", ")", ";", "assertEquals", "(", "prevforeground", ",", "field", ".", "getForeground", "(", ")", ")", ";", "setFocus", "(", "field", ")", ";", "assertEquals", "(", "\"1234\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "prevbackground", ",", "field", ".", "getBackground", "(", ")", ")", ";", "assertEquals", "(", "prevfont", ",", "field", ".", "getFont", "(", ")", ")", ";", "assertEquals", "(", "prevforeground", ",", "field", ".", "getForeground", "(", ")", ")", ";", "}", "public", "void", "test_prg_setNumber", "(", ")", "{", "field", ".", "setText", "(", "\"1123.5\"", ")", ";", "assertEquals", "(", "\"1123.5\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "\"1123.5\"", ",", "field", ".", "getNumber", "(", ")", ".", "toString", "(", ")", ")", ";", "final", "String", "bigNb", "=", "\"\"", ";", "field", ".", "setNumber", "(", "new", "BigDecimal", "(", "bigNb", ")", ")", ";", "assertEquals", "(", "bigNb", ",", "field", ".", "getNumber", "(", ")", ".", "toString", "(", ")", ")", ";", "assertEquals", "(", "bigNb", ",", "field", ".", "getText", "(", ")", ")", ";", "field", ".", "setNumber", "(", "new", "BigDecimal", "(", "\"-3.5\"", ")", ")", ";", "assertEquals", "(", "\"-3.5\"", ",", "field", ".", "getNumber", "(", ")", ".", "toString", "(", ")", ")", ";", "assertEquals", "(", "\"-3.5\"", ",", "field", ".", "getText", "(", ")", ")", ";", "}", "public", "void", "test_prg_setNumber_NA", "(", ")", "{", "field", ".", "setText", "(", "\"\"", ")", ";", "assertEquals", "(", "null", ",", "field", ".", "getNumber", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "field", ".", "getText", "(", ")", ")", ";", "field", ".", "setNumber", "(", "null", ")", ";", "assertEquals", "(", "null", ",", "field", ".", "getNumber", "(", ")", ")", ";", "assertEquals", "(", "\"\"", ",", "field", ".", "getText", "(", ")", ")", ";", "}", "public", "void", "test_setText", "(", ")", "throws", "Exception", "{", "field", ".", "setText", "(", "\"1.618\"", ")", ";", "assertEquals", "(", "\"1.618\"", ",", "field", ".", "getNumber", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "public", "void", "test_setTextNull", "(", ")", "throws", "Exception", "{", "field", ".", "setText", "(", "\"\"", ")", ";", "assertNull", "(", "field", ".", "getNumber", "(", ")", ")", ";", "}", "public", "void", "test_validNumberExpression", "(", ")", "throws", "Exception", "{", "field", ".", "setValidInputNumberExpression", "(", "\"\\\\d*.?\\\\d{0,6}\"", ")", ";", "field", ".", "setText", "(", "\"123.123456\"", ")", ";", "assertEquals", "(", "\"123.123456\"", ",", "field", ".", "getNumber", "(", ")", ".", "toString", "(", ")", ")", ";", "field", ".", "setText", "(", "\"\"", ")", ";", "assertNull", "(", "field", ".", "getNumber", "(", ")", ")", ";", "}", "@", "Override", "protected", "void", "setUp", "(", ")", "{", "setHelper", "(", "new", "JFCTestHelper", "(", ")", ")", ";", "field", "=", "new", "NumberField", "(", ")", ";", "buildWindow", "(", ")", ";", "mockPropChangeListener", "=", "new", "MockPropertyChangeListener", "(", ")", ";", "setFocus", "(", "field", ")", ";", "}", "@", "Override", "protected", "void", "tearDown", "(", ")", "{", "TestHelper", ".", "disposeWindow", "(", "window", ",", "this", ")", ";", "window", "=", "null", ";", "TestHelper", ".", "cleanUp", "(", "this", ")", ";", "}", "private", "DecimalFormatSymbols", "buildPseudoFrenchSymbol", "(", ")", "{", "DecimalFormatSymbols", "pseudoFrenchSymbol", "=", "new", "DecimalFormatSymbols", "(", ")", ";", "pseudoFrenchSymbol", ".", "setDecimalSeparator", "(", "','", ")", ";", "pseudoFrenchSymbol", ".", "setGroupingSeparator", "(", "'.'", ")", ";", "return", "pseudoFrenchSymbol", ";", "}", "private", "void", "buildWindow", "(", ")", "{", "window", "=", "new", "JFrame", "(", "\"Test", "\"", "+", "getName", "(", ")", ")", ";", "otherField", "=", "new", "JTextField", "(", ")", ";", "window", ".", "getContentPane", "(", ")", ".", "add", "(", "otherField", ",", "BorderLayout", ".", "NORTH", ")", ";", "window", ".", "getContentPane", "(", ")", ".", "add", "(", "field", ",", "BorderLayout", ".", "CENTER", ")", ";", "window", ".", "pack", "(", ")", ";", "window", ".", "setVisible", "(", "true", ")", ";", "}", "private", "NumberFieldRenderer", "createPsychedelicRenderer", "(", ")", "{", "return", "new", "NumberFieldRenderer", "(", "new", "DecimalFormat", "(", "\"#,###.00\"", ",", "buildPseudoFrenchSymbol", "(", ")", ")", ",", "field", ".", "getFont", "(", ")", ".", "deriveFont", "(", "Font", ".", "ITALIC", ")", ",", "Color", ".", "yellow", ",", "Color", ".", "gray", ",", "null", ")", ";", "}", "private", "class", "MockPropertyChangeListener", "implements", "PropertyChangeListener", "{", "PropertyChangeEvent", "lastReceivedEvent", "=", "null", ";", "int", "propChangeCalledTimes", "=", "0", ";", "public", "void", "propertyChange", "(", "PropertyChangeEvent", "evt", ")", "{", "propChangeCalledTimes", "++", ";", "lastReceivedEvent", "=", "evt", ";", "}", "}", "}", "</s>" ]
994
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "number", ";", "import", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "AbstractJFCTestCase", ";", "import", "java", ".", "awt", ".", "BorderLayout", ";", "import", "java", ".", "awt", ".", "FlowLayout", ";", "import", "java", ".", "awt", ".", "event", ".", "WindowAdapter", ";", "import", "java", ".", "awt", ".", "event", ".", "WindowEvent", ";", "import", "java", ".", "math", ".", "BigDecimal", ";", "import", "javax", ".", "swing", ".", "JFrame", ";", "import", "javax", ".", "swing", ".", "JLabel", ";", "import", "javax", ".", "swing", ".", "JTextField", ";", "import", "junit", ".", "extensions", ".", "jfcunit", ".", "JFCTestHelper", ";", "import", "junit", ".", "extensions", ".", "jfcunit", ".", "TestHelper", ";", "import", "junit", ".", "extensions", ".", "jfcunit", ".", "eventdata", ".", "StringEventData", ";", "public", "class", "PercentageFieldTest", "extends", "AbstractJFCTestCase", "{", "private", "JFrame", "window", "=", "null", ";", "private", "PercentageField", "field", ";", "private", "JTextField", "otherField", ";", "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "JFrame", "wnd", "=", "new", "JFrame", "(", "\"\"", ")", ";", "PercentageField", "fld", "=", "new", "PercentageField", "(", "6", ")", ";", "fld", ".", "setColumns", "(", "10", ")", ";", "wnd", ".", "getContentPane", "(", ")", ".", "setLayout", "(", "new", "FlowLayout", "(", "FlowLayout", ".", "CENTER", ",", "5", ",", "5", ")", ")", ";", "wnd", ".", "getContentPane", "(", ")", ".", "add", "(", "new", "JLabel", "(", "\"un", "label\"", ")", ")", ";", "wnd", ".", "getContentPane", "(", ")", ".", "add", "(", "fld", ")", ";", "wnd", ".", "getContentPane", "(", ")", ".", "add", "(", "new", "JLabel", "(", "\"\"", ")", ")", ";", "wnd", ".", "getContentPane", "(", ")", ".", "add", "(", "new", "JTextField", "(", "\"\"", ")", ")", ";", "wnd", ".", "setSize", "(", "400", ",", "150", ")", ";", "wnd", ".", "setVisible", "(", "true", ")", ";", "wnd", ".", "addWindowListener", "(", "new", "WindowAdapter", "(", ")", "{", "@", "Override", "public", "void", "windowClosing", "(", "WindowEvent", "event", ")", "{", "System", ".", "exit", "(", "0", ")", ";", "}", "}", ")", ";", "}", "public", "void", "test_gui_badValue", "(", ")", "throws", "Exception", "{", "getHelper", "(", ")", ".", "sendString", "(", "new", "StringEventData", "(", "this", ",", "field", ",", "\"100\"", ")", ")", ";", "assertEquals", "(", "\"1.00\"", ",", "field", ".", "getNumber", "(", ")", ".", "toString", "(", ")", ")", ";", "field", ".", "setText", "(", "\"\"", ")", ";", "getHelper", "(", ")", ".", "sendString", "(", "new", "StringEventData", "(", "this", ",", "field", ",", "\"99.99\"", ")", ")", ";", "assertEquals", "(", "\"0.9999\"", ",", "field", ".", "getNumber", "(", ")", ".", "toString", "(", ")", ")", ";", "field", ".", "setText", "(", "\"\"", ")", ";", "getHelper", "(", ")", ".", "sendString", "(", "new", "StringEventData", "(", "this", ",", "field", ",", "\"101\"", ")", ")", ";", "assertEquals", "(", "null", ",", "field", ".", "getNumber", "(", ")", ")", ";", "field", ".", "setText", "(", "\"\"", ")", ";", "getHelper", "(", ")", ".", "sendString", "(", "new", "StringEventData", "(", "this", ",", "field", ",", "\"99.999\"", ")", ")", ";", "assertEquals", "(", "null", ",", "field", ".", "getNumber", "(", ")", ")", ";", "}", "public", "void", "test_gui_percentage", "(", ")", "throws", "Exception", "{", "getHelper", "(", ")", ".", "sendString", "(", "new", "StringEventData", "(", "this", ",", "field", ",", "\"50.54\"", ")", ")", ";", "assertEquals", "(", "\"50.54\"", ",", "field", ".", "getText", "(", ")", ")", ";", "assertEquals", "(", "\"0.5054\"", ",", "field", ".", "getNumber", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "public", "void", "test_prg_setNumber", "(", ")", "throws", "Exception", "{", "field", ".", "setNumber", "(", "new", "BigDecimal", "(", "\"0.5\"", ")", ")", ";", "assertEquals", "(", "\"0.5\"", ",", "field", ".", "getNumber", "(", ")", ".", "toString", "(", ")", ")", ";", "assertEquals", "(", "\"50\"", ",", "field", ".", "getText", "(", ")", ")", ";", "setFocus", "(", "otherField", ")", ";", "assertEquals", "(", "\"50,00", "%\"", ",", "field", ".", "getText", "(", ")", ")", ";", "}", "public", "void", "test_prg_setNumber_digit", "(", ")", "throws", "Exception", "{", "TestHelper", ".", "disposeWindow", "(", "window", ",", "this", ")", ";", "field", "=", "new", "PercentageField", "(", "9", ")", ";", "initWindowForTest", "(", ")", ";", "field", ".", "setNumber", "(", "new", "BigDecimal", "(", "\"0.5\"", ")", ")", ";", "assertEquals", "(", "\"0.5\"", ",", "field", ".", "getNumber", "(", ")", ".", "toString", "(", ")", ")", ";", "assertEquals", "(", "\"50\"", ",", "field", ".", "getText", "(", ")", ")", ";", "setFocus", "(", "otherField", ")", ";", "assertEquals", "(", "\"50,0000000", "%\"", ",", "field", ".", "getText", "(", ")", ")", ";", "}", "@", "Override", "protected", "void", "setUp", "(", ")", "throws", "Exception", "{", "super", ".", "setUp", "(", ")", ";", "setHelper", "(", "new", "JFCTestHelper", "(", ")", ")", ";", "field", "=", "new", "PercentageField", "(", ")", ";", "initWindowForTest", "(", ")", ";", "}", "@", "Override", "protected", "void", "tearDown", "(", ")", "throws", "Exception", "{", "TestHelper", ".", "disposeWindow", "(", "window", ",", "this", ")", ";", "TestHelper", ".", "cleanUp", "(", "this", ")", ";", "window", "=", "null", ";", "super", ".", "tearDown", "(", ")", ";", "}", "private", "void", "initWindowForTest", "(", ")", "{", "buildWindow", "(", ")", ";", "setFocus", "(", "field", ")", ";", "}", "private", "void", "buildWindow", "(", ")", "{", "window", "=", "new", "JFrame", "(", "\"Test", "\"", "+", "getName", "(", ")", ")", ";", "otherField", "=", "new", "JTextField", "(", ")", ";", "window", ".", "getContentPane", "(", ")", ".", "add", "(", "otherField", ",", "BorderLayout", ".", "NORTH", ")", ";", "window", ".", "getContentPane", "(", ")", ".", "add", "(", "field", ",", "BorderLayout", ".", "CENTER", ")", ";", "window", ".", "pack", "(", ")", ";", "window", ".", "setVisible", "(", "true", ")", ";", "}", "}", "</s>" ]
995
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "number", ";", "import", "javax", ".", "swing", ".", "DefaultListCellRenderer", ";", "import", "javax", ".", "swing", ".", "JList", ";", "import", "javax", ".", "swing", ".", "JTable", ";", "import", "javax", ".", "swing", ".", "table", ".", "DefaultTableCellRenderer", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "public", "class", "PercentRendererTest", "extends", "TestCase", "{", "public", "void", "test_getTableCellRendererComponent", "(", ")", "throws", "Exception", "{", "JTable", "table", "=", "new", "JTable", "(", ")", ";", "PercentRenderer", "renderer", "=", "new", "PercentRenderer", "(", "new", "DefaultTableCellRenderer", "(", ")", ")", ";", "renderer", ".", "getTableCellRendererComponent", "(", "table", ",", "\"0\"", ",", "false", ",", "false", ",", "0", ",", "0", ")", ";", "}", "public", "void", "test_getTableCellRendererComponent_Error", "(", ")", "throws", "Exception", "{", "JTable", "table", "=", "new", "JTable", "(", ")", ";", "PercentRenderer", "renderer", "=", "new", "PercentRenderer", "(", "new", "DefaultListCellRenderer", "(", ")", ")", ";", "try", "{", "renderer", ".", "getTableCellRendererComponent", "(", "table", ",", "\"0\"", ",", "false", ",", "false", ",", "0", ",", "0", ")", ";", "fail", "(", "\"\"", ")", ";", "}", "catch", "(", "IllegalArgumentException", "exception", ")", "{", "assertEquals", "(", "PercentRenderer", ".", "LIST_NOT_TABLE_ERROR", ",", "exception", ".", "getLocalizedMessage", "(", ")", ")", ";", "}", "}", "public", "void", "test_getListCellRendererComponent", "(", ")", "throws", "Exception", "{", "JList", "list", "=", "new", "JList", "(", ")", ";", "PercentRenderer", "renderer", "=", "new", "PercentRenderer", "(", "new", "DefaultListCellRenderer", "(", ")", ")", ";", "renderer", ".", "getListCellRendererComponent", "(", "list", ",", "\"0\"", ",", "0", ",", "false", ",", "false", ")", ";", "}", "public", "void", "test_getListCellRendererComponent_Error", "(", ")", "throws", "Exception", "{", "JList", "list", "=", "new", "JList", "(", ")", ";", "PercentRenderer", "renderer", "=", "new", "PercentRenderer", "(", "new", "DefaultTableCellRenderer", "(", ")", ")", ";", "try", "{", "renderer", ".", "getListCellRendererComponent", "(", "list", ",", "\"0\"", ",", "0", ",", "false", ",", "false", ")", ";", "fail", "(", "\"\"", ")", ";", "}", "catch", "(", "IllegalArgumentException", "exception", ")", "{", "assertEquals", "(", "PercentRenderer", ".", "TABLE_NOT_LIST_ERROR", ",", "exception", ".", "getLocalizedMessage", "(", ")", ")", ";", "}", "}", "}", "</s>" ]
996
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "i18n", ";", "import", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "util", ".", "ErrorDialog", ";", "import", "net", ".", "codjo", ".", "i18n", ".", "common", ".", "Language", ";", "import", "net", ".", "codjo", ".", "i18n", ".", "common", ".", "TranslationManager", ";", "import", "net", ".", "codjo", ".", "i18n", ".", "gui", ".", "TranslationNotifier", ";", "public", "class", "InternationalizationTestUtil", "{", "private", "InternationalizationTestUtil", "(", ")", "{", "}", "public", "static", "void", "initErrorDialogTranslationBackpack", "(", ")", "{", "TranslationManager", "translationManager", "=", "new", "TranslationManager", "(", ")", ";", "TranslationNotifier", "translationNotifier", "=", "new", "TranslationNotifier", "(", "Language", ".", "FR", ",", "translationManager", ")", ";", "InternationalizationUtil", ".", "registerBundlesIfNeeded", "(", "translationManager", ")", ";", "ErrorDialog", ".", "setTranslationBackpack", "(", "translationManager", ",", "translationNotifier", ")", ";", "}", "}", "</s>" ]
997
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "progressbar", ";", "import", "junit", ".", "framework", ".", "TestCase", ";", "public", "class", "ProgressBarLabelTest", "extends", "TestCase", "{", "private", "ProgressBarLabel", "progressBarLabel", ";", "public", "void", "test_setText", "(", ")", "{", "String", "text", "=", "\"contenu\"", ";", "progressBarLabel", ".", "setText", "(", "text", ")", ";", "assertEquals", "(", "text", ",", "progressBarLabel", ".", "getText", "(", ")", ")", ";", "}", "protected", "void", "setUp", "(", ")", "throws", "Exception", "{", "progressBarLabel", "=", "new", "ProgressBarLabel", "(", ")", ";", "}", "protected", "void", "tearDown", "(", ")", "{", "progressBarLabel", "=", "null", ";", "}", "}", "</s>" ]
998
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ";", "import", "java", ".", "awt", ".", "Component", ";", "import", "junit", ".", "extensions", ".", "jfcunit", ".", "JFCTestCase", ";", "public", "abstract", "class", "AbstractJFCTestCase", "extends", "JFCTestCase", "{", "public", "void", "setFocus", "(", "Component", "component", ")", "{", "long", "start", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "do", "{", "component", ".", "requestFocusInWindow", "(", ")", ";", "flushAWT", "(", ")", ";", "}", "while", "(", "!", "component", ".", "hasFocus", "(", ")", "&&", "System", ".", "currentTimeMillis", "(", ")", "-", "start", "<", "500", ")", ";", "assertTrue", "(", "\"\"", ",", "component", ".", "hasFocus", "(", ")", ")", ";", "}", "public", "void", "transferFocus", "(", "Component", "component", ")", "{", "long", "start", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "do", "{", "component", ".", "transferFocus", "(", ")", ";", "flushAWT", "(", ")", ";", "}", "while", "(", "component", ".", "hasFocus", "(", ")", "&&", "System", ".", "currentTimeMillis", "(", ")", "-", "start", "<", "500", ")", ";", "assertTrue", "(", "\"\"", ",", "!", "component", ".", "hasFocus", "(", ")", ")", ";", "}", "}", "</s>" ]
999
[ "<s>", "package", "net", ".", "codjo", ".", "gui", ".", "toolkit", ".", "waiting", ";", "import", "net", ".", "codjo", ".", "test", ".", "common", ".", "LogString", ";", "import", "java", ".", "awt", ".", "event", ".", "ActionEvent", ";", "import", "java", ".", "awt", ".", "event", ".", "ActionListener", ";", "import", "javax", ".", "swing", ".", "JButton", ";", "import", "javax", ".", "swing", ".", "JFrame", ";", "import", "javax", ".", "swing", ".", "JTextField", ";", "import", "org", ".", "uispec4j", ".", "Button", ";", "import", "org", ".", "uispec4j", ".", "UISpecTestCase", ";", "public", "class", "WaitingPanelTest", "extends", "UISpecTestCase", "{", "private", "WaitingPanel", "waitingPanel", ";", "private", "JFrame", "frame", "=", "new", "JFrame", "(", ")", ";", "private", "JButton", "executeButton", "=", "new", "JButton", "(", ")", ";", "private", "JTextField", "textField", "=", "new", "JTextField", "(", ")", ";", "private", "LogString", "log", "=", "new", "LogString", "(", ")", ";", "public", "void", "test_noWaitingPanelDisplayed", "(", ")", "throws", "Exception", "{", "executeButton", ".", "addActionListener", "(", "new", "ActionListener", "(", ")", "{", "public", "void", "actionPerformed", "(", "ActionEvent", "evt", ")", "{", "waitingPanel", ".", "exec", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "textField", ".", "setText", "(", "\"Don", "Diego\"", ")", ";", "}", "}", ")", ";", "}", "}", ")", ";", "final", "Button", "button", "=", "new", "Button", "(", "executeButton", ")", ";", "button", ".", "click", "(", ")", ";", "assertFalse", "(", "log", ".", "getContent", "(", ")", ".", "contains", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "\"Don", "Diego\"", ",", "textField", ".", "getText", "(", ")", ")", ";", "}", "public", "void", "test_waitingPanelDisplayed", "(", ")", "throws", "Exception", "{", "executeButton", ".", "addActionListener", "(", "new", "ActionListener", "(", ")", "{", "public", "void", "actionPerformed", "(", "ActionEvent", "evt", ")", "{", "waitingPanel", ".", "exec", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "2000", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "textField", ".", "setText", "(", "\"Zorro\"", ")", ";", "}", "}", ")", ";", "}", "}", ")", ";", "Button", "button", "=", "new", "Button", "(", "executeButton", ")", ";", "button", ".", "click", "(", ")", ";", "Thread", ".", "sleep", "(", "3000", ")", ";", "assertTrue", "(", "log", ".", "getContent", "(", ")", ".", "contains", "(", "\"\"", ")", ")", ";", "assertEquals", "(", "\"Zorro\"", ",", "textField", ".", "getText", "(", ")", ")", ";", "}", "@", "Override", "protected", "void", "setUp", "(", ")", "throws", "Exception", "{", "super", ".", "setUp", "(", ")", ";", "waitingPanel", "=", "new", "WaitingPanelMock", "(", "log", ")", ";", "frame", ".", "setGlassPane", "(", "waitingPanel", ")", ";", "frame", ".", "add", "(", "executeButton", ")", ";", "log", ".", "clear", "(", ")", ";", "}", "private", "class", "WaitingPanelMock", "extends", "WaitingPanel", "{", "private", "LogString", "log", ";", "private", "WaitingPanelMock", "(", "LogString", "log", ")", "{", "this", ".", "log", "=", "log", ";", "}", "@", "Override", "public", "void", "startAnimation", "(", ")", "{", "log", ".", "call", "(", "\"\"", ")", ";", "super", ".", "startAnimation", "(", ")", ";", "}", "}", "}", "</s>" ]