Apache > Incubators > Imperius
 

SPL Language Reference

This document provides a reference to the SPL language detailing the language syntax, built-in operators and actions It is aimed as providing a quick reference for users authoring SPL policies. Please refer to the CIM-SPL specification for more details.

Introduction

Imperius (Simple Policy Language) or SPL - Is a simple standards based object-oriented policy language that allows expression of management policies using condition-action rules. Imperius provides an extensible set of over 100 operations for expressing conditions and actions.Imperius is a generalization of the CIM-SPL language. Conversely, CIM-SPL can be thought of as Imperius with CIM binding. Imperius can be extended to create similar bindings for other environments. JavaSPL (Imperius with Java binding) is another such example.

SPL Language Structure

An SPL Policy is actually a group of one or more sub policies. Each sub policy is a simple condition - action pair. An import statement declares one or more anchor classes and instances that are referenced throughout the policy.

Canonical Policy syntax

      Import  Qualifier <namespace> Class <Class Name> : <instances>*;	(one or more)	 
      Strategy <strategy>
      Policy  (one or more)
      { 
        Declaration {
          <List of constant definition>   (Optional)
          <List of macro definitions> (Optional)
        } 
        Condition {		(Optional)
          <If Condition>  /* java-like boolean expression */
        } 
        Decision {		(Required)
          <Then Decision >  /* sequence of actions */
           /*   invocations                      */
        }
      } <priority>;
	
		
		

A Sample Policy

		Import Class org.apache.imperius.javaspl.samples.windowscomputersystem.WindowsComputerSystem:system1;

    Strategy Execute_All_Applicable;

    Declaration   {

      from = "johndoe@us.ibm.com";
      to = "johndoe@us.ibm.com";
    }
    Policy {
      Declaration 	{
      supportedJavaVersion = "1.5" ; 
    	subject = "Java version noncompliance";
      message = Concatenate( "IBM does not support java :", system1.javaVersion );
    }

    Condition 	{

      system1.javaVersion != supportedJavaVersion 

    }   

    Decision  	{  
 
       		SendMail( from, to, subject, message )
  
    }
  }:1;
		
		

Import Statement

Declares the anchor classes and the instances of these classes which are referenced throughout the policy. An anchor class encapsulates the state of the system managed using policies

Syntax: Import <qualifier> Class <classname> <instance>,...;

The Qualifier is unused by JavaSPL and there can be more than one Import statements

Strategy Statement

Allows the policy author to specify which of the sub-policies will be executed at execution time

  • Execute_All_Applicable: This strategy specifies that all polices with condition evaluating to true should be executed. The policies are evaluated in the descending order of their priorities. This strategy is useful in conditions when several actions based on several different conditions need to be performed
  • Execute_First_Applicable: This strategy specifies that only the policy with the highest priority with its condition evaluating to true should be executed.

Declaration Statement

Allows the policy author to declare constants and macros that can be referenced later on in the policy. Declarations support the paradigm of declare once and use anywhere. The constants and macros declared are visible within the current policy and other embedded policies. The constants declared in the Declaration section after the Strategy Statement are visible throughout the policy

Constant Declaration: As the name suggests declares a constant. The syntax is as follows:

 <constant> = <expression> 

The data type of the LHS is determined at compile time as being same as the RHS. During evaluation of a policy the RHS expression is evaluated and its result populated in the symbol table entry for the LHS.

 //Example constant declaration
       Declaration {
        x = 2;
       }
       

Macro Declaration: Macros are actually user defined functions that can be called from within the policy. The Macros can take one or more parameters and return exactly one value. Macros help in simplifying a policy by hiding the complexity of a function in the declaration section.

 Macro {
               
               Name = <string expression>;
               type = <type constant>;
               argument = <argumentname:argumenttype>,...;
               procedure = <expression with type same as the one declared in the type field of Macro>
               }
               // type constants of SPL are : Sint8, Sint16, Sint32, Sint64, Real32, Real64, String, DateTime, Boolean, Char16
      
        //Example of a Macro Declaration
        Declaration {
            Macro   /* macro that calculates avrg of 2 nos */
            {
             Name = GetAverage; /* Name of the macro */
             type = Real64; /* Return type */
             argument = number1:Sint64,number2:Sint64; /* Input parameters and types */
             procedure = (number1 + number2) / 2 /* Actual code */
            }
        
        // Sample invocation
        
        ...
        Condition {
          2 > GetAverage(8,4)
        }
        
        }
      
      

