use of com.ramussoft.report.data.DataException in project ramus by Vitaliy-Yakovchuk.
the class ReportEditorView method getHTMLText.
protected String getHTMLText() {
String page;
try {
HashMap<String, Object> map = new HashMap<String, Object>();
Query query = queryView.getQuery();
if (query != null)
map.put("query", query);
page = ((ReportQuery) framework.getEngine()).getHTMLReport(element, map);
} catch (Exception e1) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
PrintStream s = new PrintStream(stream);
e1.printStackTrace();
if (e1 instanceof DataException)
s.println(((DataException) e1).getMessage(new MessageFormatter() {
@Override
public String getString(String key, Object[] arguments) {
return MessageFormat.format(ReportResourceManager.getString(key), arguments);
}
}));
else {
e1.printStackTrace(s);
}
s.flush();
page = new String(stream.toByteArray());
}
return page;
}
use of com.ramussoft.report.data.DataException in project ramus by Vitaliy-Yakovchuk.
the class ReportQueryImpl method getXMLReportAttribute.
private String getXMLReportAttribute(String attributeName, Element element) {
try {
final SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser;
final Hashtable<String, String> attrs = new Hashtable<String, String>();
parser = factory.newSAXParser();
byte[] bs = engine.getStream(getXMLReportPath(element));
if ((bs == null) || (bs.length == 0))
return null;
parser.parse(new ByteArrayInputStream(bs), new DefaultHandler() {
private StringBuffer sb = new StringBuffer();
private String attribute;
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if (qName.equals("attribute")) {
attribute = attributes.getValue("name");
}
sb = new StringBuffer();
}
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
if (qName.equals("attribute")) {
attrs.put(attribute, sb.toString());
}
}
@Override
public void characters(char[] ch, int start, int length) throws SAXException {
sb.append(ch, start, length);
}
});
return attrs.get(attributeName);
} catch (ParserConfigurationException e) {
throw new DataException(e);
} catch (SAXException e) {
throw new DataException(e);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
Aggregations