Java 类org.xml.sax.helpers.LocatorImpl 实例源码

项目:In-the-Box-Fork    文件:ParserAdapterTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    method = "setDocumentLocator",
    args = { Locator.class }
)
public void testSetDocumentLocator() {
    Locator l = new LocatorImpl();

    adapter.setDocumentLocator(l);

    assertEquals(logger.size(), 1);
    assertEquals("setDocumentLocator", logger.getMethod());
    assertEquals(new Object[] { l }, logger.getArgs());

    adapter.setDocumentLocator(null);

    assertEquals(logger.size(), 2);
    assertEquals("setDocumentLocator", logger.getMethod());
    assertEquals(new Object[] { null }, logger.getArgs());
}
项目:In-the-Box-Fork    文件:LocatorImplTest.java   
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "setSystemId",
        args = { String.class }
    ),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "getSystemId",
        args = { }
    )
})
public void testSetSystemIdGetSystemId() {
    LocatorImpl l = new LocatorImpl();

    l.setSystemId(SYS);
    assertEquals(SYS, l.getSystemId());

    l.setSystemId(null);
    assertEquals(null, l.getSystemId());
}
项目:OpenJSharp    文件:ClassBeanInfoImpl.java   
public BeanT createInstance(UnmarshallingContext context) throws IllegalAccessException, InvocationTargetException, InstantiationException, SAXException {

        BeanT bean = null;
        if (factoryMethod == null){
           bean = ClassFactory.create0(jaxbType);
        }else {
            Object o = ClassFactory.create(factoryMethod);
            if( jaxbType.isInstance(o) ){
                bean = (BeanT)o;
            } else {
                throw new InstantiationException("The factory method didn't return a correct object");
            }
        }

        if(xmlLocatorField!=null)
            // need to copy because Locator is mutable
            try {
                xmlLocatorField.set(bean,new LocatorImpl(context.getLocator()));
            } catch (AccessorException e) {
                context.handleError(e);
            }
        return bean;
    }
