|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.unitils.dbmaintainer.script.Script
public class Script
A class representing a script file and it's content.
Constructor Summary | |
---|---|
Script(String fileName,
Long fileLastModifiedAt,
ScriptContentHandle scriptContentHandle)
Creates a script with the given script fileName, whose content is provided by the given handle. |
|
Script(String fileName,
Long fileLastModifiedAt,
String checkSum)
Creates a script with the given fileName and content checksum. |
Method Summary | |
---|---|
int |
compareTo(Script script)
Compares the given script to this script by comparing the versions. |
protected Version |
createVersion(List<Long> parentIndexes,
File scriptFile)
Creates a version for the given script file. |
boolean |
equals(Object obj)
|
protected Long |
extractIndex(String pathPart)
Extracts the index part out of a given file name. |
String |
getCheckSum()
|
Long |
getFileLastModifiedAt()
|
String |
getFileName()
|
ScriptContentHandle |
getScriptContentHandle()
|
Version |
getVersion()
|
protected Version |
getVersionFromPath(String relativePath)
|
int |
hashCode()
|
boolean |
isIncremental()
|
boolean |
isScriptContentEqualTo(Script other,
boolean useLastModificationDates)
|
String |
toString()
Gets a string representation of this script. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Script(String fileName, Long fileLastModifiedAt, ScriptContentHandle scriptContentHandle)
fileName
- The name of the script file, not nullfileLastModifiedAt
- scriptContentHandle
- Handle providing access to the contents of the script, not nullpublic Script(String fileName, Long fileLastModifiedAt, String checkSum)
fileName
- The name of the script file, not nullfileLastModifiedAt
- checkSum
- Checksum calculated for the content of the scriptMethod Detail |
---|
public String getFileName()
public Long getFileLastModifiedAt()
public String getCheckSum()
public Version getVersion()
public ScriptContentHandle getScriptContentHandle()
public boolean isScriptContentEqualTo(Script other, boolean useLastModificationDates)
other
- Another script, not nulluseLastModificationDates
- If true, this method first checks if the lastModifiedAt property of
this Script is equal to the given one. If equal, we assume that the contents are also equal and we don't
compare the checksums. If not equal, we compare the checksums to find out whether there is a difference.
By setting this value to true, performance is heavily improved when you check for updates regularly from
the same workstation (which is the case when you use unitils's automatic database maintenance for testing).
This is because, to calculate a checksum, the script contents have to be read. This can take a few seconds
to complete, which we want to avoid since a check for database updates is started every time a test is launched
that accesses the test database.
For applying changes to an environment that can only be updated incrementally (e.g. a database use by testers
or even the production database), this parameter should be false, since working with last modification dates
is not guaranteed to be 100% bulletproof (although unlikely, it is possible that a different version of
the same file is checked out on different systems on exactly the same time).
public boolean isIncremental()
public int compareTo(Script script)
compareTo
in interface Comparable<Script>
script
- The other script, not null
protected Version createVersion(List<Long> parentIndexes, File scriptFile)
parentIndexes
- The indexes of the parent folders, not nullscriptFile
- The script file, not null
protected Version getVersionFromPath(String relativePath)
protected Long extractIndex(String pathPart)
pathPart
- The simple (only one part of path) directory or file name, not null
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |