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


Java CustomBooleanEditor类代码示例

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


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

示例1: initBinder

import org.springframework.beans.propertyeditors.CustomBooleanEditor; //导入依赖的package包/类
@InitBinder
public void initBinder(WebDataBinder binder) {
	binder.registerCustomEditor(
			Long.class,
			new CustomNumberEditor(Long.class, true));
	binder.registerCustomEditor(
			Double.class,
			new CustomNumberEditor(Double.class, true));
	binder.registerCustomEditor(
			BigDecimal.class,
			new CustomNumberEditor(
					BigDecimal.class,
					new DecimalFormat("#,##0.00"),
					true));
	binder.registerCustomEditor(
			Boolean.class,
			new CustomBooleanEditor(true));
	binder.registerCustomEditor(
			Date.class,
			new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
	binder.registerCustomEditor(
			Object.class,
			new ObjectTypeEditorHelper());
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:25,代码来源:TascaTramitacioController.java

示例2: getValueAsText

import org.springframework.beans.propertyeditors.CustomBooleanEditor; //导入依赖的package包/类
@Override
   public String getValueAsText(Object value) {
if (value == null) {
    return "";
}
if (value.getClass().isArray()) {
    Object[] arr = ((Object[]) value);
    if (arr.length == 0) {
	return "";
    }
    // Este caso se produce cuando intentamos obtener un objeto primitivo (String, Long...)
    // a partir de la segunda página en base de datos Oracle (arr[1] es numrow)
    value = arr[0];
}
String result;
if (clazz.isAssignableFrom(Boolean.class) && value != null) {
    CustomBooleanEditor editor = getBooleanEditor();
    editor.setAsText(String.valueOf(value));
    result = editor.getAsText();
} else {
    result = String.valueOf(value);
}

return result;
   }
 
开发者ID:iaunzu,项目名称:strqlbuilder,代码行数:26,代码来源:DefaultPojoFactory.java

示例3: initBinder

import org.springframework.beans.propertyeditors.CustomBooleanEditor; //导入依赖的package包/类
@InitBinder
public void initBinder(WebDataBinder binder) {
	binder.setAutoGrowNestedPaths(false);
	binder.registerCustomEditor(
			Long.class,
			new CustomNumberEditor(Long.class, true));
	binder.registerCustomEditor(
			Double.class,
			new CustomNumberEditor(Double.class, true));
	binder.registerCustomEditor(
			BigDecimal.class,
			new CustomNumberEditor(
					BigDecimal.class,
					new DecimalFormat("#,##0.00"),
					true));
	binder.registerCustomEditor(
			Boolean.class,
			new CustomBooleanEditor(true));
	binder.registerCustomEditor(
			Date.class,
			new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
	binder.registerCustomEditor(
			Object.class,
			new ObjectTypeEditorHelper());
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:26,代码来源:ExpedientConsultaInformeController.java

示例4: initBinder

import org.springframework.beans.propertyeditors.CustomBooleanEditor; //导入依赖的package包/类
@InitBinder
public void initBinder(WebDataBinder binder) {
	binder.registerCustomEditor(
			byte[].class,
			new ByteArrayMultipartFileEditor());
	binder.registerCustomEditor(
			Date.class,
			new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
	binder.registerCustomEditor(
			Long.class,
			new CustomNumberEditor(Long.class, true));
	binder.registerCustomEditor(
			Double.class,
			new CustomNumberEditor(Double.class, true));
	binder.registerCustomEditor(
			BigDecimal.class,
			new CustomNumberEditor(
					BigDecimal.class,
					new DecimalFormat("#,##0.00"),
					true));
	binder.registerCustomEditor(
			Boolean.class,
			new CustomBooleanEditor(false));
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:25,代码来源:ExpedientMassivaController.java

示例5: initBinder

import org.springframework.beans.propertyeditors.CustomBooleanEditor; //导入依赖的package包/类
@InitBinder
public void initBinder(WebDataBinder binder) {
	binder.registerCustomEditor(
			Long.class,
			new CustomNumberEditor(Long.class, true));
	binder.registerCustomEditor(
			Double.class,
			new CustomNumberEditor(Double.class, true));
	binder.registerCustomEditor(
			BigDecimal.class,
			new CustomNumberEditor(
					BigDecimal.class,
					new DecimalFormat("#,##0.00"),
					true));
	binder.registerCustomEditor(
			Boolean.class,
			new CustomBooleanEditor(false));
	binder.registerCustomEditor(
			Date.class,
			new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:22,代码来源:TascaFormController.java

示例6: initBinder

import org.springframework.beans.propertyeditors.CustomBooleanEditor; //导入依赖的package包/类
/**
 * Allows for Integers to be used as values in input tags. Normally, only strings and lists are
 * expected
 *
 * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest,
 *      org.springframework.web.bind.ServletRequestDataBinder)
 */
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
	super.initBinder(request, binder);
	
	binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true));
	binder.registerCustomEditor(java.util.Date.class, new CustomDateEditor(Context.getDateFormat(), true));
	binder.registerCustomEditor(java.util.Date.class, "valueDatetime", new CustomDateEditor(Context.getDateTimeFormat(),
	        true));
	binder.registerCustomEditor(java.util.Date.class, "valueTime", new CustomDateEditor(Context.getTimeFormat(), true));
	binder.registerCustomEditor(Location.class, new LocationEditor());
	binder.registerCustomEditor(java.lang.Boolean.class, new CustomBooleanEditor(true)); //allow for an empty boolean value
	binder.registerCustomEditor(Person.class, new PersonEditor());
	binder.registerCustomEditor(Order.class, new OrderEditor());
	binder.registerCustomEditor(Concept.class, new ConceptEditor());
	binder.registerCustomEditor(Location.class, new LocationEditor());
	binder.registerCustomEditor(Encounter.class, new EncounterEditor());
	binder.registerCustomEditor(Drug.class, new DrugEditor());
}
 
开发者ID:openmrs,项目名称:openmrs-module-legacyui,代码行数:25,代码来源:ObsFormController.java

示例7: initBinder

import org.springframework.beans.propertyeditors.CustomBooleanEditor; //导入依赖的package包/类
/**
 * Annotation that identifies methods which initialize the {@link org.springframework.web.bind.WebDataBinder} which will be
 * used for populating command and form object arguments of annotated handler methods.
 * 
 * Registers custom editors
 * 
 * Handles the date format from the form, using the application date format from application settings.
 * 
 * @param binder
 * @param locale
 */
@InitBinder
public void initBinder(WebDataBinder binder, Locale locale) {

    binder.setIgnoreInvalidFields(true);
    binder.setIgnoreUnknownFields(true);
   
    String applicationDateFormatString = appSettings.getApplicationDateFormat();
    SimpleDateFormat dateFormat = new SimpleDateFormat(applicationDateFormatString);
    dateFormat.setLenient(false);

    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
    binder.registerCustomEditor(Integer.class, new CustomNumberEditor(Integer.class, true));
    binder.registerCustomEditor(Boolean.class, new CustomBooleanEditor(true));
    binder.registerCustomEditor(XMLGregorianCalendar.class, new CustomXMLGregorianCalendarEditor(dateFormat, true));
    binder.registerCustomEditor(DateTime.class, new CustomDateTimeEditor(applicationDateFormatString, true));
    binder.registerCustomEditor(String.class, new CustomObjectEditor());

}
 
开发者ID:bullhorn,项目名称:starter-kit-spring-maven,代码行数:30,代码来源:AbstractDataTablesController.java

示例8: initBinder

import org.springframework.beans.propertyeditors.CustomBooleanEditor; //导入依赖的package包/类
@InitBinder
public void initBinder(WebDataBinder binder) {
	binder.registerCustomEditor(
			byte[].class,
			new ByteArrayMultipartFileEditor());
	binder.registerCustomEditor(
			Date.class,
			new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
	binder.registerCustomEditor(
			Long.class,
			new CustomNumberEditor(Long.class, true));
	binder.registerCustomEditor(
			Double.class,
			new CustomNumberEditor(Double.class, true));
	binder.registerCustomEditor(
			BigDecimal.class,
			new CustomNumberEditor(
					BigDecimal.class,
					new DecimalFormat("#,##0.00"),
					true));
	binder.registerCustomEditor(
			Boolean.class,
			new CustomBooleanEditor(false));
	binder.registerCustomEditor(
			Object.class,
			new ObjectTypeEditorHelper());
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:28,代码来源:ExpedientTerminiV3Controller.java

示例9: initBinder

import org.springframework.beans.propertyeditors.CustomBooleanEditor; //导入依赖的package包/类
@InitBinder
	public void initBinder(WebDataBinder binder) {
		binder.registerCustomEditor(
				Long.class,
				new CustomNumberEditor(Long.class, true));
		binder.registerCustomEditor(
				Double.class,
				new CustomNumberEditor(Double.class, true));
		binder.registerCustomEditor(
				BigDecimal.class,
				new CustomNumberEditor(
						BigDecimal.class,
						new DecimalFormat("#,##0.00"),
						true));
		binder.registerCustomEditor(
				Boolean.class,
//				new CustomBooleanEditor(false));
				new CustomBooleanEditor(true));
		binder.registerCustomEditor(
				Date.class,
				new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
//		binder.registerCustomEditor(
//				TerminiDto.class,
//				new TerminiTypeEditorHelper());
		binder.registerCustomEditor(
				Object.class,
				new ObjectTypeEditorHelper());
	}
 
开发者ID:GovernIB,项目名称:helium,代码行数:29,代码来源:ExpedientInicioPasFormController.java

示例10: initBinder

import org.springframework.beans.propertyeditors.CustomBooleanEditor; //导入依赖的package包/类
@InitBinder
public void initBinder(WebDataBinder binder) {
	binder.registerCustomEditor(
			boolean.class,
			new CustomBooleanEditor(false));
	binder.registerCustomEditor(
			Date.class,
			new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:10,代码来源:PerfilController.java

示例11: initBinder

import org.springframework.beans.propertyeditors.CustomBooleanEditor; //导入依赖的package包/类
@InitBinder
public void initBinder(WebDataBinder binder) {
	binder.registerCustomEditor(
			boolean.class,
			new CustomBooleanEditor(false));
	binder.registerCustomEditor(
			Date.class,
			new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true));
	binder.registerCustomEditor(
			Permis.class,
			new PermisTypeEditor());
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:13,代码来源:PermisController.java

示例12: getBooleanStorageAttributeValueByName

import org.springframework.beans.propertyeditors.CustomBooleanEditor; //导入依赖的package包/类
/**
 * Gets attribute value by name from the storage entity and returns it as a boolean. Most types of boolean strings are supported (e.g. true/false, on/off,
 * yes/no, etc.).
 *
 * @param attributeName the attribute name (case insensitive)
 * @param storageEntity the storage entity
 * @param attributeRequired specifies whether the attribute is mandatory (i.e. whether it has a value or not).
 * @param attributeValueRequiredIfExists specifies whether the attribute value is mandatory (i.e. the attribute must exist and its value must also contain a
 * value).
 *
 * @return the attribute value from the attribute with the attribute name as a boolean. If no value is configured and the attribute isn't required, then
 *         false is returned.
 * @throws IllegalStateException if an invalid storage attribute boolean value was configured.
 */
public boolean getBooleanStorageAttributeValueByName(String attributeName, StorageEntity storageEntity, boolean attributeRequired,
    boolean attributeValueRequiredIfExists) throws IllegalStateException
{
    // Get the boolean string value.
    // The required flag is being passed so an exception will be thrown if it is required and isn't present.
    String booleanStringValue = getStorageAttributeValueByName(attributeName, storageEntity, attributeRequired, attributeValueRequiredIfExists);

    // If it isn't required, then treat a blank value as "false".
    if (StringUtils.isBlank(booleanStringValue))
    {
        return false;
    }

    // Use custom boolean editor without allowed empty strings to convert the value of the argument to a boolean value.
    CustomBooleanEditor customBooleanEditor = new CustomBooleanEditor(attributeRequired);
    try
    {
        customBooleanEditor.setAsText(booleanStringValue);
    }
    catch (IllegalArgumentException e)
    {
        // This will produce a 500 HTTP status code error. If storage attributes are able to be updated by a REST invocation in the future,
        // we might want to consider making this a 400 instead since the user has the ability to fix the issue on their own.
        throw new IllegalStateException(String
            .format("Attribute \"%s\" for \"%s\" storage has an invalid boolean value: \"%s\".", attributeName, storageEntity.getName(),
                booleanStringValue), e);
    }

    // Return the boolean value.
    return (Boolean) customBooleanEditor.getValue();
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:46,代码来源:StorageHelper.java

示例13: getBooleanProperty

import org.springframework.beans.propertyeditors.CustomBooleanEditor; //导入依赖的package包/类
/**
 * Gets a property value as a boolean.
 *
 * @param configurationValue the boolean configuration value
 * @param environment the environment containing the property
 *
 * @return the boolean property value
 */
public Boolean getBooleanProperty(ConfigurationValue configurationValue, Environment environment)
{
    String booleanStringValue = getProperty(configurationValue, environment);

    // Use custom boolean editor without allowed empty strings to convert the value of the argument to a boolean value.
    CustomBooleanEditor customBooleanEditor = new CustomBooleanEditor(false);
    try
    {
        customBooleanEditor.setAsText(booleanStringValue);
    }
    catch (IllegalArgumentException e)
    {
        // Create an invalid state exception.
        IllegalStateException illegalStateException = new IllegalStateException(
            String.format("Configuration \"%s\" has an invalid boolean value: \"%s\".", configurationValue.getKey(), booleanStringValue), e);

        // Log the exception.
        LOGGER.error(illegalStateException.getMessage(), illegalStateException);

        // This will produce a 500 HTTP status code error.
        throw illegalStateException;
    }

    // Return the boolean value.
    return (Boolean) customBooleanEditor.getValue();
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:35,代码来源:ConfigurationHelper.java

示例14: getStringValueAsBoolean

import org.springframework.beans.propertyeditors.CustomBooleanEditor; //导入依赖的package包/类
/**
 * Retrieves the argument value, if any, as a String object and converts it to a boolean value.
 *
 * @param option the option that we want to query for
 * @param defaultValue the default value to return if option is not set or missing an argument value
 *
 * @return the value of the argument converted to a boolean value or default value when the option is not set or missing an argument value
 * @throws ParseException if the value of the argument is an invalid boolean value
 */
@SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "This is a false positive. A null check is present.")
public Boolean getStringValueAsBoolean(Option option, Boolean defaultValue) throws ParseException
{
    Boolean result;

    ensureCommandLineNotNull();
    String stringValue = getStringValue(option);

    if (StringUtils.isNotBlank(stringValue))
    {
        // Use custom boolean editor without allowed empty strings to convert the value of the argument to a boolean value.
        CustomBooleanEditor customBooleanEditor = new CustomBooleanEditor(false);
        try
        {
            customBooleanEditor.setAsText(stringValue);
        }
        catch (IllegalArgumentException e)
        {
            ParseException parseException = new ParseException(e.getMessage());
            parseException.initCause(e);
            throw parseException;
        }
        result = (Boolean) customBooleanEditor.getValue();
    }
    else
    {
        result = defaultValue;
    }

    return result;
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:41,代码来源:ArgumentParser.java

示例15: initBinder

import org.springframework.beans.propertyeditors.CustomBooleanEditor; //导入依赖的package包/类
@InitBinder
public void initBinder(WebDataBinder binder, WebRequest request) {
    binder.setIgnoreInvalidFields(true);
    binder.setIgnoreUnknownFields(true);

    String applicationDateFormatString = appSettings.getApplicationDateFormat();
    SimpleDateFormat dateFormat = new SimpleDateFormat(applicationDateFormatString);
    dateFormat.setLenient(false);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
    binder.registerCustomEditor(Integer.class, new CustomNumberEditor(Integer.class, true));
    binder.registerCustomEditor(Boolean.class, new CustomBooleanEditor(true));
    binder.registerCustomEditor(XMLGregorianCalendar.class, new CustomXMLGregorianCalendarEditor(dateFormat, true));
    binder.registerCustomEditor(DateTime.class, new CustomDateTimeEditor(applicationDateFormatString, true));
    binder.registerCustomEditor(BigDecimal.class, new CustomBigDecimalEditor(2, true));
}
 
开发者ID:bullhorn,项目名称:starter-kit-spring-maven,代码行数:16,代码来源:CoreControllerAdvice.java


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