Top Description Inners Fields Constructors Methods
liquibase.util

public Class StringClauses

extends Object
Class Inheritance
Imports
java.math.BigInteger, java.security.SecureRandom, java.util.*

Defines a list of clauses that can be manipulated and rearranged based on keys associated with each. On toString(), the clauses will be joined by the separator passed at construction time and prepended/postpended by the start/end strings set at construction time.

Note

all keys and values passed in are trimmed.
NOTE: All keys are managed in a case INSENSITIVE manner
NOTE: Null or empty clauses and subclauses are skipped in toString()

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
public static class
public static interface
public static class

Field Summary

Modifier and TypeField and Description
private LinkedHashMap<String, Object>
private final String
private final Random
private final String
private final String

Constructor Summary

AccessConstructor and Description
public
StringClauses()

Creates a new StringClause with no start or end strings and a space separator.

public
StringClauses(String separator)

Creates a new StringClause with no start or end strings and the given separator.

public
StringClauses(String start, String separator, String end)

Creates a new StringClause with the given start, end and separator.

Method Summary

Modifier and TypeMethod and Description
public StringClauses
append(String key, String clause)

Adds a new clause at the end of the list with the given key.

public StringClauses
append(String key, StringClauses subclauses)

Adds a new sub-clause at the end of the list with the given key.

public StringClauses
append(String clause)

Adds a new clause at the end of the list.

public StringClauses
append(Enum<E extends Enum<E>> name, StringClauses subclauses)

Convenience method for append(String, StringClauses) when using enums.

public StringClauses
append(Enum<E extends Enum<E>> name, String clause)

Convenience method for append(String, String) when using enums.

public StringClauses
public boolean
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public String
get(String exitingKey)

Retrieves the given key.

public String
get(Enum<E extends Enum<E>> exitingKey)

Convenience method for get(String) when using enums.

public StringClauses.ClauseIterator
private Object
getImpl(String exitingKey)

public StringClauses
getSubclause(String exitingKey)

Retrieves the given key.

public StringClauses
getSubclause(Enum<E extends Enum<E>> exitingKey)

Convenience method for getSubclause(String) when using enums

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public StringClauses
insertAfter(String existingKey, String newKey, String newValue)

Inserts a new clause after the given key.

public StringClauses
insertAfter(String existingKey, String newKey, StringClauses newValue)

Inserts a new sub-clause after the given key.

public StringClauses
insertAfter(Enum<E extends Enum<E>> existingKey, String newValue)

Convenience method for insertAfter(String, String) when using enums

public StringClauses
insertAfter(String existingKey, String newValue)

Convenience method for insertAfter(String, String, String) using the newValue as the newKey.

private StringClauses
insertAfterImpl(String existingKey, String newKey, Object newValue)

public StringClauses
insertBefore(String existingKey, String newKey, String newValue)

Inserts a new clause before the given key.

public StringClauses
insertBefore(String existingKey, String newKey, StringClauses newValue)

Inserts a new sub-clause before the given key.

public StringClauses
insertBefore(String existingKey, String newValue)

Convenience method for insertBefore(String, String, String) where the new clause key is equal to the newValue.

public StringClauses
insertBefore(Enum<E extends Enum<E>> existingKey, String newValue)

Convenience method for insertBefore(String, String) when using enums.

public StringClauses
insertBefore(Enum<E extends Enum<E>> existingKey, Enum<E extends Enum<E>> newKey, String newValue)

Convenience method for insertBefore(String, String) when using enums.

private StringClauses
insertBeforeImpl(String existingKey, String newKey, Object newValue)

public boolean
public StringClauses
public StringClauses
prepend(String key, String clause)

Adds a clause with the given key to the beginning of the list.

public StringClauses
prepend(String key, StringClauses clause)

Adds a sub-clause with the given key to the beginning of the list.

public StringClauses
prepend(String clause)

Convenience method for prepend(String, String) that uses the clause as the key.

public StringClauses
prepend(Enum<E extends Enum<E>> key, String clause)

Convenience method for prepend(String, String) when using enums

public StringClauses
prepend(Enum<E extends Enum<E>> key, StringClauses clause)

Convenience method for prepend(String, liquibase.util.StringClauses) when using enums

private StringClauses
prependImpl(String key, Object clause)

public StringClauses
remove(String key)

Removes the clause with the given key.

public StringClauses
remove(Enum<E extends Enum<E>> key)

Convenience method for remove(String) when using enums.

public StringClauses
replace(String key, String newValue)

Replaces the given key with a new string.

public StringClauses
replace(String key, StringClauses newValue)

Replaces the given key with a new sub-clause.

public StringClauses
replace(Enum<E extends Enum<E>> key, StringClauses newValue)

Convenience method for replace(String, liquibase.util.StringClauses) when using enums.

public StringClauses
replace(Enum<E extends Enum<E>> key, String newValue)

Convenience method for replace(String, String) when using enums.

private StringClauses
replaceImpl(String key, Object newValue)

public Object[]
toArray(boolean stringify)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private String
uniqueKey(String key)

Returns the key if it is not empty and/or not already used.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

clausesback to summary
private LinkedHashMap<String, Object> clauses
endback to summary
private final String end
randomback to summary
private final Random random
separatorback to summary
private final String separator
startback to summary
private final String start

Constructor Detail

StringClausesback to summary
public StringClauses()

Creates a new StringClause with no start or end strings and a space separator.

StringClausesback to summary
public StringClauses(String separator)

Creates a new StringClause with no start or end strings and the given separator.

StringClausesback to summary
public StringClauses(String start, String separator, String end)

Creates a new StringClause with the given start, end and separator.

Method Detail

appendback to summary
public StringClauses append(String key, String clause)

Adds a new clause at the end of the list with the given key.

appendback to summary
public StringClauses append(String key, StringClauses subclauses)

Adds a new sub-clause at the end of the list with the given key.

appendback to summary
public StringClauses append(String clause)

Adds a new clause at the end of the list. The key is equal to the passed clause. There is no corresponding append with just a StringClauses because the subclause may not be fully created when appended and so the key may be an unexpected value.

appendback to summary
public StringClauses append(Enum<E extends Enum<E>> name, StringClauses subclauses)

Convenience method for append(String, StringClauses) when using enums.

appendback to summary
public StringClauses append(Enum<E extends Enum<E>> name, String clause)

Convenience method for append(String, String) when using enums.

appendback to summary
public StringClauses append(StringClauses.LiteralClause literal)
containsback to summary
public boolean contains(String key)
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getback to summary
public String get(String exitingKey)

Retrieves the given key. Returns null if not set. If clause at key is a StringClause, return the string version of it. Will traverse sub-clauses to find the key.

getback to summary
public String get(Enum<E extends Enum<E>> exitingKey)

Convenience method for get(String) when using enums.

getClauseIteratorback to summary
public StringClauses.ClauseIterator getClauseIterator()
getImplback to summary
private Object getImpl(String exitingKey)
getSubclauseback to summary
public StringClauses getSubclause(String exitingKey)

Retrieves the given key. Returns null if not set. If clause at key is a String, return a new StringClause version of it. Will traverse sub-clauses to find the key.

getSubclauseback to summary
public StringClauses getSubclause(Enum<E extends Enum<E>> exitingKey)

Convenience method for getSubclause(String) when using enums

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
insertAfterback to summary
public StringClauses insertAfter(String existingKey, String newKey, String newValue)

Inserts a new clause after the given key. Throws IllegalArgumentException if the existingKey does not exist.

insertAfterback to summary
public StringClauses insertAfter(String existingKey, String newKey, StringClauses newValue)

Inserts a new sub-clause after the given key. Throws IllegalArgumentException if the existingKey does not exist.

insertAfterback to summary
public StringClauses insertAfter(Enum<E extends Enum<E>> existingKey, String newValue)

Convenience method for insertAfter(String, String) when using enums

insertAfterback to summary
public StringClauses insertAfter(String existingKey, String newValue)

Convenience method for insertAfter(String, String, String) using the newValue as the newKey.

insertAfterImplback to summary
private StringClauses insertAfterImpl(String existingKey, String newKey, Object newValue)
insertBeforeback to summary
public StringClauses insertBefore(String existingKey, String newKey, String newValue) throws IllegalArgumentException

Inserts a new clause before the given key. Throws IllegalArgumentException if the existingKey does not exist.

insertBeforeback to summary
public StringClauses insertBefore(String existingKey, String newKey, StringClauses newValue)

Inserts a new sub-clause before the given key. Throws IllegalArgumentException if the existingKey does not exist.

insertBeforeback to summary
public StringClauses insertBefore(String existingKey, String newValue)

Convenience method for insertBefore(String, String, String) where the new clause key is equal to the newValue.

insertBeforeback to summary
public StringClauses insertBefore(Enum<E extends Enum<E>> existingKey, String newValue)

Convenience method for insertBefore(String, String) when using enums.

insertBeforeback to summary
public StringClauses insertBefore(Enum<E extends Enum<E>> existingKey, Enum<E extends Enum<E>> newKey, String newValue)

Convenience method for insertBefore(String, String) when using enums.

