Java Code Examples for org.xml.sax.helpers.LocatorImpl#setSystemId()

The following examples show how to use org.xml.sax.helpers.LocatorImpl#setSystemId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WsimportOptions.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Exposing it as a public method to allow external tools such as NB to read from wsdl model and work on it.
 * TODO: WSDL model needs to be exposed - basically at tool time we need to use the runtimw wsdl model
 *
 * Binding files could be jaxws or jaxb. This method identifies jaxws and jaxb binding files and keeps them separately. jaxb binding files are given separately
 * to JAXB in {@link com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder}
 *
 * @param receiver {@link ErrorReceiver}
 */
public final void parseBindings(ErrorReceiver receiver){
    for (InputSource is : bindingFiles) {
        XMLStreamReader reader =
                XMLStreamReaderFactory.create(is,true);
        XMLStreamReaderUtil.nextElementContent(reader);
        if (reader.getName().equals(JAXWSBindingsConstants.JAXWS_BINDINGS)) {
            jaxwsCustomBindings.add(new RereadInputSource(is));
        } else if (reader.getName().equals(JAXWSBindingsConstants.JAXB_BINDINGS) ||
                reader.getName().equals(new QName(SchemaConstants.NS_XSD, "schema"))) {
            jaxbCustomBindings.add(new RereadInputSource(is));
        } else {
            LocatorImpl locator = new LocatorImpl();
            locator.setSystemId(reader.getLocation().getSystemId());
            locator.setPublicId(reader.getLocation().getPublicId());
            locator.setLineNumber(reader.getLocation().getLineNumber());
            locator.setColumnNumber(reader.getLocation().getColumnNumber());
            receiver.warning(locator, ConfigurationMessages.CONFIGURATION_NOT_BINDING_FILE(is.getSystemId()));
        }
    }
}
 
Example 2
Source File: SchemaContentHandler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
    throw new SAXException(ex);
}
 
Example 3
Source File: SchemaCompilerImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void parseSchema( String systemId, Element element ) {
    checkAbsoluteness(systemId);
    try {
        DOMScanner scanner = new DOMScanner();

        // use a locator that sets the system ID correctly
        // so that we can resolve relative URLs in most of the case.
        // it still doesn't handle xml:base and XInclude and all those things
        // correctly. There's just no way to make all those things work with DOM!
        LocatorImpl loc = new LocatorImpl();
        loc.setSystemId(systemId);
        scanner.setLocator(loc);

        scanner.setContentHandler(getParserHandler(systemId));
        scanner.scan(element);
    } catch (SAXException e) {
        // since parsing DOM shouldn't cause a SAX exception
        // and our handler will never throw it, it's not clear
        // if this will ever happen.
        fatalError(new SAXParseException2(
            e.getMessage(), null, systemId,-1,-1, e));
    }
}
 
Example 4
Source File: WsimportOptions.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Exposing it as a public method to allow external tools such as NB to read from wsdl model and work on it.
 * TODO: WSDL model needs to be exposed - basically at tool time we need to use the runtimw wsdl model
 *
 * Binding files could be jaxws or jaxb. This method identifies jaxws and jaxb binding files and keeps them separately. jaxb binding files are given separately
 * to JAXB in {@link com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder}
 *
 * @param receiver {@link ErrorReceiver}
 */
public final void parseBindings(ErrorReceiver receiver){
    for (InputSource is : bindingFiles) {
        XMLStreamReader reader =
                XMLStreamReaderFactory.create(is,true);
        XMLStreamReaderUtil.nextElementContent(reader);
        if (reader.getName().equals(JAXWSBindingsConstants.JAXWS_BINDINGS)) {
            jaxwsCustomBindings.add(new RereadInputSource(is));
        } else if (reader.getName().equals(JAXWSBindingsConstants.JAXB_BINDINGS) ||
                reader.getName().equals(new QName(SchemaConstants.NS_XSD, "schema"))) {
            jaxbCustomBindings.add(new RereadInputSource(is));
        } else {
            LocatorImpl locator = new LocatorImpl();
            locator.setSystemId(reader.getLocation().getSystemId());
            locator.setPublicId(reader.getLocation().getPublicId());
            locator.setLineNumber(reader.getLocation().getLineNumber());
            locator.setColumnNumber(reader.getLocation().getColumnNumber());
            receiver.warning(locator, ConfigurationMessages.CONFIGURATION_NOT_BINDING_FILE(is.getSystemId()));
        }
    }
}
 
