Package org.btrplace.btrpsl
Class Script
java.lang.Object
org.btrplace.btrpsl.Script
public class Script extends Object
A btrplace script that contains the declaration of VMs, nodes, and constraints.
- Author:
- Fabien Hermenier
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Script()
Make a new script with a given identifier. -
Method Summary
Modifier and Type Method Description boolean
add(Collection<BtrpElement> elems)
Add a collection of nodes or elements.boolean
add(BtrpElement el)
Add a VM or a node to the script.boolean
addConstraint(SatConstraint c)
Add a constraint to a script.void
addExportable(String name, BtrpOperand e, Set<String> scopes)
Add an external operand that can be accessed from several given scopes.boolean
canImport(String label, String namespace)
Indicates whether a namespace can import an exported variable or not.String
fullyQualifiedSymbolName(String name)
Get the fully qualified name of a symbol.Set<SatConstraint>
getConstraints()
Get the constraints declared in the script.List<Script>
getDependencies()
Get the direct dependencies of this script.Set<String>
getExported()
Get the set of exported operands label.BtrpOperand
getImportable(String label)
Get the exported variable.BtrpOperand
getImportable(String label, String namespace)
Get the exported operand from its label.List<BtrpOperand>
getImportables(String ns)
Get all the operand a given script can importString
getlocalName()
Get the local name of the script.String
getNamespace()
Get the namespace the script belongs toSet<Node>
getNodes()
Get the VMs declared in the script.Set<VM>
getVMs()
Get the VMs declared in the script.String
id()
Get the unique string identifier of the script.String
prettyDependencies()
Textual representation for the dependencies.void
setFullyQualifiedName(String n)
Set the fully qualified name of the script.String
toString()
-
Field Details
-
EXTENSION
Default file extension for script.- See Also:
- Constant Field Values
-
-
Constructor Details
-
Script
public Script()Make a new script with a given identifier.
-
-
Method Details
-
setFullyQualifiedName
Set the fully qualified name of the script.- Parameters:
n
- the fully qualified name
-
getNamespace
Get the namespace the script belongs to- Returns:
- the namespace name or
null
-
getlocalName
Get the local name of the script.- Returns:
- a non-empty String
-
id
Get the unique string identifier of the script.- Returns:
- a non-empty string
-
getVMs
Get the VMs declared in the script.- Returns:
- a set of nodes that may be empty
-
getNodes
Get the VMs declared in the script.- Returns:
- a set of nodes that may be empty
-
addConstraint
Add a constraint to a script.- Parameters:
c
- the constraint- Returns:
true
iff the constraint has been added
-
getConstraints
Get the constraints declared in the script.- Returns:
- a set of constraints that may be empty
-
add
Add a collection of nodes or elements.- Parameters:
elems
- the elements to add- Returns:
true
iff at least one element has been added
-
add
Add a VM or a node to the script.- Parameters:
el
- the element to add- Returns:
true
if the was was added
-
getImportables
Get all the operand a given script can import- Parameters:
ns
- the script namespace- Returns:
- a list of importable operand, may be empty
-
getImportable
Get the exported operand from its label.- Parameters:
label
- the operand labelnamespace
- the namespace of the script that ask for this operand.- Returns:
- the operand if exists or
null
-
getImportable
Get the exported variable. The variable must be importable by anyone.- Parameters:
label
- the label that denotes the variable- Returns:
null
if the label does not point to a variable or if the variable as some restrictions wrt. its access
-
canImport
Indicates whether a namespace can import an exported variable or not. To be imported, the label must point to an exported variable, with no import restrictions or with a given namespace compatible with the restrictions.- Parameters:
label
- the label to importnamespace
- the namespace of the script asking for the variable- Returns:
true
if the variable can be imported.false
otherwise}
-
addExportable
Add an external operand that can be accessed from several given scopes. A scope is a namespace that can ends with a wildcard ('*'). In this situation. The beginning of the scope is considered- Parameters:
name
- the name of the exported operande
- the operand to addscopes
- the namespaces of the scripts that can use this variable.null
to allow anyone
-
fullyQualifiedSymbolName
Get the fully qualified name of a symbol.- Parameters:
name
- the symbol name- Returns:
- the fully qualified symbol name.
-
getExported
Get the set of exported operands label.- Returns:
- a set of label that may be empty
-
getDependencies
Get the direct dependencies of this script.- Returns:
- the list of dependencies for this script.
-
toString
-
prettyDependencies
Textual representation for the dependencies.- Returns:
- a String containing the dependency tree.
-