@Override public void render(Parameters blockParameters, Writer w, RenderHints hints) throws FrameworkException { if (decorate) { try { decorateIntro(hints, w, null); } catch (IOException ioe) { throw new FrameworkException(ioe); } } String name = getResource(); ResourceLoader loader = ResourceLoader.Type.valueOf(resourceType.toUpperCase()).get(); try { InputStream is = loader.getResourceAsStream(name); if (is == null) throw new FrameworkException( "No such resource " + loader.getResource(name) + " in " + loader); if (xsl == null) { Reader r = loader.getReader(is, name); char[] buf = new char[1000]; int c; while ((c = r.read(buf, 0, 1000)) > 0) { w.write(buf, 0, c); } } else { /// convert using the xsl and spit out that. URL x = ResourceLoader.getConfigurationRoot().getResource(xsl); Utils.xslTransform(blockParameters, loader.getResource(name), is, w, x); } } catch (IOException ioe) { throw new FrameworkException(ioe); } catch (javax.xml.transform.TransformerException te) { throw new FrameworkException(te.getMessage(), te); } catch (RuntimeException e) { log.debug(e.getMessage(), e); throw e; } finally { if (decorate) { try { decorateOutro(hints, w); } catch (IOException ioe) { throw new FrameworkException(ioe); } } } }
public void begin(String sNamespace, String sName, Attributes oAttributes) throws XMLConfigLoaderException { String sConfigResourceName = oAttributes.getValue(Config_LoadConfig_Resource); InputStream oResourceStream = null; if (sConfigResourceName == null) { throw new XMLConfigLoaderException( "config > load-config > a value must be specified for attribute > " + Config_LoadConfig_Resource); } try { oResourceStream = _oResourceLoader.getResourceAsStream(sConfigResourceName); if (oResourceStream == null) { throw new XMLConfigLoaderException( "config > load-config > " + sConfigResourceName + " > open error"); } // cumulate the "included" configuration into _oConfig DigesterFactory.getDigester(_oConfig, _oResourceLoader).parse(oResourceStream); } catch (IOException e) { throw new XMLConfigLoaderException( "config > load-config > I/O error > " + sConfigResourceName, e); } catch (SAXException e) { throw new XMLConfigLoaderException( "config > load-config> XML parse error > " + sConfigResourceName, e); } finally { try { if (oResourceStream != null) { oResourceStream.close(); } } catch (IOException e) { throw new XMLConfigLoaderException( "config > load-config > error closing resource > " + sConfigResourceName + "", e); } } }
/** * Create a new tile map based on a given TMX file * * @param ref The location of the tile map to load * @param loadTileSets True if we want to load tilesets - including their image data * @throws SlickException Indicates a failure to load the tilemap */ public TiledMap(String ref, boolean loadTileSets) throws SlickException { this.loadTileSets = loadTileSets; ref = ref.replace('\\', '/'); load(ResourceLoader.getResourceAsStream(ref), ref.substring(0, ref.lastIndexOf("/"))); }
/** * Create a new tile map based on a given TMX file * * @param ref The location of the tile map to load * @param tileSetsLocation The location where we can find the tileset images and other resources * @throws SlickException Indicates a failure to load the tilemap */ public TiledMap(String ref, String tileSetsLocation) throws SlickException { load(ResourceLoader.getResourceAsStream(ref), tileSetsLocation); }