Policy Statement

Consists of a "if" "then" style rule. The "if" is specified using the Condition Statement and the "then" specified using the Decision Statement

Condition Statement: Consists of a boolean expression. If the Condition statement is absent it is assumed to be true.

          // Condition example
          Condition {
              freeMemory < freememorythreshold
          
          }
      
      
      

Decision Statement: Is a required statement that consists of one or more actions arranged in a sequence using the decision operators.

Types of Actions:

  • Invoke a method on the imported anchor class instance.

    <instancename>.<method name>(<expression>[,<expression>]*) <boolean operator> <numeric return code>

                  // Example of invoke method action
                  anchorInstance1.method1("xx", 2) == 0
    
                 
  • Modify the properties of the imported anchor class instance.

    Set(<instanceName>.<argument name>=<expression>[,<argument name> = <expression>]*)

                  //Example of set property action
                  Set(anchorInstance1.property1 = 2, anchorInstance1.property2 = "x")
              
  • Invoke a custom action. Custom actions are user created actions that are made available to the policy runtime as a jar. The ability to define custom actions enables the SPL language to be extended or customized for a user's environment.

    <custom action name>(<expression>[,<expression>]*)

                //Example of a custom action
                SendMail("xxx@mail.com","yyy@mail.com","hello","hi how are you?")
              
              

Ordering the Actions:

  • If-Then action ordering.

    Execute action block1 if that succeeds then execute action block2. The result of executing the action block2 will be returned. If action block1 execution fails return without execution action block2 with failure.

    <action block1> -> <action block2>

                // If-Then action
                Decision { //Clean up the system and if that succeeds send out an email
                   system.cleanup() -> SendMail(...)
                }
                
              
    Note
    An action is deemed a success if no exceptions are thrown and if the returned value satisfies the constant boolean expression.
  • Concurrency "some semantics " action ordering.

    Both action blocks are executed concurrently. If either of the action blocks executes successfully the entire execution is deemed successful.

    <action block1> || <action block2>

                // Concurrency some semantics action
                Decision { //Clean up the system and send out an email
                   system.cleanup() || SendMail(...)
                }
                
              
  • Concurrency "all semantics " action ordering.

    Both action blocks are executed concurrently. Both action blocks should execute successfully for entire execution to be deemed successful.

    <action block1> && <action block2>

                // Concurrency all semantics action
                Decision { //Clean up the system and send out an email
                   system.cleanup() && SendMail(...)
                }
                
              
  • Conditional action ordering.

    Action block1 is executed first if that fails only then action block2 is executed. If action block1 succeeds then the block returns with success, if block 1 fails then the result of execution will be whatever block2 returns.

    <action block1> | <action block2>

                // Conditional action
                Decision { //Clean up the system if that fials send out an email
                   system.cleanup() | SendMail(...)
                }
                
              

Priority: Priority is an integral value assigned to each policy that determines the relative order of execution among subpolicies. Higher number implies higher priority

        Policy {
        ...
        }1;
      
      

SPL Data Types

SPL supports all the basic Java data types along with the arrays of the data types

SPL and Java data types comparison
SPL Data Type Java Data Type Notes
Sint8 byte
Sint16 short
Sint32 int
Sint64 long
Real32 float
Real64 double
Char16 char
String String
DateTime Calendar
Reference Java object Any Java object
Boolean boolean

SPL Built-in Operators

SPL ships with over a 100 core Operators. These operators are especially useful while defining complex conditions within a policy. New custom operators can be added to enhance SPL to work with a user's specific need.

Numeric Operators

These operators perform numeric calculations on numeric operands. The implementation is largely the encapsulation of the Java Math operations.

