Cleanup (formatting; annotations)
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>
Fri, 5 Dec 2014 19:35:10 +0000 (20:35 +0100)
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>
Mon, 8 Dec 2014 10:42:43 +0000 (11:42 +0100)
platform/util/src/com/intellij/util/io/URLUtil.java

index f46b7a1884d005f2855ca342080074c2776b8f35..2799631f102aafab3ba89c432b4f4bba31adfd1c 100644 (file)
@@ -21,7 +21,6 @@ import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.CharsetToolkit;
 import com.intellij.util.Base64Converter;
 import gnu.trove.TIntArrayList;
 import com.intellij.openapi.vfs.CharsetToolkit;
 import com.intellij.util.Base64Converter;
 import gnu.trove.TIntArrayList;
-import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -50,23 +49,23 @@ public class URLUtil {
   private URLUtil() { }
 
   /**
   private URLUtil() { }
 
   /**
-   * Opens a url stream. The semantics is the sames as {@link java.net.URL#openStream()}. The
+   * Opens a url stream. The semantics is the sames as {@link URL#openStream()}. The
    * separate method is needed, since jar URLs open jars via JarFactory and thus keep them
    * mapped into memory.
    */
   @NotNull
   public static InputStream openStream(@NotNull URL url) throws IOException {
    * separate method is needed, since jar URLs open jars via JarFactory and thus keep them
    * mapped into memory.
    */
   @NotNull
   public static InputStream openStream(@NotNull URL url) throws IOException {
-    @NonNls String protocol = url.getProtocol();
+    String protocol = url.getProtocol();
     return protocol.equals(JAR_PROTOCOL) ? openJarStream(url) : url.openStream();
   }
 
   @NotNull
     return protocol.equals(JAR_PROTOCOL) ? openJarStream(url) : url.openStream();
   }
 
   @NotNull
-  public static InputStream openResourceStream(final URL url) throws IOException {
+  public static InputStream openResourceStream(@NotNull URL url) throws IOException {
     try {
       return openStream(url);
     }
     try {
       return openStream(url);
     }
-    catch(FileNotFoundException ex) {
-      @NonNls final String protocol = url.getProtocol();
+    catch (FileNotFoundException ex) {
+      String protocol = url.getProtocol();
       String file = null;
       if (protocol.equals(FILE_PROTOCOL)) {
         file = url.getFile();
       String file = null;
       if (protocol.equals(FILE_PROTOCOL)) {
         file = url.getFile();
@@ -74,7 +73,7 @@ public class URLUtil {
       else if (protocol.equals(JAR_PROTOCOL)) {
         int pos = url.getFile().indexOf("!");
         if (pos >= 0) {
       else if (protocol.equals(JAR_PROTOCOL)) {
         int pos = url.getFile().indexOf("!");
         if (pos >= 0) {
-          file = url.getFile().substring(pos+1);
+          file = url.getFile().substring(pos + 1);
         }
       }
       if (file != null && file.startsWith("/")) {
         }
       }
       if (file != null && file.startsWith("/")) {
@@ -100,18 +99,18 @@ public class URLUtil {
     }
 
     return new FilterInputStream(zipFile.getInputStream(zipEntry)) {
     }
 
     return new FilterInputStream(zipFile.getInputStream(zipEntry)) {
-        @Override
-        public void close() throws IOException {
-          super.close();
-          zipFile.close();
-        }
-      };
+      @Override
+      public void close() throws IOException {
+        super.close();
+        zipFile.close();
+      }
+    };
   }
 
   /**
    * Splits .jar URL along a separator and strips "jar" and "file" prefixes if any.
    * Returns a pair of path to a .jar file and entry name inside a .jar, or null if the URL does not contain a separator.
   }
 
   /**
    * Splits .jar URL along a separator and strips "jar" and "file" prefixes if any.
    * Returns a pair of path to a .jar file and entry name inside a .jar, or null if the URL does not contain a separator.
-   *
+   * <p/>
    * E.g. "jar:file:///path/to/jar.jar!/resource.xml" is converted into ["/path/to/jar.jar", "resource.xml"].
    */
   @Nullable
    * E.g. "jar:file:///path/to/jar.jar!/resource.xml" is converted into ["/path/to/jar.jar", "resource.xml"].
    */
   @Nullable
@@ -180,13 +179,10 @@ public class URLUtil {
   }
 
   private static int decode(char c) {
   }
 
   private static int decode(char c) {
-      if ((c >= '0') && (c <= '9'))
-          return c - '0';
-      if ((c >= 'a') && (c <= 'f'))
-          return c - 'a' + 10;
-      if ((c >= 'A') && (c <= 'F'))
-          return c - 'A' + 10;
-      return -1;
+    if ((c >= '0') && (c <= '9')) return c - '0';
+    if ((c >= 'a') && (c <= 'f')) return c - 'a' + 10;
+    if ((c >= 'A') && (c <= 'F')) return c - 'A' + 10;
+    return -1;
   }
 
   public static boolean containsScheme(@NotNull String url) {
   }
 
   public static boolean containsScheme(@NotNull String url) {
@@ -210,7 +206,9 @@ public class URLUtil {
     if (matcher.matches()) {
       try {
         String content = matcher.group(4);
     if (matcher.matches()) {
       try {
         String content = matcher.group(4);
-        return ";base64".equalsIgnoreCase(matcher.group(3)) ? Base64Converter.decode(content.getBytes(CharsetToolkit.UTF8_CHARSET)) : content.getBytes(CharsetToolkit.UTF8_CHARSET);
+        return ";base64".equalsIgnoreCase(matcher.group(3))
+               ? Base64Converter.decode(content.getBytes(CharsetToolkit.UTF8_CHARSET))
+               : content.getBytes(CharsetToolkit.UTF8_CHARSET);
       }
       catch (IllegalArgumentException e) {
         return null;
       }
       catch (IllegalArgumentException e) {
         return null;