Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package nu.validator.localentities;
  
  import java.util.HashMap;
  import java.util.Map;
  
 

Author(s):
hsivonen
Version:
$Id: LocalCacheEntityResolver.java 74 2008-09-17 10:34:15Z hsivonen $
 
 public class LocalCacheEntityResolver implements EntityResolver {
 
     private static final ClassLoader LOADER = LocalCacheEntityResolver.class.getClassLoader();
 
     private static final Map<StringStringPATH_MAP = new HashMap<StringString>();
 
     static {
         try {
             BufferedReader r = new BufferedReader(new InputStreamReader(
                     .getResourceAsStream("nu/validator/localentities/files/entitymap"), "UTF-8"));
             String line;
             while ((line = r.readLine()) != null) {
                 if ("".equals(line.trim())) {
                     break;
                 }
                 String s[] = line.split("\t");
                 .put(s[0], "nu/validator/localentities/files/" + s[1]);
             }
         } catch (IOException e) {
             throw new RuntimeException(e);
         }
     }
 
     public static InputStream getPresetsAsStream() {
         return .getResourceAsStream("nu/validator/localentities/files/presets");
     }
 
     public static InputStream getHtml5SpecAsStream() {
         return .getResourceAsStream("nu/validator/localentities/files/html5spec");
     }
     
     private EntityResolver delegate;
 
     private boolean allowRnc = false;

    

Parameters:
delegate
 
     public LocalCacheEntityResolver(EntityResolver delegate) {
         this. = delegate;
     }

    
 
     public InputSource resolveEntity(String publicIdString systemId)
             throws SAXExceptionIOException {
         String path = .get(systemId);
         if (path != null) {
             InputStream stream = .getResourceAsStream(path);
             if (stream != null) {
                 TypedInputSource is = new TypedInputSource();
                 is.setByteStream(stream);
                 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