PropertyEditorManager

PropertyEditorManager (속성 편집기 관리자)

주어진 타입 이름에 대한 속성 편집기를 찾는 데 사용할 수 있는 클래스예요. 이 속성 편집기는 주어진 객체를 편집하기 위해 java.beans.PropertyEditor 인터페이스를 지원해야 해요.

출처: Java API Reference

본문

PropertyEditorManager는 주어진 타입에 대한 편집기를 찾기 위해 세 가지 기법을 사용해요. 첫째, 특정 타입에 대해 편집기를 명시적으로 등록할 수 있는 registerEditor 메서드를 제공해요. 둘째, 주어진 타입의 패키지 한정 전체 클래스 이름에 "Editor"를 붙여 적합한 클래스를 찾으려 시도해요(예: foo.bah.FozEditor). 마지막으로 편집기 검색 경로의 각 패키지에서 타입 이름에 "Editor"를 붙인 클래스를 찾아요.

주요 메서드는 다음과 같아요.

public PropertyEditorManager()

public static void registerEditor(Class<?> targetType, Class<?> editorClass)
public static PropertyEditor findEditor(Class<?> targetType)
public static String[] getEditorSearchPath()
public static void setEditorSearchPath(String[] path)
  • registerEditor(targetType, editorClass) — 특정 타입에 대한 편집기 클래스를 등록해요.
  • findEditor(targetType) — 주어진 타입에 대한 PropertyEditor를 찾아 반환해요. 찾지 못하면 null을 반환해요.
  • getEditorSearchPath() / setEditorSearchPath(path) — 편집기 클래스를 검색할 패키지 경로를 얻거나 설정해요.

빈 편집 도구가 속성 값을 편집할 올바른 편집기를 자동으로 찾는 데 사용돼요.

더 알아보기 (Learn more)

Java 공식 API