Class Utils
- java.lang.Object
-
- de.uni_hildesheim.sse.translation.Utils
-
public class Utils extends java.lang.ObjectSome public utility methods.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUtils.SplitResultThe result of splitting a contents object.
-
Constructor Summary
Constructors Modifier Constructor Description privateUtils()Prevents this class from being instantiated from outside.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static voidalreadyDefinedError(java.lang.String name, org.eclipse.emf.ecore.EObject object, org.eclipse.emf.ecore.EStructuralFeature feature)Emits an already defined error.private static <T> java.util.List<T>assign(java.util.List<T> list, java.lang.Object element, java.lang.Class<T> type)Helper function to assign theelementtolistifelementis of typetypeand to createlistif not defined before.(package private) static voidassignComments(net.ssehub.easy.varModel.model.StructuredComment target, java.util.List<?> elements, java.util.List<net.ssehub.easy.varModel.model.Comment> comments, net.ssehub.easy.varModel.model.IModelElement parent)Assigns the comments incommentsto the corresponding model elements inelements.(package private) static voidcheckDefaultParamSequence(de.uni_hildesheim.sse.ivml.OpDefStatement op, net.ssehub.easy.varModel.model.DecisionVariableDeclaration[] param, net.ssehub.easy.dslCore.translation.MessageReceiver receiver)Checks the sequence of default and non-default parameters.(package private) static net.ssehub.easy.varModel.model.StructuredCommentcreateStructuredComment(org.eclipse.emf.ecore.EObject object, TypeContext context, java.util.List<net.ssehub.easy.varModel.model.Comment> comments)Creates a structured comment for the givenobjectincontextdepending on the contents ofcomments, i.e.static java.lang.StringgetQualifiedNameString(de.uni_hildesheim.sse.ivml.QualifiedName name)Returns a string representing a qualified name.static java.lang.StringgetQualifiedNameString(de.uni_hildesheim.sse.ivml.QualifiedName name, de.uni_hildesheim.sse.ivml.AccessName aName)Returns a string representing a qualified name.static booleanisImportResolutionEnabled()Returns whether the import resolution shall be enabled.static <T> java.util.List<T>select(java.util.List<org.eclipse.emf.ecore.EObject> list, java.lang.Class<T> type)Selects those elements out oflistwhich are an instance oftype.(package private) static voidsetAnnotations(de.uni_hildesheim.sse.ivml.OpDefStatement op, net.ssehub.easy.varModel.model.datatypes.CustomOperation operation, net.ssehub.easy.varModel.model.Project project, net.ssehub.easy.dslCore.translation.MessageReceiver receiver)Defines the annotations for an operation and validates them for the givenoperation.static Utils.SplitResultsplit(java.util.List<org.eclipse.emf.ecore.EObject> elements)Splits the now heterogeneous list of elements inelementsinto individual lists stored in the result instance.static voidsplit(java.util.List<org.eclipse.emf.ecore.EObject> elements, Utils.SplitResult result)Splits the now heterogeneous list of elements inelementsinto individual lists stored inresultinstance.static java.lang.StringtoString(de.uni_hildesheim.sse.ivml.VariableDeclaration varDecl)Turns the declared variable names of thevarDeclinto a string.(package private) static java.lang.StringtoString(java.util.List<de.uni_hildesheim.sse.ivml.VariableDeclarationPart> parts)Turns variable declaration parts into strings for debugging.(package private) static java.lang.Stringunqualified(net.ssehub.easy.varModel.model.datatypes.IDatatype type)Returns the unqualified name oftype.
-
-
-
Method Detail
-
getQualifiedNameString
public static java.lang.String getQualifiedNameString(de.uni_hildesheim.sse.ivml.QualifiedName name)
Returns a string representing a qualified name. (May change in future to structured qualified names.)- Parameters:
name- the qualified name- Returns:
- the corresponding string representation
-
getQualifiedNameString
public static java.lang.String getQualifiedNameString(de.uni_hildesheim.sse.ivml.QualifiedName name, de.uni_hildesheim.sse.ivml.AccessName aName)Returns a string representing a qualified name. (May change in future to structured qualified names.)- Parameters:
name- the qualified nameaName- optional access to a compound (may be null)- Returns:
- the corresponding string representation
-
select
public static <T> java.util.List<T> select(java.util.List<org.eclipse.emf.ecore.EObject> list, java.lang.Class<T> type)Selects those elements out oflistwhich are an instance oftype.- Type Parameters:
T- the type of elements to be selected- Parameters:
list- the list to select fromtype- the type to select upon- Returns:
- a list of elements which are an instance of
type
-
assign
private static <T> java.util.List<T> assign(java.util.List<T> list, java.lang.Object element, java.lang.Class<T> type)Helper function to assign theelementtolistifelementis of typetypeand to createlistif not defined before.- Type Parameters:
T- the type of elements to be processed- Parameters:
list- the list to insertelementintoelement- the element to be insertedtype- the type to check for- Returns:
listor a new list includingelementiftypematches
-
split
public static Utils.SplitResult split(java.util.List<org.eclipse.emf.ecore.EObject> elements)
Splits the now heterogeneous list of elements inelementsinto individual lists stored in the result instance.- Parameters:
elements- the elements to split- Returns:
- the result instance
-
split
public static void split(java.util.List<org.eclipse.emf.ecore.EObject> elements, Utils.SplitResult result)Splits the now heterogeneous list of elements inelementsinto individual lists stored inresultinstance.- Parameters:
elements- the elements to splitresult- the result instance to be modified as a side effect
-
isImportResolutionEnabled
public static final boolean isImportResolutionEnabled()
Returns whether the import resolution shall be enabled. This method is legacy and was created while the editor was in an early stage. Please check and remove if adequate.- Returns:
trueif import resolution is enabled,falseelse
-
toString
public static java.lang.String toString(de.uni_hildesheim.sse.ivml.VariableDeclaration varDecl)
Turns the declared variable names of thevarDeclinto a string. [debugging]- Parameters:
varDecl- the variable declaration- Returns:
- the names of the declared variables
-
unqualified
static java.lang.String unqualified(net.ssehub.easy.varModel.model.datatypes.IDatatype type)
Returns the unqualified name oftype.- Parameters:
type- the type- Returns:
- the unqualified name
-
createStructuredComment
static net.ssehub.easy.varModel.model.StructuredComment createStructuredComment(org.eclipse.emf.ecore.EObject object, TypeContext context, java.util.List<net.ssehub.easy.varModel.model.Comment> comments)Creates a structured comment for the givenobjectincontextdepending on the contents ofcomments, i.e. whether there are comments or not.- Parameters:
object- the EObject to create the comment forcontext- the type context to assign the created context tocomments- the comments to consider- Returns:
- the created comment object or null
-
assignComments
static void assignComments(net.ssehub.easy.varModel.model.StructuredComment target, java.util.List<?> elements, java.util.List<net.ssehub.easy.varModel.model.Comment> comments, net.ssehub.easy.varModel.model.IModelElement parent)Assigns the comments incommentsto the corresponding model elements inelements.- Parameters:
target- the structured comment to store the mapping inelements- the elements to be assigned to the commentscomments- the comments (must be of same size)parent- the explicit parent element of the comments
-
setAnnotations
static void setAnnotations(de.uni_hildesheim.sse.ivml.OpDefStatement op, net.ssehub.easy.varModel.model.datatypes.CustomOperation operation, net.ssehub.easy.varModel.model.Project project, net.ssehub.easy.dslCore.translation.MessageReceiver receiver)Defines the annotations for an operation and validates them for the givenoperation.- Parameters:
op- the defining operation statementoperation- the translated IVML operationproject- the actual projectreceiver- the message receiver for warnings and errors
-
checkDefaultParamSequence
static void checkDefaultParamSequence(de.uni_hildesheim.sse.ivml.OpDefStatement op, net.ssehub.easy.varModel.model.DecisionVariableDeclaration[] param, net.ssehub.easy.dslCore.translation.MessageReceiver receiver)Checks the sequence of default and non-default parameters.- Parameters:
op- the operation declarationparam- the parameters to checkreceiver- the message receiver for warnings and errors
-
alreadyDefinedError
static void alreadyDefinedError(java.lang.String name, org.eclipse.emf.ecore.EObject object, org.eclipse.emf.ecore.EStructuralFeature feature) throws net.ssehub.easy.dslCore.translation.TranslatorExceptionEmits an already defined error.- Parameters:
name- the already defined nameobject- the causing Ecore objectfeature- the causing feature- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- the corresponding exception always
-
toString
static java.lang.String toString(java.util.List<de.uni_hildesheim.sse.ivml.VariableDeclarationPart> parts)
Turns variable declaration parts into strings for debugging.- Parameters:
parts- the parts- Returns:
- the names
-
-