Example usage for java.lang Integer TYPE

List of usage examples for java.lang Integer TYPE

Introduction

In this page you can find the example usage for java.lang Integer TYPE.

Prototype

Class TYPE

To view the source code for java.lang Integer TYPE.

Click Source Link

Document

The Class instance representing the primitive type int .

Usage

From source file:com.puppycrawl.tools.checkstyle.api.AutomaticBean.java

/**
 * Creates a BeanUtilsBean that is configured to use
 * type converters that throw a ConversionException
 * instead of using the default value when something
 * goes wrong./*from  w ww  .  ja  v  a 2  s.c  o m*/
 *
 * @return a configured BeanUtilsBean
 */
private static BeanUtilsBean createBeanUtilsBean() {
    final ConvertUtilsBean cub = new ConvertUtilsBean();

    cub.register(new BooleanConverter(), Boolean.TYPE);
    cub.register(new BooleanConverter(), Boolean.class);
    cub.register(new ArrayConverter(boolean[].class, new BooleanConverter()), boolean[].class);
    cub.register(new ByteConverter(), Byte.TYPE);
    cub.register(new ByteConverter(), Byte.class);
    cub.register(new ArrayConverter(byte[].class, new ByteConverter()), byte[].class);
    cub.register(new CharacterConverter(), Character.TYPE);
    cub.register(new CharacterConverter(), Character.class);
    cub.register(new ArrayConverter(char[].class, new CharacterConverter()), char[].class);
    cub.register(new DoubleConverter(), Double.TYPE);
    cub.register(new DoubleConverter(), Double.class);
    cub.register(new ArrayConverter(double[].class, new DoubleConverter()), double[].class);
    cub.register(new FloatConverter(), Float.TYPE);
    cub.register(new FloatConverter(), Float.class);
    cub.register(new ArrayConverter(float[].class, new FloatConverter()), float[].class);
    cub.register(new IntegerConverter(), Integer.TYPE);
    cub.register(new IntegerConverter(), Integer.class);
    cub.register(new ArrayConverter(int[].class, new IntegerConverter()), int[].class);
    cub.register(new LongConverter(), Long.TYPE);
    cub.register(new LongConverter(), Long.class);
    cub.register(new ArrayConverter(long[].class, new LongConverter()), long[].class);
    cub.register(new ShortConverter(), Short.TYPE);
    cub.register(new ShortConverter(), Short.class);
    cub.register(new ArrayConverter(short[].class, new ShortConverter()), short[].class);
    cub.register(new RelaxedStringArrayConverter(), String[].class);

    // BigDecimal, BigInteger, Class, Date, String, Time, TimeStamp
    // do not use defaults in the default configuration of ConvertUtilsBean

    return new BeanUtilsBean(cub, new PropertyUtilsBean());
}

From source file:org.openmrs.module.pihmalawi.page.controller.MastercardPageController.java

