/** * Parse the header into an {@link Element} and set it on the response as an header tag. This method * expects well formed XML, the parsed Element will be translated into markup according to the * response content type when the response will be written to the document. * * @param header the header string to parse * @return this object * @throws ParserConfigurationException any ParserConfigurationException * @throws SAXException any SAXException */ public Content withHeaderTag(String header) throws ParserConfigurationException, SAXException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = dbf.newDocumentBuilder(); try { Document doc = builder.parse(new InputSource(new StringReader(header))); Element elt = doc.getDocumentElement(); return withHeaderTag(elt); } catch (IOException e) { // Let's save user from IOException at least throw new UndeclaredIOException(e); } }
/** * Parse the header into an {@link Element} and set it on the response as an header tag. This method * expects well formed XML, the parsed Element will be translated into markup according to the * response content type when the response will be written to the document. * * @param header the header string to parse * @return this object * @throws ParserConfigurationException any ParserConfigurationException * @throws SAXException any SAXException */ public Content withHeaderTag(String header) throws ParserConfigurationException, SAXException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = dbf.newDocumentBuilder(); try { Document doc = builder.parse(new InputSource(new StringReader(header))); Element elt = doc.getDocumentElement(); return withHeaderTag(elt); } catch (IOException e) { // Let's save user from IOException at least throw new UndeclaredIOException(e); } }