Пример #1
0
 /**
  * Assembles a bean from an XML file.
  *
  * @param <T> the expected object type
  * @param file the path to the XML file
  * @param type the expected object type
  * @return an object assembled from this XML file
  * @throws SAXException if the internal SAX parser fails
  * @throws IOException if any IO errors occur
  */
 public <T> T build(String file, Class<T> type) throws SAXException, IOException {
   _parser.parse(new File(file), this);
   return type.cast(getBean());
 }
Пример #2
0
 /**
  * Assembles a bean from an XML stream.
  *
  * @param <T> the expected object type
  * @param stream the XML input stream
  * @param type the expected object type
  * @return an object assembled from this XML stream
  * @throws SAXException if the internal SAX parser fails
  * @throws IOException if any IO errors occur
  */
 public <T> T build(InputStream stream, Class<T> type) throws SAXException, IOException {
   _parser.parse(stream, this);
   return type.cast(getBean());
 }