liquibase.util
Class StringClauses

java.lang.Object
  extended by liquibase.util.StringClauses

public class StringClauses
extends Object

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 Class Summary
static class StringClauses.ClauseIterator
           
static class StringClauses.Comment
           
static class StringClauses.Delimiter
           
static interface StringClauses.LiteralClause
           
static class StringClauses.Whitespace
           
 
Constructor Summary
StringClauses()
          Creates a new StringClause with no start or end strings and a space separator.
StringClauses(String separator)
          Creates a new StringClause with no start or end strings and the given separator.
StringClauses(String start, String separator, String end)
          Creates a new StringClause with the given start, end and separator.
 
Method Summary
 StringClauses append(Enum name, String clause)
          Convenience method for append(String, String) when using enums.
 StringClauses append(Enum name, StringClauses subclauses)
          Convenience method for append(String, StringClauses) when using enums.
 StringClauses append(String clause)
          Adds a new clause at the end of the list.
 StringClauses append(StringClauses.LiteralClause literal)
           
 StringClauses append(String key, String clause)
          Adds a new clause at the end of the list with the given key.
 StringClauses append(String key, StringClauses subclauses)
          Adds a new sub-clause at the end of the list with the given key.
 boolean contains(String key)
           
 String get(Enum exitingKey)
          Convenience method for get(String) when using enums.
 String get(String exitingKey)
          Retrieves the given key.
 StringClauses.ClauseIterator getClauseIterator()
           
 StringClauses getSubclause(Enum exitingKey)
          Convenience method for getSubclause(String) when using enums
 StringClauses getSubclause(String exitingKey)
          Retrieves the given key.
 StringClauses insertAfter(Enum existingKey, String newValue)
          Convenience method for insertAfter(String, String) when using enums
 StringClauses insertAfter(String existingKey, String newValue)
          Convenience method for insertAfter(String, String, String) using the newValue as the newKey.
 StringClauses insertAfter(String existingKey, String newKey, String newValue)
          Inserts a new clause after the given key.
 StringClauses insertAfter(String existingKey, String newKey, StringClauses newValue)
          Inserts a new sub-clause after the given key.
 StringClauses insertBefore(Enum existingKey, Enum newKey, String newValue)
          Convenience method for insertBefore(String, String) when using enums.
 StringClauses insertBefore(Enum existingKey, String newValue)
          Convenience method for insertBefore(String, String) when using enums.
 StringClauses insertBefore(String existingKey, String newValue)
          Convenience method for insertBefore(String, String, String) where the new clause key is equal to the newValue.
 StringClauses insertBefore(String existingKey, String newKey, String newValue)
          Inserts a new clause before the given key.
 StringClauses insertBefore(String existingKey, String newKey, StringClauses newValue)
          Inserts a new sub-clause before the given key.
 boolean isEmpty()
           
 StringClauses prepend(Enum key, String clause)
          Convenience method for prepend(String, String) when using enums
 StringClauses prepend(Enum key, StringClauses clause)
          Convenience method for prepend(String, liquibase.util.StringClauses) when using enums
 StringClauses prepend(String clause)
          Convenience method for prepend(String, String) that uses the clause as the key.
 StringClauses prepend(StringClauses.LiteralClause literal)
           
 StringClauses prepend(String key, String clause)
          Adds a clause with the given key to the beginning of the list.
 StringClauses prepend(String key, StringClauses clause)
          Adds a sub-clause with the given key to the beginning of the list.
 StringClauses remove(Enum key)
          Convenience method for remove(String) when using enums.
 StringClauses remove(String key)
          Removes the clause with the given key.
 StringClauses replace(Enum key, String newValue)
          Convenience method for replace(String, String) when using enums.
 StringClauses replace(Enum key, StringClauses newValue)
          Convenience method for replace(String, liquibase.util.StringClauses) when using enums.
 StringClauses replace(String key, String newValue)
          Replaces the given key with a new string.
 StringClauses replace(String key, StringClauses newValue)
          Replaces the given key with a new sub-clause.
 StringClauses replaceIfExists(String key, String newValue)
          Replaces the given key with a new string.
 Object[] toArray(boolean stringify)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringClauses

public StringClauses()
Creates a new StringClause with no start or end strings and a space separator.


StringClauses

public StringClauses(String separator)
Creates a new StringClause with no start or end strings and the given separator.


StringClauses

public StringClauses(String start,
                     String separator,
                     String end)
Creates a new StringClause with the given start, end and separator.

Method Detail

append

public StringClauses append(String key,
                            String clause)
Adds a new clause at the end of the list with the given key.


append

public StringClauses append(String key,
                            StringClauses subclauses)
Adds a new sub-clause at the end of the list with the given key.


append

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.


append

public StringClauses append(Enum name,
                            StringClauses subclauses)
Convenience method for append(String, StringClauses) when using enums.


append

public StringClauses append(Enum name,
                            String clause)
Convenience method for append(String, String) when using enums.


append

public StringClauses append(StringClauses.LiteralClause literal)

prepend

public StringClauses prepend(StringClauses.LiteralClause literal)

prepend

public StringClauses prepend(String key,
                             String clause)
Adds a clause with the given key to the beginning of the list.


prepend

public StringClauses prepend(String key,
                             StringClauses clause)
Adds a sub-clause with the given key to the beginning of the list.


prepend

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


prepend

public StringClauses prepend(Enum key,
                             String clause)
Convenience method for prepend(String, String) when using enums


prepend

public StringClauses prepend(Enum key,
                             StringClauses clause)
Convenience method for prepend(String, liquibase.util.StringClauses) when using enums


remove

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.


remove

public StringClauses remove(Enum key)
Convenience method for remove(String) when using enums.


replace

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

Throws:
IllegalArgumentException

replaceIfExists

public StringClauses replaceIfExists(String key,
                                     String newValue)
                              throws IllegalArgumentException
Replaces the given key with a new string. If the existing key does not exist, throws IllegalArgumentException

Throws:
IllegalArgumentException

contains

public boolean contains(String key)

replace

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


replace

public StringClauses replace(Enum key,
                             StringClauses newValue)
Convenience method for replace(String, liquibase.util.StringClauses) when using enums.


replace

public StringClauses replace(Enum key,
                             String newValue)
Convenience method for replace(String, String) when using enums.


insertBefore

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.

Throws:
IllegalArgumentException

insertBefore

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.


insertBefore

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


insertBefore

public StringClauses insertBefore(Enum existingKey,
                                  String newValue)
Convenience method for insertBefore(String, String) when using enums.


insertBefore

public StringClauses insertBefore(Enum existingKey,
                                  Enum newKey,
                                  String newValue)
Convenience method for insertBefore(String, String) when using enums.


insertAfter

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.


insertAfter

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.


insertAfter

public StringClauses insertAfter(Enum existingKey,
                                 String newValue)
Convenience method for insertAfter(String, String) when using enums


insertAfter

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


get

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.


get

public String get(Enum exitingKey)
Convenience method for get(String) when using enums.


getSubclause

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.


getSubclause

public StringClauses getSubclause(Enum exitingKey)
Convenience method for getSubclause(String) when using enums


getClauseIterator

public StringClauses.ClauseIterator getClauseIterator()

toString

public String toString()
Overrides:
toString in class Object

toArray

public Object[] toArray(boolean stringify)

isEmpty

public boolean isEmpty()


Copyright © 2016 Liquibase.org. All rights reserved.