public void controller(@RequestParam(value = "patientId", required = false) Patient patient,
        @RequestParam(value = "headerForm") String headerForm,
        @RequestParam(value = "flowsheets") String[] flowsheets,
        @RequestParam(value = "viewOnly", required = false) Boolean viewOnly,
        @RequestParam(value = "requireEncounter", required = false) Boolean requireEncounter, UiUtils ui,
        PageModel model, @SpringBean("htmlFormEntryService") HtmlFormEntryService htmlFormEntryService,
        @SpringBean("formService") FormService formService,
        @SpringBean("locationService") LocationService locationService,
        @SpringBean("coreResourceFactory") ResourceFactory resourceFactory,
        @InjectBeans PatientDomainWrapper patientDomainWrapper, PageRequest pageRequest) {

    patientDomainWrapper.setPatient(patient);
    model.addAttribute("patient", patientDomainWrapper);
    model.addAttribute("headerForm", headerForm);
    model.addAttribute("flowsheets", flowsheets);
    model.addAttribute("requireEncounter", (requireEncounter == null || requireEncounter));

    Location defaultLocation = null;
    Integer locationId = pageRequest.getSession().getAttribute(PihMalawiWebConstants.SESSION_LOCATION_ID,
            Integer.TYPE);
    if (locationId != null) {
        defaultLocation = locationService.getLocation(locationId);
    }/*from w  w  w .ja  va 2 s .  c o  m*/

    List<Encounter> allEncounters = new ArrayList<Encounter>();

    List<String> alerts = new ArrayList<String>();

    String headerFormResource = "pihmalawi:htmlforms/" + headerForm + ".xml";

    HtmlForm headerHtmlForm = getHtmlFormFromResource(headerFormResource, resourceFactory, formService,
            htmlFormEntryService);
    model.addAttribute("headerForm", headerForm);

    Encounter headerEncounter = null;
    List<Encounter> headerEncounters = getEncountersForForm(patient, headerHtmlForm);
    if (headerEncounters.size() > 0) {
        headerEncounter = headerEncounters.get(headerEncounters.size() - 1); // Most recent
        if (headerEncounters.size() > 1) {
            alerts.add("WARNING:  More than one " + headerHtmlForm.getName()
                    + " encounters exist for this patient.  Displaying the most recent only.");
        }
        allEncounters.add(headerEncounter);
    }
    model.addAttribute("headerEncounter", headerEncounter);

    Map<String, HtmlForm> flowsheetForms = new LinkedHashMap<String, HtmlForm>();
    Map<String, List<Integer>> flowsheetEncounters = new LinkedHashMap<String, List<Integer>>();
    if (flowsheets != null) {
        for (String flowsheet : flowsheets) {
            String flowsheetResource = "pihmalawi:htmlforms/" + flowsheet + ".xml";
            HtmlForm htmlForm = getHtmlFormFromResource(flowsheetResource, resourceFactory, formService,
                    htmlFormEntryService);
            flowsheetForms.put(flowsheet, htmlForm);
            List<Integer> encIds = new ArrayList<Integer>();
            List<Encounter> encounters = getEncountersForForm(patient, htmlForm);
            for (Encounter e : encounters) {
                encIds.add(e.getEncounterId());
                allEncounters.add(e);
            }
            flowsheetEncounters.put(flowsheet, encIds);
        }
    }
    model.addAttribute("flowsheetForms", flowsheetForms);
    model.addAttribute("flowsheetEncounters", flowsheetEncounters);

    model.addAttribute("alerts", alerts);

    if (defaultLocation == null) {
        Date maxDate = null;
        if (allEncounters.size() > 0) {
            for (Encounter e : allEncounters) {
                if (maxDate == null || maxDate.compareTo(e.getEncounterDatetime()) < 0) {
                    maxDate = e.getEncounterDatetime();
                    defaultLocation = e.getLocation();
                }
            }
        }
    }
    model.addAttribute("defaultLocationId", defaultLocation == null ? null : defaultLocation.getLocationId());
    model.addAttribute("viewOnly", viewOnly == Boolean.TRUE);

    model.addAttribute("returnUrl", ui.pageLink("pihmalawi", "mastercard", SimpleObject.create("patientId",
            patient.getId(), "headerForm", headerForm, "flowsheets", flowsheets, "viewOnly", viewOnly)));
}

From source file:nl.strohalm.cyclos.controls.settings.EditLocalSettingsAction.java

