Package org.xml.sax.helpers

Examples of org.xml.sax.helpers.LocatorImpl


   /** Returns a locator implementation. */
   private LocatorImpl getLocatorImpl(LocatorImpl fillin) {

      Locator here = fErrorReporter.getLocator();
      if (fillin == null)
         return new LocatorImpl(here);
      fillin.setPublicId(here.getPublicId());
      fillin.setSystemId(here.getSystemId());
      fillin.setLineNumber(here.getLineNumber());
      fillin.setColumnNumber(here.getColumnNumber());
      return fillin;
View Full Code Here


        Assert.assertTrue("Invalid response from interceptor", result);
    }

    @Test
    public void testCreateRequestValidationFaultAxiom() throws Exception {
        LocatorImpl locator = new LocatorImpl();
        locator.setLineNumber(0);
        locator.setColumnNumber(0);
        SAXParseException[] exceptions = new SAXParseException[]{new SAXParseException("Message 1", locator),
                new SAXParseException("Message 2", locator),};
        MessageContext messageContext = new DefaultMessageContext(new AxiomSoapMessageFactory());
        interceptor.handleRequestValidationErrors(messageContext, exceptions);
        ByteArrayOutputStream os = new ByteArrayOutputStream();
View Full Code Here

        catch (XMLParseException e) {
            Exception ex = e.getException();
            if (ex == null || ex instanceof CharConversionException) {
                // must be a parser exception; mine it for locator info and throw
                // a SAXParseException
                LocatorImpl locatorImpl = new LocatorImpl();
                locatorImpl.setPublicId(e.getPublicId());
                locatorImpl.setSystemId(e.getExpandedSystemId());
                locatorImpl.setLineNumber(e.getLineNumber());
                locatorImpl.setColumnNumber(e.getColumnNumber());
                throw (ex == null) ?
                        new SAXParseException(e.getMessage(), locatorImpl) :
                        new SAXParseException(e.getMessage(), locatorImpl, ex);
            }
            if (ex instanceof SAXException) {
View Full Code Here

        catch (XMLParseException e) {
            Exception ex = e.getException();
            if (ex == null || ex instanceof CharConversionException) {
                // must be a parser exception; mine it for locator info and throw
                // a SAXParseException
                LocatorImpl locatorImpl = new LocatorImpl();
                locatorImpl.setPublicId(e.getPublicId());
                locatorImpl.setSystemId(e.getExpandedSystemId());
                locatorImpl.setLineNumber(e.getLineNumber());
                locatorImpl.setColumnNumber(e.getColumnNumber());
                throw (ex == null) ?
                        new SAXParseException(e.getMessage(), locatorImpl) :
                        new SAXParseException(e.getMessage(), locatorImpl, ex);
            }
            if (ex instanceof SAXException) {
View Full Code Here

    static void convertToSAXParseException(XMLParseException e) throws SAXException {
        Exception ex = e.getException();
        if (ex == null) {
            // must be a parser exception; mine it for locator info and throw
            // a SAXParseException
            LocatorImpl locatorImpl = new LocatorImpl();
            locatorImpl.setPublicId(e.getPublicId());
            locatorImpl.setSystemId(e.getExpandedSystemId());
            locatorImpl.setLineNumber(e.getLineNumber());
            locatorImpl.setColumnNumber(e.getColumnNumber());
            throw new SAXParseException(e.getMessage(), locatorImpl);
        }
        if (ex instanceof SAXException) {
            // why did we create an XMLParseException?
            throw (SAXException) ex;
View Full Code Here

     */
    public void parse(InputSource source,
                      ContentHandler contentHandler)
                        throws SAXException, IOException {

        LocatorImpl locator = new LocatorImpl();

        locator.setPublicId(source.getPublicId());
        locator.setSystemId(source.getSystemId());
        locator.setLineNumber(1);
        locator.setColumnNumber(1);

        contentHandler.setDocumentLocator(locator);
        contentHandler.startDocument();
        contentHandler.startPrefixMapping("", URI);

        AttributesImpl atts = new AttributesImpl();

        contentHandler.startElement(URI, "text", "text", atts);

        LineNumberReader reader = null;

        if (source.getCharacterStream()!=null) {
            reader = new LineNumberReader(source.getCharacterStream());
        } else {
            reader = new LineNumberReader(new InputStreamReader(source.getByteStream()));
        }

        String line, newline = null;
        String separator = System.getProperty("line.separator");

        while (true) {
            if (newline==null) {
                line = reader.readLine();
            } else {
                line = newline;
            }

            if (line==null) {
                break;
            }

            newline = reader.readLine();

            line = (newline!=null) ? line+separator : line;

            locator.setLineNumber(reader.getLineNumber());
            locator.setColumnNumber(1);
            contentHandler.characters(line.toCharArray(), 0, line.length());

            if (newline==null) {
                break;
            }
View Full Code Here

        } catch (SourceException se) {
            throw new ProcessingException("Error during resolving of '"+
                                          this.source+"'.", se);
        }

        LocatorImpl locator = new LocatorImpl();

        locator.setSystemId(this.inputSource.getURI());
        locator.setLineNumber(1);
        locator.setColumnNumber(1);

        contentHandler.setDocumentLocator(locator);
        contentHandler.startDocument();
        contentHandler.startPrefixMapping("", URI);

        AttributesImpl atts = new AttributesImpl();

        contentHandler.startElement(URI, "text", "text", atts);

        LineNumberReader reader = new LineNumberReader(in);
        String line, newline = null;
        String separator = System.getProperty("line.separator");

        while (true) {
            if (newline==null) {
                line = reader.readLine();
            } else {
                line = newline;
            }

            if (line==null) {
                break;
            }

            newline = reader.readLine();

            line = (newline!=null) ? line+separator : line;

            locator.setLineNumber(reader.getLineNumber());
            locator.setColumnNumber(1);
            contentHandler.characters(line.toCharArray(), 0, line.length());

            if (newline==null) {
                break;
            }
View Full Code Here

            }
           
            SAXMarshaller serializer = new SAXMarshaller(writer,prefixMapper,this);
       
            // set a DocumentLocator that doesn't provide any information
            writer.setDocumentLocator( new LocatorImpl() );
            writer.startDocument();
            obj.serializeBody(serializer);
            writer.endDocument();
           
            serializer.reconcileID();   // extra check
View Full Code Here

  public void replay(final ContentHandler handler) throws SAXException {
    if (fatalError != null) {
      throw fatalError;
    }
    LocatorImpl replayLocation = new LocatorImpl();
    handler.setDocumentLocator(replayLocation);
    for (Iterator iter = events.iterator(); iter.hasNext();) {
      ElementEvent event = (ElementEvent) iter.next();
      event.replay(handler, replayLocation);
    }
View Full Code Here

    private Locator location;

    ElementEvent(final String localName, final Locator location) {
      this.localName = localName;
      if (location != null) {
        this.location = new LocatorImpl(location);
      }
    }
View Full Code Here

TOP

Related Classes of org.xml.sax.helpers.LocatorImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.