Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 // Copyright © 2013 Solita Oy <www.solita.fi>
 // This software is released under the MIT License.
 // The license text is at http://opensource.org/licenses/MIT
 
 package fi.solita.datatree.xml;
 
 
public class MappedResourceResolver implements LSResourceResolver {
    private static DOMImplementationLS lsFactory;
    static {
        try {
            DOMImplementation impl = DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation();
             = (DOMImplementationLSimpl;
        } catch (ParserConfigurationException e) {
            throw new RuntimeException(e);
        }
    }
    private final Map<StringStringsystemIdsByNamespace = new ConcurrentHashMap<>();
    public MappedResourceResolver() {
        with(.getClass().getResource("xml.xsd"));
    }
    public MappedResourceResolver with(String namespaceURIURL newSystemId) {
        return with(namespaceURInewSystemId.toString());
    }
    public MappedResourceResolver with(String namespaceURIString newSystemId) {
        .put(namespaceURInewSystemId);
        return this;
    }
    @Override
    public LSInput resolveResource(String typeString namespaceURIString publicIdString systemIdString baseURI) {
        if (type.equals(.)) {
            String newSystemId = .get(namespaceURI);
            if (newSystemId != null) {
                LSInput input = .createLSInput();
                input.setSystemId(newSystemId);
                return input;
            }
        }
        return null;
    }
New to GrepCode? Check out our FAQ X