项目:OpenJSharp    文件:WsimportOptions.java   
/**
 * 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()));
        }
    }
}
项目:OpenJSharp    文件:SchemaCompilerImpl.java   
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));
    }
}
项目:OpenJSharp    文件:DomHandlerEx.java   
ResultImpl() {
    try {
        DocumentBuilderFactory factory = XmlFactory.createDocumentBuilderFactory(false); // safe - only used for BI
        s2d = new SAX2DOMEx(factory);
    } catch (ParserConfigurationException e) {
        throw new AssertionError(e);    // impossible
    }

    XMLFilterImpl f = new XMLFilterImpl() {
        @Override
        public void setDocumentLocator(Locator locator) {
            super.setDocumentLocator(locator);
            location = new LocatorImpl(locator);
        }
    };
    f.setContentHandler(s2d);

    setHandler(f);
}
项目:OpenJSharp    文件:SchemaContentHandler.java   
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);
}
项目:openjdk-jdk10    文件:SchemaCompilerImpl.java   
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));
    }
}
项目:openjdk-jdk10    文件:DomHandlerEx.java   
ResultImpl() {
    try {
        DocumentBuilderFactory factory = XmlFactory.createDocumentBuilderFactory(false); // safe - only used for BI
        s2d = new SAX2DOMEx(factory);
    } catch (ParserConfigurationException e) {
        throw new AssertionError(e);    // impossible
    }

    XMLFilterImpl f = new XMLFilterImpl() {
        @Override
        public void setDocumentLocator(Locator locator) {
            super.setDocumentLocator(locator);
            location = new LocatorImpl(locator);
        }
    };
    f.setContentHandler(s2d);

    setHandler(f);
}
项目:openjdk-jdk10    文件:WsimportOptions.java   
/**
 * 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()));
        }
    }
}
项目:openjdk-jdk10    文件:ClassBeanInfoImpl.java   
public BeanT createInstance(UnmarshallingContext context) throws IllegalAccessException, InvocationTargetException, InstantiationException, SAXException {

        BeanT bean = null;
        if (factoryMethod == null){
           bean = ClassFactory.create0(jaxbType);
        }else {
            Object o = ClassFactory.create(factoryMethod);
            if( jaxbType.isInstance(o) ){
                bean = (BeanT)o;
            } else {
                throw new InstantiationException("The factory method didn't return a correct object");
            }
        }

        if(xmlLocatorField!=null)
            // need to copy because Locator is mutable
            try {
                xmlLocatorField.set(bean,new LocatorImpl(context.getLocator()));
            } catch (AccessorException e) {
                context.handleError(e);
            }
        return bean;
    }
项目:openjdk-jdk10    文件:SchemaContentHandler.java   
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);
}
项目:openjdk9    文件:SchemaCompilerImpl.java   
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));
    }
}
项目:openjdk9    文件:DomHandlerEx.java   
ResultImpl() {
    try {
        DocumentBuilderFactory factory = XmlFactory.createDocumentBuilderFactory(false); // safe - only used for BI
        s2d = new SAX2DOMEx(factory);
    } catch (ParserConfigurationException e) {
        throw new AssertionError(e);    // impossible
    }

    XMLFilterImpl f = new XMLFilterImpl() {
        @Override
        public void setDocumentLocator(Locator locator) {
            super.setDocumentLocator(locator);
            location = new LocatorImpl(locator);
        }
    };
    f.setContentHandler(s2d);

    setHandler(f);
}
项目:openjdk9    文件:WsimportOptions.java   
/**
 * 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()));
        }
    }
}
项目:openjdk9    文件:ClassBeanInfoImpl.java   
public BeanT createInstance(UnmarshallingContext context) throws IllegalAccessException, InvocationTargetException, InstantiationException, SAXException {

        BeanT bean = null;
        if (factoryMethod == null){
           bean = ClassFactory.create0(jaxbType);
        }else {
            Object o = ClassFactory.create(factoryMethod);
            if( jaxbType.isInstance(o) ){
                bean = (BeanT)o;
            } else {
                throw new InstantiationException("The factory method didn't return a correct object");
            }
        }

        if(xmlLocatorField!=null)
            // need to copy because Locator is mutable
            try {
                xmlLocatorField.set(bean,new LocatorImpl(context.getLocator()));
            } catch (AccessorException e) {
                context.handleError(e);
            }
        return bean;
    }
项目:openjdk9    文件:SchemaContentHandler.java   
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);
}
项目:lookaside_java-1.8.0-openjdk    文件:LocatableWebServiceException.java   
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;
}
项目:lookaside_java-1.8.0-openjdk    文件:ClassBeanInfoImpl.java   
public BeanT createInstance(UnmarshallingContext context) throws IllegalAccessException, InvocationTargetException, InstantiationException, SAXException {

        BeanT bean = null;
        if (factoryMethod == null){
           bean = ClassFactory.create0(jaxbType);
        }else {
            Object o = ClassFactory.create(factoryMethod);
            if( jaxbType.isInstance(o) ){
                bean = (BeanT)o;
            } else {
                throw new InstantiationException("The factory method didn't return a correct object");
            }
        }

        if(xmlLocatorField!=null)
            // need to copy because Locator is mutable
            try {
                xmlLocatorField.set(bean,new LocatorImpl(context.getLocator()));
            } catch (AccessorException e) {
                context.handleError(e);
            }
        return bean;
    }
项目:lookaside_java-1.8.0-openjdk    文件:WsimportOptions.java   
/**
 * 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()));
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:SchemaCompilerImpl.java   
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));
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:DomHandlerEx.java   
ResultImpl() {
    try {
        DocumentBuilderFactory factory = XmlFactory.createDocumentBuilderFactory(false); // safe - only used for BI
        s2d = new SAX2DOMEx(factory);
    } catch (ParserConfigurationException e) {
        throw new AssertionError(e);    // impossible
    }

    XMLFilterImpl f = new XMLFilterImpl() {
        @Override
        public void setDocumentLocator(Locator locator) {
            super.setDocumentLocator(locator);
            location = new LocatorImpl(locator);
        }
    };
    f.setContentHandler(s2d);

    setHandler(f);
}
项目:lookaside_java-1.8.0-openjdk    文件:SchemaContentHandler.java   
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);
}
项目:max-ws    文件:SchemaCompilerEx.java   
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));
    }
}
项目:infobip-open-jdk-8    文件:ClassBeanInfoImpl.java   
public BeanT createInstance(UnmarshallingContext context) throws IllegalAccessException, InvocationTargetException, InstantiationException, SAXException {

        BeanT bean = null;
        if (factoryMethod == null){
           bean = ClassFactory.create0(jaxbType);
        }else {
            Object o = ClassFactory.create(factoryMethod);
            if( jaxbType.isInstance(o) ){
                bean = (BeanT)o;
            } else {
                throw new InstantiationException("The factory method didn't return a correct object");
            }
        }

        if(xmlLocatorField!=null)
            // need to copy because Locator is mutable
            try {
                xmlLocatorField.set(bean,new LocatorImpl(context.getLocator()));
            } catch (AccessorException e) {
                context.handleError(e);
            }
        return bean;
    }
项目:infobip-open-jdk-8    文件:WsimportOptions.java   
/**
 * 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()));
        }
    }
}
项目:infobip-open-jdk-8    文件:SchemaCompilerImpl.java   
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));
    }
}
项目:infobip-open-jdk-8    文件:DomHandlerEx.java   
ResultImpl() {
    try {
        DocumentBuilderFactory factory = XmlFactory.createDocumentBuilderFactory(false); // safe - only used for BI
        s2d = new SAX2DOMEx(factory);
    } catch (ParserConfigurationException e) {
        throw new AssertionError(e);    // impossible
    }

    XMLFilterImpl f = new XMLFilterImpl() {
        @Override
        public void setDocumentLocator(Locator locator) {
            super.setDocumentLocator(locator);
            location = new LocatorImpl(locator);
        }
    };
    f.setContentHandler(s2d);

    setHandler(f);
}
项目:infobip-open-jdk-8    文件:SchemaContentHandler.java   
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);
}
项目:jing-trang    文件:PatternMatcherTest.java   
@DataProvider(name = "startTagPairs")
Object[][] startTagPairs() {
  final Name foo = new Name("", "foo");
  final Name bar = new Name("", "bar");
  Set<Name> nameSet = new HashSet<Name>();
  nameSet.add(foo);
  nameSet.add(bar);
  final NormalizedNameClass foobarNNC = new NormalizedNsNameClass(nameSet, EMPTY_MAP);
  final Locator loc = new LocatorImpl();
  return new Object[][] {
          { rootMatcher(makeChoice(makeElement(new SimpleNameClass(foo), makeEmpty(), loc),
                                   makeElement(new SimpleNameClass(bar), makeEmpty(), loc))),
            foobarNNC }

  };
}
项目:jing-trang    文件:PatternMatcherTest.java   
@DataProvider(name = "attributePairs")
Object[][] attributePairs() {
  final Name foo = new Name("", "foo");
  final Name bar = new Name("", "bar");
  Set<Name> nameSet = new HashSet<Name>();
  nameSet.add(foo);
  nameSet.add(bar);
  final NormalizedNameClass foobarNNC = new NormalizedNsNameClass(nameSet, EMPTY_MAP);
  final Locator loc = new LocatorImpl();
  return new Object[][] {
          { rootAttributeMatcher(makeElement(new SimpleNameClass(root),
                                             makeGroup(makeAttribute(new SimpleNameClass(foo), makeText(), loc),
                                                       makeAttribute(new SimpleNameClass(bar), makeText(), loc)),
                                             loc)),
            foobarNNC }                    
  };
}
项目:xerces-for-android    文件:SchemaContentHandler.java   
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);
}
项目:ttt    文件:Converter.java   
private int hasTextField(LocatorImpl locator, String[] parts, int partIndex, NonTextAttributeTreatment nonTextAttributeTreatment) {
    while (partIndex < parts.length) {
        String field = parts[partIndex];
        if (field.length() == 0) {
            return -1;
        } else {
            int[] delims = countTextAttributeDelimiters(field);
            if (inTextAttribute) {
                if ((delims[1] > 0) && (delims[0] < delims[1]))
                    inTextAttribute = false;
                return partIndex;
            } else if (isTextField(locator, field, partIndex, nonTextAttributeTreatment)) {
                return partIndex;
            } else if ((delims[0] > 0) && (delims[0] > delims[1])) {
                inTextAttribute = true;
                return partIndex;
            } else
                return -1;
        }
    }
    return -1;
}
项目:cxf-plus    文件:ClassBeanInfoImpl.java   
public BeanT createInstance(UnmarshallingContext context) throws IllegalAccessException, InvocationTargetException, InstantiationException, SAXException {

    BeanT bean = null;        
    if (factoryMethod == null){
       bean = ClassFactory.create0(jaxbType);
    }else {
        Object o = ClassFactory.create(factoryMethod);
        if( jaxbType.isInstance(o) ){
            bean = (BeanT)o;
        } else {
            throw new InstantiationException("The factory method didn't return a correct object");
        }
    }

    if(xmlLocatorField!=null)
        // need to copy because Locator is mutable
        try {
            xmlLocatorField.set(bean,new LocatorImpl(context.getLocator()));
        } catch (AccessorException e) {
            context.handleError(e);
        }
    return bean;
}
项目:In-the-Box-Fork    文件:XMLFilterImplTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    method = "setDocumentLocator",
    args = { Locator.class }
)
public void testSetDocumentLocator() {
    Locator l = new LocatorImpl();

    child.setDocumentLocator(l);

    assertEquals(logger.size(), 1);
    assertEquals("setDocumentLocator", logger.getMethod());
    assertEquals(new Object[] { l }, logger.getArgs());

    child.setDocumentLocator(null);

    assertEquals(logger.size(), 2);
    assertEquals("setDocumentLocator", logger.getMethod());
    assertEquals(new Object[] { null }, logger.getArgs());
}
项目:In-the-Box-Fork    文件:LocatorImplTest.java   
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "setPublicId",
        args = { String.class }
    ),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "getPublicId",
        args = { }
    )
})
public void testSetPublicIdGetPublicId() {
    LocatorImpl l = new LocatorImpl();

    l.setPublicId(PUB);
    assertEquals(PUB, l.getPublicId());

    l.setPublicId(null);
    assertEquals(null, l.getPublicId());
}
项目:In-the-Box-Fork    文件:LocatorImplTest.java   
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "setLineNumber",
        args = { int.class }
    ),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "getLineNumber",
        args = { }
    )
})
public void testSetLineNumberGetLineNumber() {
    LocatorImpl l = new LocatorImpl();

    l.setLineNumber(ROW);
    assertEquals(ROW, l.getLineNumber());

    l.setLineNumber(0);
    assertEquals(0, l.getLineNumber());
}
项目:In-the-Box-Fork    文件:LocatorImplTest.java   
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "setColumnNumber",
        args = { int.class }
    ),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "getColumnNumber",
        args = { }
    )
})
public void testSetColumnNumberGetColumnNumber() {
    LocatorImpl l = new LocatorImpl();

    l.setColumnNumber(COL);
    assertEquals(COL, l.getColumnNumber());

    l.setColumnNumber(0);
    assertEquals(0, l.getColumnNumber());
}
项目:In-the-Box-Fork    文件:XMLReaderAdapterTest.java   
@TestTargetNew(
    level = TestLevel.COMPLETE,
    method = "setDocumentLocator",
    args = { Locator.class }
)
public void testSetDocumentLocator() {
    // Ordinary case
    LocatorImpl locator = new LocatorImpl();
    adapter.setDocumentLocator(locator);

    assertEquals("setDocumentLocator", logger.getMethod());
    assertEquals(new Object[] { locator }, logger.getArgs());

    // null case (for the DocumentHandler itself!)
    adapter.setDocumentHandler(null);
    adapter.setDocumentLocator(locator);
}
项目:OLD-OpenJDK8    文件:ClassBeanInfoImpl.java   
public BeanT createInstance(UnmarshallingContext context) throws IllegalAccessException, InvocationTargetException, InstantiationException, SAXException {

        BeanT bean = null;
        if (factoryMethod == null){
           bean = ClassFactory.create0(jaxbType);
        }else {
            Object o = ClassFactory.create(factoryMethod);
            if( jaxbType.isInstance(o) ){
                bean = (BeanT)o;
            } else {
                throw new InstantiationException("The factory method didn't return a correct object");
            }
        }

        if(xmlLocatorField!=null)
            // need to copy because Locator is mutable
            try {
                xmlLocatorField.set(bean,new LocatorImpl(context.getLocator()));
            } catch (AccessorException e) {
                context.handleError(e);
            }
        return bean;
    }