本文整理汇总了Java中java.beans.PropertyEditorManager.setEditorSearchPath方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyEditorManager.setEditorSearchPath方法的具体用法?Java PropertyEditorManager.setEditorSearchPath怎么用?Java PropertyEditorManager.setEditorSearchPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.beans.PropertyEditorManager
的用法示例。
在下文中一共展示了PropertyEditorManager.setEditorSearchPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import java.beans.PropertyEditorManager; //导入方法依赖的package包/类
private static void test(String[] path) {
try {
Beans.setDesignTime(true);
Beans.setGuiAvailable(true);
Introspector.setBeanInfoSearchPath(path);
PropertyEditorManager.setEditorSearchPath(path);
} catch (SecurityException exception) {
throw new Error("unexpected security exception", exception);
}
}
示例2: testFindEditorAccordingPath_1
import java.beans.PropertyEditorManager; //导入方法依赖的package包/类
public void testFindEditorAccordingPath_1() throws Exception {
// Regression Harmony-1205
String newPath[] = new String[origPath.length + 1];
newPath[0] = "org.apache.harmony.beans.tests.support";
for (int i = 0; i < origPath.length; i++) {
newPath[i + 1] = origPath[i];
}
PropertyEditorManager.setEditorSearchPath(newPath);
PropertyEditor editor = PropertyEditorManager.findEditor(Class
.forName("java.lang.String"));
assertEquals(org.apache.harmony.beans.tests.support.StringEditor.class,
editor.getClass());
}
示例3: testFindEditorAccordingPath_2
import java.beans.PropertyEditorManager; //导入方法依赖的package包/类
public void testFindEditorAccordingPath_2() throws Exception {
// Regression Harmony-1205
String newPath[] = new String[origPath.length + 1];
newPath[origPath.length] = "org.apache.harmony.beans.tests.support";
for (int i = 0; i < origPath.length; i++) {
newPath[i] = origPath[i];
}
PropertyEditorManager.setEditorSearchPath(newPath);
PropertyEditor editor = PropertyEditorManager.findEditor(Class
.forName("java.lang.String"));
assertEquals(org.apache.harmony.beans.editors.StringEditor.class,
editor.getClass());
}
示例4: installCorePropertyEditors
import java.beans.PropertyEditorManager; //导入方法依赖的package包/类
protected static final void installCorePropertyEditors() {
String[] syspesp = PropertyEditorManager.getEditorSearchPath();
String[] nbpesp = new String[] {
"org.netbeans.beaninfo.editors", // NOI18N
"org.openide.explorer.propertysheet.editors", // NOI18N
};
String[] allpesp = new String[syspesp.length + nbpesp.length];
System.arraycopy(nbpesp, 0, allpesp, 0, nbpesp.length);
System.arraycopy(syspesp, 0, allpesp, nbpesp.length, syspesp.length);
PropertyEditorManager.setEditorSearchPath(allpesp);
}
示例5: main
import java.beans.PropertyEditorManager; //导入方法依赖的package包/类
public static void main(String[] args) {
String[] oldPath = PropertyEditorManager.getEditorSearchPath();
String[] newPath = {"aaa.bbb", "aaa.ccc",};
PropertyEditorManager.setEditorSearchPath(newPath);
if (null != PropertyEditorManager.findEditor(Test4968709.class))
throw new Error("found unexpected editor");
PropertyEditorManager.setEditorSearchPath(oldPath);
if (null == PropertyEditorManager.findEditor(Double.TYPE))
throw new Error("expected editor is not found");
}
示例6: testGetEditorSearchPath
import java.beans.PropertyEditorManager; //导入方法依赖的package包/类
public void testGetEditorSearchPath() {
String[] original = PropertyEditorManager.getEditorSearchPath();
String[] path = new String[] { "java.beans",
"org.apache.harmony.beans.tests.java.beans.editor", "", };
PropertyEditorManager.setEditorSearchPath(path);
String[] newPath = PropertyEditorManager.getEditorSearchPath();
assertTrue(Arrays.equals(path, newPath));
PropertyEditorManager.setEditorSearchPath(original);
}
示例7: testSetEditorSearchPath_nullpath
import java.beans.PropertyEditorManager; //导入方法依赖的package包/类
public void testSetEditorSearchPath_nullpath() {
String[] original = PropertyEditorManager.getEditorSearchPath();
PropertyEditorManager.setEditorSearchPath(new String[] { null });
assertEquals(1, PropertyEditorManager.getEditorSearchPath().length);
assertNull(PropertyEditorManager.getEditorSearchPath()[0]);
assertNull(PropertyEditorManager.findEditor(PropertyEditorManagerTest.class));
PropertyEditorManager.setEditorSearchPath(original);
}
示例8: testFindEditorByDefaultLocation
import java.beans.PropertyEditorManager; //导入方法依赖的package包/类
/**
* The test checks the method findEditor() for editors on search path
*/
public void testFindEditorByDefaultLocation() {
PropertyEditorManager
.setEditorSearchPath(new String[] { "org.apache.harmony.beans.tests.java.beans.editors" });
PropertyEditor pe = PropertyEditorManager
.findEditor(AnotherSampleProperty.class);
assertNotNull("No property editor found", pe);
assertTrue(pe instanceof AnotherSamplePropertyEditor);
}
示例9: testGetSetEditorPath
import java.beans.PropertyEditorManager; //导入方法依赖的package包/类
public void testGetSetEditorPath() throws Exception{
String[] s = new String[]{"path1", "path2"};
PropertyEditorManager.setEditorSearchPath(s);
s[1] = "path3";
String[] s2 = PropertyEditorManager.getEditorSearchPath();
assertFalse(s==s2);
assertEquals("path1", s2[0]);
}
示例10: testFindEditorAccordingPath_3
import java.beans.PropertyEditorManager; //导入方法依赖的package包/类
public void testFindEditorAccordingPath_3() throws Exception {
// Regression Harmony-5477
class TestClassLoader extends ClassLoader {
protected Class<?> findClass(String name) throws ClassNotFoundException {
if (!MOCK_TEST_CLASS_EDITOR.equals(name)) {
throw new ClassNotFoundException(name);
}
try {
byte[] buf = new byte[1024];
InputStream in = getResourceAsStream(MOCK_TEST_CLASS_EDITOR_FILE);
int sz = 0;
int read;
while ((read = in.read(buf, sz, buf.length - sz)) >= 0) {
sz += read;
}
return defineClass(MOCK_TEST_CLASS_EDITOR, buf, 0, sz);
} catch (IOException e) {
throw (ClassNotFoundException) new ClassNotFoundException(
e.getMessage()).initCause(e);
}
}
}
PropertyEditorManager.setEditorSearchPath(new String[] { "testPackage" });
ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(new TestClassLoader());
PropertyEditor editor = PropertyEditorManager.findEditor(TestClass.class);
assertEquals(MOCK_TEST_CLASS_EDITOR, editor.getClass().getName());
} finally {
Thread.currentThread().setContextClassLoader(oldLoader);
}
}
示例11: testStringEditor
import java.beans.PropertyEditorManager; //导入方法依赖的package包/类
public void testStringEditor() throws Exception {
// Regression Harmony-1199
PropertyEditorManager.setEditorSearchPath(origPath);
PropertyEditor editor = PropertyEditorManager.findEditor(Class
.forName("java.lang.String"));
String text = "A sample string";
editor.setAsText(text);
assertEquals(text, editor.getAsText());
}
示例12: registerPropertyEditors
import java.beans.PropertyEditorManager; //导入方法依赖的package包/类
public static synchronized void registerPropertyEditors() {
if (clsReg == null) {
clsReg = new AbstractRegistrator(PEClassRegistration.class) {
@Override
void register() {
ClassLoader clsLoader = findClsLoader();
for (Iterator it = lookupResult.allInstances().iterator(); it.hasNext();) {
PEClassRegistration clsReg = (PEClassRegistration) it.next();
for (String type : clsReg.targetTypes) {
try {
Class<?> cls = getClassFromCanonicalName(type);
Class<?> editorCls = Class.forName(clsReg.editorClass, true, clsLoader);
PropertyEditorManager.registerEditor(cls, editorCls);
} catch (ClassNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
}
}
}
@Override
void init() {
}
};
} else {
clsReg.register();
}
if (pkgReg == null) {
pkgReg = new AbstractRegistrator(PEPackageRegistration.class) {
@Override
void register() {
Set<String> newPath = new LinkedHashSet<String> ();
for (Iterator it = lookupResult.allInstances().iterator(); it.hasNext();) {
PEPackageRegistration pkgReg = (PEPackageRegistration) it.next();
newPath.add(pkgReg.pkg);
}
newPath.addAll(originalPath);
PropertyEditorManager.setEditorSearchPath(newPath.toArray(new String[newPath.size()]));
}
@Override
void init() {
if (originalPath == null) {
originalPath = Arrays.asList(PropertyEditorManager.getEditorSearchPath());
}
}
};
} else {
pkgReg.register();
}
if (beanInfoReg == null) {
beanInfoReg = new AbstractRegistrator(BeanInfoRegistration.class) {
@Override
void register() {
Set<String> newPath = new LinkedHashSet<String> ();
for (Iterator it = lookupResult.allInstances().iterator(); it.hasNext();) {
BeanInfoRegistration biReg = (BeanInfoRegistration) it.next();
newPath.add(biReg.searchPath);
}
newPath.addAll(originalBeanInfoSearchPath);
Introspector.setBeanInfoSearchPath(newPath.toArray(new String[newPath.size()]));
}
@Override
void init() {
if (originalBeanInfoSearchPath == null) {
originalBeanInfoSearchPath = Arrays.asList(Introspector.getBeanInfoSearchPath());
}
}
};
} else {
beanInfoReg.register();
}
}
示例13: run
import java.beans.PropertyEditorManager; //导入方法依赖的package包/类
public void run() {
PropertyEditorManager.registerEditor(ThirdBean.class, ThirdBeanEditor.class);
test(FirstBean.class, FirstBeanEditor.class);
test(SecondBean.class, null);
test(ThirdBean.class, ThirdBeanEditor.class);
// test editors for default primitive types
test(Byte.TYPE, ByteEditor.class);
test(Short.TYPE, ShortEditor.class);
test(Integer.TYPE, IntegerEditor.class);
test(Long.TYPE, LongEditor.class);
test(Boolean.TYPE, BooleanEditor.class);
test(Float.TYPE, FloatEditor.class);
test(Double.TYPE, DoubleEditor.class);
// test editors for default object types
test(Byte.class, ByteEditor.class);
test(Short.class, ShortEditor.class);
test(Integer.class, IntegerEditor.class);
test(Long.class, LongEditor.class);
test(Boolean.class, BooleanEditor.class);
test(Float.class, FloatEditor.class);
test(Double.class, DoubleEditor.class);
test(String.class, StringEditor.class);
test(Color.class, ColorEditor.class);
test(Font.class, FontEditor.class);
test(Enumeration.class, EnumEditor.class);
PropertyEditorManager.registerEditor(ThirdBean.class, null);
PropertyEditorManager.setEditorSearchPath(SEARCH_PATH);
test(FirstBean.class, FirstBeanEditor.class);
test(SecondBean.class, SecondBeanEditor.class);
test(ThirdBean.class, ThirdBeanEditor.class);
// test editors for default primitive types
test(Byte.TYPE, ByteEditor.class);
test(Short.TYPE, ShortEditor.class);
test(Integer.TYPE, IntegerEditor.class);
test(Long.TYPE, LongEditor.class);
test(Boolean.TYPE, BooleanEditor.class);
test(Float.TYPE, FloatEditor.class);
test(Double.TYPE, DoubleEditor.class);
// test editors for default object types
test(Byte.class, null);
test(Short.class, null);
test(Integer.class, null);
test(Long.class, null);
test(Boolean.class, null);
test(Float.class, null);
test(Double.class, null);
test(String.class, null);
test(Color.class, null);
test(Font.class, null);
test(Enumeration.class, EnumEditor.class);
}
示例14: run
import java.beans.PropertyEditorManager; //导入方法依赖的package包/类
public void run() {
if (this.passed) {
SunToolkit.createNewAppContext();
}
PropertyEditorManager.registerEditor(ThirdBean.class, ThirdBeanEditor.class);
test(FirstBean.class, FirstBeanEditor.class);
test(SecondBean.class, null);
test(ThirdBean.class, ThirdBeanEditor.class);
// test editors for default primitive types
test(Byte.TYPE, ByteEditor.class);
test(Short.TYPE, ShortEditor.class);
test(Integer.TYPE, IntegerEditor.class);
test(Long.TYPE, LongEditor.class);
test(Boolean.TYPE, BooleanEditor.class);
test(Float.TYPE, FloatEditor.class);
test(Double.TYPE, DoubleEditor.class);
// test editors for default object types
test(Byte.class, ByteEditor.class);
test(Short.class, ShortEditor.class);
test(Integer.class, IntegerEditor.class);
test(Long.class, LongEditor.class);
test(Boolean.class, BooleanEditor.class);
test(Float.class, FloatEditor.class);
test(Double.class, DoubleEditor.class);
test(String.class, StringEditor.class);
test(Color.class, ColorEditor.class);
test(Font.class, FontEditor.class);
test(Enumeration.class, EnumEditor.class);
PropertyEditorManager.registerEditor(ThirdBean.class, null);
PropertyEditorManager.setEditorSearchPath(SEARCH_PATH);
test(FirstBean.class, FirstBeanEditor.class);
test(SecondBean.class, SecondBeanEditor.class);
test(ThirdBean.class, ThirdBeanEditor.class);
// test editors for default primitive types
test(Byte.TYPE, ByteEditor.class);
test(Short.TYPE, ShortEditor.class);
test(Integer.TYPE, IntegerEditor.class);
test(Long.TYPE, LongEditor.class);
test(Boolean.TYPE, BooleanEditor.class);
test(Float.TYPE, FloatEditor.class);
test(Double.TYPE, DoubleEditor.class);
// test editors for default object types
test(Byte.class, null);
test(Short.class, null);
test(Integer.class, null);
test(Long.class, null);
test(Boolean.class, null);
test(Float.class, null);
test(Double.class, null);
test(String.class, null);
test(Color.class, null);
test(Font.class, null);
test(Enumeration.class, EnumEditor.class);
this.passed = true;
}
示例15: tearDown
import java.beans.PropertyEditorManager; //导入方法依赖的package包/类
public void tearDown(){
PropertyEditorManager.setEditorSearchPath(defaultSearchPath);
}