public DataBinder<LocalSettings> getDataBinder() {
    if (dataBinder == null) {

        final BeanBinder<TransactionNumber> transactionNumberBinder = BeanBinder
                .instance(TransactionNumber.class, "transactionNumber");
        transactionNumberBinder.registerBinder("prefix", PropertyBinder.instance(String.class, "prefix"));
        transactionNumberBinder.registerBinder("padLength", PropertyBinder.instance(Integer.TYPE, "padLength"));
        transactionNumberBinder.registerBinder("suffix", PropertyBinder.instance(String.class, "suffix"));
        transactionNumberBinder.registerBinder("enabled", PropertyBinder.instance(Boolean.TYPE, "enabled"));

        final BeanBinder<LocalSettings> binder = BeanBinder.instance(LocalSettings.class);
        binder.registerBinder("applicationName", PropertyBinder.instance(String.class, "applicationName"));
        binder.registerBinder("applicationUsername",
                PropertyBinder.instance(String.class, "applicationUsername"));
        binder.registerBinder("rootUrl", PropertyBinder.instance(String.class, "rootUrl"));

        binder.registerBinder("language", PropertyBinder.instance(Language.class, "language"));
        binder.registerBinder("numberLocale",
                PropertyBinder.instance(LocalSettings.NumberLocale.class, "numberLocale"));
        binder.registerBinder("precision", PropertyBinder.instance(LocalSettings.Precision.class, "precision"));
        binder.registerBinder("highPrecision",
                PropertyBinder.instance(LocalSettings.Precision.class, "highPrecision"));
        binder.registerBinder("decimalInputMethod",
                PropertyBinder.instance(LocalSettings.DecimalInputMethod.class, "decimalInputMethod"));
        binder.registerBinder("datePattern",
                PropertyBinder.instance(LocalSettings.DatePattern.class, "datePattern"));
        binder.registerBinder("timePattern",
                PropertyBinder.instance(LocalSettings.TimePattern.class, "timePattern"));
        binder.registerBinder("timeZone",
                PropertyBinder.instance(TimeZone.class, "timeZone", TimeZoneConverter.instance()));
        binder.registerBinder("containerUrl", PropertyBinder.instance(String.class, "containerUrl"));

        binder.registerBinder("maxIteratorResults",
                PropertyBinder.instance(Integer.TYPE, "maxIteratorResults"));
        binder.registerBinder("maxPageResults", PropertyBinder.instance(Integer.TYPE, "maxPageResults"));
        binder.registerBinder("maxAjaxResults", PropertyBinder.instance(Integer.TYPE, "maxAjaxResults"));
        binder.registerBinder("maxUploadSize", PropertyBinder.instance(Integer.TYPE, "maxUploadSize"));
        binder.registerBinder("maxUploadUnits", PropertyBinder.instance(FileUnits.class, "maxUploadUnits"));
        binder.registerBinder("maxImageWidth", PropertyBinder.instance(Integer.TYPE, "maxImageWidth"));
        binder.registerBinder("maxImageHeight", PropertyBinder.instance(Integer.TYPE, "maxImageHeight"));
        binder.registerBinder("maxThumbnailWidth", PropertyBinder.instance(Integer.TYPE, "maxThumbnailWidth"));
        binder.registerBinder("maxThumbnailHeight",
                PropertyBinder.instance(Integer.TYPE, "maxThumbnailHeight"));

        binder.registerBinder("csvUseHeader", PropertyBinder.instance(Boolean.TYPE, "csvUseHeader"));
        binder.registerBinder("csvRecordSeparator",
                PropertyBinder.instance(LocalSettings.CsvRecordSeparator.class, "csvRecordSeparator"));
        binder.registerBinder("csvValueSeparator",
                PropertyBinder.instance(LocalSettings.CsvValueSeparator.class, "csvValueSeparator"));
        binder.registerBinder("csvStringQuote",
                PropertyBinder.instance(LocalSettings.CsvStringQuote.class, "csvStringQuote"));

        binder.registerBinder("cyclosId", PropertyBinder.instance(String.class, "cyclosId"));
        binder.registerBinder("smsEnabled", PropertyBinder.instance(Boolean.TYPE, "smsEnabled"));
        binder.registerBinder("sendSmsWebServiceUrl",
                PropertyBinder.instance(String.class, "sendSmsWebServiceUrl"));
        binder.registerBinder("smsCustomFieldId", PropertyBinder.instance(Long.TYPE, "smsCustomFieldId"));
        binder.registerBinder("smsChannelName", PropertyBinder.instance(String.class, "smsChannelName"));

        binder.registerBinder("emailRequired", PropertyBinder.instance(Boolean.TYPE, "emailRequired"));
        binder.registerBinder("emailUnique", PropertyBinder.instance(Boolean.TYPE, "emailUnique"));
        binder.registerBinder("transactionNumber", transactionNumberBinder);

        binder.registerBinder("brokeringExpirationPeriod",
                DataBinderHelper.timePeriodBinder("brokeringExpirationPeriod"));
        binder.registerBinder("deleteMessagesOnTrashAfter",
                DataBinderHelper.timePeriodBinder("deleteMessagesOnTrashAfter"));
        binder.registerBinder("deletePendingRegistrationsAfter",
                DataBinderHelper.timePeriodBinder("deletePendingRegistrationsAfter"));
        binder.registerBinder("memberSortOrder",
                PropertyBinder.instance(LocalSettings.SortOrder.class, "memberSortOrder"));
        binder.registerBinder("memberResultDisplay",
                PropertyBinder.instance(LocalSettings.MemberResultDisplay.class, "memberResultDisplay"));
        binder.registerBinder("adDescriptionFormat",
                PropertyBinder.instance(TextFormat.class, "adDescriptionFormat"));
        binder.registerBinder("messageFormat", PropertyBinder.instance(TextFormat.class, "messageFormat"));

        binder.registerBinder("schedulingHour", PropertyBinder.instance(Integer.TYPE, "schedulingHour"));
        binder.registerBinder("schedulingMinute", PropertyBinder.instance(Integer.TYPE, "schedulingMinute"));
        binder.registerBinder("transferListenerClass",
                PropertyBinder.instance(String.class, "transferListenerClass"));

        binder.registerBinder("maxChargebackTime", DataBinderHelper.timePeriodBinder("maxChargebackTime"));
        binder.registerBinder("chargebackDescription",
                PropertyBinder.instance(String.class, "chargebackDescription"));
        binder.registerBinder("showCountersInAdCategories",
                PropertyBinder.instance(Boolean.TYPE, "showCountersInAdCategories"));

        dataBinder = binder;//from   ww  w. ja  va  2s .  c o  m
    }
    return dataBinder;
}

