org.xml.sax.InputSource#getSystemId ( )源码实例Demo

下面列出了org.xml.sax.InputSource#getSystemId ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openjdk-8-source   文件: SAXDocumentParser.java
public void parse(InputSource input) throws IOException, SAXException {
    try {
        InputStream s = input.getByteStream();
        if (s == null) {
            String systemId = input.getSystemId();
            if (systemId == null) {
                throw new SAXException(CommonResourceBundle.getInstance().getString("message.inputSource"));
            }
            parse(systemId);
        } else {
            parse(s);
        }
    } catch (FastInfosetException e) {
        logger.log(Level.FINE, "parsing error", e);
        throw new SAXException(e);
    }
}
 
源代码2 项目: JDKSourceCode1.8   文件: EntityResolver2Wrapper.java
/**
 * Creates an XMLInputSource from a SAX InputSource.
 */
private XMLInputSource createXMLInputSource(InputSource source, String baseURI) {

    String publicId = source.getPublicId();
    String systemId = source.getSystemId();
    String baseSystemId = baseURI;
    InputStream byteStream = source.getByteStream();
    Reader charStream = source.getCharacterStream();
    String encoding = source.getEncoding();
    XMLInputSource xmlInputSource =
        new XMLInputSource(publicId, systemId, baseSystemId);
    xmlInputSource.setByteStream(byteStream);
    xmlInputSource.setCharacterStream(charStream);
    xmlInputSource.setEncoding(encoding);
    return xmlInputSource;

}
 
源代码3 项目: hottub   文件: DOMForestParser.java
public void parse(
    InputSource source,
    ContentHandler contentHandler,
    ErrorHandler errorHandler,
    EntityResolver entityResolver )
    throws SAXException, IOException {

    String systemId = source.getSystemId();
    Document dom = forest.get(systemId);

    if(dom==null) {
        // if no DOM tree is built for it,
        // let the fall back parser parse the original document.
        //
        // for example, XSOM parses datatypes.xsd (XML Schema part 2)
        // but this will never be built into the forest.
        fallbackParser.parse( source, contentHandler, errorHandler, entityResolver );
        return;
    }

    scanner.scan( dom, contentHandler );
}
 
源代码4 项目: hottub   文件: DTDParser.java
/**
 * Parse a DTD.
 */
public void parse(String uri)
        throws IOException, SAXException {
    InputSource in;

    init();
    // System.out.println ("parse (\"" + uri + "\")");
    in = resolver.resolveEntity(null, uri);

    // If custom resolver punts resolution to parser, handle it ...
    if (in == null) {
        in = Resolver.createInputSource(new java.net.URL(uri), false);

        // ... or if custom resolver doesn't correctly construct the
        // input entity, patch it up enough so relative URIs work, and
        // issue a warning to minimize later confusion.
    } else if (in.getSystemId() == null) {
        warning("P-065", null);
        in.setSystemId(uri);
    }

    parseInternal(in);
}
 
源代码5 项目: cacheonix-core   文件: DOMConfigurator.java
/**
   Configure log4j by reading in a log4j.dtd compliant XML
   configuration file.

*/
protected
void doConfigure(final InputSource inputSource, LoggerRepository repository) 
                                        throws FactoryConfigurationError {
    if (inputSource.getSystemId() == null) {
        inputSource.setSystemId("dummy://log4j.dtd");
    }
    ParseAction action = new ParseAction() {
        public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
            return parser.parse(inputSource);
        }
        public String toString() { 
            return "input source [" + inputSource.toString() + "]"; 
        }
    };
    doConfigure(action, repository);
  }
 
源代码6 项目: jdk8u60   文件: EntityResolver2Wrapper.java
/**
 * Creates an XMLInputSource from a SAX InputSource.
 */
private XMLInputSource createXMLInputSource(InputSource source, String baseURI) {

    String publicId = source.getPublicId();
    String systemId = source.getSystemId();
    String baseSystemId = baseURI;
    InputStream byteStream = source.getByteStream();
    Reader charStream = source.getCharacterStream();
    String encoding = source.getEncoding();
    XMLInputSource xmlInputSource =
        new XMLInputSource(publicId, systemId, baseSystemId);
    xmlInputSource.setByteStream(byteStream);
    xmlInputSource.setCharacterStream(charStream);
    xmlInputSource.setEncoding(encoding);
    return xmlInputSource;

}
 
源代码7 项目: openjdk-jdk8u-backup   文件: SAXDocumentParser.java
public void parse(InputSource input) throws IOException, SAXException {
    try {
        InputStream s = input.getByteStream();
        if (s == null) {
            String systemId = input.getSystemId();
            if (systemId == null) {
                throw new SAXException(CommonResourceBundle.getInstance().getString("message.inputSource"));
            }
            parse(systemId);
        } else {
            parse(s);
        }
    } catch (FastInfosetException e) {
        logger.log(Level.FINE, "parsing error", e);
        throw new SAXException(e);
    }
}
 
