org.dbmaintain.script
Class ScriptContentHandle

java.lang.Object
  extended by org.dbmaintain.script.ScriptContentHandle
Direct Known Subclasses:
ScriptContentHandle.StringScriptContentHandle, ScriptContentHandle.UrlScriptContentHandle

public abstract class ScriptContentHandle
extends Object

A handle for getting the script content as a stream.

Author:
Tim Ducheyne, Filip Neven, Jessica Austin

Nested Class Summary
static class ScriptContentHandle.StringScriptContentHandle
          A handle for getting the script content as a stream.
static class ScriptContentHandle.UrlScriptContentHandle
          A handle for getting the script content as a stream.
 
Field Summary
protected  String encoding
           
protected  boolean ignoreCarriageReturnsWhenCalculatingCheckSum
           
protected  MessageDigest scriptDigest
           
protected  Reader scriptReader
           
 
Constructor Summary
protected ScriptContentHandle(String encoding, boolean ignoreCarriageReturnsWhenCalculatingCheckSum)
           
 
Method Summary
 String getCheckSum()
           
protected  String getHexPresentation(byte[] byteArray)
           
 String getScriptContentsAsString(long maxNrChars)
           
protected  MessageDigest getScriptDigest()
           
protected abstract  InputStream getScriptInputStream()
          NOTE: Make sure you don't forget to close the stream!
 Reader openScriptContentReader()
          Opens a stream to the content of the script.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scriptDigest

protected MessageDigest scriptDigest

scriptReader

protected Reader scriptReader

encoding

protected String encoding

ignoreCarriageReturnsWhenCalculatingCheckSum

protected boolean ignoreCarriageReturnsWhenCalculatingCheckSum
Constructor Detail

ScriptContentHandle

protected ScriptContentHandle(String encoding,
                              boolean ignoreCarriageReturnsWhenCalculatingCheckSum)
Parameters:
encoding - The encoding of the script, not null
ignoreCarriageReturnsWhenCalculatingCheckSum - If true, carriage return chars will be ignored when calculating check sums
Method Detail

openScriptContentReader

public Reader openScriptContentReader()
Opens a stream to the content of the script.

NOTE: do not forget to close the stream after usage.

Returns:
The content stream, not null

getCheckSum

public String getCheckSum()

getScriptDigest

protected MessageDigest getScriptDigest()
                                 throws IOException
Throws:
IOException

getScriptContentsAsString

public String getScriptContentsAsString(long maxNrChars)

getHexPresentation

protected String getHexPresentation(byte[] byteArray)

getScriptInputStream

protected abstract InputStream getScriptInputStream()
NOTE: Make sure you don't forget to close the stream!

Returns:
stream providing access to the script content, not null


Copyright © 2011. All Rights Reserved.