fi.iki.hsivonen.xml
Class PrudentHttpEntityResolver

java.lang.Object
  extended by fi.iki.hsivonen.xml.PrudentHttpEntityResolver
All Implemented Interfaces:
EntityResolver

public class PrudentHttpEntityResolver
extends Object
implements EntityResolver

Version:
$Id: PrudentHttpEntityResolver.java,v 1.1 2005/01/08 08:11:26 hsivonen Exp $
Author:
hsivonen

Field Summary
private  boolean acceptAllKnownXmlTypes
           
private  boolean allowGenericXml
           
private  boolean allowHtml
           
private  boolean allowRnc
           
private  boolean allowXhtml
           
private static Pattern CHARSET
           
private static org.apache.commons.httpclient.HttpClient client
           
private  ErrorHandler errorHandler
           
private  com.hp.hpl.jena.iri.IRIFactory iriFactory
           
private  boolean laxContentType
           
private static org.apache.log4j.Logger log4j
           
private static org.apache.commons.httpclient.MultiThreadedHttpConnectionManager manager
           
private static int maxRequests
           
private  int requestsLeft
           
private  int sizeLimit
           
 
Constructor Summary
PrudentHttpEntityResolver(int sizeLimit, boolean laxContentType, ErrorHandler errorHandler)
           
 
Method Summary
private  String buildAccept()
           
 boolean isAcceptAllKnownXmlTypes()
          Returns the acceptAllKnownXmlTypes.
 boolean isAllowGenericXml()
          Returns the allowGenericXml.
 boolean isAllowHtml()
          Returns the allowHtml.
 boolean isAllowRnc()
           
 boolean isAllowXhtml()
          Returns the allowXhtml.
 boolean isOnlyHtmlAllowed()
           
 InputSource resolveEntity(String publicId, String systemId)
           
protected  boolean rncContentType(String type, InputSource is)
           
 void setAcceptAllKnownXmlTypes(boolean acceptAllKnownXmlTypes)
          Sets the acceptAllKnownXmlTypes.
 void setAllowGenericXml(boolean allowGenericXml)
          Sets the allowGenericXml.
 void setAllowHtml(boolean expectHtml)
           
 void setAllowRnc(boolean allowRnc)
           
 void setAllowXhtml(boolean allowXhtml)
          Sets the allowXhtml.
static void setParams(int connectionTimeout, int socketTimeout, int maxRequests)
          Sets the timeouts of the HTTP client.
static void setUserAgent(String ua)
           
protected  boolean xmlContentType(String type, InputSource is)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log4j

private static final org.apache.log4j.Logger log4j

CHARSET

private static final Pattern CHARSET

manager

private static final org.apache.commons.httpclient.MultiThreadedHttpConnectionManager manager

client

private static final org.apache.commons.httpclient.HttpClient client

maxRequests

private static int maxRequests

sizeLimit

private int sizeLimit

errorHandler

private ErrorHandler errorHandler

requestsLeft

private int requestsLeft

laxContentType

private boolean laxContentType

allowRnc

private boolean allowRnc

allowHtml

private boolean allowHtml

allowXhtml

private boolean allowXhtml

acceptAllKnownXmlTypes

private boolean acceptAllKnownXmlTypes

allowGenericXml

private boolean allowGenericXml

iriFactory

private com.hp.hpl.jena.iri.IRIFactory iriFactory
Constructor Detail

PrudentHttpEntityResolver

public PrudentHttpEntityResolver(int sizeLimit,
                                 boolean laxContentType,
                                 ErrorHandler errorHandler)
Parameters:
connectionTimeout -
socketTimeout -
sizeLimit -
Method Detail

setParams

public static void setParams(int connectionTimeout,
                             int socketTimeout,
                             int maxRequests)
Sets the timeouts of the HTTP client.

Parameters:
connectionTimeout - timeout until connection established in milliseconds. Zero means no timeout.
socketTimeout - timeout for waiting for data in milliseconds. Zero means no timeout.

setUserAgent

public static void setUserAgent(String ua)

resolveEntity

public InputSource resolveEntity(String publicId,
                                 String systemId)
                          throws SAXException,
                                 IOException
Specified by:
resolveEntity in interface EntityResolver
Throws:
SAXException
IOException
See Also:
EntityResolver.resolveEntity(java.lang.String, java.lang.String)

xmlContentType

protected boolean xmlContentType(String type,
                                 InputSource is)
                          throws SAXException
Throws:
SAXException

rncContentType

protected boolean rncContentType(String type,
                                 InputSource is)
                          throws SAXException
Throws:
SAXException

isAllowRnc

public boolean isAllowRnc()
Returns:
Returns the allowRnc.

setAllowRnc

public void setAllowRnc(boolean allowRnc)
Parameters:
allowRnc - The allowRnc to set.

setAllowHtml

public void setAllowHtml(boolean expectHtml)
Parameters:
b -

isAcceptAllKnownXmlTypes

public boolean isAcceptAllKnownXmlTypes()
Returns the acceptAllKnownXmlTypes.

Returns:
the acceptAllKnownXmlTypes

setAcceptAllKnownXmlTypes

public void setAcceptAllKnownXmlTypes(boolean acceptAllKnownXmlTypes)
Sets the acceptAllKnownXmlTypes.

Parameters:
acceptAllKnownXmlTypes - the acceptAllKnownXmlTypes to set

isAllowGenericXml

public boolean isAllowGenericXml()
Returns the allowGenericXml.

Returns:
the allowGenericXml

setAllowGenericXml

public void setAllowGenericXml(boolean allowGenericXml)
Sets the allowGenericXml.

Parameters:
allowGenericXml - the allowGenericXml to set

isAllowXhtml

public boolean isAllowXhtml()
Returns the allowXhtml.

Returns:
the allowXhtml

setAllowXhtml

public void setAllowXhtml(boolean allowXhtml)
Sets the allowXhtml.

Parameters:
allowXhtml - the allowXhtml to set

buildAccept

private String buildAccept()

isAllowHtml

public boolean isAllowHtml()
Returns the allowHtml.

Returns:
the allowHtml

isOnlyHtmlAllowed

public boolean isOnlyHtmlAllowed()