Numeric Operators
Name Description Syntax Example
+ Returns the sum of two given numeric expressions (<numeric expression1> + <numeric expression2> ) 2 + 4
/ Returns the result of dividing two numeric expressions (<numeric expression1> / <numeric expression2> ) 4 / 2
* Returns the product of numeric expression1 and numeric expression2 (<numeric expression1> * <numeric expression2>) (2*2)
- Subtracts numeric argument 2 from numeric argument 1 (<numeric expression1> - <numeric expression2>) (4 - 2)
Abs Returns the absolute value of the given numeric expression Abs( <numeric expression> ) Abs(2.4)
Ceiling Returns the closest integer greater than or equal to the given numeric expressions Ceiling(<numeric expression>) Ceiling(2.4)
Exp Returns the exponential value of the given numeric expressions Exp(<numeric expression>) Exp(2)
Floor Returns the closest integer smaller than or equal to the given numeric expressions Floor(<numeric expression>) Floor(2.4)
Ln Returns the natural log of the given numeric expressions Ln(<numeric expression>) Ln(2.4)
Log10 Returns the log to the base 10 of the given numeric expressions Log10(<numeric expression>) Log10(2.4)
Mod Returns the remainder after diving numeric expression1 with numeric expression2 (<numeric expression1> % <numeric expression2>) (4%2)
Power Returns the numeric value after raising numeric expression1 to the power of numeric expression2 Power(<numeric expression1> , <numeric expression2>) Power(2,2)
Rint Rounds to the closest integer Rint(<numeric expression>) Rint(2.4)
Round Adds 0.5 to the argument and returns the closest integer Round(<numeric expression>) Round(2.4)
SquareRoot Returns the square root of the given numeric expressions SquareRoot(<numeric expression>) SquareRoot(4)

Comparison Operators

As the name suggests these operators perform comparisons among type comparable operands. The return value is always Boolean.

Comparison Operators
Name Description Syntax Example
== Returns true if the given two comparable expressions are equal ( <expression1> == <expression2> ) 2 == 2
> Returns true if the value of expression1 is greater than the value of expression2. The given two expressions need to be comparable ( <expression1> > <expression2> ) 5 > 4
>= Returns true if the value of expression1 is greater than or equal to the value of expression2. The given two expressions need to be comparable Only permitted on String, numeric or calendar types ( <expression1> >= <expression2> ) 5 >= 5
< Returns true if the value of expression1 is less than the value of expression2. The given two expressions need to be comparable Only permitted on String, numeric or calendar types ( <expression1> < <expression2> ) 3 < 4
<= Returns true if the value of expression1 is less than or equal to the value of expression2. The given two expressions need to be comparable Only permitted on String, numeric or calendar types ( <expression1> <= <expression2> ) 3 <= 4
!= Returns true if the given two comparable expressions are not equal ( <expression1> != <expression2> ) 2 != 4

Boolean Operators

These operators perform Logical operations like And, Or, Xor on Boolean operands.

Boolean Operators
Name Description Syntax Example
&& Returns the result of a logical and on the two given boolean expressions ( <boolean expression1> && <boolean expression2> ) true && true
! Returns the result of a logical not on the given boolean expression !(<boolean expression> ) !(false)
|| Returns the result of a logical Or on the given two boolean expressions (<boolean expression1> || <boolean expression2> ) (false || true)
^ Returns the result of a logical XOr on the given two boolean expressions (<boolean expression1> ^ <boolean expression2> ) (false ^ true)

String Operators

A group of operators that deal with string operands. These include operators to manipulate strings or test strings for specific patterns.

String Operators
Name Description Syntax Example
Concatenate Returns the result of concatenating the two given string expressions Concatenate( <string expression1>, <string expression2> ) Concatenate("x","y")
Contains Returns true if string expression1 contains string expression2 Contains( <string expression1>, <string expression2> ) Contains("xyz","y")
ContainsOnlyDigits Returns true if string expression1 only contains digits ContainsOnlyDigits( <string expression1>) ContainsOnlyDigits("100")
ContainsOnlyLetters Returns true if string expression1 only contains letters ContainsOnlyLetters( <string expression1>) ContainsOnlyLetters("abc")
ContainsOnlyLettersOrDigits Returns true if string expression1 only contains letters or digts ContainsOnlyLettersOrDigits( <string expression1>) ContainsOnlyLettersOrDigits("abc12")
EndsWith Returns true if string expression1 ends with string expression2 EndsWith( <string expression1>,<string expression2>) EndsWith("abc12","12")
LeftSubString The LeftSubstring operator returns a prefix of a given string argument by taking three arguments. How to compute the prefix is determined by the arguments. The first argument MUST be a string and it indicates the given string, the second argument MUST be either an integer or a string indicating an offset, and the third argument MUST be a string indicating a direction and is either "LeftToRight" or "RightToLeft". When the offset is given by a number, the prefix is determined by counting the character position by the offset from either left to right (from the beginning of the string) or from right to left (from the end of the string). In particular, if the direction is "LeftToRight", the offset indicates the number of characters to return from the beginning of the string. If the direction is "RightToLeft", the offset indicates the number of characters to skip from the end of the string. For example, leftSubstring("Mississippi", 4, "LeftToRight") returns "Miss", and leftSubstring("Mississippi", 4, "RightToLeft") returns "Mississ". When the offset is given by a string, the prefix is determined by searching for the offset string in the original string in the direction specified by the third parameter. The returned substring consists of the characters on the left side of the offset string LeftSubString( <string expression1>,<numeric expression2>,<string expression3>) LeftSubString("StateSymbolAndZip",2, "LefToRight") //get the state
MatchesRegExp Returns true if string expression1 matches the regular expression defined by string expression2 MatchesRegExp( <string expression1>,<string expression2>) MatchesRegExp("cat","cat")
MiddleSubString The MiddleSubstring operator returns a middle portion of a given string using various arguments as filters. How to compute the suffix is determined by the arguments. MiddleSubstring takes four arguments: original string, first offset, second offset, and direction string. The first and second offsets MUST be specified either by a number or a string. The direction string can be either "LeftToRight" or "RightToLeft". The meaning of the first offset is similar to that in the rightSubstring: it indicates where the resulting substring starts scanning, either from the left or from the right based on the direction string. The meaning of the second offset is as follows: if it is a number, it simply indicates the number of characters to return; if it is a string, it specifies where the substring should end. MiddleSubString( <string expression1>,<expression2>,<expression1>,<string expression1>) middleSubstring("Mississippi", 4, 5, "LeftToRight") = "issip" middleSubstring("Mississippi", 4, 5, "RightToLeft") = "ippi" middleSubstring("Mississippi", "ss", 5, "LeftToRight") = "issip" middleSubstring("Mississippi", "ss", 5, "RightToLeft") = "ippi" middleSubstring("Mississippi", 4, "ss", "LeftToRight") = "i" middleSubstring("Mississippi", 4, "ss", "RightToLeft") = "" middleSubstring("Mississippi", "ss", "ip", "LeftToRight") = "iss" middleSubstring("Mississippi", "ss", "ip", "RightToLeft") = "Missi"
ReplaceSubString Returns a string resulting from replacing all instances of the fromSubstring with toSubstring in a given string. ReplaceSubString( <string expression1>,<from string expression>,<to string expression>) ReplaceSubString(name,"cat","dog")
RightSubString The RightSubstring operator returns a suffix of a given string argument by taking three arguments. How to compute the suffix is determined by the arguments. The first argument MUST be a string and it indicates the given string, the second argument MUST be either an integer or a string indicating an offset, and the third argument MUST be a string indicating a direction and is either "LeftToRight" or "RightToLeft". When the offset is given by a number, the suffix is determined by simply counting the character position by the offset from either left to right (from the beginning of the string) or from right to left (from the end of the string). In particular, if the direction "RightToLeft", the offset indicates the number of characters to return as a suffix. If the direction is "LeftToRight", the offset indicates the number of characters to skip from the beginning of the string. Refer the CIM-SPL specification for more details. RightSubString( <string expression1>,<numeric expression2>,<string expression3>) RightSubString("StateSymbolAndZip",2, "LefToRight") //get the zip
StartsWith Returns true if string expression1 starts with string expression2 StartsWith( <string expression1>,<string expression2>) StartsWith("just a test","just")
StringLength Returns the string length StringLength( <string expression1>) StringLength("string") //6
SubString The substring operator takes either two or three arguments. The first and second arguments of this operator are REQUIRED while the third argument is OPTIONAL. The first argument of this operator MUST be a string argument, while the second and third argument MUST be integer argument. This operator MUST return the substring of the first string argument, starting at the position indicated by the second numeric argument and going to the end of the string or the position indicated by the third numeric argument - 1. The position of a character is determined as follows: The first character is at position 0, the second character is at position 1, and so on. The second numeric argument MUST be greater than or equal to 0. The third numeric argument MUST be greater than the second numeric argument if the third argument is present. If the starting position given by the second numeric argument greater than the length of the string, an empty string SHALL be returned. If the third numeric position is not present, the string starting at the second numeric position until the end of the string SHALL be returned. Refer the CIM-SPL specification for more details. SubString( <string expression1>,<numeric expression2>,[<numeric expression2>]) SubString("Robert Hancock", 2, 8) //returns bert H
Word This operator MUST take three argument. The first two argument MUST be of type string and the third argument MUST be of type number. This operator MUST extracts n words from the first string argument where the third argument specifies the number n. Words are defined as text between the separator substring given by the second argument. Refer the CIM-SPL specification for more details. Word( <string expression1>,<seperator string expression>,<numeric expression>) Word("alpha"," ",3)
ToUpper Converts the argument string to uppercase ToUpper( <string expression1>) ToUpper("alpha") // returns "ALPHA"
ToLower Converts the argument string to lowercase ToLower( <string expression1>) ToLower("ALPHA") // returns "alpha"

