-1
나는 ecore 파일을 읽고 ecore 파일에서 모든 클래스 e 객체를 가져오고 싶은 eobjects.Now 클래스를 포함하는 ecore 파일을 가지고있다.ecore 파일에서 eobjects를 읽는 것.
나는 ecore 파일을 읽고 ecore 파일에서 모든 클래스 e 객체를 가져오고 싶은 eobjects.Now 클래스를 포함하는 ecore 파일을 가지고있다.ecore 파일에서 eobjects를 읽는 것.
사용자 지정 접미어로 특정 xmi 파일을 다시로드 하시겠습니까? 여기
는 루트 EObject를을 특정 위치 (경로)에서는 Ecore 파일을로드하고 반환하는 방법의 예입니다public static EObject loadYourModel(String path) {
/*Initialzie Models*/
YourPackage.eINSTANCE.eClass();
/*register your xmi resources*/
final Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
final Map<String, Object> m = reg.getExtensionToFactoryMap();
/*put all your different ecore file suffixes in the map; suffix = YourPackage.eNAME*/
m.put(YourPackage.eNAME, new XMIResourceFactoryImpl());
/*you can put all different package names here*/
/*Create a new Resource set to store the EObjects from the file*/
ResourceSet resSet = new ResourceSetImpl();
/*get the resource of your ecore file*/
Resource resource = resSet.getResource(URI.createURI(path), true);
/*Get the first element = root of your model hierachy*/
EObject root = resource.getContents().get(0);
return root;
}