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


Java Converter类代码示例

本文整理汇总了Java中com.vaadin.data.util.converter.Converter的典型用法代码示例。如果您正苦于以下问题:Java Converter类的具体用法?Java Converter怎么用?Java Converter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: convertToPresentation

import com.vaadin.data.util.converter.Converter; //导入依赖的package包/类
@Override
public Date convertToPresentation(LocalTime value, Class<? extends Date> targetType, Locale locale)
		throws com.vaadin.data.util.converter.Converter.ConversionException {
	if (value != null) {
		final Calendar calendar = Calendar.getInstance(locale);
		calendar.set(Calendar.YEAR, 0);
		calendar.set(Calendar.MONTH, 0);
		calendar.set(Calendar.DAY_OF_MONTH, 0);
		calendar.set(Calendar.MILLISECOND, 0);
		calendar.set(Calendar.HOUR_OF_DAY, value.getHour());
		calendar.set(Calendar.MINUTE, value.getMinute());
		calendar.set(Calendar.SECOND, value.getSecond());
		return calendar.getTime();
	}
	return null;
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:17,代码来源:DateToLocalTimeConverter.java

示例2: setValue

import com.vaadin.data.util.converter.Converter; //导入依赖的package包/类
@Override
public void setValue(Object newValue) throws ReadOnlyException, Converter.ConversionException {
    Class propertyType = propertyPath.getMetaProperty().getJavaType();
    if (Set.class.isAssignableFrom(propertyType)) {
        if (newValue == null) {
            newValue = new HashSet();
        } else {
            if (newValue instanceof Collection) {
                newValue = new HashSet<>((Collection<?>) newValue);
            } else {
                newValue = Collections.singleton(newValue);
            }
        }
    } else if (List.class.isAssignableFrom(propertyType)) {
        if (newValue == null) {
            newValue = new ArrayList();
        } else {
            if (newValue instanceof Collection) {
                newValue = new ArrayList<>((Collection<?>) newValue);
            } else {
                newValue = Collections.singletonList(newValue);
            }
        }
    }
    super.setValue(newValue);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:27,代码来源:WebTwinColumn.java

示例3: convertToPresentation

import com.vaadin.data.util.converter.Converter; //导入依赖的package包/类
@Override
public Object convertToPresentation(Datatype value,
		Class<? extends Object> targetType, Locale locale)
		throws Converter.ConversionException {
	if (value == null) {
		return null;
	}
	if (targetType.isInstance(String.class) ||
		targetType.getName().equals(String.class.getName())) {
		return value.getXacmlId();
	}
	if (targetType.isInstance(Identifier.class) ||
		targetType.getName().equals(Identifier.class.getName())) {
		return value.getIdentifer();
	}
	return value.getIdentifer();
}
 
开发者ID:apache,项目名称:incubator-openaz,代码行数:18,代码来源:DatatypeConverter.java

示例4: convertToPresentation

import com.vaadin.data.util.converter.Converter; //导入依赖的package包/类
@Override
public Object convertToPresentation(ConstraintType value,
		Class<? extends Object> targetType, Locale locale)
		throws Converter.ConversionException {
	if (logger.isTraceEnabled()) {
		logger.trace("convertToPresentation:" + value + " target " + targetType);
	}
	if (value == null) {
		return null;
	}
	if (targetType.isAssignableFrom(String.class)) {
		return value.getConstraintType();
	}
	if (targetType.isInstance(Integer.class)) {
		return value.getId();
	}
	return null;
}
 
开发者ID:apache,项目名称:incubator-openaz,代码行数:19,代码来源:ConstraintTypeConverter.java

示例5: convertToPresentation

import com.vaadin.data.util.converter.Converter; //导入依赖的package包/类
@Override
public String convertToPresentation(Enum availability,
        java.lang.Class<? extends String> targetType, Locale locale)
        throws Converter.ConversionException {
    String text = super.convertToPresentation(availability, targetType,
            locale);

    String color = "";
    if (availability == Availability.AVAILABLE) {
        color = "#2dd085";
    } else if (availability == Availability.COMING) {
        color = "#ffc66e";
    } else if (availability == Availability.DISCONTINUED) {
        color = "#f54993";
    }

    String iconCode = "<span class=\"v-icon\" style=\"font-family: "
            + FontAwesome.CIRCLE.getFontFamily() + ";color:" + color
            + "\">&#x"
            + Integer.toHexString(FontAwesome.CIRCLE.getCodepoint())
            + ";</span>";

    return iconCode + " " + text;
}
 
开发者ID:vaadin,项目名称:archetype-application-example,代码行数:25,代码来源:ProductGrid.java

示例6: FieldDescriptor

import com.vaadin.data.util.converter.Converter; //导入依赖的package包/类
/**
 * Constructor for setting values of the FieldDefinition.
 * @param id ID of the field.
 * @param labelKey Localization key of the field.
 * @param fieldClass Field editor component or null.
 * @param converter Field converter.
 * @param width Width of the field.
 * @param valueAlignment Value vertical alignment.
 * @param valueType Type of the field value.
 * @param defaultValue Default value for field.
 * @param readOnly true if field is readonly.
 * @param sortable true if field is sortable.
 * @param required true if field is required.
 */
public FieldDescriptor(final String id, final String labelKey, final Class<? extends Field> fieldClass,
        final Converter<?,?> converter, final int width,
        final HorizontalAlignment valueAlignment, final Class<?> valueType,
        final Object defaultValue, final boolean readOnly, final boolean sortable, final boolean required) {
    super();
    this.id = id;
    this.labelKey = labelKey;
    this.width = width;
    this.valueType = valueType;
    this.defaultValue = defaultValue;
    this.fieldClass = fieldClass;
    this.converter = converter;
    this.readOnly = readOnly;
    this.sortable = sortable;
    this.required = required;
    if (valueAlignment != null) {
        this.valueAlignment = valueAlignment;
    }
}
 
开发者ID:bubblecloud,项目名称:ilves,代码行数:34,代码来源:FieldDescriptor.java

示例7: convertToPresentation

import com.vaadin.data.util.converter.Converter; //导入依赖的package包/类
@Override
public Object convertToPresentation(Datatype value,
		Class<? extends Object> targetType, Locale locale)
		throws com.vaadin.data.util.converter.Converter.ConversionException {
	if (value == null) {
		return null;
	}
	if (targetType.isInstance(String.class) ||
		targetType.getName().equals(String.class.getName())) {
		return value.getXacmlId();
	}
	if (targetType.isInstance(Identifier.class) ||
		targetType.getName().equals(Identifier.class.getName())) {
		return value.getIdentifer();
	}
	return value.getIdentifer();
}
 
开发者ID:att,项目名称:XACML,代码行数:18,代码来源:DatatypeConverter.java

示例8: convertToPresentation

import com.vaadin.data.util.converter.Converter; //导入依赖的package包/类
@Override
public Object convertToPresentation(ConstraintType value,
		Class<? extends Object> targetType, Locale locale)
		throws com.vaadin.data.util.converter.Converter.ConversionException {
	if (logger.isTraceEnabled()) {
		logger.trace("convertToPresentation:" + value + " target " + targetType);
	}
	if (value == null) {
		return null;
	}
	if (targetType.isAssignableFrom(String.class)) {
		return value.getConstraintType();
	}
	if (targetType.isInstance(Integer.class)) {
		return value.getId();
	}
	return null;
}
 
开发者ID:att,项目名称:XACML,代码行数:19,代码来源:ConstraintTypeConverter.java

示例9: convertToModel

import com.vaadin.data.util.converter.Converter; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public BigDecimal convertToModel(String value, final Class<? extends BigDecimal> targetType, final Locale locale)
		throws com.vaadin.data.util.converter.Converter.ConversionException {
	if (value == null || value.isEmpty()) {
		return null;
	}

	// Remove leading and trailing white space
	value = value.trim();

	// Parse and detect errors. If the full string was not used, it is
	// an error.
	BigDecimal parsedValue = (BigDecimal) getFormat(locale).parse(value, new ParsePosition(0));
	if (parsedValue == null) {
		parsedValue = (BigDecimal) getLenientFormat(locale).parse(value, new ParsePosition(0));
	}
	if (parsedValue == null) {
		throw new ConversionException(MessageFormat.format(
				"Значение '{0}' не является допустимым числом", value));
	}

	return parsedValue;
}
 
开发者ID:ExtaSoft,项目名称:extacrm,代码行数:25,代码来源:StringToMoneyConverter.java

示例10: convertToModel

import com.vaadin.data.util.converter.Converter; //导入依赖的package包/类
@Override
public Age convertToModel(final Object value, final Class<? extends Age> targetType, final Locale locale)
		throws com.vaadin.data.util.converter.Converter.ConversionException
{
	Age result = null;

	AgeConverter.logger.debug("converToModel: value={} valueType: {} targetType: {}", value,
			value != null ? value.getClass() : "null", targetType);

	if (value instanceof Object || value instanceof String)
	{
		result = new Age((String) value);
	}

	AgeConverter.logger.debug("result: {}", result);
	return result;
}
 
开发者ID:bsutton,项目名称:scoutmaster,代码行数:18,代码来源:AgeConverter.java

示例11: convertToPresentation

import com.vaadin.data.util.converter.Converter; //导入依赖的package包/类
@Override
public Object convertToPresentation(final Age value, final Class<? extends Object> targetType, final Locale locale)
		throws com.vaadin.data.util.converter.Converter.ConversionException
{
	String result = "0";

	AgeConverter.logger.debug("convertToPresentation: value {} targetType: {}", value, targetType);
	if (value != null)
	{
		result = value.toString();
	}
	else
	{
		result = "";
	}
	AgeConverter.logger.debug("result: {}", result);
	return result;
}
 
开发者ID:bsutton,项目名称:scoutmaster,代码行数:19,代码来源:AgeConverter.java

示例12: convertToModel

import com.vaadin.data.util.converter.Converter; //导入依赖的package包/类
@Override
public Period convertToModel(final Object value, final Class<? extends Period> targetType, final Locale locale)
		throws com.vaadin.data.util.converter.Converter.ConversionException
{
	Period result = null;

	PeriodConverter.logger.debug("converToModel: value: {} valueType: {} targetType: {}", value,
			value != null ? value.getClass() : "null", targetType);

	if (value instanceof Object || value instanceof String)
	{
		result = new Period((String) value);
	}

	PeriodConverter.logger.debug("result: {}", result);
	return result;
}
 
开发者ID:bsutton,项目名称:scoutmaster,代码行数:18,代码来源:PeriodConverter.java

示例13: convertToPresentation

import com.vaadin.data.util.converter.Converter; //导入依赖的package包/类
@Override
public Object convertToPresentation(final Period value, final Class<? extends Object> targetType,
		final Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException
{
	String result = "0";

	PeriodConverter.logger.debug("convertToPresentation: value: {}  targetType: {}",
			value == null ? "null" : value, targetType);
	if (value != null)
	{
		result = value.toString();
	}
	else
	{
		result = "";
	}
	PeriodConverter.logger.debug("result: {}", result);
	return result;
}
 
开发者ID:bsutton,项目名称:scoutmaster,代码行数:20,代码来源:PeriodConverter.java

示例14: convertToModel

import com.vaadin.data.util.converter.Converter; //导入依赖的package包/类
@Override
public Phone convertToModel(final Object value, final Class<? extends Phone> targetType, final Locale locale)
		throws com.vaadin.data.util.converter.Converter.ConversionException
{
	Phone result = null;
	final PhoneDao daoPhone = new DaoFactory().getPhoneDao();

	PhoneConverter.logger.debug("converToModel: value: {} valueType: {} targetType: {}", value,
			value != null ? value.getClass() : "null", targetType);

	if (value instanceof Long)
	{
		PhoneConverter.logger.debug("Calling findById");
		result = daoPhone.findById((Long) value);
	}
	else if (value instanceof Object || value instanceof String)
	{
		result = new Phone((String) value);
	}

	PhoneConverter.logger.debug("result: {}", result);
	return result;
}
 
开发者ID:bsutton,项目名称:scoutmaster,代码行数:24,代码来源:PhoneConverter.java

示例15: convertToPresentation

import com.vaadin.data.util.converter.Converter; //导入依赖的package包/类
@Override
public Object convertToPresentation(final Phone value, final Class<? extends Object> targetType, final Locale locale)
		throws com.vaadin.data.util.converter.Converter.ConversionException
{
	String result = "0";

	PhoneConverter.logger.debug("convertToPresentation: value: {} targetType: {}", value, targetType);
	if (value != null)
	{
		result = value.getPhoneNo();
	}
	else
	{
		result = "";
	}
	PhoneConverter.logger.debug("result: {}", result);
	return result;
}
 
开发者ID:bsutton,项目名称:scoutmaster,代码行数:19,代码来源:PhoneConverter.java


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