From source file:net.maritimecloud.endorsement.config.OperationPageableParameterReader.java

@Override
public void apply(OperationContext context) {
    List<ResolvedMethodParameter> methodParameters = context.getParameters();
    List<Parameter> parameters = newArrayList();

    for (ResolvedMethodParameter methodParameter : methodParameters) {
        ResolvedType resolvedType = methodParameter.getParameterType();

        if (pageableType.equals(resolvedType)) {
            ParameterContext parameterContext = new ParameterContext(methodParameter, new ParameterBuilder(),
                    context.getDocumentationContext(), context.getGenericsNamingStrategy(), context);
            Function<ResolvedType, ? extends ModelReference> factory = createModelRefFactory(parameterContext);

            ModelReference intModel = factory.apply(resolver.resolve(Integer.TYPE));
            ModelReference stringModel = factory.apply(resolver.resolve(List.class, String.class));

            parameters.add(new ParameterBuilder().parameterType("query").name("page").modelRef(intModel)
                    .description("Results page you want to retrieve (0..N)").build());
            parameters.add(new ParameterBuilder().parameterType("query").name("size").modelRef(intModel)
                    .description("Number of records per page").build());
            parameters.add(new ParameterBuilder().parameterType("query").name("sort").modelRef(stringModel)
                    .allowMultiple(true)
                    .description("Sorting criteria in the format: property(,asc|desc). "
                            + "Default sort order is ascending. " + "Multiple sort criteria are supported.")
                    .build());//ww w. j a va 2s  .c  o  m
            context.operationBuilder().parameters(parameters);
        }
    }
}

From source file:com.mikecorrigan.trainscorekeeper.XPagerAdapter.java

@Override
public Fragment getItem(int index) {
    Log.vc(VERBOSE, TAG, "getItem: index=" + index);

    if (index > pageSpecs.length) {
        Log.e(TAG, "getItem: invalid index=" + index);
        return null;
    }/*from   w  w w  .  j  av  a  2s. co m*/

    PageSpec pageSpec = pageSpecs[index];
    if (pageSpec == null) {
        Log.e(TAG, "getItem: page spec for index=" + index);
        return null;
    }

    try {
        Method method = pageSpec.clazz.getMethod("newInstance", Integer.TYPE, JSONObject.class);
        pageSpec.fragment = (Fragment) method.invoke(null /* this */, index, pageSpec.jsonSpec);
        return pageSpec.fragment;
    } catch (IllegalAccessException e) {
        Log.th(TAG, e, "getItem");
    } catch (InvocationTargetException e) {
        Log.th(TAG, e, "getItem");
    } catch (NoSuchMethodException e) {
        Log.th(TAG, e, "getItem");
    }

    Log.e(TAG, "getItem: failed, index=" + index);
    return null;
}

