1 19 package org.openide.filesystems; 20 21 import java.io.IOException ; 22 import org.openide.util.Exceptions; 23 24 25 29 final class FSException extends IOException { 30 31 32 34 35 private Object [] args; 36 37 38 private FSException(String resource, Object [] args) { 39 super(resource); 40 this.args = args; 41 } 42 43 45 public String getMessage() { 46 return " " + getLocalizedMessage(); } 48 49 51 public String getLocalizedMessage() { 52 String res = super.getMessage(); 53 String format = FileSystem.getString(res); 54 55 if (args != null) { 56 return java.text.MessageFormat.format(format, args); 57 } else { 58 return format; 59 } 60 } 61 62 66 public static void io(String resource) throws IOException { 67 FSException fsExc = new FSException(resource, null); 68 Exceptions.attachLocalizedMessage(fsExc, fsExc.getLocalizedMessage()); 69 throw fsExc; 70 } 71 72 public static void io(String resource, Object [] args) 73 throws IOException { 74 FSException fsExc = new FSException(resource, args); 75 Exceptions.attachLocalizedMessage(fsExc, fsExc.getLocalizedMessage()); 76 throw fsExc; 77 } 78 79 public static void io(String resource, Object arg1) 80 throws IOException { 81 FSException fsExc = new FSException(resource, new Object [] { arg1 }); 82 Exceptions.attachLocalizedMessage(fsExc, fsExc.getLocalizedMessage()); 83 throw fsExc; 84 } 85 86 public static void io(String resource, Object arg1, Object arg2) 87 throws IOException { 88 FSException fsExc = new FSException(resource, new Object [] { arg1, arg2 }); 89 Exceptions.attachLocalizedMessage(fsExc, fsExc.getLocalizedMessage()); 90 throw fsExc; 91 } 92 93 public static void io(String resource, Object arg1, Object arg2, Object arg3) 94 throws IOException { 95 FSException fsExc = new FSException(resource, new Object [] { arg1, arg2, arg3 }); 96 Exceptions.attachLocalizedMessage(fsExc, fsExc.getLocalizedMessage()); 97 throw fsExc; 98 } 99 100 public static void io(String resource, Object arg1, Object arg2, Object arg3, Object arg4) 101 throws IOException { 102 FSException fsExc = new FSException(resource, new Object [] { arg1, arg2, arg3, arg4 }); 103 Exceptions.attachLocalizedMessage(fsExc, fsExc.getLocalizedMessage()); 104 throw fsExc; 105 } 106 } 107 | Popular Tags |