@Test public void testRegressionTiles352() throws IOException { URL configFile = this.getClass().getClassLoader().getResource( "org/apache/tiles/config/defs_regression_TILES-352.xml"); assertNotNull("Config file not found", configFile); InputStream source = configFile.openStream(); Map<String, Definition> name2defs = reader.read(source); source.close(); Definition root = name2defs.get("root"); Attribute attribute = root.getAttribute("body"); Definition child = name2defs.get(attribute.getValue()); ListAttribute listAttribute = (ListAttribute) child.getAttribute("list"); List<Attribute> list = listAttribute.getValue(); assertEquals((list.get(0)).getValue(), "This is a value"); }
public Map<String, Definition> read(Object source) { definitions = new LinkedHashMap<String, Definition>(); if (source == null) { return null; } InputStream input; try { input = (InputStream) source; } catch (ClassCastException e) { throw new DefinitionsFactoryException( "Invalid source type. Requires java.io.InputStream.", e); } try { digester.push(this); digester.parse(input); } catch (SAXException e) { throw new DefinitionsFactoryException( "XML error reading definitions.", e); } catch (IOException e) { throw new DefinitionsFactoryException( "I/O Error reading definitions.", e); } finally { digester.clear(); } return definitions; }
DigesterDefinitionsReader implements DefinitionsReader { public Map<String, Definition> read(Object source) { definitions = new LinkedHashMap<String, Definition>(); if (source == null) { return null; } InputStream input; try { input = (InputStream) source; } catch (ClassCastException e) { throw new DefinitionsFactoryException( "Invalid source type. Requires java.io.InputStream.", e); } try { digester.push(this); digester.parse(input); } catch (SAXException e) { throw new DefinitionsFactoryException( "XML error reading definitions.", e); } catch (IOException e) { throw new DefinitionsFactoryException( "I/O Error reading definitions.", e); } finally { digester.clear(); } return definitions; } }
DigesterDefinitionsReader implements DefinitionsReader { public Map<String, Definition> read(Object source) { definitions = new LinkedHashMap<String, Definition>(); if (source == null) { return null; } InputStream input; try { input = (InputStream) source; } catch (ClassCastException e) { throw new DefinitionsFactoryException( "Invalid source type. Requires java.io.InputStream.", e); } try { digester.push(this); digester.parse(input); } catch (SAXException e) { throw new DefinitionsFactoryException( "XML error reading definitions.", e); } catch (IOException e) { throw new DefinitionsFactoryException( "I/O Error reading definitions.", e); } finally { digester.clear(); } return definitions; } DigesterDefinitionsReader(); }
DigesterDefinitionsReader implements DefinitionsReader { public Map<String, Definition> read(Object source) { definitions = new LinkedHashMap<String, Definition>(); if (source == null) { return null; } InputStream input; try { input = (InputStream) source; } catch (ClassCastException e) { throw new DefinitionsFactoryException( "Invalid source type. Requires java.io.InputStream.", e); } try { digester.push(this); digester.parse(input); } catch (SAXException e) { throw new DefinitionsFactoryException( "XML error reading definitions.", e); } catch (IOException e) { throw new DefinitionsFactoryException( "I/O Error reading definitions.", e); } finally { digester.clear(); } return definitions; } DigesterDefinitionsReader(); void setValidating(boolean validating); Map<String, Definition> read(Object source); void addDefinition(Definition definition); }
DigesterDefinitionsReader implements DefinitionsReader { public Map<String, Definition> read(Object source) { definitions = new LinkedHashMap<String, Definition>(); if (source == null) { return null; } InputStream input; try { input = (InputStream) source; } catch (ClassCastException e) { throw new DefinitionsFactoryException( "Invalid source type. Requires java.io.InputStream.", e); } try { digester.push(this); digester.parse(input); } catch (SAXException e) { throw new DefinitionsFactoryException( "XML error reading definitions.", e); } catch (IOException e) { throw new DefinitionsFactoryException( "I/O Error reading definitions.", e); } finally { digester.clear(); } return definitions; } DigesterDefinitionsReader(); void setValidating(boolean validating); Map<String, Definition> read(Object source); void addDefinition(Definition definition); static final String PARSER_VALIDATE_PARAMETER_NAME; }