源代码8 项目: openjdk-jdk8u-backup   文件: DOMForestParser.java
public void parse(InputSource source, ContentHandler handler, ErrorHandler errorHandler, EntityResolver entityResolver)

            throws SAXException, IOException {
        String systemId = source.getSystemId();
        Document dom = forest.get(systemId);

        if (dom == null) {
            // if no DOM tree is built for it,
            // let the fall back parser parse the original document.
            //
            // for example, XSOM parses datatypes.xsd (XML Schema part 2)
            // but this will never be built into the forest.
            fallbackParser.parse(source, handler, errorHandler, entityResolver);
            return;
        }

        scanner.scan(dom, handler);

    }
 
源代码9 项目: openjdk-jdk8u-backup   文件: DTDParser.java
/**
 * Parse a DTD.
 */
public void parse(String uri)
        throws IOException, SAXException {
    InputSource in;

    init();
    // System.out.println ("parse (\"" + uri + "\")");
    in = resolver.resolveEntity(null, uri);

    // If custom resolver punts resolution to parser, handle it ...
    if (in == null) {
        in = Resolver.createInputSource(new java.net.URL(uri), false);

        // ... or if custom resolver doesn't correctly construct the
        // input entity, patch it up enough so relative URIs work, and
        // issue a warning to minimize later confusion.
    } else if (in.getSystemId() == null) {
        warning("P-065", null);
        in.setSystemId(uri);
    }

    parseInternal(in);
}
 
源代码10 项目: netbeans   文件: Util.java
public static FileObject toFileObject(InputSource src) {
   try {
       String sysId = src.getSystemId();
       return FileUtil.toFileObject(new File(new URI(sysId)));
   } catch (URISyntaxException ex) {
       LOG.log(Level.WARNING, "File URI malformed", ex);
       return null;
   }
}
 
源代码11 项目: openjdk-8   文件: SAXInputSource.java
public SAXInputSource(XMLReader reader, InputSource inputSource) {
    super(inputSource != null ? inputSource.getPublicId() : null,
            inputSource != null ? inputSource.getSystemId() : null, null);
    if (inputSource != null) {
        setByteStream(inputSource.getByteStream());
        setCharacterStream(inputSource.getCharacterStream());
        setEncoding(inputSource.getEncoding());
    }
    fInputSource = inputSource;
    fXMLReader = reader;
}
 
源代码12 项目: CloverETL-Engine   文件: XmlUtils.java
public static void setSystemId(InputSource inputSource, URL contextUrl, String input) {
	if (inputSource.getSystemId() == null) {
		String systemId = XmlUtils.getSystemId(contextUrl, input);
		if (systemId != null) {
			inputSource.setSystemId(systemId);
		}
	}
}
 
private boolean parseSomeSetup(InputSource source)
        throws SAXException, IOException, IllegalAccessException,
                                 java.lang.reflect.InvocationTargetException,
                                 java.lang.InstantiationException
{
        if(fConfigSetInput!=null)
        {
                // Obtain input from SAX inputSource object, construct XNI version of
                // that object. Logic adapted from Xerces2.
                Object[] parms1={source.getPublicId(),source.getSystemId(),null};
                Object xmlsource=fConfigInputSourceCtor.newInstance(parms1);
                Object[] parmsa={source.getByteStream()};
                fConfigSetByteStream.invoke(xmlsource,parmsa);
                parmsa[0]=source.getCharacterStream();
                fConfigSetCharStream.invoke(xmlsource,parmsa);
                parmsa[0]=source.getEncoding();
                fConfigSetEncoding.invoke(xmlsource,parmsa);

                // Bugzilla5272 patch suggested by Sandy Gao.
                // Has to be reflection to run with Xerces2
                // after compilation against Xerces1. or vice
                // versa, due to return type mismatches.
                Object[] noparms=new Object[0];
                fReset.invoke(fIncrementalParser,noparms);

                parmsa[0]=xmlsource;
                fConfigSetInput.invoke(fPullParserConfig,parmsa);

                // %REVIEW% Do first pull. Should we instead just return true?
                return parseSome();
        }
        else
        {
                Object[] parm={source};
                Object ret=fParseSomeSetup.invoke(fIncrementalParser,parm);
                return ((Boolean)ret).booleanValue();
        }
}
 
源代码14 项目: commons-configuration   文件: XMLConfiguration.java
/**
 * Loads a configuration file from the specified input source.
 *
 * @param source the input source
 * @throws ConfigurationException if an error occurs
 */
private void load(final InputSource source) throws ConfigurationException
{
    if (locator == null)
    {
        throw new ConfigurationException("Load operation not properly "
                + "initialized! Do not call read(InputStream) directly,"
                + " but use a FileHandler to load a configuration.");
    }

    try
    {
        final URL sourceURL = locator.getSourceURL();
        if (sourceURL != null)
        {
            source.setSystemId(sourceURL.toString());
        }

        final DocumentBuilder builder = createDocumentBuilder();
        final Document newDocument = builder.parse(source);
        final Document oldDocument = getDocument();
        initProperties(XMLDocumentHelper.forSourceDocument(newDocument),
                oldDocument == null);
    }
    catch (final SAXParseException spe)
    {
        throw new ConfigurationException("Error parsing " + source.getSystemId(), spe);
    }
    catch (final Exception e)
    {
        this.getLogger().debug("Unable to load the configuration: " + e);
        throw new ConfigurationException("Unable to load the configuration", e);
    }
}
 
源代码15 项目: cxf   文件: AbstractWrapperWSDLLocator.java
public InputSource getBaseInputSource() {
    InputSource is = parent.getBaseInputSource();
    fromParent = true;
    if (is == null) {
        is = getInputSource();
        fromParent = false;
    } else {
        baseUri = is.getSystemId();
    }
    last = is;

    return is;
}
 
源代码16 项目: openjdk-jdk9   文件: XMLInputSource.java
/**
 * Constructs an input source from a SAX InputSource
 * object.
 *
 * @param inputSource  a SAX InputSource
 * @param isCreatedByResolver a flag to indicate whether the source is
 * created by a resolver
 */
public XMLInputSource(InputSource inputSource, boolean isCreatedByResolver) {
    fPublicId = inputSource.getPublicId();
    fSystemId = inputSource.getSystemId();
    fByteStream = inputSource.getByteStream();
    fCharStream = inputSource.getCharacterStream();
    fEncoding = inputSource.getEncoding();
    fIsCreatedByResolver = isCreatedByResolver;
}
 
源代码17 项目: TencentKona-8   文件: SAXInputSource.java
public SAXInputSource(XMLReader reader, InputSource inputSource) {
    super(inputSource != null ? inputSource.getPublicId() : null,
            inputSource != null ? inputSource.getSystemId() : null, null);
    if (inputSource != null) {
        setByteStream(inputSource.getByteStream());
        setCharacterStream(inputSource.getCharacterStream());
        setEncoding(inputSource.getEncoding());
    }
    fInputSource = inputSource;
    fXMLReader = reader;
}
 
private boolean parseSomeSetup(InputSource source)
        throws SAXException, IOException, IllegalAccessException,
                                 java.lang.reflect.InvocationTargetException,
                                 java.lang.InstantiationException
{
        if(fConfigSetInput!=null)
        {
                // Obtain input from SAX inputSource object, construct XNI version of
                // that object. Logic adapted from Xerces2.
                Object[] parms1={source.getPublicId(),source.getSystemId(),null};
                Object xmlsource=fConfigInputSourceCtor.newInstance(parms1);
                Object[] parmsa={source.getByteStream()};
                fConfigSetByteStream.invoke(xmlsource,parmsa);
                parmsa[0]=source.getCharacterStream();
                fConfigSetCharStream.invoke(xmlsource,parmsa);
                parmsa[0]=source.getEncoding();
                fConfigSetEncoding.invoke(xmlsource,parmsa);

                // Bugzilla5272 patch suggested by Sandy Gao.
                // Has to be reflection to run with Xerces2
                // after compilation against Xerces1. or vice
                // versa, due to return type mismatches.
                Object[] noparms=new Object[0];
                fReset.invoke(fIncrementalParser,noparms);

                parmsa[0]=xmlsource;
                fConfigSetInput.invoke(fPullParserConfig,parmsa);

                // %REVIEW% Do first pull. Should we instead just return true?
                return parseSome();
        }
        else
        {
                Object[] parm={source};
                Object ret=fParseSomeSetup.invoke(fIncrementalParser,parm);
                return ((Boolean)ret).booleanValue();
        }
}
 
private boolean parseSomeSetup(InputSource source)
        throws SAXException, IOException, IllegalAccessException,
                                 java.lang.reflect.InvocationTargetException,
                                 java.lang.InstantiationException
{
        if(fConfigSetInput!=null)
        {
                // Obtain input from SAX inputSource object, construct XNI version of
                // that object. Logic adapted from Xerces2.
                Object[] parms1={source.getPublicId(),source.getSystemId(),null};
                Object xmlsource=fConfigInputSourceCtor.newInstance(parms1);
                Object[] parmsa={source.getByteStream()};
                fConfigSetByteStream.invoke(xmlsource,parmsa);
                parmsa[0]=source.getCharacterStream();
                fConfigSetCharStream.invoke(xmlsource,parmsa);
                parmsa[0]=source.getEncoding();
                fConfigSetEncoding.invoke(xmlsource,parmsa);

                // Bugzilla5272 patch suggested by Sandy Gao.
                // Has to be reflection to run with Xerces2
                // after compilation against Xerces1. or vice
                // versa, due to return type mismatches.
                Object[] noparms=new Object[0];
                fReset.invoke(fIncrementalParser,noparms);

                parmsa[0]=xmlsource;
                fConfigSetInput.invoke(fPullParserConfig,parmsa);

                // %REVIEW% Do first pull. Should we instead just return true?
                return parseSome();
        }
        else
        {
                Object[] parm={source};
                Object ret=fParseSomeSetup.invoke(fIncrementalParser,parm);
                return ((Boolean)ret).booleanValue();
        }
}
 
源代码20 项目: mycore   文件: MCREntityResolver.java
private InputSource resolvedEntity(InputSource entity) {
    String msg = "Resolved to: " + entity.getSystemId() + ".";
    LOGGER.debug(msg);
    return entity;
}