Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package nu.validator.xml;
 
 import java.io.File;
 import java.util.Map;
 

Author(s):
hsivonen
Version:
$Id$
public class LocalCacheEntityResolver implements EntityResolver {
    private Map<StringStringpathMap;
    private EntityResolver delegate;
    
    private boolean allowRnc = false;

    
The map must be safe for concurrent reads.

Parameters:
pathMap
delegate
    public LocalCacheEntityResolver(Map<StringStringpathMapEntityResolver delegate) {
        this. = pathMap;
        this. = delegate;
    }
    
    public InputSource resolveEntity(String publicIdString systemId)
            throws SAXExceptionIOException {
        String path = .get(systemId);
        if(path != null) {
            File f = new File(path);
            if (f.exists()) {
                TypedInputSource is = new TypedInputSource();
                is.setByteStream(new FileInputStream(f));
                is.setSystemId(systemId);
                is.setPublicId(publicId);
                if(systemId.endsWith(".rnc")) {
                    is.setType("application/relax-ng-compact-syntax");
                    if(!) {
                        throw new IOException("Not an XML resource: " + systemId);
                    }
                } else if(systemId.endsWith(".dtd")) {
                    is.setType("application/xml-dtd");  
                } else if(systemId.endsWith(".ent")) {
                    is.setType("application/xml-external-parsed-entity");                    
                } else {
                    is.setType("application/xml");                    
                }
                return is;
            }            
        }
        return .resolveEntity(publicIdsystemId);
    }

    

Returns:
Returns the allowRnc.
    public boolean isAllowRnc() {
        return ;
    }
    

Parameters:
allowRnc The allowRnc to set.
    public void setAllowRnc(boolean allowRnc) {
        this. = allowRnc;
    }
New to GrepCode? Check out our FAQ X