From source file:org.briljantframework.data.vector.Convert.java

@SuppressWarnings("unchecked")
private static <T> T convertNumber(Class<T> cls, Number num) {
    if (cls.equals(Double.class) || cls.equals(Double.TYPE)) {
        return (T) (Double) num.doubleValue();
    } else if (cls.equals(Float.class) || cls.equals(Float.TYPE)) {
        return (T) (Float) num.floatValue();
    } else if (cls.equals(Long.class) || cls.equals(Long.TYPE)) {
        return (T) (Long) num.longValue();
    } else if (cls.equals(Integer.class) || cls.equals(Integer.TYPE)) {
        return (T) (Integer) num.intValue();
    } else if (cls.equals(Short.class) || cls.equals(Short.TYPE)) {
        return (T) (Short) num.shortValue();
    } else if (cls.equals(Byte.class) || cls.equals(Byte.TYPE)) {
        return (T) (Byte) num.byteValue();
    } else if (Complex.class.equals(cls)) {
        return cls.cast(Complex.valueOf(num.doubleValue()));
    } else if (Logical.class.equals(cls)) {
        return cls.cast(num.intValue() == 1 ? Logical.TRUE : Logical.FALSE);
    } else if (Boolean.class.equals(cls)) {
        return cls.cast(num.intValue() == 1);
    } else {/* ww  w .j a  v  a 2 s.  c  om*/
        return Na.of(cls);
    }
}

From source file:de.micromata.genome.util.strings.converter.StandardStringConverter.java

@Override
public char getTypeChar(Object value) {
    if (value == null) {
        return ConvertedStringTypes.NULL.getShortType();
    }/*  w w  w .  jav a2  s  .  c  om*/
    Class<?> cls = value.getClass();

    if (value instanceof String) {
        return ConvertedStringTypes.STRING.getShortType();
    }

    Class<?> vclass = value.getClass();

    if (value instanceof Boolean || vclass == Boolean.TYPE) {
        return ConvertedStringTypes.BOOLEAN.getShortType();
    }
    if (value instanceof Byte || vclass == Byte.TYPE) {
        return ConvertedStringTypes.BYTE.getShortType();
    }
    if (value instanceof Short || vclass == Short.TYPE) {
        return ConvertedStringTypes.SHORT.getShortType();
    }
    if (value instanceof Integer || vclass == Integer.TYPE) {
        return ConvertedStringTypes.INTEGER.getShortType();
    }
    if (value instanceof Long || vclass == Long.TYPE) {
        return ConvertedStringTypes.LONG.getShortType();
    }
    if (value instanceof Float || vclass == Float.TYPE) {
        return ConvertedStringTypes.FLOAT.getShortType();
    }
    if (value instanceof Double || vclass == Double.TYPE) {
        return ConvertedStringTypes.DOUBLE.getShortType();
    }
    if (value instanceof Character || vclass == Character.TYPE) {
        return ConvertedStringTypes.CHAR.getShortType();
    }
    if (value instanceof Date) {
        return ConvertedStringTypes.DATE.getShortType();
    }
    if (value instanceof BigDecimal) {
        return ConvertedStringTypes.BIGDECIMAL.getShortType();
    }
    if (value instanceof Character) {
        return ConvertedStringTypes.CHAR.getShortType();
    }
    if (value instanceof byte[]) {
        return ConvertedStringTypes.BYTEARRAY.getShortType();
    }
    if (value instanceof String[]) {
        return ConvertedStringTypes.STRINGARRAY.getShortType();
    }
    if (value instanceof Long[]) {
        return ConvertedStringTypes.LONGARRAY.getShortType();
    }

    // if (value instanceof Serializable)
    // return ConvertedStringTypes.XMLOBJECT;
    return ConvertedStringTypes.CUSTOM.getShortType();
}