Collection Operators

These are array manipulation and comparison operators. These operators encapsulate the complexity of traditional programming language constructs like loops and make the language more readable and maintainable.

Collection Operators
Name Description Syntax Example
AllInCollection Checks whether all objects in a collection have a given property. The valid operator constant strings are "OR", "AND", "XOR", "NOT_EQUAL", "EQUAL", "LESS", "GREATER", "LESS_OR_EQUAL", "GREATER_OR_EQUAL" AllInCollection( <expression1>, <boolean or relational operator constant string> <collection>) AllInCollection(2,"LESS",arr) //where arr = [5,6,7] returns true
AnyInCollection Checks whether any object in a collection has a given property. The valid operator constant strings are "OR", "AND", "XOR", "NOT_EQUAL", "EQUAL", "LESS", "GREATER", "LESS_OR_EQUAL", "GREATER_OR_EQUAL" AnyInCollection( <expression1>, <boolean or relational operator constant string> <collection>) AnyInCollection(2,"LESS",arr) //where arr = [1,6,7] returns true
ApplyToCollection Applies an arithmetic operation to each element in a collection. The valid operator constant strings are "PLUS ","MINUS ","MULTIPLY","DIVIDE", ApplyToCollection( <expression1>, <arithmetic operator constant string> <numeric collection>) ApplyToCollection(2,"PLUS",arr) //where arr = [1,6,7] returns arr ] [3,8,9]
AvrgInCollection Calculates the average of a numeric collection. AvrgInCollection( <numeric collection>) AvrgInCollection(arr) //where arr = [2,3] returns 2.5
CollectionSize Returns the size of the collection CollectionSize( <numeric collection>) CollectionSize(arr) //where arr = [2,3,4] returns 3
EqCollection Returns true if two collections of comparable types are equal EqCollection( <collection1>,<collection2>) EqCollection(arr1,arr2) //where arr1 = [2,3,4] and arr2 = [2,3,4] returns true
InCollection Returns true if the given value is a member of the collection (of compatible type) InCollection( <expression>,<collection>) InCollection(2,arr1) //where arr1 = [2,3,4] returns true
Max Returns greatest value in a numeric collection Max( <numeric collection>) Max(arr1) //where arr1 = [2,3,4] returns 4
Min Returns smallest value in a numeric collection Min( <numeric collection>) Min(arr1) //where arr1 = [2,3,4] returns 2
MedianInCollection Calculates the median of a numeric collection. MedianInCollection( <numeric collection>) MedianInCollection(arr) //where arr = [2,3,4] returns 3
SdInCollection Calculates the standard deviation of a numeric collection. SdInCollection( <numeric collection>) SdInCollection(arr) //where arr = [2,3,4] returns 0.81
SubCollection Checks whether collection2 is a subset of collection1 SubCollection( <collection1>,<collection2>) SubCollection(arr,arr2) //where arr = [2,3,4] and arr2 = [3,4] returns true
Union Creates a union of 2 collections Union( <collection1>,<collection2>) Union(arr,arr2) //where arr = [2,3,4] and arr2 = [5,6] returns [2,3,4,5,6]

