Returns the resource in debug mode. Here an extra step is used to rewrite
the URL in debug mode

@param reader
the reader
@param context
the generator context
@return the reader
346992
protected Reader generateResourceForDebug(Reader rd, GeneratorContext context) {

		// Rewrite the image URL
		StringWriter writer = new StringWriter();
		try {
			IOUtils.copy(rd, writer);
			String content = rewriteUrl(context, writer.toString());
			rd = new StringReader(content);
		} catch (IOException e) {
			throw new BundlingProcessException(e);
		}

		return rd;
	}
318972
@Override
	public Reader getResource(JoinableResourceBundle bundle, String resourceName, boolean processingBundle) {

		Reader rd = null;
		FileInputStream fis = (FileInputStream) getResourceAsStream(resourceName);
		if (fis != null) {
			FileChannel inchannel = fis.getChannel();
			rd = Channels.newReader(inchannel, charset.newDecoder(), -1);
		}

		return rd;
	}
207784
@Override
	public Reader getResource(JoinableResourceBundle bundle, String resourceName) throws ResourceNotFoundException {

		return getResource(bundle, resourceName, false);
	}
504318
public static Reader getResourceAsReader(String resource) {
        InputStream in = classLoaderWrapper.getResourceAsStream(resource);
        if (in == null) {
            return null;
        }
        return new InputStreamReader(in);
    }
641790
@Override
	public Reader getResource(JoinableResourceBundle bundle, String resourceName, boolean processingBundle,
			List<Class<?>> excludedReader) throws ResourceNotFoundException {

		if (ThreadLocalJawrContext.isInterruptingProcessingBundle()) {
			throw new InterruptBundlingProcessException();
		}
		Reader rd = null;

		String resourceExtension = FileNameUtils.getExtension(resourceName);
		boolean generatedPath = generatorRegistry.isPathGenerated(resourceName);
		if (generatedPath || allowedExtensions.contains(resourceExtension.toLowerCase())) {
			List<TextResourceReader> list = new ArrayList<>();
			list.addAll(resourceReaders);
			for (TextResourceReader rsReader : list) {
				if (!isInstanceOf(rsReader, excludedReader)) {
					if (!(rsReader instanceof ResourceGenerator)
							|| ((ResourceGenerator) rsReader).getResolver().matchPath(resourceName)) {
						try {
							rd = rsReader.getResource(bundle, resourceName, processingBundle);
						} catch (Exception e) {
							if (LOGGER.isDebugEnabled()) {
								LOGGER.debug("An exception occured while trying to read resource '" + resourceName
										+ "'. Continuing with other readers. Error : ", e);
							} else if (LOGGER.isInfoEnabled()) {
								LOGGER.info("An exception occured while trying to read resource '" + resourceName
										+ "'. Continuing with other readers. Error : " + e.getMessage());
							}
						}
						if (rd != null) {
							break;
						}
					}
				}
			}
		} else {
			LOGGER.warn("The resource '" + resourceName + "' will not be read as its extension is not an allowed one.");
		}

		if (rd == null) {
			throw new ResourceNotFoundException(resourceName);
		}

		return rd;
	}
216324
@Override
	public Reader getResource(JoinableResourceBundle bundle, String resourceName, boolean processingBundle)
			throws ResourceNotFoundException {

		return getResource(bundle, resourceName, processingBundle, new ArrayList<Class<?>>());
	}
499552
private static Reader readerFromUrl(String resourceName) throws IOException {
    URL resourceUrl = TemplateVars.class.getResource(resourceName);
    InputStream in;
    try {
      if (resourceUrl.getProtocol().equalsIgnoreCase("file")) {
        in = inputStreamFromFile(resourceUrl);
      } else if (resourceUrl.getProtocol().equalsIgnoreCase("jar")) {
        in = inputStreamFromJar(resourceUrl);
      } else {
        throw new AssertionError("Template fallback logic fails for: " + resourceUrl);
      }
    } catch (URISyntaxException e) {
      throw new IOException(e);
    }
    return new InputStreamReader(in, StandardCharsets.UTF_8);
  }
366130
public static Object load(Reader reader) throws IOException {
    Map<String, Object> data = getSnakeYaml().load(reader);
    return modelMapper(data);
  }