From source file:nz.ac.otago.psyanlab.common.designer.program.stage.EditPropPropertiesFragment.java

/**
 * Get the prop with properties set from the user entered values.
 * /* w  w  w.j av  a  2s .  c o  m*/
 * @return Prop with user values.
 */
public Prop getConfiguredProp() {
    for (String name : mViewMap.keySet()) {
        Field field = mFieldMap.get(name);
        View view = mViewMap.get(name);

        Object value;

        if (view instanceof EditText) {
            String in = ((EditText) view).getText().toString();
            if (in == null) {
                continue;
            }

            if (field.getType().isAssignableFrom(Integer.TYPE)) {
                try {
                    value = Integer.valueOf(((EditText) view).getText().toString());
                } catch (NumberFormatException e) {
                    // Bad input here can be ignored. Continue to next item.
                    continue;
                }
            } else if (field.getType().isAssignableFrom(Float.TYPE)) {
                try {
                    value = Float.valueOf(((EditText) view).getText().toString());
                } catch (NumberFormatException e) {
                    // Bad input here can be ignored. Continue to next item.
                    continue;
                }
            } else if (field.getType().isAssignableFrom(String.class)) {
                value = ((EditText) view).getText().toString();
            } else {
                continue;
            }
        } else {
            continue;
        }

        try {
            field.set(mProp, value);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }

    return mProp;
}

From source file:com.twitter.elephantbird.pig.piggybank.Invoker.java

private static Class<?> stringToClass(String klass) throws FrontendException {
    if ("string".equalsIgnoreCase(klass)) {
        return String.class;
    } else if ("int".equalsIgnoreCase(klass)) {
        return Integer.TYPE;
    } else if ("double".equalsIgnoreCase(klass)) {
        return Double.TYPE;
    } else if ("float".equalsIgnoreCase(klass)) {
        return Float.TYPE;
    } else if ("long".equalsIgnoreCase(klass)) {
        return Long.TYPE;
    } else if ("double[]".equalsIgnoreCase(klass)) {
        return DOUBLE_ARRAY_CLASS;
    } else if ("int[]".equalsIgnoreCase(klass)) {
        return INT_ARRAY_CLASS;
    } else if ("long[]".equalsIgnoreCase(klass)) {
        return LONG_ARRAY_CLASS;
    } else if ("float[]".equalsIgnoreCase(klass)) {
        return FLOAT_ARRAY_CLASS;
    } else if ("string[]".equalsIgnoreCase(klass)) {
        return STRING_ARRAY_CLASS;
    } else {/*from w  ww. j  a v a 2 s .  c o  m*/
        throw new FrontendException("unable to find matching class for " + klass);
    }

}

From source file:org.eclipse.gyrex.monitoring.internal.mbeans.MetricSetMBean.java

private OpenType detectType(final Class type) {
    if ((Long.class == type) || (Long.TYPE == type)) {
        return SimpleType.LONG;
    } else if ((Integer.class == type) || (Integer.TYPE == type)) {
        return SimpleType.INTEGER;
    } else if ((Double.class == type) || (Double.TYPE == type)) {
        return SimpleType.DOUBLE;
    } else if ((Float.class == type) || (Float.TYPE == type)) {
        return SimpleType.FLOAT;
    } else if ((Byte.class == type) || (Byte.TYPE == type)) {
        return SimpleType.BYTE;
    } else if ((Short.class == type) || (Short.TYPE == type)) {
        return SimpleType.SHORT;
    } else if ((Boolean.class == type) || (Boolean.TYPE == type)) {
        return SimpleType.BOOLEAN;
    } else if (BigDecimal.class == type) {
        return SimpleType.BIGDECIMAL;
    } else if (BigInteger.class == type) {
        return SimpleType.BIGINTEGER;
    } else if ((Character.class == type) || (Character.TYPE == type)) {
        return SimpleType.CHARACTER;
    }//from   ww  w .  j av  a2 s .co m

    // last fallback to strings
    if (isConvertibleToString(type)) {
        return SimpleType.STRING;
    }

    // give up
    return null;
}