// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/ICollector.java
// public interface ICollector<T> {
//   /**
//    * Add a element to the collector.
//    */
//   void collect(T element);
// }
// 
// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/IResourceTaskReference.java
// public interface IResourceTaskReference {
//   /** Return the name of the task reference. This is typically a local name. */
//   String getName();
// 
//   /** Return the task reference as an input stream. */
//   InputStream newInputStream() throws IOException;
// 
//   /**
//    * Return the time this resource was last modified, in milliseconds since the epoch.
//    */
//   long getLastModified() throws IOException;
// 
//   /** 
//    * Return the task reference path. Provide enough metadata to give it some distinction,
//    * separate from other providers.
//    */
//   String getPath();
// 
//   /**
//    * Return the File representation of this resource. Is {@code null} it's not a File.
//    */
//   File asFile();
// 
//   /**
//    * Return the MD5 hash of this task
//    */
//   long computeMD5() throws IOException;
// }
// 
// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/plugin/core/ResourceTaskProvider.java
// public abstract class ResourceTaskProvider implements IResourceTaskProvider {
// 
//   /**
//    * Throws exception, ensures subclasses implement equals method.
//    */
//   @Override
//   public boolean equals(Object obj) {
//     throw new RuntimeException(this.getClass().getName() + "doesn't implement equals");
//   }
// 
//   /**
//    * Throws exception, ensures subclasses implement hashCode method.
//    */
//   @Override
//   public int hashCode() {
//     throw new RuntimeException(this.getClass().getName() + "doesn't implement hashCode");
//   }
// }


import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import com.google.common.base.Preconditions;
import com.google.common.hash.Hashing;
import com.google.common.io.ByteStreams;
import com.google.common.io.InputSupplier;
import com.google.eclipse.mechanic.ICollector;
import com.google.eclipse.mechanic.IResourceTaskReference;
import com.google.eclipse.mechanic.plugin.core.ResourceTaskProvider;
import com.google.gson.JsonSyntaxException;
   * Create a new instance.
   *
   * <p>The constructor takes two caches. One has a shorter lifetime and so is more frequently
   * polled, to get the list of tasks to process. The other has a longer lifetime (12 hours
   * ATM) and is used to cache actual tasks (e.g. .epf files) which are much less likely to change.
   *
   * @param uri The URI that contains information about tasks.
   * @param stateSensitiveCache short term cache.
   * @param longTermCache long term cache.
   */
  public static UriTaskProvider newInstance(
      URI uri,
      IUriContentProvider stateSensitiveCache,
      IUriContentProvider longTermCache) throws IOException {

    UriTaskProvider instance = new UriTaskProvider(
        uri, stateSensitiveCache, longTermCache);
    instance.setModel();
    return instance;
  }

  private void setModel() throws IOException, JsonSyntaxException {
    InputStream inputStream = stateSensitiveCache.get(uri);
    try {
      model = UriTaskProviderModelParser.read(inputStream);
    } finally {
      inputStream.close();
    }
  }

// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/ICollector.java
// public interface ICollector<T> {
//   /**
//    * Add a element to the collector.
//    */
//   void collect(T element);
// }
// 
// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/IResourceTaskReference.java
// public interface IResourceTaskReference {
//   /** Return the name of the task reference. This is typically a local name. */
//   String getName();
// 
//   /** Return the task reference as an input stream. */
//   InputStream newInputStream() throws IOException;
// 
//   /**
//    * Return the time this resource was last modified, in milliseconds since the epoch.
//    */
//   long getLastModified() throws IOException;
// 
//   /** 
//    * Return the task reference path. Provide enough metadata to give it some distinction,
//    * separate from other providers.
//    */
//   String getPath();
// 
//   /**
//    * Return the File representation of this resource. Is {@code null} it's not a File.
//    */
//   File asFile();
// 
//   /**
//    * Return the MD5 hash of this task
//    */
//   long computeMD5() throws IOException;
// }
// 
// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/plugin/core/ResourceTaskProvider.java
// public abstract class ResourceTaskProvider implements IResourceTaskProvider {
// 
//   /**
//    * Throws exception, ensures subclasses implement equals method.
//    */
//   @Override
//   public boolean equals(Object obj) {
//     throw new RuntimeException(this.getClass().getName() + "doesn't implement equals");
//   }
// 
//   /**
//    * Throws exception, ensures subclasses implement hashCode method.
//    */
//   @Override
//   public int hashCode() {
//     throw new RuntimeException(this.getClass().getName() + "doesn't implement hashCode");
//   }
// }


// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/internal/UriTaskProvider.java
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import com.google.common.base.Preconditions;
import com.google.common.hash.Hashing;
import com.google.common.io.ByteStreams;
import com.google.common.io.InputSupplier;
import com.google.eclipse.mechanic.ICollector;
import com.google.eclipse.mechanic.IResourceTaskReference;
import com.google.eclipse.mechanic.plugin.core.ResourceTaskProvider;
import com.google.gson.JsonSyntaxException;

   * Create a new instance.
   *
   * <p>The constructor takes two caches. One has a shorter lifetime and so is more frequently
   * polled, to get the list of tasks to process. The other has a longer lifetime (12 hours
   * ATM) and is used to cache actual tasks (e.g. .epf files) which are much less likely to change.
   *
   * @param uri The URI that contains information about tasks.
   * @param stateSensitiveCache short term cache.
   * @param longTermCache long term cache.
   */
  public static UriTaskProvider newInstance(
      URI uri,
      IUriContentProvider stateSensitiveCache,
      IUriContentProvider longTermCache) throws IOException {

    UriTaskProvider instance = new UriTaskProvider(
        uri, stateSensitiveCache, longTermCache);
    instance.setModel();
    return instance;
  }

  private void setModel() throws IOException, JsonSyntaxException {
    InputStream inputStream = stateSensitiveCache.get(uri);
    try {
      model = UriTaskProviderModelParser.read(inputStream);
    } finally {
      inputStream.close();
    }
  }

  public void collectTaskReferences(String localPath, String filter, ICollector<IResourceTaskReference> collector) {