xsul.util
Class Util

java.lang.Object
  extended byxsul.util.Util

public class Util
extends java.lang.Object


Constructor Summary
Util()
           
 
Method Summary
static void copyInput2Output(java.io.InputStream in, java.io.OutputStream out)
          Method copyInput2Output copies an InputStream to an OutputStream.
static java.lang.String escapeForHtml(java.lang.String text)
           
static java.lang.String escapeXml(java.lang.String s)
           
static java.lang.String escapeXml(java.lang.String s, boolean escapeNewLine, boolean escapeTabs)
           
static java.lang.String getContentTypeCharset(java.lang.String contentType)
           
static java.lang.String getContentTypeCharset(java.lang.String contentType, java.lang.String defaultCharset)
           
static XmlDocument getDocumentOutOfElement(XmlElement outgoingMessage)
           
static java.lang.String getHostfromURL(java.lang.String url)
           
static int getPortnumfromURL(java.lang.String url)
           
static QName getQNameContent(XmlElement el)
           
static java.lang.String getSvcnamefromURL(java.lang.String url)
           
static boolean isWhiteSpace(java.lang.String txt)
           
static java.lang.String printable(char ch)
           
static java.lang.String printable(java.lang.String s)
           
static java.lang.String printable(java.lang.String s, boolean escapeNewLine)
           
static java.lang.String printable(java.lang.String s, boolean escapeNewLine, boolean escapeTabs)
           
static byte[] readInputStreamToByteArray(java.io.InputStream in)
           
static void removeIgnorableSpace(XmlElement e)
           
static void safeSerializeXmlElement(XmlElement el, XmlSerializer ser)
           
static java.lang.String safeSerializeXmlItem(java.lang.Object item)
           
static void safeSerializeXmlItem(java.lang.Object child, XmlSerializer ser)
          It is safe serialization in sense that non XML serializable content is represnted as toString() and no exception is thrown (so one can even print Thread to XML).
static java.lang.String safeXmlToString(java.util.List xmlContainers)
          Will serialize XML and call toString() on unrecongized objects
static QName toQName(XmlElement context, java.lang.String qnameValue)
           
static java.lang.String validateNcName(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

getDocumentOutOfElement

public static XmlDocument getDocumentOutOfElement(XmlElement outgoingMessage)

safeXmlToString

public static java.lang.String safeXmlToString(java.util.List xmlContainers)
Will serialize XML and call toString() on unrecongized objects


safeSerializeXmlItem

public static java.lang.String safeSerializeXmlItem(java.lang.Object item)

safeSerializeXmlElement

public static void safeSerializeXmlElement(XmlElement el,
                                           XmlSerializer ser)
                                    throws java.io.IOException
Throws:
java.io.IOException

safeSerializeXmlItem

public static void safeSerializeXmlItem(java.lang.Object child,
                                        XmlSerializer ser)
                                 throws java.lang.IllegalArgumentException,
                                        java.lang.IllegalStateException,
                                        java.io.IOException,
                                        XmlBuilderException
It is safe serialization in sense that non XML serializable content is represnted as toString() and no exception is thrown (so one can even print Thread to XML).
NOTE: use this and related methods for debuggin purposes only!!!
NOTE: this method is not suitable to generate correct XML (output from toString() may be hard or impossible to deserialize !!!!)

Throws:
java.lang.IllegalArgumentException
java.lang.IllegalStateException
java.io.IOException
XmlBuilderException

validateNcName

public static java.lang.String validateNcName(java.lang.String name)

getQNameContent

public static QName getQNameContent(XmlElement el)
                             throws DataValidationException
Throws:
DataValidationException

toQName

public static QName toQName(XmlElement context,
                            java.lang.String qnameValue)
                     throws DataValidationException
Throws:
DataValidationException

getContentTypeCharset

public static java.lang.String getContentTypeCharset(java.lang.String contentType)

getContentTypeCharset

public static java.lang.String getContentTypeCharset(java.lang.String contentType,
                                                     java.lang.String defaultCharset)

readInputStreamToByteArray

public static final byte[] readInputStreamToByteArray(java.io.InputStream in)
                                               throws java.io.IOException
Throws:
java.io.IOException

removeIgnorableSpace

public static final void removeIgnorableSpace(XmlElement e)

isWhiteSpace

public static final boolean isWhiteSpace(java.lang.String txt)

escapeForHtml

public static java.lang.String escapeForHtml(java.lang.String text)

escapeXml

public static final java.lang.String escapeXml(java.lang.String s)

escapeXml

public static final java.lang.String escapeXml(java.lang.String s,
                                               boolean escapeNewLine,
                                               boolean escapeTabs)

printable

public static final java.lang.String printable(java.lang.String s)

printable

public static final java.lang.String printable(java.lang.String s,
                                               boolean escapeNewLine)

printable

public static final java.lang.String printable(java.lang.String s,
                                               boolean escapeNewLine,
                                               boolean escapeTabs)

printable

public static final java.lang.String printable(char ch)

copyInput2Output

public static void copyInput2Output(java.io.InputStream in,
                                    java.io.OutputStream out)
                             throws java.io.IOException
Method copyInput2Output copies an InputStream to an OutputStream. Notice that jakarta commons IO has IOUtils.copy with the same function. However we save one more jar file here ;)

Parameters:
in - an InputStream
out - an OutputStream
Throws:
java.io.IOException

getHostfromURL

public static java.lang.String getHostfromURL(java.lang.String url)

getPortnumfromURL

public static int getPortnumfromURL(java.lang.String url)

getSvcnamefromURL

public static java.lang.String getSvcnamefromURL(java.lang.String url)


IU Extreme! Lab (http://www.extreme.indiana.edu)