public PushHistory(int maxHistoryLength,JSONObject json){
  this.maxHistoryLength=maxHistoryLength;
  this.entries=new PriorityQueue<Entry>(maxHistoryLength + 1);
  this.pushIds=new HashSet<String>(maxHistoryLength + 1);
  this.lastTime=null;
  if (json != null) {
    JSONObject jsonHistory=json.optJSONObject("seen");
    if (jsonHistory != null) {
      Iterator<String> it=jsonHistory.keys();
      while (it.hasNext()) {
        String pushId=(String)it.next();
        String timestamp=jsonHistory.optString(pushId,null);
        if (pushId != null && timestamp != null) {
          tryInsertPush(pushId,timestamp);
        }
      }
    }
    setLastReceivedTimestamp(json.optString("lastTime",null));
  }
}

public PushHistory ( int maxHistoryLength , JSONObject json ) { this . maxHistoryLength = maxHistoryLength ; this . entries = new PriorityQueue < Entry > ( maxHistoryLength + 1 ) ; this . pushIds = new HashSet < String > ( maxHistoryLength + 1 ) ; this . lastTime = null ; if ( json != null ) { JSONObject jsonHistory = json . optJSONObject ( "seen" ) ; if ( jsonHistory != null ) { Iterator < String > it = jsonHistory . keys ( ) ; while ( it . hasNext ( ) ) { String pushId = ( String ) it . next ( ) ; String timestamp = jsonHistory . optString ( pushId , null ) ; if ( pushId != null && timestamp != null ) { tryInsertPush ( pushId , timestamp ) ; } } } setLastReceivedTimestamp ( json . optString ( "lastTime" , null ) ) ; } }
creates a push history object from a json object that looks like this : { " seen " : { " push_id_1 " : " 2013 - 11 - 01t22 : 01 : 00 . 000z " , " push_id_2 " : " 2013 - 11 - 01t22 : 01 : 01 . 000z " , " push_id_3 " : " 2013 - 11 - 01t22 : 01 : 02 . 000z " } , " lasttime " : " 2013 - 11 - 01t22 : 01 : 02 . 000z " } the " history " entries correspond to entries in the " entries " queue . the " lasttime " entry corresponds to the " lasttime " field .
