Example usage for java.io InvalidObjectException InvalidObjectException

List of usage examples for java.io InvalidObjectException InvalidObjectException

Introduction

In this page you can find the example usage for java.io InvalidObjectException InvalidObjectException.

Prototype

public InvalidObjectException(String reason) 

Source Link

Document

Constructs an InvalidObjectException.

Usage

From source file:com.daskiworks.ghwatch.backend.WatchedRepositoriesParser.java

public static WatchedRepositories parseNotificationStream(JSONArray json) throws InvalidObjectException {
    WatchedRepositories ret = new WatchedRepositories();
    try {/*w  ww.j av  a  2  s .  c o  m*/

        for (int i = 0; i < json.length(); i++) {
            JSONObject repository = json.getJSONObject(i);
            JSONObject owner = repository.getJSONObject("owner");
            ret.addRepository(new Repository(repository.getLong("id"), repository.getString("url"),
                    repository.getString("full_name"), owner.getString("avatar_url"),
                    repository.getString("html_url")));
        }
    } catch (Exception e) {
        throw new InvalidObjectException("JSON message is invalid: " + e.getMessage());
    }
    return ret;
}

From source file:com.phoenixst.plexus.examples.Path.java

private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {
    in.defaultReadObject();/*  w  w  w .  ja  va  2 s .c o  m*/
    if (getNodeSize() < 2) {
        throw new InvalidObjectException("A Path must have at least 2 nodes: " + getNodeSize());
    }
}

From source file:com.phoenixst.collections.NotPredicate.java

private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {
    in.defaultReadObject();/*from  w  w  w  .  j ava2s. c  o m*/
    if (pred == null) {
        throw new InvalidObjectException("Predicate is null.");
    }
}

From source file:com.phoenixst.collections.ContainsPredicate.java

private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {
    in.defaultReadObject();/*from w ww. j  ava 2  s .  co  m*/
    if (collection == null) {
        throw new InvalidObjectException("Collection is null.");
    }
}

From source file:com.phoenixst.plexus.examples.CompleteGraph.java

private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {
    in.defaultReadObject();/*w  w  w .ja va  2 s.c  o  m*/
    if (getNodeSize() < 1) {
        throw new InvalidObjectException("A Complete Graph must have at least 1 node: " + getNodeSize());
    }
}

From source file:com.phoenixst.collections.InstanceofPredicate.java

private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {
    in.defaultReadObject();/* w  ww.  ja v a  2  s.  co m*/
    if (testClass == null) {
        throw new InvalidObjectException("Class is null.");
    }
}

From source file:com.phoenixst.plexus.util.ChildTraverserFactory.java

private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {
    in.defaultReadObject();/*from w w w. j a v a  2 s. co  m*/
    if (forest == null) {
        throw new InvalidObjectException("Forest is null.");
    }
}

From source file:com.phoenixst.plexus.util.EqualsTraverserPredicate.java

private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {
    in.defaultReadObject();/*from w  ww.j av  a 2  s  .  co m*/
    if (testEdge == null) {
        throw new InvalidObjectException("Test Graph.Edge is null.");
    }
}

From source file:com.daskiworks.ghwatch.backend.NotificationStreamParser.java

public static NotificationStream parseNotificationStream(JSONArray json) throws InvalidObjectException {
    NotificationStream ret = new NotificationStream();
    try {/*from ww w.  ja  v  a2 s  .  c o  m*/

        for (int i = 0; i < json.length(); i++) {
            JSONObject notification = json.getJSONObject(i);

            JSONObject subject = notification.getJSONObject("subject");
            JSONObject repository = notification.getJSONObject("repository");
            String updatedAtStr = Utils.trimToNull(notification.getString("updated_at"));
            Date updatedAt = null;
            try {
                if (updatedAtStr != null) {
                    if (updatedAtStr.endsWith("Z"))
                        updatedAtStr = updatedAtStr.replace("Z", "GMT");
                    updatedAt = df.parse(updatedAtStr);
                }
            } catch (ParseException e) {
                Log.w(TAG, "Invalid date format for value: " + updatedAtStr);
            }

            ret.addNotification(new Notification(notification.getLong("id"), notification.getString("url"),
                    subject.getString("title"), subject.getString("type"), subject.getString("url"),
                    subject.getString("latest_comment_url"), repository.getString("full_name"),
                    repository.getJSONObject("owner").getString("avatar_url"), updatedAt,
                    notification.getString("reason")));

        }
    } catch (Exception e) {
        throw new InvalidObjectException("JSON message is invalid: " + e.getMessage());
    }
    return ret;
}

From source file:com.phoenixst.collections.AndPredicate.java

private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {
    in.defaultReadObject();//from  ww  w  .  j a v  a  2s  . c om
    if (left == null) {
        throw new InvalidObjectException("Left Predicate is null.");
    }
    if (right == null) {
        throw new InvalidObjectException("Right Predicate is null.");
    }
}