Package com.meterware.httpunit
Class HttpUnitUtils
- java.lang.Object
-
- com.meterware.httpunit.HttpUnitUtils
-
public class HttpUnitUtils extends java.lang.ObjectUtility code shared by httpunit and servletunit.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_CHARACTER_SETstatic intDEFAULT_TEXT_BUFFER_SIZE
-
Constructor Summary
Constructors Constructor Description HttpUnitUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Stringdecode(java.lang.String byteString)Returns an interpretation of the specified URL-encoded string, using the iso-8859-1 character set.static java.lang.Stringdecode(java.lang.String string, java.lang.String charset)Decodes a URL safe string into its original form using the specified character set.static voidhandleException(java.lang.Throwable th)handle Exceptions and thowablesstatic booleanisEclipse()are we running in the Eclipse IDE?protected static booleanisEXCEPTION_DEBUG()static javax.xml.parsers.DocumentBuildernewParser()creates a parser using JAXP API.static org.w3c.dom.Documentparse(java.io.InputStream inputStream)parse the given inputStream with a new Parserstatic org.w3c.dom.Documentparse(org.xml.sax.InputSource inputSource)parse the given inputSource with a new Parserstatic java.lang.String[]parseContentTypeHeader(java.lang.String header)Returns the content type and encoding as a pair of strings.static java.lang.StringparseISToString(java.io.InputStream is)parse an InputStream to a string (for debugging)static booleansetEXCEPTION_DEBUG(boolean exception_debug)static java.lang.StringstripQuotes(java.lang.String value)strip the quotes from a value
-
-
-
Field Detail
-
DEFAULT_TEXT_BUFFER_SIZE
public static final int DEFAULT_TEXT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_CHARACTER_SET
public static final java.lang.String DEFAULT_CHARACTER_SET
- See Also:
- Constant Field Values
-
-
Method Detail
-
handleException
public static void handleException(java.lang.Throwable th)
handle Exceptions and thowables- Parameters:
th-
-
isEclipse
public static boolean isEclipse()
are we running in the Eclipse IDE?- Returns:
- whether we are running in the Eclipse environment
-
parseContentTypeHeader
public static java.lang.String[] parseContentTypeHeader(java.lang.String header)
Returns the content type and encoding as a pair of strings. If no character set is specified, the second entry will be null.- Parameters:
header- the header to parse- Returns:
- a string array with the content type and the content charset
-
stripQuotes
public static java.lang.String stripQuotes(java.lang.String value)
strip the quotes from a value- Parameters:
value-- Returns:
- the stripped value
-
decode
public static java.lang.String decode(java.lang.String byteString)
Returns an interpretation of the specified URL-encoded string, using the iso-8859-1 character set.- Since:
- 1.6
-
decode
public static java.lang.String decode(java.lang.String string, java.lang.String charset)Decodes a URL safe string into its original form using the specified character set. Escaped characters are converted back to their original representation. This method is copied from the Jakarta Commons Codec;org.apache.commons.codec.net.URLCodecclass.- Parameters:
string- URL safe string to convert into its original form- Returns:
- original string
- Throws:
java.lang.IllegalArgumentException- thrown if URL decoding is unsuccessful,
-
parseISToString
public static java.lang.String parseISToString(java.io.InputStream is)
parse an InputStream to a string (for debugging)- Parameters:
is-- Returns:
- the string gotten from the inputString
-
parse
public static org.w3c.dom.Document parse(org.xml.sax.InputSource inputSource) throws org.xml.sax.SAXException, java.io.IOExceptionparse the given inputSource with a new Parser- Parameters:
inputSource-- Returns:
- the document parsed from the input Source
- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
parse
public static org.w3c.dom.Document parse(java.io.InputStream inputStream) throws org.xml.sax.SAXException, java.io.IOExceptionparse the given inputStream with a new Parser- Parameters:
inputStream-- Returns:
- the document parsed from the input Stream
- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
newParser
public static javax.xml.parsers.DocumentBuilder newParser() throws org.xml.sax.SAXExceptioncreates a parser using JAXP API.- Throws:
org.xml.sax.SAXException
-
isEXCEPTION_DEBUG
protected static boolean isEXCEPTION_DEBUG()
- Returns:
- the eXCEPTION_DEBUG
-
setEXCEPTION_DEBUG
public static boolean setEXCEPTION_DEBUG(boolean exception_debug)
- Parameters:
exception_debug- the eXCEPTION_DEBUG to set
-
-