Calendar Operators

These operators allow comparison and retrieval of Date-Time related attributes.

Calendar Operators
Name Description Syntax Example
GetCurrentTime Returns the current system date time GetCurrentTime() GetCurrentTime()
GetDayOfMonth Returns the day of month for the given datetime argument. The argument must be either a string of the form yyyymmddHHMMSS.mmmmmmsUUU or a java.util.Calendar GetDayOfMonth(<datetime>) GetDayOfMonth("20071013143920.000000-300") //returns 13
GetDayOfWeek Returns the day of week for the given datetime argument. Sunday = 1, Monday = 2 etc The argument must be eithera string of the form yyyymmddHHMMSS.mmmmmmsUUU or a java.util.Calendar GetDayOfWeek(<datetime>) GetDayOfWeek("20081013143920.000000-300") //returns 2
GetDayOfWeekInMonth MUST return the day of the week in month of the REQUIRED DATETIME argument as a numeric value, e.g., the DAY_OF_MONTH 1 through 7 always correspond to DAY_OF_WEEK_IN_MONTH 1; 8 through 14 correspond to DAY_OF_WEEK_IN_MONTH 2, and so on. DAY_OF_WEEK_IN_MONTH 0 indicates the week before DAY_OF_WEEK_IN_MONTH 1. Negative values count back from the end of the month, so the last Sunday of a month is specified as DAY_OF_WEEK = SUNDAY, DAY_OF_WEEK_IN_MONTH = -1. The argument must be eithera string of the form yyyymmddHHMMSS.mmmmmmsUUU or a java.util.Calendar GetDayOfWeekInMonth(<datetime>) GetDayOfWeekInMonth("20081013143920.000000-300") //returns 2
GetDayOfYear Returns the day of year for the given datetime argument. The argument must be eithera string of the form yyyymmddHHMMSS.mmmmmmsUUU or a java.util.Calendar GetDayOfYear(<datetime>) GetDayOfYear("20080113143920.000000-300") //returns 13
GetHour12 Returns the hour for the given datetime argument in 12 hr format. The argument must be eithera string of the form yyyymmddHHMMSS.mmmmmmsUUU or a java.util.Calendar GetHour12(<datetime>) GetHour12("20080113143920.000000-300") //returns 2
GetHour24 Returns the hour for the given datetime argument in 24 hr format. The argument must be eithera string of the form yyyymmddHHMMSS.mmmmmmsUUU or a java.util.Calendar GetHour24(<datetime>) GetHour24("20080113143920.000000-300") //returns 14
GetMillisecond Returns the millisecond for the given datetime argument. The argument must be eithera string of the form yyyymmddHHMMSS.mmmmmmsUUU or a java.util.Calendar GetMillisecond(<datetime>) GetMillisecond("20080113143920.000234-300") //returns 234
GetMinute Returns the minute for the given datetime argument. The argument must be eithera string of the form yyyymmddHHMMSS.mmmmmmsUUU or a java.util.Calendar GetMinute(<datetime>) GetMinute("20080113143920.000234-300") //returns 39
GetMonth Returns the month for the given datetime argument. The argument must be eithera string of the form yyyymmddHHMMSS.mmmmmmsUUU or a java.util.Calendar GetMonth(<datetime>) GetMonth("20080113143920.000234-300") //returns 1
GetSecond Returns the second for the given datetime argument. The argument must be eithera string of the form yyyymmddHHMMSS.mmmmmmsUUU or a java.util.Calendar GetSecond(<datetime>) GetSecond("20080113143920.000234-300") //returns 20
GetWeekOfMonth Returns the week within the month for the given datetime argument. The argument must be eithera string of the form yyyymmddHHMMSS.mmmmmmsUUU or a java.util.Calendar GetWeekOfMonth(<datetime>) GetWeekOfMonth("20080113143920.000234-300") //returns 2
GetWeekOfYear Returns the week of the year for the given datetime argument. The argument must be eithera string of the form yyyymmddHHMMSS.mmmmmmsUUU or a java.util.Calendar GetWeekOfYear(<datetime>) GetWeekOfYear("20080113143920.000234-300") //returns 2
GetYear Returns the year for the given datetime argument. The argument must be eithera string of the form yyyymmddHHMMSS.mmmmmmsUUU or a java.util.Calendar GetYear(<datetime>) GetYear("20080113143920.000234-300") //returns 2008
IsAfter Returns true if date argument1 is after date argument2. The argument must be eithera string of the form yyyymmddHHMMSS.mmmmmmsUUU or a java.util.Calendar IsAfter(<datetime1>,<datetime2>) IsAfter("20080113143920.000234-300","20070113143920.000234-300") //returns true
IsBefore Returns true if date argument1 is before date argument2. The argument must be eithera string of the form yyyymmddHHMMSS.mmmmmmsUUU or a java.util.Calendar IsBefore(<datetime1>,<datetime2>) IsBefore("20080113143920.000234-300","20070113143920.000234-300") //returns false
IsWithin Returns true if date argument1 is within date argument2 and argument3. The arguments must be eithera string of the form yyyymmddHHMMSS.mmmmmmsUUU or a java.util.Calendar IsWithin(<datetime1>,<datetime2>,<datetime3>) IsWithin("20070113143920.000234-300","20060113143920.000234-300","20080113143920.000234-300") //returns false

