@Override public void writeAsEncodedUnicode(Writer writer) throws XMLStreamException { delegate.writeAsEncodedUnicode(writer); }
public void doFilter( ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; RequestURIParts parts = parseParts(request); if (parts != null) { String realBaseAddress = parts.getBaseAddress(); String idlPath = parts.getFilePath(); InputStream idl = this.servletContext.getResourceAsStream(idlPath); if (idl != null) { servletResponse.setContentType("text/xml"); String assumedBaseAddress = null; try { XMLEventReader eventReader = this.inputFactory.createXMLEventReader(idl); XMLEventWriter eventWriter = this.outputFactory.createXMLEventWriter(servletResponse.getWriter()); while (eventReader.hasNext()) { XMLEvent event = eventReader.nextEvent(); if (event.isProcessingInstruction()) { String target = ((ProcessingInstruction) event).getTarget(); if ("enunciate-assumed-base-uri".equals(target)) { assumedBaseAddress = ((ProcessingInstruction) event).getData(); if (assumedBaseAddress.endsWith("/")) { assumedBaseAddress = assumedBaseAddress.substring(0, assumedBaseAddress.length() - 1); } } continue; } else if (event.getEventType() == XMLStreamConstants.CDATA || event.getEventType() == XMLStreamConstants.CHARACTERS) { String data = ((Characters) event).getData(); if (assumedBaseAddress != null && data.contains(assumedBaseAddress)) { data = data.replace(assumedBaseAddress, realBaseAddress); event = new DelegatingCharacters(((Characters) event), data); } } else if (event.getEventType() == XMLStreamConstants.START_ELEMENT) { List<Attribute> attributes = new ArrayList<Attribute>(); Iterator attributesIt = ((StartElement) event).getAttributes(); while (attributesIt.hasNext()) { Attribute attribute = (Attribute) attributesIt.next(); String value = attribute.getValue(); if (assumedBaseAddress != null && value.contains(assumedBaseAddress)) { value = value.replace(assumedBaseAddress, realBaseAddress); attribute = new DelegatingAttribute(attribute, value); event = new DelegatingStartElement(((StartElement) event), attributes); } attributes.add(attribute); } } eventWriter.add(event); } eventReader.close(); eventWriter.flush(); eventWriter.close(); return; } catch (XMLStreamException e) { throw new ServletException(e); } } } chain.doFilter(servletRequest, servletResponse); }
@Override public Characters asCharacters() { return delegate.asCharacters(); }
@Override public QName getSchemaType() { return delegate.getSchemaType(); }
@Override public StartElement asStartElement() { return delegate.asStartElement(); }
@Override public EndElement asEndElement() { return delegate.asEndElement(); }
@Override public boolean isCharacters() { return delegate.isCharacters(); }
@Override public boolean isEndDocument() { return delegate.isEndDocument(); }
@Override public boolean isEntityReference() { return delegate.isEntityReference(); }
@Override public boolean isProcessingInstruction() { return delegate.isProcessingInstruction(); }
@Override public boolean isNamespace() { return delegate.isNamespace(); }
@Override public boolean isAttribute() { return delegate.isAttribute(); }
@Override public boolean isStartElement() { return delegate.isStartElement(); }
@Override public Location getLocation() { return delegate.getLocation(); }
@Override public int getEventType() { return delegate.getEventType(); }