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


Java IConverter类代码示例

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


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

示例1: getTeamNameAutoCompleteField

import org.apache.wicket.util.convert.IConverter; //导入依赖的package包/类
private AutoCompleteTextField<Team> getTeamNameAutoCompleteField() {
	AutoCompleteTextField<Team> field = new IndicatingAjaxAutoCompleteTextField<Team>("add.teamName", Model.of((Team) null),
			Team.class, getAutocompleteRenderer(), WebConstants.getDefaultAutoCompleteSettings()) {

				@Override
				protected Iterator<Team> getChoices(String input) {
					return getPotentialTeams(input);
				}

				@Override
				public <Team> IConverter<Team> getConverter(Class<Team> type) {
					return (IConverter<Team>) getAutocompleteConverter();
				}
			};
	field.setRequired(true);
	return field;
}
 
开发者ID:U-QASAR,项目名称:u-qasar.platform,代码行数:18,代码来源:UserEditPage.java

示例2: matches

import org.apache.wicket.util.convert.IConverter; //导入依赖的package包/类
/**
 *
 * @param count count (name + count) to check
 * @param converter optional converter to apply to value before comparison
 * @return true IFF the {@link Count#getCount() } is more than {@link #getMinimalOccurence()
 * } {@link Count#getName() } contains {@link #getName() } (case
 * insensitive)
 */
@Override
public boolean matches(Count count, IConverter<String> converter) {
    if (count.getCount() >= minimalOccurence) {
        if (namePattern == null) {
            // no pattern to compare to, always matches
            return true;
        } else {
            // convert value if converter is provided
            final String value;
            if (converter == null) {
                value = count.getName();
            } else {
                value = converter.convertToString(count.getName(), null);
            }
            return namePattern.matcher(value).find();
        }
    } else {
        // too few occurences, no match
        return false;
    }
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:30,代码来源:NameAndCountFieldValuesFilter.java

示例3: createConverter

import org.apache.wicket.util.convert.IConverter; //导入依赖的package包/类
private IConverter<Date> createConverter() {
	IConverter<Date> mainConverter = new PatternDateConverter(datePattern, getString(datePattern.getJavaPatternKey()));
	if (datePatternsToTryAfter.isEmpty() && datePatternsToTryBefore.isEmpty()) {
		return mainConverter;
	} else {
		ImmutableList.Builder<IConverter<Date>> preemptiveConverters = ImmutableList.builder();
		for (IDatePattern datePatternToTryBefore : datePatternsToTryBefore) {
			preemptiveConverters.add(new PatternDateConverter(datePatternToTryBefore, getString(datePatternToTryBefore.getJavaPatternKey())));
		}
		ImmutableList.Builder<IConverter<Date>> alternativeConverters = ImmutableList.builder();
		for (IDatePattern datePatternToTryAfter : datePatternsToTryAfter) {
			alternativeConverters.add(new PatternDateConverter(datePatternToTryAfter, getString(datePatternToTryAfter.getJavaPatternKey())));
		}
		return new CascadingConverter<>(mainConverter, preemptiveConverters.build(), alternativeConverters.build());
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:17,代码来源:DatePicker.java

示例4: getConverter

import org.apache.wicket.util.convert.IConverter; //导入依赖的package包/类
@Override
public <C> IConverter<C> getConverter(final Class<C> type) {
    final IConverter<C> converter = super.getConverter(type);
    if (converter instanceof AbstractDecimalConverter<?>) {
        final AbstractDecimalConverter<?> adc = (AbstractDecimalConverter<?>) converter;
        final ConcurrentHashMap<Locale, NumberFormat> numberFormats = Reflections.field("numberFormats")
                .ofType(ConcurrentHashMap.class)
                .in(adc)
                .get();
        for (final Locale l : Locale.getAvailableLocales()) {
            final DecimalFormat format = element.getFormat(l);
            format.setParseBigDecimal(true);
            numberFormats.put(l, format);
        }
    }
    return converter;
}
 
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:18,代码来源:ModelNumberTextField.java

示例5: getModelValue

import org.apache.wicket.util.convert.IConverter; //导入依赖的package包/类
@Override
protected String getModelValue()
{
	Number value = getModelObject();
	if (value == null)
	{
		return "";
	}
	else
	{
		IConverter<Number> converter = (IConverter<Number>) getConverter(value.getClass());
		if (converter != null) {
			return converter.convertToString(value, this.getLocale());
		} else {
			return Objects.stringValue(value);
		}
	}
}
 
开发者ID:Nocket,项目名称:nocket,代码行数:19,代码来源:DMDNumberTextField.java

示例6: populateItem

import org.apache.wicket.util.convert.IConverter; //导入依赖的package包/类
@Override
public void populateItem(Item<ICellPopulator<T>> item, String componentId, IModel<T> rowModel) {
    item.add(new Label(componentId, createLabelModel(rowModel)) {
        @Override
        public IConverter getConverter(Class type) {
            String columnName = column;
            if (genericDataTablePanel.getColumnConverter().containsKey(columnName)) {
                GenericDataTablePanel.Tupel t = (Tupel) genericDataTablePanel.getColumnConverter().get(columnName);
                if (type.isAssignableFrom(type) && t.two != null) {
                    return t.two;
                }
            }
            return super.getConverter(type);
        }
    });
}
 
开发者ID:Nocket,项目名称:nocket,代码行数:17,代码来源:GenericDataTablePanelPropertyColumn.java

示例7: generateLabelForChoice

import org.apache.wicket.util.convert.IConverter; //导入依赖的package包/类
/**
 * Generates the initial label that is displayed inside the button for the given choice.
 *
 * @param choice the choice being rendered
 * @return the choice label
 */
@SuppressWarnings("unchecked")
protected String generateLabelForChoice(T choice) {
    Object displayValue = getChoiceRenderer().getDisplayValue(choice);
    Class<?> objectClass = displayValue == null ? null : displayValue.getClass();

    String label = "";

    if (objectClass != null && objectClass != String.class) {
        IConverter converter = getConverter(objectClass);
        label = converter.convertToString(displayValue, getLocale());
    } else if (displayValue != null) {
        label = displayValue.toString();
    }

    return label;
}
 
开发者ID:flex-oss,项目名称:flex-ui,代码行数:23,代码来源:ButtonRadioChoice.java

示例8: createMinMaxNumberField

import org.apache.wicket.util.convert.IConverter; //导入依赖的package包/类
@SuppressWarnings("serial")
public static SingleTextFieldPanel createMinMaxNumberField(final String id, final IModel<Integer> model, final Integer minimum,
    final Integer maximum, final IConverter converter)
{
  final SingleTextFieldPanel panel = new SingleTextFieldPanel(id);
  final MinMaxNumberField<Integer> textField;
  if (converter != null) {
    textField = new MinMaxNumberField<Integer>("text", model, minimum, maximum) {
      /**
       * @see org.projectforge.web.wicket.components.MinMaxNumberField#getConverter(java.lang.Class)
       */
      @Override
      public <C> IConverter<C> getConverter(final Class<C> type)
      {
        return converter;
      }
    };
  } else {
    textField = new MinMaxNumberField<Integer>("text", model, minimum, maximum);
  }
  panel.setTextField(textField);
  return panel;
}
 
开发者ID:micromata,项目名称:projectforge-webapp,代码行数:24,代码来源:SingleTextFieldPanel.java

示例9: createValueLabel

import org.apache.wicket.util.convert.IConverter; //导入依赖的package包/类
protected Label createValueLabel(String id, Object value, final PivotField pivotField) {
	return new Label(id, Model.of((Serializable) value)) {
		
		private static final long serialVersionUID = 1L;

		@SuppressWarnings("unchecked")
		@Override
		public <C> IConverter<C> getConverter(Class<C> type) {
			IConverter<C> converter = (IConverter<C>) pivotField.getConverter();
			if (converter != null) {
				return converter;
			}
			
			return super.getConverter(type);
		}

	};
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:19,代码来源:PivotTable.java

示例10: toObject

import org.apache.wicket.util.convert.IConverter; //导入依赖的package包/类
/**
 * Utility method to convert string values to the corresponding objects.
 * 
 * @param clazz
 *            the type of the object we want to obtain.
 * @param value
 *            the string value we want to convert.
 * @return the object corresponding to the converted string value, or null
 *         if value parameter is null
 */
public static Object toObject(Class clazz, String value) throws IllegalArgumentException {
	if (value == null)
		return null;
	// we use the standard Wicket conversion mechanism to obtain the
	// converted value.
	try {
		IConverter converter = Application.get().getConverterLocator().getConverter(clazz);

		return converter.convertToObject(value, Session.get().getLocale());
	} catch (Exception e) {
		WebResponse response = (WebResponse) RequestCycle.get().getResponse();

		response.setStatus(400);
		response.write("Could not find a suitable constructor for value '" + value
				+ "' of type '" + clazz + "'");

		return null;
	}
}
 
开发者ID:bitstorm,项目名称:Wicket-rest-annotations,代码行数:30,代码来源:AbstractRestResource.java

示例11: initLayout

import org.apache.wicket.util.convert.IConverter; //导入依赖的package包/类
private void initLayout() {
    IModel data = new PropertyModel(getModel(), SearchValue.F_VALUE);

    final DisplayableRenderer renderer = new DisplayableRenderer(choices);
    final DropDownChoice input = new DropDownChoice(ID_COMBO_INPUT, data, choices, renderer) {

        @Override
        public IConverter getConverter(Class type) {
            return renderer;
        }
    };
    input.setNullValid(true);
    input.setOutputMarkupId(true);
    add(input);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:16,代码来源:ComboPopupPanel.java

示例12: postprocessValue

import org.apache.wicket.util.convert.IConverter; //导入依赖的package包/类
private String postprocessValue(String value) {
    if (value != null) {
        final IConverter<String> converter = getFieldValueConverter();
        if (converter != null) {
            return converter.convertToString(value, null);
        }
    }
    return value;
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:10,代码来源:SolrFieldStringModel.java

示例13: getObject

import org.apache.wicket.util.convert.IConverter; //导入依赖的package包/类
@Override
public String getObject() {
    final IConverter<String> converter = VloWicketApplication.get().getFieldValueConverterProvider().getConverter(field);
    if (converter == null) {
        logger.warn("No converter for field {}", field);
        return valueModel.getObject();
    } else {
        return converter.convertToString(valueModel.getObject(), Session.get().getLocale());
    }
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:11,代码来源:ConvertedFieldValueModel.java

示例14: filter

import org.apache.wicket.util.convert.IConverter; //导入依赖的package包/类
private Iterable<FacetField.Count> filter(List<FacetField.Count> list) {
    if (hasFilter()) {
        final IConverter<String> converter = fieldValueConverterProvider.getConverter(model.getObject().getName());
        return Iterables.filter(list, new Predicate<FacetField.Count>() {
            @Override
            public boolean apply(Count input) {
                return getFilterModel().getObject().matches(input, converter);
            }
        });
    } else {
        return list;
    }
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:14,代码来源:FacetFieldValuesProvider.java

示例15: getConverter

import org.apache.wicket.util.convert.IConverter; //导入依赖的package包/类
@Override
public IConverter<String> getConverter(String fieldName) {
    switch (fieldName) {
        case FacetConstants.FIELD_LANGUAGE_CODE:
            return languageCodeConverter;
        case FacetConstants.FIELD_DESCRIPTION:
            return descriptionConverter;
        case FacetConstants.FIELD_AVAILABILITY:
            return availabilityConverter;
        case FacetConstants.FIELD_LICENSE:
            return licenseConverter;
        default:
            return null;
    }
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:16,代码来源:FieldValueConverterProviderImpl.java


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