jetbrains.buildServer.parameters
Class ReferencesResolverUtil

java.lang.Object
  extended by jetbrains.buildServer.parameters.ReferencesResolverUtil

public class ReferencesResolverUtil
extends java.lang.Object

Contains utility methods simplifying references processing in build and run parameters

Author:
Yegor.Yarko Date: 10.08.2008

Nested Class Summary
static interface ReferencesResolverUtil.ReferencesResolverListener
           
 
Constructor Summary
ReferencesResolverUtil()
           
 
Method Summary
static boolean containsReference(java.lang.String value)
          Returns true if the specified value contains at least one reference.
static boolean containsReference(java.lang.String value, java.lang.String[] prefixes, boolean allowSpaces)
          Returns true if the specified value contains at least one reference that starts from one of the prefixes.
static java.util.Set<java.lang.String> findParametersReferringToKey(java.util.Map<java.lang.String,java.lang.String> parameters, java.util.Collection<java.lang.String> keys)
           
static java.util.Set<java.lang.String> getReferences(java.lang.String value)
          Returns all of the references present in the specified value.
static java.util.Set<java.lang.String> getReferences(java.lang.String value, java.lang.String[] prefixes, boolean allowSpaces)
          Finds all of the references present in the specified value that start with one of the prefixes.
static boolean isReference(java.lang.String value)
          Returns true if the specified value contains exactly one parameter reference without any static text.
static java.lang.String makeReference(java.lang.String propertyName)
          Makes a TeamCity %foo% like reference from a given property name
static boolean mayContainReference(java.lang.String value)
           
static void resolve(java.lang.String value, ReferencesResolverUtil.ReferencesResolverListener listener)
          Processes the value calling appropriate listener methods for each found static text of reference name.
static java.lang.String unescape(java.lang.String value)
          Accepts value which may contain escaped sequences: %%, these sequences will be unescaped, converted to one %
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReferencesResolverUtil

public ReferencesResolverUtil()
Method Detail

makeReference

@NotNull
public static java.lang.String makeReference(@NotNull
                                                     java.lang.String propertyName)
Makes a TeamCity %foo% like reference from a given property name

Parameters:
propertyName - parameter name
Returns:
reference to a given parameter
Since:
6.5.4

resolve

public static void resolve(@NotNull
                           java.lang.String value,
                           @NotNull
                           ReferencesResolverUtil.ReferencesResolverListener listener)
Processes the value calling appropriate listener methods for each found static text of reference name. This method considers as reference any non-empty text enclosed with "%" symbols. A reference can contain spaces.

Parameters:
value -
listener -

unescape

@NotNull
public static java.lang.String unescape(@NotNull
                                                java.lang.String value)
Accepts value which may contain escaped sequences: %%, these sequences will be unescaped, converted to one %

Parameters:
value - value
Returns:
unescaped value

containsReference

public static boolean containsReference(@NotNull
                                        java.lang.String value)
Returns true if the specified value contains at least one reference. Only references that does not contain spaces in the name are found.

Parameters:
value - value to check
Returns:
true if at least one reference found

containsReference

public static boolean containsReference(@NotNull
                                        java.lang.String value,
                                        @NotNull
                                        java.lang.String[] prefixes,
                                        boolean allowSpaces)
Returns true if the specified value contains at least one reference that starts from one of the prefixes.

Parameters:
value - value to check
prefixes - prefixes of the references searched. If array is empty, any token between "%" is considered a reference.
allowSpaces - true to allow spaces int he references and false otherwise.
Returns:
true if at least one reference found

isReference

public static boolean isReference(@NotNull
                                  java.lang.String value)
Returns true if the specified value contains exactly one parameter reference without any static text.

Parameters:
value - value to check
Returns:
true if single reference found

mayContainReference

public static boolean mayContainReference(@NotNull
                                          java.lang.String value)

findParametersReferringToKey

@NotNull
public static java.util.Set<java.lang.String> findParametersReferringToKey(@NotNull
                                                                                   java.util.Map<java.lang.String,java.lang.String> parameters,
                                                                                   @NotNull
                                                                                   java.util.Collection<java.lang.String> keys)

getReferences

public static java.util.Set<java.lang.String> getReferences(@NotNull
                                                            java.lang.String value)
Returns all of the references present in the specified value. Only references that do not contain spaces in the name are found.

Parameters:
value - value to check
Returns:
all of the references present in the specified value

getReferences

public static java.util.Set<java.lang.String> getReferences(@NotNull
                                                            java.lang.String value,
                                                            @NotNull
                                                            java.lang.String[] prefixes,
                                                            boolean allowSpaces)
Finds all of the references present in the specified value that start with one of the prefixes. Only references that does not contain spaces in the name are found.

Parameters:
value - value to check
Returns:
the references found