Skip to content

Instantly share code, notes, and snippets.

@jamiechapman
Last active March 14, 2019 07:37

Revisions

  1. jamiechapman revised this gist Apr 12, 2013. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions ParseProxyObject.java
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    // By Jamie Chapman, @chappers57
    // License: open, do as you wish, just don't blame me if stuff breaks ;-)

    public class ParseProxyObject implements Serializable {

    private static final long serialVersionUID = 1L;
  2. jamiechapman revised this gist Apr 12, 2013. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions ParseProxyObject.java
    Original file line number Diff line number Diff line change
    @@ -23,6 +23,8 @@ public ParseProxyObject(ParseObject object) {
    } else if(classType == ParseUser.class) {
    ParseProxyObject parseUserObject = new ParseProxyObject((ParseObject)object.get(key));
    values.put(key, parseUserObject);
    } else {
    // You might want to add more conditions here, for embedded ParseObject, ParseFile, etc.
    }
    }
    }
  3. jamiechapman revised this gist Apr 12, 2013. 1 changed file with 12 additions and 8 deletions.
    20 changes: 12 additions & 8 deletions ParseProxyObject.java
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,3 @@
    package com.<YOUR_PACKAGE>;

    import java.io.Serializable;
    import java.util.HashMap;

    import com.parse.ParseObject;

    public class ParseProxyObject implements Serializable {

    private static final long serialVersionUID = 1L;
    @@ -27,6 +20,9 @@ public ParseProxyObject(ParseObject object) {
    if(classType == byte[].class || classType == String.class ||
    classType == Integer.class || classType == Boolean.class) {
    values.put(key, object.get(key));
    } else if(classType == ParseUser.class) {
    ParseProxyObject parseUserObject = new ParseProxyObject((ParseObject)object.get(key));
    values.put(key, parseUserObject);
    }
    }
    }
    @@ -63,7 +59,15 @@ public byte[] getBytes(String key) {
    }
    }

    public ParseProxyObject getParseUser(String key) {
    if(has(key)) {
    return (ParseProxyObject) values.get(key);
    } else {
    return null;
    }
    }

    public Boolean has(String key) {
    return values.containsKey(key);
    }
    }
    }
  4. jamiechapman revised this gist Apr 12, 2013. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions ParseProxyObject.java
    Original file line number Diff line number Diff line change
    @@ -8,8 +8,7 @@
    public class ParseProxyObject implements Serializable {

    private static final long serialVersionUID = 1L;

    HashMap<String, Object> values = new HashMap<String, Object>();
    private HashMap<String, Object> values = new HashMap<String, Object>();

    public HashMap<String, Object> getValues() {
    return values;
  5. jamiechapman revised this gist Apr 12, 2013. 1 changed file with 10 additions and 6 deletions.
    16 changes: 10 additions & 6 deletions ParseProxyObject.java
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    import com.parse.ParseObject;

    public class ParseProxyObject implements Serializable {
    private static final long serialVersionUID = 1L;

    HashMap<String, Object> values = new HashMap<String, Object>();
    @@ -33,34 +33,38 @@ public ParseProxyObject(ParseObject object) {
    }

    public String getString(String key) {
    if(values.containsKey(key)) {
    if(has(key)) {
    return (String) values.get(key);
    } else {
    return "";
    }
    }

    public int getInt(String key) {
    if(values.containsKey(key)) {
    if(has(key)) {
    return (Integer)values.get(key);
    } else {
    return 0;
    }
    }

    public Boolean getBoolean(String key) {
    if(values.containsKey(key)) {
    if(has(key)) {
    return (Boolean)values.get(key);
    } else {
    return false;
    }
    }

    public byte[] getBytes(String key) {
    if(values.containsKey(key)) {
    if(has(key)) {
    return (byte[])values.get(key);
    } else {
    return new byte[0];
    }
    }
    }

    public Boolean has(String key) {
    return values.containsKey(key);
    }
    }
  6. jamiechapman created this gist Apr 12, 2013.
    66 changes: 66 additions & 0 deletions ParseProxyObject.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,66 @@
    package com.<YOUR_PACKAGE>;

    import java.io.Serializable;
    import java.util.HashMap;

    import com.parse.ParseObject;

    public class ParseProxyObject implements Serializable {

    private static final long serialVersionUID = 1L;

    HashMap<String, Object> values = new HashMap<String, Object>();

    public HashMap<String, Object> getValues() {
    return values;
    }

    public void setValues(HashMap<String, Object> values) {
    this.values = values;
    }

    public ParseProxyObject(ParseObject object) {

    // Loop the keys in the ParseObject
    for(String key : object.keySet()) {
    @SuppressWarnings("rawtypes")
    Class classType = object.get(key).getClass();
    if(classType == byte[].class || classType == String.class ||
    classType == Integer.class || classType == Boolean.class) {
    values.put(key, object.get(key));
    }
    }
    }

    public String getString(String key) {
    if(values.containsKey(key)) {
    return (String) values.get(key);
    } else {
    return "";
    }
    }

    public int getInt(String key) {
    if(values.containsKey(key)) {
    return (Integer)values.get(key);
    } else {
    return 0;
    }
    }

    public Boolean getBoolean(String key) {
    if(values.containsKey(key)) {
    return (Boolean)values.get(key);
    } else {
    return false;
    }
    }

    public byte[] getBytes(String key) {
    if(values.containsKey(key)) {
    return (byte[])values.get(key);
    } else {
    return new byte[0];
    }
    }
    }