use of org.switchyard.quickstarts.demos.library.types.ObjectFactory in project quickstarts by jboss-switchyard.
the class Library method toString.
public String toString(boolean detailed) {
StringWriter sw = new StringWriter();
synchronized (librarian) {
try {
if (detailed) {
JAXBContext ctx = JAXBContext.newInstance("org.switchyard.quickstarts.demos.library.types");
Marshaller m = ctx.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
ObjectFactory of = new ObjectFactory();
for (Book book : isbns_to_books.values()) {
int quantity = isbns_to_quantities.get(book.getIsbn());
sw.write("\nBook (quantity=" + quantity + ")\n");
m.marshal(of.createBook(book), sw);
sw.write('\n');
}
} else {
for (Book book : isbns_to_books.values()) {
int quantity = isbns_to_quantities.get(book.getIsbn());
sw.write(book.getTitle() + " (" + quantity + ")\n");
}
}
} catch (Throwable t) {
t.printStackTrace();
}
}
return sw.toString().trim();
}
Aggregations