Example 5
Source File: SchemaContentHandler.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
    throw new SAXException(ex);
}
 
Example 6
Source File: SchemaCompilerImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void parseSchema( String systemId, Element element ) {
    checkAbsoluteness(systemId);
    try {
        DOMScanner scanner = new DOMScanner();

        // use a locator that sets the system ID correctly
        // so that we can resolve relative URLs in most of the case.
        // it still doesn't handle xml:base and XInclude and all those things
        // correctly. There's just no way to make all those things work with DOM!
        LocatorImpl loc = new LocatorImpl();
        loc.setSystemId(systemId);
        scanner.setLocator(loc);

        scanner.setContentHandler(getParserHandler(systemId));
        scanner.scan(element);
    } catch (SAXException e) {
        // since parsing DOM shouldn't cause a SAX exception
        // and our handler will never throw it, it's not clear
        // if this will ever happen.
        fatalError(new SAXParseException2(
            e.getMessage(), null, systemId,-1,-1, e));
    }
}
 
Example 7
Source File: SchemaCompilerImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void parseSchema( String systemId, Element element ) {
    checkAbsoluteness(systemId);
    try {
        DOMScanner scanner = new DOMScanner();

        // use a locator that sets the system ID correctly
        // so that we can resolve relative URLs in most of the case.
        // it still doesn't handle xml:base and XInclude and all those things
        // correctly. There's just no way to make all those things work with DOM!
        LocatorImpl loc = new LocatorImpl();
        loc.setSystemId(systemId);
        scanner.setLocator(loc);

        scanner.setContentHandler(getParserHandler(systemId));
        scanner.scan(element);
    } catch (SAXException e) {
        // since parsing DOM shouldn't cause a SAX exception
        // and our handler will never throw it, it's not clear
        // if this will ever happen.
        fatalError(new SAXParseException2(
            e.getMessage(), null, systemId,-1,-1, e));
    }
}
 
Example 8
Source File: WsimportOptions.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Exposing it as a public method to allow external tools such as NB to read from wsdl model and work on it.
 * TODO: WSDL model needs to be exposed - basically at tool time we need to use the runtimw wsdl model
 *
 * Binding files could be jaxws or jaxb. This method identifies jaxws and jaxb binding files and keeps them separately. jaxb binding files are given separately
 * to JAXB in {@link com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder}
 *
 * @param receiver {@link ErrorReceiver}
 */
public final void parseBindings(ErrorReceiver receiver){
    for (InputSource is : bindingFiles) {
        XMLStreamReader reader =
                XMLStreamReaderFactory.create(is,true);
        XMLStreamReaderUtil.nextElementContent(reader);
        if (reader.getName().equals(JAXWSBindingsConstants.JAXWS_BINDINGS)) {
            jaxwsCustomBindings.add(new RereadInputSource(is));
        } else if (reader.getName().equals(JAXWSBindingsConstants.JAXB_BINDINGS) ||
                reader.getName().equals(new QName(SchemaConstants.NS_XSD, "schema"))) {
            jaxbCustomBindings.add(new RereadInputSource(is));
        } else {
            LocatorImpl locator = new LocatorImpl();
            locator.setSystemId(reader.getLocation().getSystemId());
            locator.setPublicId(reader.getLocation().getPublicId());
            locator.setLineNumber(reader.getLocation().getLineNumber());
            locator.setColumnNumber(reader.getLocation().getColumnNumber());
            receiver.warning(locator, ConfigurationMessages.CONFIGURATION_NOT_BINDING_FILE(is.getSystemId()));
        }
    }
}
 
Example 9
Source File: LocatableWebServiceException.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static Locator toLocation(XMLStreamReader xsr) {
    LocatorImpl loc = new LocatorImpl();
    Location in = xsr.getLocation();
    loc.setSystemId(in.getSystemId());
    loc.setPublicId(in.getPublicId());
    loc.setLineNumber(in.getLineNumber());
    loc.setColumnNumber(in.getColumnNumber());
    return loc;
}
 