Unary Operators

As the name suggests these operators require only a single operand.

Unary Operators
Name Description Syntax Example
Unary Minus operator Negates a numeric expression -(<expression>) -(2+4)
Unary Plus operator Leaves a numeric expression unchanged +(<expression>) +(2+4)
Unary Not operator Negates a boolean expression !(<boolean expression>) !(true)

Cast Operators

These are transformation operators that allow legal conversions between different data types. Note: General rules of widening and shortening conversions apply.

Cast Operators
Name Description Syntax Example
ToBoolean Converts an expression to boolean ToBoolean(<expression>) ToBoolean("true") // returns true
ToREAL32 Converts an expression to float ToReal32(<expression>) ToReal32(4) // returns 4.0
ToREAL64 Converts an expression to double ToReal64(<expression>) ToReal64(4) // returns 4.0
ToSINT16 Converts an expression to short ToSINT16(<expression>) ToSINT16(4) // returns 4
ToSINT32 Converts an expression to int ToSINT32(<expression>) ToSINT32(4.0) // returns 4
ToSINT64 Converts an expression to long ToSINT64(<expression>) ToSINT64(4) // returns 4
ToSINT8 Converts an expression to byte ToSINT8(<expression>) ToSINT8(4) // returns 4
ToString Converts an expression to string ToString(<expression>) ToString(4) // returns "4"

Built in Actions

SPL comes out of the box with a set of Actions. Users can extend the SPL action set by adding their own custom actions.

Core SPL Actions
Name Description Syntax Example
ReturnValues Allows the objects to be returned after policy execution. ReturnValues(<expression>,[<expression>]*) ReturnValues("xx") // returns String "xx"
SendMail Sends an email to the given email address with the given subject and message body. Note: SendMail is not a core action but is provided as an example of a custom action. SendMail(<from address string expression>,<to address string expression>,<subject string expression>,<message body string expression>) SendMail("from@mail.com","to@mail.com","hi","whaddup?")
CommandLineExecution Executes a shell or batch command. Note: CommandLineExecution is not a core action but is provided as an example of a custom action. CommandLineExecution(<string command expression>) CommandLineExecution("cleanmgr /sagerun:128")

References