예제 #1
0
  @Override
  public Map<String, Entry<JsonElement, Long>> loadAll(Coll<?> coll) {
    // Create Ret
    Map<String, Entry<JsonElement, Long>> ret = null;

    // Get Directory
    File directory = getDirectory(coll);
    if (!directory.isDirectory()) return ret;

    // Find All
    File[] files = directory.listFiles(JsonFileFilter.get());

    // Create Ret
    ret = new LinkedHashMap<String, Entry<JsonElement, Long>>(files.length);

    // For Each Found
    for (File file : files) {
      // Get ID
      String id = idFromFile(file);

      // Get Entry
      Entry<JsonElement, Long> entry = loadFile(file);
      // NOTE: The entry can be a failed one with null and 0.
      // NOTE: We add it anyways since it's an informative failure.
      // NOTE: This is supported by our defined specification.

      // Add
      ret.put(id, entry);
    }

    // Return Ret
    return ret;
  }
예제 #2
0
  @Override
  public Collection<String> getIds(Coll<?> coll) {
    List<String> ret = new ArrayList<String>();

    // Scan the collection folder for .json files
    File collDir = getDirectory(coll);
    if (!collDir.isDirectory()) return ret;
    for (File file : collDir.listFiles(JsonFileFilter.get())) {
      ret.add(idFromFile(file));
    }

    return ret;
  }
예제 #3
0
  @Override
  public Map<String, Long> getId2mtime(Coll<?> coll) {
    // Create Ret
    Map<String, Long> ret = new HashMap<String, Long>();

    // Get Directory
    File directory = getDirectory(coll);
    if (!directory.isDirectory()) return ret;

    // For each .json file
    for (File file : directory.listFiles(JsonFileFilter.get())) {
      String id = idFromFile(file);
      long mtime = file.lastModified();
      // TODO: Check is 0 here?
      ret.put(id, mtime);
    }

    // Return Ret
    return ret;
  }