当前位置: 首页>>代码示例>>Java>>正文


Java PropertyEditor.setAsText方法代码示例

本文整理汇总了Java中java.beans.PropertyEditor.setAsText方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyEditor.setAsText方法的具体用法?Java PropertyEditor.setAsText怎么用?Java PropertyEditor.setAsText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.beans.PropertyEditor的用法示例。


在下文中一共展示了PropertyEditor.setAsText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testTheEditorHonoursSeparatorAttribute

import java.beans.PropertyEditor; //导入方法依赖的package包/类
public void testTheEditorHonoursSeparatorAttribute () throws Exception {
    NP np = new NP ();
    np.setValue ("item.separator", "-");
    
    PropertyEditor p = np.getPropertyEditor ();
    assertNotNull ("There is some editor", p);
    assertEquals ("It is StringArrayEditor", StringArrayEditor.class, p.getClass ());
    ((StringArrayEditor)p).readEnv (np);
    
    p.setAsText ("A-B");
    
    String[] value = (String[])p.getValue ();
    
    assertNotNull ("Values is there", value);
    if (value.length != 2 || !"A".equals (value[0]) || !"B".equals(value[1])) {
        fail ("Unexpected arrays: " + Arrays.asList (value));
    }
    
    p.setValue (new String[] { "X", "Y" });
    String t = np.getPropertyEditor ().getAsText ();
    if (!"X- Y".equals (t)) {
        fail ("Wrong text: " + t);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:StringArrayEditorTest.java

示例2: getValueFromBeanInfoPropertyEditor

import java.beans.PropertyEditor; //导入方法依赖的package包/类
public static Object getValueFromBeanInfoPropertyEditor(
                       Class<?> attrClass, String attrName, String attrValue,
                       Class<?> propertyEditorClass) 
    throws JasperException 
{
    try {
        PropertyEditor pe =
            (PropertyEditor)propertyEditorClass.newInstance();
        pe.setAsText(attrValue);
        return pe.getValue();
    } catch (Exception ex) {
        throw new JasperException(
            Localizer.getMessage("jsp.error.beans.property.conversion",
                                 attrValue, attrClass.getName(), attrName,
                                 ex.getMessage()));
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:18,代码来源:JspRuntimeLibrary.java

示例3: getValueFromPropertyEditorManager

import java.beans.PropertyEditor; //导入方法依赖的package包/类
public static Object getValueFromPropertyEditorManager(Class<?> attrClass, String attrName, String attrValue)
		throws JasperException {
	try {
		PropertyEditor propEditor = PropertyEditorManager.findEditor(attrClass);
		if (propEditor != null) {
			propEditor.setAsText(attrValue);
			return propEditor.getValue();
		} else {
			throw new IllegalArgumentException(
					Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
		}
	} catch (IllegalArgumentException ex) {
		throw new JasperException(Localizer.getMessage("jsp.error.beans.property.conversion", attrValue,
				attrClass.getName(), attrName, ex.getMessage()));
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:17,代码来源:JspRuntimeLibrary.java

示例4: getValueFromBeanInfoPropertyEditor

import java.beans.PropertyEditor; //导入方法依赖的package包/类
public static Object getValueFromBeanInfoPropertyEditor(
	           Class attrClass, String attrName, String attrValue,
		   Class propertyEditorClass) 
throws JasperException 
   {
try {
    PropertyEditor pe = (PropertyEditor)propertyEditorClass.newInstance();
    pe.setAsText(attrValue);
    return pe.getValue();
} catch (Exception ex) {
    throw new JasperException(
               Localizer.getMessage("jsp.error.beans.property.conversion",
			     attrValue, attrClass.getName(), attrName,
			     ex.getMessage()));
}
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:JspRuntimeLibrary.java

示例5: getValueFromPropertyEditorManager

import java.beans.PropertyEditor; //导入方法依赖的package包/类
public static Object getValueFromPropertyEditorManager(
             Class attrClass, String attrName, String attrValue) 
throws JasperException 
   {
try {
    PropertyEditor propEditor = 
	PropertyEditorManager.findEditor(attrClass);
    if (propEditor != null) {
	propEditor.setAsText(attrValue);
	return propEditor.getValue();
    } else {
	throw new IllegalArgumentException(
                   Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
    }
} catch (IllegalArgumentException ex) {
    throw new JasperException(
               Localizer.getMessage("jsp.error.beans.property.conversion",
			     attrValue, attrClass.getName(), attrName,
			     ex.getMessage()));
}
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:JspRuntimeLibrary.java

示例6: getValueFromPropertyEditorManager

import java.beans.PropertyEditor; //导入方法依赖的package包/类
public static Object getValueFromPropertyEditorManager(
                 Class<?> attrClass, String attrName, String attrValue) 
    throws JasperException 
{
    try {
        PropertyEditor propEditor = 
            PropertyEditorManager.findEditor(attrClass);
        if (propEditor != null) {
            propEditor.setAsText(attrValue);
            return propEditor.getValue();
        } else {
            throw new IllegalArgumentException(
                Localizer.getMessage("jsp.error.beans.propertyeditor.notregistered"));
        }
    } catch (IllegalArgumentException ex) {
        throw new JasperException(
            Localizer.getMessage("jsp.error.beans.property.conversion",
                                 attrValue, attrClass.getName(), attrName,
                                 ex.getMessage()));
    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:22,代码来源:JspRuntimeLibrary.java

示例7: testEnumPropEd

import java.beans.PropertyEditor; //导入方法依赖的package包/类
public void testEnumPropEd() throws Exception {
    EProp prop = new EProp();
    PropertyEditor ed = PropUtils.getPropertyEditor(prop);
    assertEquals( EnumPropertyEditor.class, ed.getClass());
    assertFalse(ed.supportsCustomEditor());
    assertFalse(ed.isPaintable());
    String[] tags = ed.getTags();
    assertNotNull(tags);
    assertEquals("[CHOCOLATE, VANILLA, STRAWBERRY]", Arrays.toString(tags));
    assertEquals(E.VANILLA, ed.getValue());
    assertEquals("VANILLA", ed.getAsText());
    ed.setAsText("STRAWBERRY");
    assertEquals(E.STRAWBERRY, ed.getValue());
    assertEquals(E.class.getName().replace('$', '.') + ".STRAWBERRY", ed.getJavaInitializationString());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:EnumPropertyEditorTest.java

示例8: testNulls

import java.beans.PropertyEditor; //导入方法依赖的package包/类
public void testNulls() throws Exception {
    EProp prop = new EProp();
    PropertyEditor ed = PropUtils.getPropertyEditor(prop);
    assertEquals( EnumPropertyEditor.class, ed.getClass());
    ed.setAsText("");
    assertEquals(null, ed.getValue());
    assertEquals("", ed.getAsText());
    assertEquals("null", ed.getJavaInitializationString());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:EnumPropertyEditorTest.java

示例9: testLocalizedNames

import java.beans.PropertyEditor; //导入方法依赖的package包/类
public void testLocalizedNames() throws Exception {
    ABProp prop = new ABProp();
    PropertyEditor ed = PropUtils.getPropertyEditor(prop);
    assertEquals( EnumPropertyEditor.class, ed.getClass());
    ed.setAsText("");
    assertEquals("myA", ed.getTags()[0]);
    assertEquals("myB", ed.getTags()[1]);
    assertEquals(null, ed.getValue());
    ed.setAsText("myB");
    assertEquals("myB", ed.getAsText());
    assertEquals(BetterToString.class.getName().replace('$', '.') + ".B", ed.getJavaInitializationString());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:EnumPropertyEditorTest.java

示例10: loadFromProperties

import java.beans.PropertyEditor; //导入方法依赖的package包/类
/**
 * Initializes folder from the properties object.
 * @param props
 */
protected void loadFromProperties(Properties props, String prefix) throws IntrospectionException {
    Enumeration<String> keys = (Enumeration<String>) props.propertyNames();
    prefix = prefix + getName() + ".";
    // load properties in this folder
    while (keys.hasMoreElements()) {
        String key = keys.nextElement();
        if (key.startsWith(prefix)) {
            String posfix = key.replaceFirst(prefix, "");
            if (!posfix.contains(".")) {
                // the posfix represents a name of a property
                Property prop = getProperty(posfix);
                if (prop == null) {
                	continue;
                }
                // exploit the JavaBeans property editors to convert the values from text
                PropertyEditor editor = PropertyEditorManager.findEditor(prop.getType());
                if (editor == null) {
                	continue;
                }
                editor.setAsText(props.getProperty(key));
                prop.setValue(editor.getValue());
             
            }
        }
        ;
    }

    // load all subfolders
    for (Folder folder : getFolders()) {
        folder.loadFromProperties(props, prefix);
    }

}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:38,代码来源:Folder.java

示例11: parseImp

import java.beans.PropertyEditor; //导入方法依赖的package包/类
@Override
public Object parseImp(String input, ParserHelper helper) {
    PropertyEditor editor = findEditor(helper.getRawTargetClass());
    if (editor == null) {
        return TRY_NEXT;
    }
    editor.setAsText(input);
    return editor.getValue();
}
 
开发者ID:Yoio,项目名称:X4J,代码行数:10,代码来源:DynamicParsers.java

示例12: writeAttribute

import java.beans.PropertyEditor; //导入方法依赖的package包/类
protected void writeAttribute ( final PropertyDescriptor pd, final Variant value ) throws Exception
{
    final Method m = pd.getWriteMethod ();
    if ( m == null )
    {
        throw new RuntimeException ( "Failed to write since write method cannot be found" );
    }

    final Object target = getTarget ();

    if ( target == null )
    {
        throw new RuntimeException ( "No current target attached" );
    }

    final Class<?> targetType = pd.getPropertyType ();
    final Object o = convertWriteType ( targetType, value );

    if ( o != null )
    {
        // try the direct approach
        m.invoke ( target, o );
    }
    else
    {
        // try a "by string" approach
        final PropertyEditor pe = PropertyEditorManager.findEditor ( targetType );
        pe.setAsText ( value.asString () );
    }

}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:32,代码来源:AbstractObjectExporter.java

示例13: getValueFromBeanInfoPropertyEditor

import java.beans.PropertyEditor; //导入方法依赖的package包/类
public static Object getValueFromBeanInfoPropertyEditor(Class<?> attrClass, String attrName, String attrValue,
		Class<?> propertyEditorClass) throws JasperException {
	try {
		PropertyEditor pe = (PropertyEditor) propertyEditorClass.newInstance();
		pe.setAsText(attrValue);
		return pe.getValue();
	} catch (Exception ex) {
		throw new JasperException(Localizer.getMessage("jsp.error.beans.property.conversion", attrValue,
				attrClass.getName(), attrName, ex.getMessage()));
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:12,代码来源:JspRuntimeLibrary.java

示例14: doConvertTextValue

import java.beans.PropertyEditor; //导入方法依赖的package包/类
/**
 * Convert the given text value using the given property editor.
 * @param oldValue the previous value, if available (may be {@code null})
 * @param newTextValue the proposed text value
 * @param editor the PropertyEditor to use
 * @return the converted value
 */
private Object doConvertTextValue(Object oldValue, String newTextValue, PropertyEditor editor) {
	try {
		editor.setValue(oldValue);
	}
	catch (Exception ex) {
		if (logger.isDebugEnabled()) {
			logger.debug("PropertyEditor [" + editor.getClass().getName() + "] does not support setValue call", ex);
		}
		// Swallow and proceed.
	}
	editor.setAsText(newTextValue);
	return editor.getValue();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:TypeConverterDelegate.java

示例15: setAsText

import java.beans.PropertyEditor; //导入方法依赖的package包/类
public Object setAsText(final String str) {
    final PropertyEditor editor = fetchFromPool();
    try {
        editor.setAsText(str);
        return editor.getValue();
    } finally {
        pool.putInPool(editor);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:ThreadSafePropertyEditor.java


注:本文中的java.beans.PropertyEditor.setAsText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。