jd.xml.util
Class XmlSource

java.lang.Object
  extended byjd.xml.util.XmlSource

public class XmlSource
extends Object

XmlSource represents the uri and a source of a document.


Constructor Summary
XmlSource(File file)
          Create a XmlSource from a file.
XmlSource(InputSource inputSource)
          Create a XmlSource from a SAX InputSource.
XmlSource(String uri)
          Create a XmlSource from a uri.
XmlSource(String uri, InputStream in, boolean closeInput)
          Create a XmlSource from an InputStream.
XmlSource(String uri, Object document)
          Create a XmlSource by directly providing the document content.
XmlSource(String uri, Reader reader, boolean closeInput, String encoding)
          Create a XmlSource from a Reader.
XmlSource(URL url)
          Create a XmlSource from a URL.
 
Method Summary
 void cleanup()
          Cleanup any resources.
protected  void finalize()
          Call cleanup.
 Object getDocument()
          Return the document if one was provided at creation.
 String getDocumentContent()
          Return the document content.
 InputSource getInputSource()
          Return an InputSource for the document if the document was not directly provided.
 Object getParser()
          Return the Parser previously set by setParser().
 String getUri()
          Return the uri of this XmlSource.
static InputStream openInputStream(String uri)
           
 void reset()
           
 void setParser(Object parser)
          Set the Parser that should be used to parse the xml document denoted by this XmlSource.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlSource

public XmlSource(String uri)
Create a XmlSource from a uri.


XmlSource

public XmlSource(String uri,
                 Object document)
Create a XmlSource by directly providing the document content.

Parameters:
uri - the uri of the document
document - an arbitrary document (e.g. a String, a DOM document, etc.)

XmlSource

public XmlSource(File file)
          throws IOException
Create a XmlSource from a file.


XmlSource

public XmlSource(URL url)
Create a XmlSource from a URL.


XmlSource

public XmlSource(String uri,
                 InputStream in,
                 boolean closeInput)
Create a XmlSource from an InputStream.

Parameters:
uri - the uri of the document
in - an InputStream
closeInput - flag wether to close the InputStream when cleanup() is called
See Also:
cleanup()

XmlSource

public XmlSource(String uri,
                 Reader reader,
                 boolean closeInput,
                 String encoding)
Create a XmlSource from a Reader.

Parameters:
uri - the uri of the document
reader - a Reader
closeInput - flag wether to close the Reader when cleanup() is called
encoding - the encoding used by the reader. Null if not known.
See Also:
cleanup()

XmlSource

public XmlSource(InputSource inputSource)
Create a XmlSource from a SAX InputSource.

Parameters:
inputSource - the inputSource
Method Detail

finalize

protected void finalize()
                 throws Throwable
Call cleanup.

Throws:
Throwable

setParser

public void setParser(Object parser)
Set the Parser that should be used to parse the xml document denoted by this XmlSource.

See Also:
getParser()

getParser

public Object getParser()
Return the Parser previously set by setParser().

See Also:
setParser(java.lang.Object)

getUri

public String getUri()
Return the uri of this XmlSource.


getInputSource

public InputSource getInputSource()
                           throws IOException
Return an InputSource for the document if the document was not directly provided.

Returns:
the InputSource or null if a document was directly provided
Throws:
IOException - called if an I/O error occurrs

getDocument

public Object getDocument()
Return the document if one was provided at creation.

Returns:
the document or null
See Also:
XmlSource(String, Object)

getDocumentContent

public String getDocumentContent()
                          throws IOException
Return the document content.

Throws:
IOException
See Also:
XmlSource(String, Object)

openInputStream

public static InputStream openInputStream(String uri)
                                   throws IOException
Throws:
IOException

cleanup

public void cleanup()
Cleanup any resources. If an InputStream was opened it will be closed.


reset

public void reset()
           throws IOException
Throws:
IOException