/** * Return the input stream that results from applying the given transformer URL to the provided * input stream. * * @param inputStream the stream to transform * @param bundle the resource representing the transformer * @return the transformed stream */ protected InputStream getInputStream(InputStream inputStream, Bundle bundle, String path) { String namespace = bundle.getSymbolicName(); String[] transformTypes = templates.getTransformTypes(); if (transformTypes.length == 0) { return null; } for (int i = 0; i < transformTypes.length; i++) { StreamTransformer transformer = transformers.getTransformer(transformTypes[i]); if (transformer == null) { continue; } TransformTuple[] transformTuples = templates.getTransformsFor(transformTypes[i]); if (transformTuples == null) { continue; } for (int j = 0; j < transformTuples.length; j++) { TransformTuple transformTuple = transformTuples[j]; if (match(transformTuple.bundlePattern, namespace) && match(transformTuple.pathPattern, path)) { try { return transformer.getInputStream(inputStream, transformTuple.transformerUrl); } catch (IOException e) { TransformerHook.log( FrameworkLogEntry.ERROR, "Problem obtaining transformed stream from transformer : " //$NON-NLS-1$ + transformer.getClass().getName(), e); } } } } return null; }
/** * Answers whether the resource at the given path or any of its children has a transform * associated with it. * * @param path * @return whether the resource at the given path or any of its children has a transform * associated with it. */ private boolean hasTransforms(String path) { if (!transformers.hasTransformers()) { return false; } return templates.hasTransformsFor(data.getBundle()); }