com.microsoft.tfs.core.clients.versioncontrol
Class PropertyUtils

java.lang.Object
  extended by com.microsoft.tfs.core.clients.versioncontrol.PropertyUtils

public abstract class PropertyUtils
extends java.lang.Object

Static methods to validate TFS 2010/2012 property names and values.

Thread-safety:
thread-safe

Constructor Summary
PropertyUtils()
           
 
Method Summary
static void checkForInvalidCharacters(java.lang.String string, java.lang.String argumentName)
          Checks the given string for invalid (control) characters, and throws IllegalArgumentException if found.
static PropertyValue[] clonePropertyValues(PropertyValue[] values)
          Returns a new array with new PropertyValue instances matching the given values.
static boolean equals(PropertyValue[] values1, PropertyValue[] values2)
           
static PropertyValue[] mergePendingValues(PropertyValue[] existingValues, PropertyValue[] pendingValues)
          Merges existing and pending property values.
static java.lang.String[] mergePropertyFilters(java.lang.String[] filters1, java.lang.String[] filters2)
          Merges two arrays of property filters into one arrays that matches all the items the two arrays would match individually.
static PropertyValue[] selectDirtyPropertyValues(PropertyValue[] propertyValues)
          Selects the "dirty" PropertyValues from the given array and returns only those.
static PropertyValue selectMatching(PropertyValue[] values, java.lang.String itemPropertyFilter)
          Selects the property value that matches the given filter.
static PropertyValue[] selectMatching(PropertyValue[] values, java.lang.String[] itemPropertyFilters)
          Selects the property values that match the given filters.
static PropertyValue[] selectUnique(PropertyValue[] values)
          Deprecated. remove this method as soon as the TFS bug gets fixed that returns duplicate property values
static void validatePropertyFilter(java.lang.String propertyNameFilter)
          Checks a single property name filter for length and content compliance.
static void validatePropertyFilters(java.lang.String[] propertyNameFilters)
          Checks each of the given property name filter strings for length and content compliance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyUtils

public PropertyUtils()
Method Detail

validatePropertyFilters

public static void validatePropertyFilters(java.lang.String[] propertyNameFilters)
Checks each of the given property name filter strings for length and content compliance.

Parameters:
propertyNameFilters - the property name filters to check (must not be null)

validatePropertyFilter

public static void validatePropertyFilter(java.lang.String propertyNameFilter)
Checks a single property name filter for length and content compliance.

Parameters:
propertyNameFilter - the property name filter to check (must not be null)

checkForInvalidCharacters

public static void checkForInvalidCharacters(java.lang.String string,
                                             java.lang.String argumentName)
                                      throws java.lang.IllegalArgumentException
Checks the given string for invalid (control) characters, and throws IllegalArgumentException if found.

Parameters:
string - the string to check (must not be null)
argumentName - the name of the string to use in error text (must not be null)
Throws:
java.lang.IllegalArgumentException - if the string had invalid characters

selectDirtyPropertyValues

public static PropertyValue[] selectDirtyPropertyValues(PropertyValue[] propertyValues)
Selects the "dirty" PropertyValues from the given array and returns only those.

Parameters:
propertyValues - the property values to select dirty ones from (must not be null)
Returns:
the array of "dirty" property values

clonePropertyValues

public static PropertyValue[] clonePropertyValues(PropertyValue[] values)
Returns a new array with new PropertyValue instances matching the given values. The value object inside each PropertyValue item (byte[], String, Boolean, etc.) is not cloned.

Parameters:
values - the values to clone (may be null or empty)
Returns:
a new array of new values, or null if the given values array was null

selectMatching

public static PropertyValue selectMatching(PropertyValue[] values,
                                           java.lang.String itemPropertyFilter)
Selects the property value that matches the given filter.

Parameters:
values - the properties to select from (if null, null is returned)
itemPropertyFilter - the filter to match (if null, null is returned)
Returns:
the matched PropertyValue or null if none matched or none were supplied

selectMatching

public static PropertyValue[] selectMatching(PropertyValue[] values,
                                             java.lang.String[] itemPropertyFilters)
Selects the property values that match the given filters. The result contains only the unique matches (no duplicates).

Parameters:
values - the properties to select from (if null, null is returned)
itemPropertyFilters - the filters to match (if null, null is returned)
Returns:
the matched PropertyValues or null if none matched or none were supplied

selectUnique

public static PropertyValue[] selectUnique(PropertyValue[] values)
Deprecated. remove this method as soon as the TFS bug gets fixed that returns duplicate property values

Returns the unique values from the given values as a new array.

Parameters:
values - the values to select from (may be null )
Returns:
a new array containing the unique values, or null if the given values were null, or empty if the given values were emtpy

mergePendingValues

public static PropertyValue[] mergePendingValues(PropertyValue[] existingValues,
                                                 PropertyValue[] pendingValues)
Merges existing and pending property values.

Parameters:
existingValues - the existing (typically WorkspaceLocalItem's) values (may be null or empty)
pendingValues - the pending (typically LocalPendingChange's) values (may be null or empty)
Returns:
the merge values, null if both the given value arrays were null or the merge result is no property values

mergePropertyFilters

public static java.lang.String[] mergePropertyFilters(java.lang.String[] filters1,
                                                      java.lang.String[] filters2)
Merges two arrays of property filters into one arrays that matches all the items the two arrays would match individually. Returns null when both inputs are null . Order is not preserved.

Parameters:
filters1 - the first array of filters (may be null)
filters2 - the second array of filters (may be null)
Returns:
a new array of filters including the filters from both given arrays of filters, or null if the specified filters were null and there are no extra filters

equals

public static boolean equals(PropertyValue[] values1,
                             PropertyValue[] values2)


© 2015 Microsoft. All rights reserved.