insertBeforeImplback to summary
private StringClauses insertBeforeImpl(String existingKey, String newKey, Object newValue)
isEmptyback to summary
public boolean isEmpty()
prependback to summary
public StringClauses prepend(StringClauses.LiteralClause literal)
prependback to summary
public StringClauses prepend(String key, String clause)

Adds a clause with the given key to the beginning of the list.

prependback to summary
public StringClauses prepend(String key, StringClauses clause)

Adds a sub-clause with the given key to the beginning of the list.

prependback to summary
public StringClauses prepend(String clause)

Convenience method for prepend(String, String) that uses the clause as the key.

prependback to summary
public StringClauses prepend(Enum<E extends Enum<E>> key, String clause)

Convenience method for prepend(String, String) when using enums

prependback to summary
public StringClauses prepend(Enum<E extends Enum<E>> key, StringClauses clause)

Convenience method for prepend(String, liquibase.util.StringClauses) when using enums

prependImplback to summary
private StringClauses prependImpl(String key, Object clause) throws IllegalArgumentException
removeback to summary
public StringClauses remove(String key)

Removes the clause with the given key. Removes case insensitively. If key doesn't exist, operation is a no-op.

removeback to summary
public StringClauses remove(Enum<E extends Enum<E>> key)

Convenience method for remove(String) when using enums.

replaceback to summary
public StringClauses replace(String key, String newValue) throws IllegalArgumentException

Replaces the given key with a new string. If the existing key does not exist, throws IllegalArgumentException

replaceback to summary
public StringClauses replace(String key, StringClauses newValue)

Replaces the given key with a new sub-clause. If the existing key does not exist, throws IllegalArgumentException

replaceback to summary
public StringClauses replace(Enum<E extends Enum<E>> key, StringClauses newValue)

Convenience method for replace(String, liquibase.util.StringClauses) when using enums.

replaceback to summary
public StringClauses replace(Enum<E extends Enum<E>> key, String newValue)

Convenience method for replace(String, String) when using enums.

replaceImplback to summary
private StringClauses replaceImpl(String key, Object newValue)
toArrayback to summary
public Object[] toArray(boolean stringify)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
uniqueKeyback to summary
private String uniqueKey(String key)

Returns the key if it is not empty and/or not already used. If it is already used, it generates a random value for the key.

liquibase.util back to summary

public Class StringClauses.ClauseIterator

extends Object
implements Iterator
Class Inheritance
All Implemented Interfaces
java.util.Iterator

Field Summary

Modifier and TypeField and Description
private final LinkedHashMap<String, Object>
private final ListIterator<String>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public Object
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

public Object
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).

public void
replace(Object newClause)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clausesback to summary
private final LinkedHashMap<String, Object> clauses
keyIteratorback to summary
private final ListIterator<String> keyIterator

Constructor Detail

ClauseIteratorback to summary
public ClauseIterator(LinkedHashMap<String, Object> clauses)

Method Detail

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public Object next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:Object

the next element in the iteration

Annotations
@Override
nextNonWhitespaceback to summary
public Object nextNonWhitespace()
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override
replaceback to summary
public void replace(Object newClause)
liquibase.util back to summary

public Class StringClauses.Comment

extends Object
implements LiteralClause
Class Inheritance
All Implemented Interfaces
liquibase.util.StringClauses.LiteralClause

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
public
Comment(String value)

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Object.toString.

Implements liquibase.util.StringClauses.LiteralClause.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

valueback to summary
private final String value

Constructor Detail

Commentback to summary
public Comment(String value)

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements liquibase.util.StringClauses.LiteralClause.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
liquibase.util back to summary

public Class StringClauses.Delimiter

extends Object
implements LiteralClause
Class Inheritance
All Implemented Interfaces
liquibase.util.StringClauses.LiteralClause

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Object.toString.

Implements liquibase.util.StringClauses.LiteralClause.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

valueback to summary
private final String value

Constructor Detail

Delimiterback to summary
public Delimiter(String value)

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements liquibase.util.StringClauses.LiteralClause.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
liquibase.util back to summary

public Interface StringClauses.LiteralClause

Known Direct Implementers
liquibase.util.StringClauses.Delimiter, liquibase.util.StringClauses.Whitespace, liquibase.util.StringClauses.Comment

Method Summary

Modifier and TypeMethod and Description
public String

Method Detail

toStringback to summary
public String toString()
liquibase.util back to summary

public Class StringClauses.Whitespace

extends Object
implements LiteralClause
Class Inheritance
All Implemented Interfaces
liquibase.util.StringClauses.LiteralClause

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Object.toString.

Implements liquibase.util.StringClauses.LiteralClause.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

valueback to summary
private final String value

Constructor Detail

Whitespaceback to summary
public Whitespace(String value)

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements liquibase.util.StringClauses.LiteralClause.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override