Beispiel #1
0
 public void setContentHandler(ContentHandler handler) {
   // System.out.println(getClass().getName()+".setContentHandler " +
   // handler.getClass().getName());
   SaxSink saxSink = new SimpleSaxSink(handler);
   flow = flow.replaceDefaultSaxSink(context, saxSink);
   super.setContentHandler(handler);
 }
Beispiel #2
0
  /**
   * Creates a new {@link WSEndpointReference} by replacing the address of this EPR to the new one.
   *
   * <p>The following example shows how you can use this to force an HTTPS EPR, when the endpoint
   * can serve both HTTP and HTTPS requests.
   *
   * <pre>
   * if(epr.getAddress().startsWith("http:"))
   *   epr = epr.createWithAddress("https:"+epr.getAddress().substring(5));
   * </pre>
   *
   * @param newAddress This is a complete URL to be written inside &lt;Adress> element of the EPR,
   *     such as "http://foo.bar/abc/def"
   */
  public @NotNull WSEndpointReference createWithAddress(@NotNull final String newAddress) {
    MutableXMLStreamBuffer xsb = new MutableXMLStreamBuffer();
    XMLFilterImpl filter =
        new XMLFilterImpl() {
          private boolean inAddress = false;

          public void startElement(String uri, String localName, String qName, Attributes atts)
              throws SAXException {
            if (localName.equals("Address") && uri.equals(version.nsUri)) inAddress = true;
            super.startElement(uri, localName, qName, atts);
          }

          public void characters(char ch[], int start, int length) throws SAXException {
            if (!inAddress) super.characters(ch, start, length);
          }

          public void endElement(String uri, String localName, String qName) throws SAXException {
            if (inAddress) super.characters(newAddress.toCharArray(), 0, newAddress.length());
            inAddress = false;
            super.endElement(uri, localName, qName);
          }
        };
    filter.setContentHandler(xsb.createFromSAXBufferCreator());
    try {
      infoset.writeTo(filter, false);
    } catch (SAXException e) {
      throw new AssertionError(e); // impossible since we are writing from XSB to XSB.
    }

    return new WSEndpointReference(xsb, version);
  }
Beispiel #3
0
    /**
     * <i>[SAX ContentHandler interface support]</i> Processes a start of document event.
     *
     * <p>This implementation creates a new JDOM document builder and marks the current result as
     * "under construction".
     *
     * @throws SAXException if any error occurred while creating the document builder.
     */
    public void startDocument() throws SAXException {
      this.startDocumentReceived = true;

      // Reset any previously set result.
      setResult(null);

      // Create the actual JDOM document builder and register it as
      // ContentHandler on the superclass (XMLFilterImpl): this
      // implementation will take care of propagating the LexicalHandler
      // events.
      this.saxHandler = new FragmentHandler(getFactory());
      super.setContentHandler(this.saxHandler);

      // And propagate event.
      super.startDocument();
    }