use of javax.xml.stream.XMLStreamException in project uPortal by Jasig.
the class StaxEventLexicalContentHandler method startDTD.
/* (non-Javadoc)
* @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public void startDTD(String name, String publicId, String systemId) throws SAXException {
// System identifier must be specified to print DOCTYPE.
// This method is only called if the system identifier is specified.
// Since the HTML5 DOCTYPE declaration does not include a system
// identifier, this code allows the static string EMPTY to serve as
// a temporary system id for doctypes which should not have one set.
// If public identifier is specified print 'PUBLIC
// <public> <system>', or if a non-'EMPTY' system identifier is
// specified, print 'SYSTEM <system>'.
final StringBuilder dtdBuilder = new StringBuilder("<!DOCTYPE ");
dtdBuilder.append(name);
if (publicId != null) {
dtdBuilder.append(" PUBLIC \"").append(publicId).append("\" \"");
dtdBuilder.append(systemId).append("\"");
} else if (!EMPTY_SYSTEM_IDENTIFIER.equals(systemId)) {
dtdBuilder.append(" SYSTEM \"");
dtdBuilder.append(systemId).append("\"");
}
dtdBuilder.append(">");
final DTD event = eventFactory.createDTD(dtdBuilder.toString());
try {
this.consumeEvent(event);
} catch (XMLStreamException ex) {
throw new SAXException("Could not create DTD: " + ex.getMessage(), ex);
}
}
use of javax.xml.stream.XMLStreamException in project uPortal by Jasig.
the class StaxEventLexicalContentHandler method endCDATA.
/* (non-Javadoc)
* @see org.xml.sax.ext.LexicalHandler#endCDATA()
*/
@Override
public void endCDATA() throws SAXException {
final Characters event = eventFactory.createCData(cdata.toString());
cdata = null;
try {
this.consumeEvent(event);
} catch (XMLStreamException ex) {
throw new SAXException("Could not create CDATA: " + ex.getMessage(), ex);
}
}
use of javax.xml.stream.XMLStreamException in project uPortal by Jasig.
the class StaticDocumentComponent method getEventReader.
/* (non-Javadoc)
* @see org.apereo.portal.rendering.PipelineComponent#getEventReader(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public PipelineEventReader<XMLEventReader, XMLEvent> getEventReader(HttpServletRequest request, HttpServletResponse response) {
final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
final DocumentBuilder documentBuilder;
try {
documentBuilder = documentBuilderFactory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
throw new RuntimeException(e);
}
final InputStream documentStream;
try {
documentStream = this.document.getInputStream();
} catch (IOException e) {
throw new RuntimeException(e);
}
final Document document;
try {
document = documentBuilder.parse(documentStream);
} catch (SAXException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
IOUtils.closeQuietly(documentStream);
}
final XMLInputFactory inputFactory = XMLInputFactory.newFactory();
final DOMSource source = new DOMSource(document);
final XMLEventReader streamReader;
try {
streamReader = inputFactory.createXMLEventReader(source);
} catch (XMLStreamException e) {
throw new RuntimeException(e);
}
return new PipelineEventReaderImpl<XMLEventReader, XMLEvent>(streamReader);
}
use of javax.xml.stream.XMLStreamException in project aries by apache.
the class InitContextExample method initContext.
@Override
public void initContext(ContextEnricher contextEnricher) {
final Map<String, String> customParameters = contextEnricher.getBlueprintConfiguration().getCustomParameters();
for (final String param : customParameters.keySet()) {
if (param.startsWith("example.")) {
final String key = param.split("\\.")[1];
contextEnricher.addBlueprintContentWriter("enrichContextWithExample-" + key, new XmlWriter() {
@Override
public void write(XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
xmlStreamWriter.writeEmptyElement("example");
xmlStreamWriter.writeDefaultNamespace("http://exampleNamespace");
xmlStreamWriter.writeAttribute("id", key);
xmlStreamWriter.writeAttribute("value", customParameters.get(param));
}
});
}
}
}
use of javax.xml.stream.XMLStreamException in project aima-java by aimacode.
the class SVGGroupParserTest method testParse.
@Test
public void testParse() {
IGeometric2D x;
IGeometric2D y;
Iterator<IGeometric2D> j;
try {
j = testParser.parse(this.getClass().getResourceAsStream(file), groupID).iterator();
Iterator<IGeometric2D> i = testGroup.iterator();
while (i.hasNext()) {
x = i.next();
y = j.next();
if (x instanceof Circle2D && y instanceof Circle2D) {
assertEquals("Circle: Center-X.", ((Circle2D) (y)).getCenter().getX(), ((Circle2D) (x)).getCenter().getX(), 0.000005d);
assertEquals("Circle: Center-Y.", ((Circle2D) (y)).getCenter().getY(), ((Circle2D) (x)).getCenter().getY(), 0.000005d);
assertEquals("Circle: Radius.", ((Circle2D) (y)).getRadius(), ((Circle2D) (x)).getRadius(), 0.000005d);
} else if (x instanceof Ellipse2D && y instanceof Ellipse2D) {
assertEquals("Ellipse: Center-X.", ((Ellipse2D) (y)).getCenter().getX(), ((Ellipse2D) (x)).getCenter().getX(), 0.000005d);
assertEquals("Ellipse: Center-Y.", ((Ellipse2D) (y)).getCenter().getY(), ((Ellipse2D) (x)).getCenter().getY(), 0.000005d);
assertEquals("Ellipse: Horizontal length.", ((Ellipse2D) (y)).getHorizontalLength(), ((Ellipse2D) (x)).getHorizontalLength(), 0.000005d);
assertEquals("Ellipse: Vertical length.", ((Ellipse2D) (y)).getVerticalLength(), ((Ellipse2D) (x)).getVerticalLength(), 0.000005d);
assertEquals("Ellipse: Rotation angle.", ((Ellipse2D) (y)).getAngle(), ((Ellipse2D) (x)).getAngle(), 0.000005d);
} else if (x instanceof Line2D && y instanceof Line2D) {
assertEquals("Line: Start-X.", ((Line2D) (y)).getStart().getX(), ((Line2D) (x)).getStart().getX(), 0.000005d);
assertEquals("Line: Start-Y.", ((Line2D) (y)).getStart().getY(), ((Line2D) (x)).getStart().getY(), 0.000005d);
assertEquals("Line: End-X.", ((Line2D) (y)).getEnd().getX(), ((Line2D) (x)).getEnd().getX(), 0.000005d);
assertEquals("Line: End-Y.", ((Line2D) (y)).getEnd().getY(), ((Line2D) (x)).getEnd().getY(), 0.000005d);
} else if (x instanceof Polyline2D && y instanceof Polyline2D) {
if (((Polyline2D) x).getVertexes().length != ((Polyline2D) x).getVertexes().length)
fail();
else {
for (int k = 0; k < ((Polyline2D) x).getVertexes().length; k++) {
assertEquals("Polygon: Vertex-X", ((Polyline2D) x).getVertexes()[k].getX(), ((Polyline2D) y).getVertexes()[k].getX(), 0.000005d);
assertEquals("Polygon: Vertex-Y", ((Polyline2D) x).getVertexes()[k].getY(), ((Polyline2D) y).getVertexes()[k].getY(), 0.000005d);
}
}
} else if (x instanceof Rect2D && y instanceof Rect2D) {
assertEquals("Line: UpperLeft-X.", ((Rect2D) (y)).getUpperLeft().getX(), ((Rect2D) (x)).getUpperLeft().getX(), 0.000005d);
assertEquals("Line: UpperLeft-Y.", ((Rect2D) (y)).getUpperLeft().getY(), ((Rect2D) (x)).getUpperLeft().getY(), 0.000005d);
assertEquals("Line: LowerRight-X.", ((Rect2D) (y)).getLowerRight().getX(), ((Rect2D) (x)).getLowerRight().getX(), 0.000005d);
assertEquals("Line: LowerRight-Y.", ((Rect2D) (y)).getLowerRight().getY(), ((Rect2D) (x)).getLowerRight().getY(), 0.000005d);
}
}
assertFalse("Both groups are the same length and contain only legal shapes.", i.hasNext() || j.hasNext());
} catch (XMLStreamException e) {
e.printStackTrace();
fail();
} catch (NullPointerException e) {
e.printStackTrace();
fail();
}
}
Aggregations