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
5c0b9d25
Commit
5c0b9d25
authored
8 years ago
by
Johannes Eder
Browse files
Options
Downloads
Patches
Plain Diff
new utility method
parent
91788241
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/EMFResourceUtils.java
+36
-1
36 additions, 1 deletion
...rc/org/fortiss/tooling/kernel/utils/EMFResourceUtils.java
with
36 additions
and
1 deletion
org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/EMFResourceUtils.java
+
36
−
1
View file @
5c0b9d25
...
...
@@ -41,7 +41,7 @@ import org.fortiss.tooling.kernel.ToolingKernelActivator;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating
GREEN
Hash:
05A7E1EF00860F1627C27B2E7E6675A9
* @ConQAT.Rating
YELLOW
Hash:
56BD3983999FF36819DDEDE7854E36EF
*/
public
final
class
EMFResourceUtils
{
/**
...
...
@@ -112,6 +112,41 @@ public final class EMFResourceUtils {
return
null
;
}
/**
* Loads the root model element from the given {@link URI}. Logs errors to the console and
* returns <code>null</code>.
*
* @param uri
* the resource {@link URI}.
* @param topLevelClass
* the type of the top level class to be returned
* @return the root {@link EObject} of class type topLevelClass (first root which is found of
* this type is returned)
*/
public
static
Pair
<
EObject
,
Map
<
EObject
,
AnyType
>>
loadModelFromFileWithUnknownFeatures
(
URI
uri
,
Class
<?>
topLevelClass
)
{
try
{
ResourceSet
rset
=
new
ResourceSetImpl
();
Resource
r
;
r
=
rset
.
createResource
(
uri
);
r
.
load
(
EMFResourceUtils
.
buildOptionsMap
());
Map
<
EObject
,
AnyType
>
unknownFeatures
=
r
instanceof
XMIResource
?
((
XMIResource
)
r
).
getEObjectToExtensionMap
()
:
new
HashMap
<
EObject
,
AnyType
>();
if
(!
r
.
getContents
().
isEmpty
())
{
for
(
EObject
content
:
r
.
getContents
())
{
if
(
topLevelClass
.
isAssignableFrom
(
content
.
getClass
()))
return
new
Pair
<
EObject
,
Map
<
EObject
,
AnyType
>>(
content
,
unknownFeatures
);
}
}
}
catch
(
IOException
ex
)
{
error
(
ToolingKernelActivator
.
getDefault
(),
"Failed to load model from "
+
uri
.
toString
(),
ex
);
}
return
null
;
}
/**
* Loads the root model element from the given {@link URI}. Logs errors to the console and
* returns <code>null</code>.
...
...
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