Ignore a few working files and folders
authorChristos KK Loverdos <loverdos@gmail.com>
Thu, 31 Jan 2013 16:09:12 +0000 (18:09 +0200)
committerChristos KK Loverdos <loverdos@gmail.com>
Fri, 1 Feb 2013 09:29:46 +0000 (11:29 +0200)
.gitignore
src/gr/grnet/pithos/web/client/Resource.java [moved from src/gr/grnet/pithos/web/client/foldertree/Resource.java with 55% similarity]

index 94493bd..5b56847 100644 (file)
@@ -14,3 +14,7 @@ gwt-unitCache
 docs/build
 pithos-web-client.sublime-project
 pithos-web-client.sublime-workspace
+.ant_targets
+.DS_Store
+out
+__gitstats
  * or implied, of GRNET S.A.
  */
 
-package gr.grnet.pithos.web.client.foldertree;
+package gr.grnet.pithos.web.client;
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.http.client.Response;
 import com.google.gwt.i18n.client.DateTimeFormat;
 import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
-import com.google.gwt.json.client.JSONNumber;
-import com.google.gwt.json.client.JSONObject;
-import com.google.gwt.json.client.JSONString;
-
+import com.google.gwt.json.client.*;
 import gr.grnet.pithos.web.client.Invitations;
 import gr.grnet.pithos.web.client.SharingUsers;
+import gr.grnet.pithos.web.client.foldertree.AccountResource;
+import gr.grnet.pithos.web.client.foldertree.File;
+import gr.grnet.pithos.web.client.foldertree.FileVersions;
+import gr.grnet.pithos.web.client.foldertree.Folder;
 
 import java.util.Date;
 
 public abstract class Resource {
 
-    protected static String unmarshallString(JSONObject obj, String key){
-        if(obj.get(key) != null) {
-            JSONString s = obj.get(key).isString();
-            if(s != null)
+    protected static String unmarshallString(JSONObject obj, String key) {
+        final JSONValue jsonValue = obj.get(key);
+        if(jsonValue != null) {
+            JSONString s = jsonValue.isString();
+            if(s != null) {
                 return s.stringValue();
+            }
         }
         return null;
     }
 
-    protected static int unmarshallInt(JSONObject obj, String key){
-        if(obj.get(key) != null)
-            if(obj.get(key).isNumber() != null)
-                return (int) obj.get(key).isNumber().doubleValue();
+    protected static int unmarshallInt(JSONObject obj, String key) {
+        final JSONValue jsonValue = obj.get(key);
+        if(jsonValue != null) {
+            final JSONNumber jsonNumber = jsonValue.isNumber();
+            if(jsonNumber != null) {
+                return (int) jsonNumber.doubleValue();
+            }
+        }
         return -1;
     }
 
-    protected static long unmarshallLong(JSONObject obj, String key){
-        if(obj.get(key) != null) {
-            JSONNumber value = obj.get(key).isNumber();
-            if(value != null)
-                return (long) value.doubleValue();
+    protected static long unmarshallLong(JSONObject obj, String key) {
+        final JSONValue jsonValue = obj.get(key);
+        if(jsonValue != null) {
+            final JSONNumber jsonNumber = jsonValue.isNumber();
+            if(jsonNumber != null) {
+                return (long) jsonNumber.doubleValue();
+            }
         }
         return -1;
     }
 
-    protected static boolean unmarshallBoolean(JSONObject obj, String key){
-        if(obj.get(key) != null)
-            if(obj.get(key).isBoolean() != null)
-                return obj.get(key).isBoolean().booleanValue();
+    protected static boolean unmarshallBoolean(JSONObject obj, String key) {
+        final JSONValue jsonValue = obj.get(key);
+        if(jsonValue != null) {
+            final JSONBoolean aBoolean = jsonValue.isBoolean();
+            if(aBoolean != null) {
+                return aBoolean.booleanValue();
+            }
+        }
         return false;
     }
 
-    protected static Date unmarshallDate(JSONObject obj, String key){
-        if(obj.get(key) != null) {
-            JSONString s = obj.get(key).isString();
-            if (s != null)
-                               try {
-                                       return DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).parse(s.stringValue());
-                               } catch (IllegalArgumentException e) {
-                                       GWT.log("", e);
-                               }
+    protected static Date unmarshallDate(JSONObject obj, String key) {
+        final JSONValue jsonValue = obj.get(key);
+        if(jsonValue != null) {
+            JSONString jsonString = jsonValue.isString();
+            if(jsonString != null) {
+                try {
+                    return DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).parse(jsonString.stringValue());
+                }
+                catch(IllegalArgumentException e) {
+                    GWT.log("", e);
+                }
+            }
         }
         return null;
     }
 
     public static native String getDate(Long ms)/*-{
-        return (new Date(ms)).toUTCString();
+      return (new Date(ms)).toUTCString();
     }-*/;
 
     @SuppressWarnings("unchecked")
-       public static <T> T createFromResponse(Class<T> aClass, String owner, Response response, T result) {
-       T result1 = null;
-        if (aClass.equals(AccountResource.class)) {
+    public static <T> T createFromResponse(Class<T> aClass, String owner, Response response, T result) {
+        T result1 = null;
+        if(aClass.equals(AccountResource.class)) {
             result1 = (T) AccountResource.createFromResponse(owner, response, (AccountResource) result);
         }
-        else if (aClass.equals(Folder.class)) {
+        else if(aClass.equals(Folder.class)) {
             result1 = (T) Folder.createFromResponse(owner, response, (Folder) result);
         }
-        else if (aClass.equals(File.class)) {
+        else if(aClass.equals(File.class)) {
             result1 = (T) File.createFromResponse(owner, response, (File) result);
         }
-        else if (aClass.equals(SharingUsers.class)) {
-               result1 = (T) SharingUsers.createFromResponse(response, (SharingUsers) result);
+        else if(aClass.equals(SharingUsers.class)) {
+            result1 = (T) SharingUsers.createFromResponse(response, (SharingUsers) result);
         }
-        else if (aClass.equals(FileVersions.class)) {
-               result1 = (T) FileVersions.createFromResponse(response);
+        else if(aClass.equals(FileVersions.class)) {
+            result1 = (T) FileVersions.createFromResponse(response);
         }
-        else if (aClass.equals(Invitations.class)) {
-               result1 = (T) Invitations.createFromResponse(response);
+        else if(aClass.equals(Invitations.class)) {
+            result1 = (T) Invitations.createFromResponse(response);
         }
         return result1;
     }
-    
+
     public abstract Date getLastModified();
 }