All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hubspot.jinjava.loader.CascadingResourceLocator Maven / Gradle / Ivy

There is a newer version: 2.7.3
Show newest version
package com.hubspot.jinjava.loader;

import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Arrays;

import com.hubspot.jinjava.interpret.JinjavaInterpreter;

public class CascadingResourceLocator implements ResourceLocator {

  private Iterable locators;

  public CascadingResourceLocator(ResourceLocator... locators) {
    this.locators = Arrays.asList(locators);
  }

  @Override
  public String getString(String fullName, Charset encoding,
      JinjavaInterpreter interpreter) throws IOException {

    for (ResourceLocator locator : locators) {
      try {
        return locator.getString(fullName, encoding, interpreter);
      } catch (ResourceNotFoundException e) { /* */
      }
    }

    throw new ResourceNotFoundException("Couldn't find resource: " + fullName);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy