Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
af3
kernel
Commits
3d262f05
Commit
3d262f05
authored
12 years ago
by
Florian Hölzl
Browse files
Options
Downloads
Patches
Plain Diff
code generation for composite
refs 121
parent
db7c92f8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/TransformationUtils.java
+39
-28
39 additions, 28 deletions
...org/fortiss/tooling/kernel/utils/TransformationUtils.java
with
39 additions
and
28 deletions
org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/TransformationUtils.java
+
39
−
28
View file @
3d262f05
...
...
@@ -31,7 +31,7 @@ import org.fortiss.tooling.kernel.service.ITransformationService;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating
GREEN
Hash:
A592C08FD3D4504BBFC841C98C4A627
A
* @ConQAT.Rating
YELLOW
Hash:
34A2DE2F88136C0B20E55E74D6E7F00
A
*/
public
final
class
TransformationUtils
{
/**
...
...
@@ -44,24 +44,22 @@ public final class TransformationUtils {
* the class of the transformation result
* @param context
* the transformation context
* @return the transformation result (an instance of class
* <code>targetClass</code>).
* @return the transformation result (an instance of class <code>targetClass</code>).
* @throws ChainTransformationFailedException
* if no transformation chain could be found or none of the
* possible chains succeeded.
*/
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
extends
Object
>
T
createTransformedObjectFor
(
final
EObject
sourceElement
,
final
Class
<
T
>
targetClass
,
ITransformationContext
context
)
public
static
<
T
extends
Object
>
T
createTransformedObjectFor
(
final
EObject
sourceElement
,
final
Class
<
T
>
targetClass
,
ITransformationContext
context
)
throws
ChainTransformationFailedException
{
List
<
TransformationProviderChain
>
chainList
=
ITransformationService
.
INSTANCE
.
getTransformationProviderChain
(
sourceElement
.
getClass
(),
targetClass
,
context
);
List
<
TransformationProviderChain
>
chainList
=
ITransformationService
.
INSTANCE
.
getTransformationProviderChain
(
sourceElement
.
getClass
(),
targetClass
,
context
);
ChainTransformationFailedException
e
=
null
;
if
(!
chainList
.
isEmpty
())
{
if
(!
chainList
.
isEmpty
())
{
Object
executableObject
=
null
;
for
(
TransformationProviderChain
chain
:
chainList
)
{
for
(
TransformationProviderChain
chain
:
chainList
)
{
try
{
// for the moment, we use the first chain
// alternatives need an interpretation of the context, which
...
...
@@ -69,37 +67,36 @@ public final class TransformationUtils {
executableObject
=
chain
.
transform
(
sourceElement
,
context
);
e
=
null
;
break
;
}
catch
(
ChainTransformationFailedException
ctfe
)
{
}
catch
(
ChainTransformationFailedException
ctfe
)
{
// fall through
e
=
ctfe
;
}
}
if
(
e
==
null
&&
executableObject
!=
null
)
{
return
(
T
)
executableObject
;
if
(
e
==
null
&&
executableObject
!=
null
)
{
return
(
T
)
executableObject
;
}
}
if
(
e
!=
null
)
{
if
(
e
!=
null
)
{
throw
e
;
}
throw
new
ChainTransformationFailedException
(
null
,
null
,
null
,
null
)
{
/** {@inheritDoc} */
@Override
public
String
getMessage
()
{
return
"No transformation chain found from "
+
sourceElement
+
" to "
+
targetClass
.
getName
();
return
"No transformation chain found from "
+
sourceElement
+
" to "
+
targetClass
.
getName
();
}
};
}
/**
* Searches a transformation chain for the given model element and the
* target class and returns the transformation result. This method returns
*
<code>null</code> if
the transformation failed. The exception is
* target class and returns the transformation result. This method returns
<code>null</code> if
* the transformation failed. The exception is
* suppressed.
*
* This is a fail-silent version of
* {@link #createTransformedObjectFor(EObject, Class, ITransformationContext)}
* .
* {@link #createTransformedObjectFor(EObject, Class, ITransformationContext)} .
*
* @param sourceElement
* the source of the transformation
...
...
@@ -107,18 +104,32 @@ public final class TransformationUtils {
* the class of the transformation result
* @param context
* the transformation context
* @return the transformation result (an instance of class
* <code>targetClass</code>).
* @return the transformation result (an instance of class <code>targetClass</code>).
*/
public
static
<
T
extends
Object
>
T
createTransformedObjectWithoutExceptionFor
(
EObject
sourceElement
,
Class
<
T
>
targetClass
,
ITransformationContext
context
)
{
EObject
sourceElement
,
Class
<
T
>
targetClass
,
ITransformationContext
context
)
{
try
{
T
result
=
createTransformedObjectFor
(
sourceElement
,
targetClass
,
context
);
T
result
=
createTransformedObjectFor
(
sourceElement
,
targetClass
,
context
);
return
result
;
}
catch
(
ChainTransformationFailedException
ctfe
)
{
}
catch
(
ChainTransformationFailedException
ctfe
)
{
return
null
;
}
}
/**
* Searches a transformation chain for the given model element and the target class and returns
* {@code true} if such a chain exists.
*
* @param sourceElement
* the source of the transformation
* @param targetClass
* the class of the transformation result
* @param context
* the transformation context
* @return {@code true} if a transformation chain exists, {@code false} otherwise
*/
public
static
boolean
canTransform
(
EObject
sourceElement
,
Class
<?>
targetClass
,
ITransformationContext
context
)
{
return
ITransformationService
.
INSTANCE
.
canTransform
(
sourceElement
,
targetClass
,
context
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment