@Test public void testAttrsBad() { FsEntry e = new FsEntry(); assertFalse(e.parseJson("{\"path\":\"a/path/\", \"name\":{\"name:\":\"aname\",\"dirIndex\":2}, \"attrs\":[{\"whatever\":1}, {\"yo\":\"mama\"}]}")); }
public boolean parseJson(String jsonstr) { Map<String,Object> json = null; try { json = (Map<String,Object>) mapper.readValue(jsonstr, Map.class); } catch (IOException e) { return false; } final Map<String,Object> map = new HashMap<String,Object>(); try { final Map<String,Object> nRec = JSON.getAs(json, "name", Map.class); final String p = JSON.getAs(json, "path", String.class); final String n = JSON.getAs(nRec, "name", String.class); if (json.containsKey("fs")) { final Map<String,Object> fsRec = JSON.getAs(json, "fs", Map.class); map.put("fs_byte_offset", fsRec.get("byteOffset")); map.put("fs_id", fsRec.get("fsID")); map.put("fs_block_size", fsRec.get("blockSize")); } long sz = 0; if (json.containsKey("meta")) { final Map<String,Object> mRec = JSON.getAs(json, "meta", Map.class); Created = addDate(map, "created", mRec, "crtime"); Written = addDate(map, "written", mRec, "mtime"); Accessed = addDate(map, "accessed", mRec, "atime"); Updated = addDate(map, "updated", mRec, "ctime"); sz = (JSON.getAs(mRec, "size", Number.class)).longValue(); addOptLong(map, "meta_flags", mRec, "flags"); addOptLong(map, "uid", mRec, "uid"); addOptLong(map, "gid", mRec, "gid"); addOptLong(map, "meta_type", mRec, "type"); addOptLong(map, "seq", mRec, "seq"); addOptLong(map, "mode", mRec, "mode"); addOptLong(map, "content_len", mRec, "content_len"); addOptLong(map, "meta_addr", mRec, "addr"); addOptLong(map, "nlink", mRec, "nlink"); hasMRec = true; } else { hasMRec = false; } if (json.containsKey("attrs")) { map.put("attrs", json.get("attrs")); } Path = p; Name = n; map.put("path", Path); map.put("name", Name); Size = sz; map.put("size", Size); map.put("dirIndex", nRec.get("dirIndex")); addOptLong(map, "name_flags", nRec, "flags"); addOptLong(map, "meta_seq", nRec, "meta_seq"); addOptLong(map, "name_type", nRec, "type"); putAll(map); return true; } catch (JSON.DataException e) { return false; } }
FsEntry extends HashMap<String,Object> { public boolean parseJson(String jsonstr) { Map<String,Object> json = null; try { json = (Map<String,Object>) mapper.readValue(jsonstr, Map.class); } catch (IOException e) { return false; } final Map<String,Object> map = new HashMap<String,Object>(); try { final Map<String,Object> nRec = JSON.getAs(json, "name", Map.class); final String p = JSON.getAs(json, "path", String.class); final String n = JSON.getAs(nRec, "name", String.class); if (json.containsKey("fs")) { final Map<String,Object> fsRec = JSON.getAs(json, "fs", Map.class); map.put("fs_byte_offset", fsRec.get("byteOffset")); map.put("fs_id", fsRec.get("fsID")); map.put("fs_block_size", fsRec.get("blockSize")); } long sz = 0; if (json.containsKey("meta")) { final Map<String,Object> mRec = JSON.getAs(json, "meta", Map.class); Created = addDate(map, "created", mRec, "crtime"); Written = addDate(map, "written", mRec, "mtime"); Accessed = addDate(map, "accessed", mRec, "atime"); Updated = addDate(map, "updated", mRec, "ctime"); sz = (JSON.getAs(mRec, "size", Number.class)).longValue(); addOptLong(map, "meta_flags", mRec, "flags"); addOptLong(map, "uid", mRec, "uid"); addOptLong(map, "gid", mRec, "gid"); addOptLong(map, "meta_type", mRec, "type"); addOptLong(map, "seq", mRec, "seq"); addOptLong(map, "mode", mRec, "mode"); addOptLong(map, "content_len", mRec, "content_len"); addOptLong(map, "meta_addr", mRec, "addr"); addOptLong(map, "nlink", mRec, "nlink"); hasMRec = true; } else { hasMRec = false; } if (json.containsKey("attrs")) { map.put("attrs", json.get("attrs")); } Path = p; Name = n; map.put("path", Path); map.put("name", Name); Size = sz; map.put("size", Size); map.put("dirIndex", nRec.get("dirIndex")); addOptLong(map, "name_flags", nRec, "flags"); addOptLong(map, "meta_seq", nRec, "meta_seq"); addOptLong(map, "name_type", nRec, "type"); putAll(map); return true; } catch (JSON.DataException e) { return false; } } }
FsEntry extends HashMap<String,Object> { public boolean parseJson(String jsonstr) { Map<String,Object> json = null; try { json = (Map<String,Object>) mapper.readValue(jsonstr, Map.class); } catch (IOException e) { return false; } final Map<String,Object> map = new HashMap<String,Object>(); try { final Map<String,Object> nRec = JSON.getAs(json, "name", Map.class); final String p = JSON.getAs(json, "path", String.class); final String n = JSON.getAs(nRec, "name", String.class); if (json.containsKey("fs")) { final Map<String,Object> fsRec = JSON.getAs(json, "fs", Map.class); map.put("fs_byte_offset", fsRec.get("byteOffset")); map.put("fs_id", fsRec.get("fsID")); map.put("fs_block_size", fsRec.get("blockSize")); } long sz = 0; if (json.containsKey("meta")) { final Map<String,Object> mRec = JSON.getAs(json, "meta", Map.class); Created = addDate(map, "created", mRec, "crtime"); Written = addDate(map, "written", mRec, "mtime"); Accessed = addDate(map, "accessed", mRec, "atime"); Updated = addDate(map, "updated", mRec, "ctime"); sz = (JSON.getAs(mRec, "size", Number.class)).longValue(); addOptLong(map, "meta_flags", mRec, "flags"); addOptLong(map, "uid", mRec, "uid"); addOptLong(map, "gid", mRec, "gid"); addOptLong(map, "meta_type", mRec, "type"); addOptLong(map, "seq", mRec, "seq"); addOptLong(map, "mode", mRec, "mode"); addOptLong(map, "content_len", mRec, "content_len"); addOptLong(map, "meta_addr", mRec, "addr"); addOptLong(map, "nlink", mRec, "nlink"); hasMRec = true; } else { hasMRec = false; } if (json.containsKey("attrs")) { map.put("attrs", json.get("attrs")); } Path = p; Name = n; map.put("path", Path); map.put("name", Name); Size = sz; map.put("size", Size); map.put("dirIndex", nRec.get("dirIndex")); addOptLong(map, "name_flags", nRec, "flags"); addOptLong(map, "meta_seq", nRec, "meta_seq"); addOptLong(map, "name_type", nRec, "type"); putAll(map); return true; } catch (JSON.DataException e) { return false; } }  }
FsEntry extends HashMap<String,Object> { public boolean parseJson(String jsonstr) { Map<String,Object> json = null; try { json = (Map<String,Object>) mapper.readValue(jsonstr, Map.class); } catch (IOException e) { return false; } final Map<String,Object> map = new HashMap<String,Object>(); try { final Map<String,Object> nRec = JSON.getAs(json, "name", Map.class); final String p = JSON.getAs(json, "path", String.class); final String n = JSON.getAs(nRec, "name", String.class); if (json.containsKey("fs")) { final Map<String,Object> fsRec = JSON.getAs(json, "fs", Map.class); map.put("fs_byte_offset", fsRec.get("byteOffset")); map.put("fs_id", fsRec.get("fsID")); map.put("fs_block_size", fsRec.get("blockSize")); } long sz = 0; if (json.containsKey("meta")) { final Map<String,Object> mRec = JSON.getAs(json, "meta", Map.class); Created = addDate(map, "created", mRec, "crtime"); Written = addDate(map, "written", mRec, "mtime"); Accessed = addDate(map, "accessed", mRec, "atime"); Updated = addDate(map, "updated", mRec, "ctime"); sz = (JSON.getAs(mRec, "size", Number.class)).longValue(); addOptLong(map, "meta_flags", mRec, "flags"); addOptLong(map, "uid", mRec, "uid"); addOptLong(map, "gid", mRec, "gid"); addOptLong(map, "meta_type", mRec, "type"); addOptLong(map, "seq", mRec, "seq"); addOptLong(map, "mode", mRec, "mode"); addOptLong(map, "content_len", mRec, "content_len"); addOptLong(map, "meta_addr", mRec, "addr"); addOptLong(map, "nlink", mRec, "nlink"); hasMRec = true; } else { hasMRec = false; } if (json.containsKey("attrs")) { map.put("attrs", json.get("attrs")); } Path = p; Name = n; map.put("path", Path); map.put("name", Name); Size = sz; map.put("size", Size); map.put("dirIndex", nRec.get("dirIndex")); addOptLong(map, "name_flags", nRec, "flags"); addOptLong(map, "meta_seq", nRec, "meta_seq"); addOptLong(map, "name_type", nRec, "type"); putAll(map); return true; } catch (JSON.DataException e) { return false; } }  void clear(); Map<String, Object> getChangedItems(); boolean containsKey(Object key); boolean containsValue(Object value); @Deprecated Set<Map.Entry<String,Object>> entrySet(); @Deprecated boolean equals(Object o); Object get(Object key); boolean isEmpty(); @Deprecated Set<String> keySet(); Object put(String key, Object value); void putAll(Map<? extends String,? extends Object> m); @Deprecated Object remove(Object key); int size(); @Deprecated Collection<Object> values(); void setFileSystem(FileSystem fs); Map<String, StreamProxy> getStreams(); Object getStream(); Object getStream(String key); InputStream getInputStream(); InputStream getInputStream(String key); boolean hasMetadata(); String getPath(); String getName(); String getID(); String extension(); String fullPath(); Date getCreated(); Date getWritten(); Date getAccessed(); Date getUpdated(); long getSize(); boolean parseJson(String jsonstr); }
FsEntry extends HashMap<String,Object> { public boolean parseJson(String jsonstr) { Map<String,Object> json = null; try { json = (Map<String,Object>) mapper.readValue(jsonstr, Map.class); } catch (IOException e) { return false; } final Map<String,Object> map = new HashMap<String,Object>(); try { final Map<String,Object> nRec = JSON.getAs(json, "name", Map.class); final String p = JSON.getAs(json, "path", String.class); final String n = JSON.getAs(nRec, "name", String.class); if (json.containsKey("fs")) { final Map<String,Object> fsRec = JSON.getAs(json, "fs", Map.class); map.put("fs_byte_offset", fsRec.get("byteOffset")); map.put("fs_id", fsRec.get("fsID")); map.put("fs_block_size", fsRec.get("blockSize")); } long sz = 0; if (json.containsKey("meta")) { final Map<String,Object> mRec = JSON.getAs(json, "meta", Map.class); Created = addDate(map, "created", mRec, "crtime"); Written = addDate(map, "written", mRec, "mtime"); Accessed = addDate(map, "accessed", mRec, "atime"); Updated = addDate(map, "updated", mRec, "ctime"); sz = (JSON.getAs(mRec, "size", Number.class)).longValue(); addOptLong(map, "meta_flags", mRec, "flags"); addOptLong(map, "uid", mRec, "uid"); addOptLong(map, "gid", mRec, "gid"); addOptLong(map, "meta_type", mRec, "type"); addOptLong(map, "seq", mRec, "seq"); addOptLong(map, "mode", mRec, "mode"); addOptLong(map, "content_len", mRec, "content_len"); addOptLong(map, "meta_addr", mRec, "addr"); addOptLong(map, "nlink", mRec, "nlink"); hasMRec = true; } else { hasMRec = false; } if (json.containsKey("attrs")) { map.put("attrs", json.get("attrs")); } Path = p; Name = n; map.put("path", Path); map.put("name", Name); Size = sz; map.put("size", Size); map.put("dirIndex", nRec.get("dirIndex")); addOptLong(map, "name_flags", nRec, "flags"); addOptLong(map, "meta_seq", nRec, "meta_seq"); addOptLong(map, "name_type", nRec, "type"); putAll(map); return true; } catch (JSON.DataException e) { return false; } }  void clear(); Map<String, Object> getChangedItems(); boolean containsKey(Object key); boolean containsValue(Object value); @Deprecated Set<Map.Entry<String,Object>> entrySet(); @Deprecated boolean equals(Object o); Object get(Object key); boolean isEmpty(); @Deprecated Set<String> keySet(); Object put(String key, Object value); void putAll(Map<? extends String,? extends Object> m); @Deprecated Object remove(Object key); int size(); @Deprecated Collection<Object> values(); void setFileSystem(FileSystem fs); Map<String, StreamProxy> getStreams(); Object getStream(); Object getStream(String key); InputStream getInputStream(); InputStream getInputStream(String key); boolean hasMetadata(); String getPath(); String getName(); String getID(); String extension(); String fullPath(); Date getCreated(); Date getWritten(); Date getAccessed(); Date getUpdated(); long getSize(); boolean parseJson(String jsonstr);  }