Example 10
Source File: WSDLParserExtensionFacade.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private Locator getLocator(XMLStreamReader reader) {
    Location location = reader.getLocation();
        LocatorImpl loc = new LocatorImpl();
        loc.setSystemId(location.getSystemId());
        loc.setLineNumber(location.getLineNumber());
    return loc;
}
 
Example 11
Source File: WSDLParserExtensionFacade.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private Locator getLocator(XMLStreamReader reader) {
    Location location = reader.getLocation();
        LocatorImpl loc = new LocatorImpl();
        loc.setSystemId(location.getSystemId());
        loc.setLineNumber(location.getLineNumber());
    return loc;
}
 
Example 12
Source File: CompactSyntax.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void reportEscapeSyntaxException(EscapeSyntaxException e) {
  if (eh != null) {
    LocatorImpl loc = new LocatorImpl();
    loc.setLineNumber(e.getLineNumber());
    loc.setColumnNumber(e.getColumnNumber());
    loc.setSystemId(sourceUri);
    try {
      eh.error(new SAXParseException(localizer.message(e.getKey()), loc));
    }
    catch (SAXException se) {
      throw new BuildException(se);
    }
  }
}
 
Example 13
Source File: CompactSyntax.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void doError(String message, Token tok) {
  hadError = true;
  if (eh != null) {
    LocatorImpl loc = new LocatorImpl();
    loc.setLineNumber(tok.beginLine);
    loc.setColumnNumber(tok.beginColumn);
    loc.setSystemId(sourceUri);
    try {
      eh.error(new SAXParseException(message, loc));
    }
    catch (SAXException se) {
      throw new BuildException(se);
    }
  }
}
 
Example 14
Source File: CompactSyntax.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void reportEscapeSyntaxException(EscapeSyntaxException e) {
  if (eh != null) {
    LocatorImpl loc = new LocatorImpl();
    loc.setLineNumber(e.getLineNumber());
    loc.setColumnNumber(e.getColumnNumber());
    loc.setSystemId(sourceUri);
    try {
      eh.error(new SAXParseException(localizer.message(e.getKey()), loc));
    }
    catch (SAXException se) {
      throw new BuildException(se);
    }
  }
}
 
Example 15
Source File: CompactSyntax.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void reportEscapeSyntaxException(EscapeSyntaxException e) {
  if (eh != null) {
    LocatorImpl loc = new LocatorImpl();
    loc.setLineNumber(e.getLineNumber());
    loc.setColumnNumber(e.getColumnNumber());
    loc.setSystemId(sourceUri);
    try {
      eh.error(new SAXParseException(localizer.message(e.getKey()), loc));
    }
    catch (SAXException se) {
      throw new BuildException(se);
    }
  }
}
 
Example 16
Source File: CompactSyntax.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void doError(String message, Token tok) {
  hadError = true;
  if (eh != null) {
    LocatorImpl loc = new LocatorImpl();
    loc.setLineNumber(tok.beginLine);
    loc.setColumnNumber(tok.beginColumn);
    loc.setSystemId(sourceUri);
    try {
      eh.error(new SAXParseException(message, loc));
    }
    catch (SAXException se) {
      throw new BuildException(se);
    }
  }
}
 
Example 17
Source File: WSDLParserExtensionFacade.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private Locator getLocator(XMLStreamReader reader) {
    Location location = reader.getLocation();
        LocatorImpl loc = new LocatorImpl();
        loc.setSystemId(location.getSystemId());
        loc.setLineNumber(location.getLineNumber());
    return loc;
}
 
Example 18
Source File: LocatableWebServiceException.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static Locator toLocation(XMLStreamReader xsr) {
    LocatorImpl loc = new LocatorImpl();
    Location in = xsr.getLocation();
    loc.setSystemId(in.getSystemId());
    loc.setPublicId(in.getPublicId());
    loc.setLineNumber(in.getLineNumber());
    loc.setColumnNumber(in.getColumnNumber());
    return loc;
}
 
Example 19
Source File: AbstractObjectImpl.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public final @NotNull Locator getLocation() {
    LocatorImpl loc = new LocatorImpl();
    loc.setSystemId(systemId);
    loc.setLineNumber(lineNumber);
    return loc;
}
 
Example 20
Source File: AbstractObjectImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public final @NotNull Locator getLocation() {
    LocatorImpl loc = new LocatorImpl();
    loc.setSystemId(systemId);
    loc.setLineNumber(lineNumber);
    return loc;
}