73508
public Reader getConfResourceAsReader(String name) {
		try {
			URL url= getResource(name);

			if (url == null) {
				LOG.info(name + " not found");
				return null;
			} else {
				LOG.info("found resource " + name + " at " + url);
			}

			return new InputStreamReader(url.openStream(), Charsets.UTF_8);
		} catch (Exception e) {
			return null;
		}
	}
491973
public PdfImportedPage getImportedPage(PdfReader reader, int pageNumber) {
        if (currentPdfReaderInstance != null) {
            if (currentPdfReaderInstance.getReader() != reader) {
                try {
                    currentPdfReaderInstance.getReader().close();
                    currentPdfReaderInstance.getReaderFile().close();
                }
                catch (IOException ioe) {
                    // empty on purpose
                }
                currentPdfReaderInstance = reader.getPdfReaderInstance(this);
            }
        }
        else {
            currentPdfReaderInstance = reader.getPdfReaderInstance(this);
        }
        return currentPdfReaderInstance.getImportedPage(pageNumber);            
    }
1050145
public Object parse(Reader reader) {
        if (reader == null) {
            throw new IllegalArgumentException("Reader must not be null");
        }

        Object content;
        JsonParser parser = createParser();
        content = parser.parse(reader);
        return content;
    }
603230
public Reader getReader() throws IOException {
        if (stream != null) {
            Reader reader = new InputStreamReader(stream, configuration.getSourceEncoding());
            stream = null;
            return reader;
        }
        return null;
    }
167773
@Override
	protected String rewriteUrl(GeneratorContext context, String content) throws IOException {

		// Here we create a new context where the bundle name is the Jawr
		// generator CSS path
		// The version of the CSS classpath for debug mode will be different
		// compare to the standard one
		JoinableResourceBundle tempBundle = new JoinableResourceBundleImpl(ResourceGenerator.CSS_DEBUGPATH, null, null,
				null, null, null, context.getConfig().getGeneratorRegistry());
		BundleProcessingStatus tempStatus = new BundleProcessingStatus(BundleProcessingStatus.FILE_PROCESSING_TYPE,
				tempBundle, context.getResourceReaderHandler(), context.getConfig());

		CSSURLPathRewriterPostProcessor postProcessor = new CSSURLPathRewriterPostProcessor();
		String resourcePath = context.getPath();
		tempStatus.setLastPathAdded(getGeneratorPrefix() + GeneratorRegistry.PREFIX_SEPARATOR + resourcePath);
		StringBuffer resourceData = postProcessor.postProcessBundle(tempStatus, new StringBuffer(content));
		return resourceData.toString();

	}
673728
public V deserialize( JsonReader reader, JsonDeserializationContext ctx ) {
        return getDeserializer().deserialize( reader, ctx, getParameters() );
    }
349494
protected Reader createTempResource(GeneratorContext context, CacheMode cacheMode, Reader rd) {
		String filePath = getTempFilePath(context, cacheMode);
		Writer wr = null;
		FileOutputStream fos = null;
		try {
			File f = new File(filePath);
			if (!f.getParentFile().exists()) {
				f.getParentFile().mkdirs();
			}
			String content = IOUtils.toString(rd);
			fos = new FileOutputStream(f);
			FileChannel channel = fos.getChannel();
			wr = Channels.newWriter(channel, config.getResourceCharset().newEncoder(), -1);
			wr.write(content);

			rd = new StringReader(content);
		} catch (IOException e) {
			throw new BundlingProcessException("Unable to create temporary resource for '" + context.getPath() + "'",
					e);
		} finally {
			IOUtils.close(wr);
			IOUtils.close(fos);
		}

		return rd;
	}
27490
public <T> T read(final Reader reader, final DataTypeDescriptor<T> descriptor)
			throws Exception {
		if (reader == null) throw new NullPointerException("reader");
		if (descriptor == null) throw new NullPointerException("descriptor");

		JsonParser parser = factory.createParser(reader);
		return read(parser, descriptor);
	}
199644
public static Properties loadProperties(Reader reader) {
        Properties prop = new Properties();
        try {
            prop.load(reader);
        } catch (IOException e) {
            throw E.ioException(e);
        } finally {
            IO.close(reader);
        }
        return prop;
    }