파트 참조 통계 생성
EGL은 프로그램이 참조하는 파트의 로그를 작성하는 데 사용할 수 있는 네 개의 Java™ 클래스를 포함합니다.
PartInfoFactory 클래스를 사용하여 Eclipse IDE 내에서 파트 참조 통계를 생성하십시오. EGLSDK 클래스와 함께 GenerationServer 클래스를 사용하여 IDE의 외부에서 로그를 생성하십시오.
PartInfoFactory
PartInfoFactory 클래스는
다음 위치에 있습니다.
com.ibm.etools.egl.ui.parts.PartInfoFactory
PartInfoFactory 클래스는 다음 메소드를 포함합니다.
public static IPartInfo[] getReferencePartList(IFile eglFile)
throws Exception
public static IPartInfo[] getReferencePartList(IFile eglFile,
boolean removeUnusedMembers)
throws Exception
public static IPartInfo[] getReferenceElementsList(IFile eglFile)
throws Exception
public static IPartInfo[] getReferenceElementsList(IFile eglFile,
boolean removeUnusedMembers)
throws Exception
- IPartInfo
- getReferencePartList()가 리턴하는 배열이며 eglFile의 첫 번째 기본 파트와 참조 파트를 포함합니다.
- eglFile
- 참조 통계를 생성 중인 파트를 포함하는 파일입니다.
- removeUnusedMembers
- 사용되지 않는 파트를 리턴된 파트의 목록에서 제거해야 하는지 여부를 지정합니다.
다음 예제는 genPart.egl 파일에서
파트 목록을 검색하고 IPartInfo에서 목록을 저장합니다.
IPartInfo[] parts = PartInfoFactory.getReferencePartList(genPart);
GenerationServer
GenerationServer 클래스는
다음 위치에 있습니다.
com.ibm.etools.egl.GenerationServer
GenerationServer 클래스는 다음 메소드를 포함합니다.
public static void addListener(IGenerationListener listener)
public static void removeListener(IGenerationListener listener)
public static void enableGeneration (boolean flag)
enableGeneration 부울 true 또는 false 플래그 설정을 허용하여 파트의 생성이 발생하는지 여부를 지정합니다. 기본값은 true입니다. EGLSDK를 호출하기 전에 해당 값을 false로 설정하면 후속 생성을 발생시키지 않고 EGL 소스와 연관된 값을 구문 분석하고 빌드할 수 있습니다.
- 리스너
- IGenerationListener 인터페이스의 인스턴스입니다. 이 주제에서 "IGenerationListener 인터페이스"를 참조하십시오.
public static IPartInfo[] getAllUniqueReferencedParts(
IPartInfo[] parts)
public static IElementInfo[] getAllUniqueReferecedElements(
IElementInfo[] elements)
- 파트
- 참조된 모든 파트의 배열을 작성하는 데 사용된 파트의 배열입니다. 배열의 모든 파트는 고유합니다.
- 요소
- 참조된 모든 파트, 중첩 함수, 참조된 프로그램 및 기타 요소의 배열을 작성하는 데 사용된 요소의 배열입니다. 배열의 모든 요소는 고유합니다.
다음 예제는
Java 프로그램 내에서 EGLSDK 클래스를 호출하여
Eclipse IDE 외부의 EGL 생성을 호출합니다.
GenerationServer.addListener(listener);
com.ibm.etools.egl.util.EGLSDK eglsdk = new com.ibm.etools.egl.util.EGLSDK();
GenerationServer.removeListener(listener);
IGenerationListener 인터페이스
IGenerationListener 인터페이스는 다음 메소드를 포함합니다.
- begin()
- 지정된 파트의 생성 시작에 호출됩니다.
- acceptGeneratedPart(파트)
- 파트가 생성된 알림을 제공합니다. 이 메소드는 연관된 파트(DataTables 및 FormGroups)를 생성 중인 경우 하나의 생성에 대해 여러 변 호출될 수 있습니다.
- acceptAssociatedPart(파트)
- 생성 중에 파트가 발생한 알림을 제공합니다.
- end()
- 지정된 파트의 생성 끝에 호출됩니다.
IPartInfo 인터페이스
IPartInfo 인터페이스는 다음 메소드를 포함합니다.
- getPackageName()
- 파트의 패키지 이름을 리턴합니다. 이름은 '.'로 구분된 패키지 문자열입니다.
- getResourceName()
- 파트가 정의된 파일의 전체 경로 이름을 리턴합니다.
- getSource()
- 프로그램, 함수, 레코드 또는 기타 파트일 수 있는 이 파트의 EGL 소스 텍스트를 리턴합니다. 이 메소드에는 EGL 파트가 빌드되어 있어야 하며 EGL 컴파일된 IR의 정확도에 의존합니다.
- getSource(Set resources, List partList)
- 프로그램, 함수, 레코드 또는 기타 파트일 수 있는 이 파트의 EGL 소스 텍스트를 리턴합니다. 이 메소드에서 EGL 파트를 빌드할 필요가 없으며 호출 중에 이 파트의 EGL 소스가 구문 분석되게 합니다.
일반적으로, 새로운 Set 및 ArrayList를 얻은 후 조치의 모든 파트를 처리하도록 로직을 둘러싸서 해제됩니다. 예를 들어, 다음과 같습니다.
public void run(IAction action) {
resources = new HashSet();
partList = new ArrayList();
Iterator selectionIterator = this.selection.iterator();
while (selectionIterator.hasNext()) {
Object object = selectionIterator.next();
if ((object instanceof IEGLFile)) {
IEGLFile iEglFile = (IEGLFile) object;
try {
IFile eglFile = ResourcesPlugin.getWorkspace().getRoot().getFile(iEglFile.getUnderlyingResource().getFullPath());
IPartInfo[] associatedParts = PartInfoFactory.getReferencePartList(eglFile);
generateEglSourceFile(associatedParts, eglFile);
} catch (Exception e) {
e.printStackTrace();
}
}
}
resources = null;
partList = null;
}
private static void generateEsf(IPartInfo[] associatedParts, IFile eglFile) {
....
associatedParts = GenerationServer.getAllUniqueReferecedParts(associatedParts);
try {
BufferedWriter out = new BufferedWriter(new FileWriter(outFile, false));
for (int i = 0; i < associatedParts.length; i++) {
out.write(associatedParts[i].getSource(resources, partList));
out.write("\n");
}
out.close();
}
catch (Exception e) {
e.printStackTrace();
}
}