JAL-1517 source formatting
[jalview.git] / src / jalview / ext / paradise / Annotate3D.java
index b588161..4842033 100644 (file)
@@ -52,22 +52,24 @@ import org.json.simple.parser.ParseException;
 public class Annotate3D
 {
   private static String twoDtoolsURL = "http://arn-ibmc.in2p3.fr/api/compute/2d";
+
   private static ContentHandler createContentHandler()
   {
-    ContentHandler ch = new ContentHandler() {
+    ContentHandler ch = new ContentHandler()
+    {
 
       @Override
       public void startJSON() throws ParseException, IOException
       {
         // TODO Auto-generated method stub
-        
+
       }
 
       @Override
       public void endJSON() throws ParseException, IOException
       {
         // TODO Auto-generated method stub
-        
+
       }
 
       @Override
@@ -120,10 +122,11 @@ public class Annotate3D
         // TODO Auto-generated method stub
         return false;
       }
-      
+
     };
     return ch;
   }
+
   public static Iterator<Reader> getRNAMLForPDBFileAsString(String pdbfile)
           throws Exception
   {
@@ -131,81 +134,106 @@ public class Annotate3D
     vals.add(new BasicNameValuePair("tool", "rnaview"));
     vals.add(new BasicNameValuePair("data", pdbfile));
     vals.add(new BasicNameValuePair("output", "rnaml"));
-    // return processJsonResponseFor(HttpClientUtils.doHttpUrlPost(twoDtoolsURL, vals));
+    // return processJsonResponseFor(HttpClientUtils.doHttpUrlPost(twoDtoolsURL,
+    // vals));
     ArrayList<Reader> readers = new ArrayList<Reader>();
     readers.add(HttpClientUtils.doHttpUrlPost(twoDtoolsURL, vals));
     return readers.iterator();
 
   }
-  public static Iterator<Reader> processJsonResponseFor(Reader respons) throws Exception
+
+  public static Iterator<Reader> processJsonResponseFor(Reader respons)
+          throws Exception
   {
     org.json.simple.parser.JSONParser jp = new org.json.simple.parser.JSONParser();
-    try {
+    try
+    {
       final JSONArray responses = (JSONArray) jp.parse(respons);
       final Iterator rvals = responses.iterator();
-      return new Iterator<Reader>() 
+      return new Iterator<Reader>()
+      {
+        @Override
+        public boolean hasNext()
         {
-          @Override
-          public boolean hasNext()
-          {
-            return rvals.hasNext();
-          }
-          @Override
-          public Reader next()
-          {
-            JSONObject val=(JSONObject) rvals.next();
-            
-            Object sval = null;
-            try {
-              sval = val.get("2D");
-            } catch (Exception x) {x.printStackTrace();};
-            if (sval==null)
-            {
-              System.err.println("DEVELOPER WARNING: Annotate3d didn't return a '2D' tag in its response. Consider checking output of server. Response was :"+val.toString());
-              
-              sval = "";
-            }
-            return new StringReader((sval instanceof JSONObject) ? ((JSONObject)sval).toString():sval.toString());
-            
-          }@Override
-          public void remove()
+          return rvals.hasNext();
+        }
+
+        @Override
+        public Reader next()
+        {
+          JSONObject val = (JSONObject) rvals.next();
+
+          Object sval = null;
+          try
           {
-            throw new Error("Remove: Not implemented");
-            
-          }@Override
-          protected Object clone() throws CloneNotSupportedException
+            sval = val.get("2D");
+          } catch (Exception x)
           {
-            throw new CloneNotSupportedException("Clone: Not implemented");
-          }@Override
-          public boolean equals(Object obj)
+            x.printStackTrace();
+          }
+          ;
+          if (sval == null)
           {
-            return super.equals(obj);
-          }@Override
-          protected void finalize() throws Throwable
+            System.err
+                    .println("DEVELOPER WARNING: Annotate3d didn't return a '2D' tag in its response. Consider checking output of server. Response was :"
+                            + val.toString());
+
+            sval = "";
+          }
+          return new StringReader(
+                  (sval instanceof JSONObject) ? ((JSONObject) sval)
+                          .toString() : sval.toString());
+
+        }
+
+        @Override
+        public void remove()
+        {
+          throw new Error("Remove: Not implemented");
+
+        }
+
+        @Override
+        protected Object clone() throws CloneNotSupportedException
+        {
+          throw new CloneNotSupportedException("Clone: Not implemented");
+        }
+
+        @Override
+        public boolean equals(Object obj)
+        {
+          return super.equals(obj);
+        }
+
+        @Override
+        protected void finalize() throws Throwable
+        {
+          while (rvals.hasNext())
           {
-            while (rvals.hasNext())
-            {
-              rvals.next();
-            }
-            super.finalize();
+            rvals.next();
           }
-        };
+          super.finalize();
+        }
+      };
     } catch (Exception foo)
     {
-      throw new Exception("Couldn't parse response from Annotate3d server.",foo);
+      throw new Exception(
+              "Couldn't parse response from Annotate3d server.", foo);
     }
-    
-    
+
   }
 
-  public static Iterator<Reader> getRNAMLForPDBId(String pdbid) throws Exception
+  public static Iterator<Reader> getRNAMLForPDBId(String pdbid)
+          throws Exception
   {
     List<NameValuePair> vals = new ArrayList<NameValuePair>();
     vals.add(new BasicNameValuePair("tool", "rnaview"));
     vals.add(new BasicNameValuePair("pdbid", pdbid));
     vals.add(new BasicNameValuePair("output", "rnaml"));
-    java.net.URL geturl = new URL(twoDtoolsURL+"?tool=rnaview&pdbid="+pdbid+"&output=rnaml");
-    //return processJsonResponseFor(new InputStreamReader(geturl.openStream()));
+    java.net.URL geturl = new URL(twoDtoolsURL + "?tool=rnaview&pdbid="
+            + pdbid + "&output=rnaml");
+    // return processJsonResponseFor(new
+    // InputStreamReader(geturl.openStream()));
     ArrayList<Reader> readers = new ArrayList<Reader>();
     readers.add(new InputStreamReader(geturl.openStream()));
     return readers.iterator();