コード例 #1
0
 public static File appendSuffix(File file, String suffix) throws IOException {
   if (file == null) {
     Throw.ioe(TAG, "File is null.");
     return null; // To make static analysis happy
   }
   checkValidSuffix(suffix);
   if (file.getAbsolutePath().endsWith(suffix))
     Throw.ioe(TAG, "File already has suffix %s: %s", suffix, file.getAbsolutePath());
   return new File(file.getAbsolutePath() + suffix);
 }
コード例 #2
0
ファイル: PrintOn.java プロジェクト: akuhn/ch.akuhn.util
 private boolean overridesToString(Object object) {
   try {
     Class<?> type = object.getClass();
     Method toString = type.getMethod("toString");
     return toString.getDeclaringClass() != Object.class;
   } catch (SecurityException ex) {
     throw Throw.exception(ex);
   } catch (NoSuchMethodException ex) {
     throw Throw.exception(ex);
   }
 }
コード例 #3
0
 public static void checkReadableDirectory(File dir) throws IOException {
   if (dir == null) {
     Throw.ioe(TAG, "Directory object File is null.");
   } else {
     if (!dir.exists()) Throw.ioe(TAG, "Directory does not exist: " + dir.getAbsolutePath());
     if (!dir.isDirectory()) Throw.ioe(TAG, "Not a directory: " + dir.getAbsolutePath());
     if (!dir.canRead()) Throw.ioe(TAG, "No read permission: " + dir.getAbsolutePath());
     if (!dir.canExecute())
       Throw.ioe(TAG, "No execute (access files) permission: " + dir.getAbsolutePath());
   }
 }
コード例 #4
0
 public static File replaceSuffix(File file, String newSuffix) throws IOException {
   if (file == null) {
     Throw.ioe(TAG, "File is null.");
     return null; // To make static analysis happy
   }
   checkValidSuffix(newSuffix);
   String currentSuffix = getSuffix(file);
   if (newSuffix.equals(currentSuffix))
     Throw.ioe(TAG, "File already has suffix %s: %s", newSuffix, file.getAbsolutePath());
   String path = file.getAbsolutePath();
   String withoutSuffix = StringUtils.removeEnd(path, currentSuffix);
   return appendSuffix(new File(withoutSuffix), newSuffix);
 }
コード例 #5
0
ファイル: Factory.java プロジェクト: akuhn/ch.akuhn.util
 public T create(Object obj1, Object obj2, Object obj3) {
   try {
     return takeThree.newInstance(obj1, obj2, obj3);
   } catch (Exception ex) {
     throw Throw.exception(ex);
   }
 }
コード例 #6
0
ファイル: Factory.java プロジェクト: akuhn/ch.akuhn.util
 public T create(Object obj) {
   try {
     return takeOne.newInstance(obj);
   } catch (Exception ex) {
     throw Throw.exception(ex);
   }
 }
コード例 #7
0
ファイル: PrintOn.java プロジェクト: akuhn/ch.akuhn.util
 public final PrintOn append(CharSequence string, int start, int end) {
   try {
     buf.append(string, start, end);
   } catch (IOException ex) {
     throw Throw.exception(ex);
   }
   return this;
 }
コード例 #8
0
ファイル: PrintOn.java プロジェクト: akuhn/ch.akuhn.util
 public final PrintOn append(char c) {
   try {
     buf.append(c);
   } catch (IOException ex) {
     throw Throw.exception(ex);
   }
   return this;
 }
コード例 #9
0
ファイル: PrintOn.java プロジェクト: akuhn/ch.akuhn.util
 public final void close() {
   if (buf instanceof Closeable) {
     try {
       ((Closeable) buf).close();
     } catch (IOException ex) {
       throw Throw.exception(ex);
     }
   }
 }
コード例 #10
0
 public static String getSuffix(File file) throws IOException {
   if (file == null) {
     Throw.ioe(TAG, "File is null.");
     return null; // To make static analysis happy
   }
   String path = file.getAbsolutePath();
   String suffix = "." + StringUtils.substringAfterLast(path, ".");
   checkValidSuffix(suffix);
   return suffix;
 }
コード例 #11
0
 /** Returns a subdirectory of outer. Creates it if necesssary and checks for write permissions. */
 public static synchronized File getSubdir(File outer, String name) throws IOException {
   File dir = new File(outer, name);
   if (!dir.exists()) {
     if (!dir.mkdirs()) {
       Throw.ioe(TAG, "Failed to create " + dir.getAbsolutePath());
     }
   }
   checkWritableDirectory(dir);
   return dir;
 }
コード例 #12
0
ファイル: Main.java プロジェクト: kstv/DexHunter
  public void run() {
    InstField instField = new InstField();
    instField.run();

    StaticField.run();

    IntMath.run();
    FloatMath.run();
    Compare.run();

    Monitor.run();
    Switch.run();
    Array.run();
    Classes.run();
    Goto.run();
    MethodCall.run();
    Throw.run();

    try {
      UnresTest1.run();
    } catch (VerifyError ve) {
      System.out.println("Caught: " + ve);
    }
    try {
      UnresTest1.run();
    } catch (VerifyError ve) {
      System.out.println("Caught (retry): " + ve);
    }

    try {
      UnresTest2.run();
    } catch (VerifyError ve) {
      System.out.println("Caught: " + ve);
    } catch (Throwable th) {
      // We and the RI throw ClassNotFoundException, but that isn't declared so javac
      // won't let us try to catch it.
      th.printStackTrace();
    }
    InternedString.run();
  }
コード例 #13
0
 public static void checkValidSuffix(String suffix) throws IOException {
   if (suffix == null) {
     Throw.ioe(TAG, "Suffix is null.");
   } else {
     if ("".equals(suffix)) Throw.ioe(TAG, "Suffix is empty string.");
     if (!suffix.startsWith(".")) Throw.ioe(TAG, "Suffix must start with a dot: \"%s\".", suffix);
     if (suffix.length() < 2)
       Throw.ioe(TAG, "Suffix \"%s\" is too short. Must be (dot)[a-z]{1,10}.", suffix);
     if (suffix.length() > 11)
       Throw.ioe(TAG, "Suffix \"%s\" is too long. Must be (dot)[a-z]{1,10}.", suffix);
     if (!StringUtils.containsOnly(
         suffix.substring(1, suffix.length()), "abcdefghijklmnopqrstuvwxyz"))
       Throw.ioe(
           TAG, "Suffix \"%s\" contains weird characters. Must be (dot)[a-z]{1,10}.", suffix);
   }
 }
コード例 #14
0
ファイル: Cgen.java プロジェクト: Evoludo/InsenseCompilerUnix
 public void throw_clause_end() {
   IExceptionBlock exception_code = findNearestEnclosingTryExceptBlock();
   if (exception_code != null) {
     ((Throw) currentCode).setInTryBlock(true);
   }
 }
コード例 #15
0
 public static void checkWritableDirectory(File dir) throws IOException {
   checkReadableDirectory(dir);
   if (!dir.canWrite()) Throw.ioe(TAG, "No write permission: " + dir.getAbsolutePath());
 }