org.dbmaintain.script.executedscriptinfo
Class ScriptIndexes

java.lang.Object
  extended by org.dbmaintain.script.executedscriptinfo.ScriptIndexes
All Implemented Interfaces:
Comparable<ScriptIndexes>

public class ScriptIndexes
extends Object
implements Comparable<ScriptIndexes>

Class representing the indexes of a script.

Some examples:

01_folder/01_subfolder/1_script ==> 1,1,1
01_folder/02_subfolder/1_script ==> 1,2,1
01_folder/02_subfolder/script ==> 1,2,null
folder/subfolder/2_script ==> null,null,2
script ==> null

The last index defines whether the script is incremental or repeatable: if the last index is null, the script is repeatable; if not, it is incremental.

Author:
Filip Neven, Tim Ducheyne

Constructor Summary
ScriptIndexes(List<Long> indexes)
          Creates a new version.
ScriptIndexes(String indexString)
          Creates a new version.
 
Method Summary
protected  void assertValidIndexes()
           
 int compareTo(ScriptIndexes otherVersion)
          Compares the given version to this version using the index values.
 boolean equals(Object object)
           
protected  List<Long> extractIndexes(String indexString)
          Extracts the indexes out of the given string as followes: 1.x.2.x => 1, null, 2, null
 List<Long> getIndexes()
          An empty list if no version is defined.
 String getIndexesString()
          Gets a string representation of the indexes as followes: 1, null, 2, null => 1.x.2.x
 int hashCode()
           
 boolean isIncrementalScript()
           
 boolean isRepeatableScript()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScriptIndexes

public ScriptIndexes(List<Long> indexes)
Creates a new version.

Parameters:
indexes - The script indexes, not null

ScriptIndexes

public ScriptIndexes(String indexString)
Creates a new version.

Parameters:
indexString - The indexes as a string
Method Detail

getIndexes

public List<Long> getIndexes()
An empty list if no version is defined.

Returns:
The script index, not null

isIncrementalScript

public boolean isIncrementalScript()

isRepeatableScript

public boolean isRepeatableScript()

assertValidIndexes

protected void assertValidIndexes()

getIndexesString

public String getIndexesString()
Gets a string representation of the indexes as followes: 1, null, 2, null => 1.x.2.x

Returns:
The string, not null

extractIndexes

protected List<Long> extractIndexes(String indexString)
Extracts the indexes out of the given string as followes: 1.x.2.x => 1, null, 2, null

Parameters:
indexString - The string
Returns:
The list of longs or nulls in case of 'x'

toString

public String toString()
Overrides:
toString in class Object
Returns:
The string representation of the version.

compareTo

public int compareTo(ScriptIndexes otherVersion)
Compares the given version to this version using the index values.

If both scripts have an index, the index is used. If one of the scripts has an index, it is considerer lower than the script that does not have an index.

Specified by:
compareTo in interface Comparable<ScriptIndexes>
Parameters:
otherVersion - The other version, not null
Returns:
-1 when this version is smaller, 0 if equal, 1 when larger

hashCode

public int hashCode()
Overrides:
hashCode in class Object
Returns:
A computed hashcode value dependent on the indexes

equals

public boolean equals(Object object)
Overrides:
equals in class Object
Parameters:
object - The object to compare with
Returns:
True if the given object has the same indexes


Copyright © 2011. All Rights Reserved.