Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.github.jsr330.spi.config.xml;
 
 import java.io.File;
 import java.io.Reader;
This is a simple com.github.jsr330.spi.config.builder.ConfigBuilder-based SAX configurator.
public class XmlConfig {
    
    static final Logger LOGGER = LoggerFactory.getLogger(XmlConfig.class);
    
    protected Reader source;
    
    public XmlConfig(String json) {
         = new StringReader(json);
    }
    
    public XmlConfig(File filethrows FileNotFoundException {
         = new InputStreamReader(new FileInputStream(file));
    }
    
    public XmlConfig(URL sourcethrows IOException {
        this. = new InputStreamReader(source.openStream());
    }
    
    public XmlConfig(byte[] json) {
         = new StringReader(new String(json));
    }
    
    public XmlConfig(byte[] jsonCharset charset) {
         = new StringReader(new String(jsoncharset));
    }
    
    public XmlConfig(InputStream source) {
        this. = new InputStreamReader(source);
    }
    
    public XmlConfig(Reader source) {
        this. = source;
    }
    
    
Gets the com.github.jsr330.spi.TypeConfig by parsing the XML file. The correct sequence is ensured by the corresponding XSD file.
    public TypeConfig getConfig(final ClassLoader loaderthrows IOExceptionSAXException {
        final ConfigBuilder builder = new ConfigBuilder();
        XMLReader sax;
        
        if ( != null) {
            try {
                sax = XMLReaderFactory.createXMLReader();
                sax.setContentHandler(new ConfigHandler(loaderbuilder));
                sax.parse(new InputSource());
                
                return builder.build();
            } finally {
                try {
                    .close();
                } catch (IOException exception) {
                    .debug("error while closing reader."exception);
                }
            }
        }
        
        return null;
    }
    
New to GrepCode? Check out our FAQ X