com.microsoft.tfs.core.checkinpolicies
Class PolicyDefinition

java.lang.Object
  extended by com.microsoft.tfs.core.checkinpolicies.PolicyDefinition

public class PolicyDefinition
extends java.lang.Object

A PolicyDefinition represents a policy that is configured for a team project on a Team Foundation Server. A definition has a policy type, some flags like whether it is enabled, and policy type-specific configuration information.

Several PolicyDefinition objects may be defined on a single team project, and these are collected in a PolicyAnnotation for serialization.

This class does not define a type of checkin policy (see PolicyType), rather it defines an "attachment" of a policy (and its configuration info) to a Team Project.

A PolicyDefinition has an evaluation priority (see getPriority()), which is a number that represents whether a policy should be evaluated early or later when there are multiple policies definied for a team project. Lower values mean earlier evaluation, and higher values are later. The default priority is 0. Negative numbers can be used.

Each definition also contains regular expressions that allow the user to limit which items the policy applies to within a team project. These expressions are stored as an array of strings. An empty array means apply the policy to all items inside the team project. A non-empty array means apply the policy to all items inside the the team project that match any of the expressions in the array.

Since:
TEE-SDK-10.1
Thread-safety:
immutable

Field Summary
static int SUPPORTED_VERSION
          The single data version we read and write.
 
Constructor Summary
PolicyDefinition(PolicyInstance instance, boolean enabled, int priority, java.lang.String[] scopeExpressions)
          Creates a PolicyDefinition that describes the given instance's type and configuration.
PolicyDefinition(PolicyType type, Memento configurationMemento, boolean enabled, int priority, java.lang.String[] scopeExpressions)
          Constructs a PolicyDefinition to hold the given information.
 
Method Summary
static PolicyDefinition fromMemento(Memento definitionMemento)
          Reads a full PolicyDefinition from the given memento and its children.
 Memento getConfigurationMemento()
           
 int getPriority()
          Gets the evaluation priority for this definition.
 java.lang.String[] getScopeExpressions()
          Gets the regular expression strings that define the scope of this policy definition (for items inside a team project).
 PolicyType getType()
           
 boolean isEnabled()
           
 void toMemento(Memento definitionMemento)
          Writes this definition's data into the given empty Memento.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUPPORTED_VERSION

public static final int SUPPORTED_VERSION
The single data version we read and write.

Constant Field Value:
1
See Also:
Constant Field Values
Constructor Detail

PolicyDefinition

public PolicyDefinition(PolicyType type,
                        Memento configurationMemento,
                        boolean enabled,
                        int priority,
                        java.lang.String[] scopeExpressions)
Constructs a PolicyDefinition to hold the given information.


PolicyDefinition

public PolicyDefinition(PolicyInstance instance,
                        boolean enabled,
                        int priority,
                        java.lang.String[] scopeExpressions)
Creates a PolicyDefinition that describes the given instance's type and configuration. The configuration and type data is copied from the given instance immediately.

Parameters:
instance - a configured PolicyInstance to create a definition for (must not be null)
enabled - true if the policy definition is enabled, false if it is disabled.
priority - the evaluation priority of this definition (see getPriority()). 0 is a good default.
Method Detail

fromMemento

public static PolicyDefinition fromMemento(Memento definitionMemento)
                                    throws PolicySerializationException
Reads a full PolicyDefinition from the given memento and its children.

Parameters:
definitionMemento - the memento node to read definition information from (must not be null)
Returns:
the definition information read from the memento.
Throws:
PolicySerializationException - if an error occurred reading the definitions

toMemento

public void toMemento(Memento definitionMemento)
Writes this definition's data into the given empty Memento.

Parameters:
definitionMemento - the empty memento to write this definition's data into (must not be null)

isEnabled

public boolean isEnabled()
Returns:
true if this definition is enabled (policy is enforced) or false if it is disabled (policy is not enforced).

getPriority

public int getPriority()
Gets the evaluation priority for this definition. Definitions with priorities are evaluated before ones with higher priorities. Definitions at equal priorities are evaluated in an undefined order.

Returns:
the evaluation priority

getType

public PolicyType getType()
Returns:
the policy type this definition is for.

getScopeExpressions

public java.lang.String[] getScopeExpressions()
Gets the regular expression strings that define the scope of this policy definition (for items inside a team project). An empty array means apply the policy to all items in the team project. A non-empty array means apply the policy to all items inside the team project that match any of the expressions in the array.

Returns:
the regular expression strings that define which items inside a team project this policy applies to (empty array means apply to all).

getConfigurationMemento

public Memento getConfigurationMemento()
Returns:
the configuration data in the form of a Memento that this definition uses.


© 2015 Microsoft. All rights reserved.