List of usage examples for org.apache.commons.lang3.math NumberUtils isNumber
public static boolean isNumber(final String str)
Checks whether the String a valid Java number.
Valid numbers include hexadecimal marked with the 0x
or 0X
qualifier, octal numbers, scientific notation and numbers marked with a type qualifier (e.g.
From source file:org.apache.olingo.commons.core.data.AbstractJsonSerializer.java
private void value(final JsonGenerator jgen, final String type, final Value value) throws IOException { final EdmTypeInfo typeInfo = type == null ? null : new EdmTypeInfo.Builder().setTypeExpression(type).build(); if (value.isNull()) { jgen.writeNull();/*from w w w. j ava 2 s . c om*/ } else if (value.isSimple()) { final boolean isNumber = typeInfo == null ? NumberUtils.isNumber(value.asSimple().get()) : ArrayUtils.contains(NUMBER_TYPES, typeInfo.getPrimitiveTypeKind()); final boolean isBoolean = typeInfo == null ? (value.asSimple().get().equalsIgnoreCase(Boolean.TRUE.toString()) || value.asSimple().get().equalsIgnoreCase(Boolean.FALSE.toString())) : typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Boolean; if (isNumber) { jgen.writeNumber(value.asSimple().get()); } else if (isBoolean) { jgen.writeBoolean(BooleanUtils.toBoolean(value.asSimple().get())); } else { jgen.writeString(value.asSimple().get()); } } else if (value.isGeospatial()) { jgen.writeStartObject(); geoSerializer.serialize(jgen, value.asGeospatial().get()); jgen.writeEndObject(); } else if (value.isCollection()) { collection(jgen, typeInfo == null ? null : typeInfo.getFullQualifiedName().toString(), value.asCollection()); } else if (value.isComplex()) { jgen.writeStartObject(); for (Property property : value.asComplex().get()) { property(jgen, property, property.getName()); } jgen.writeEndObject(); } }
From source file:org.apache.olingo.fit.Services.java
@GET @Path("/People/{type:.*}") public Response getPeople(@Context final UriInfo uriInfo, @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, @PathParam("type") final String type, @QueryParam("$top") @DefaultValue(StringUtils.EMPTY) final String top, @QueryParam("$skip") @DefaultValue(StringUtils.EMPTY) final String skip, @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, @QueryParam("$count") @DefaultValue(StringUtils.EMPTY) final String count, @QueryParam("$filter") @DefaultValue(StringUtils.EMPTY) final String filter, @QueryParam("$search") @DefaultValue(StringUtils.EMPTY) final String search, @QueryParam("$orderby") @DefaultValue(StringUtils.EMPTY) final String orderby, @QueryParam("$skiptoken") @DefaultValue(StringUtils.EMPTY) final String skiptoken) { return StringUtils.isBlank(filter) && StringUtils.isBlank(search) ? NumberUtils.isNumber(type) ? getEntityInternal(uriInfo.getRequestUri().toASCIIString(), accept, "People", type, format, null, null)//ww w . ja va 2 s . c om : getEntitySet(accept, "People", type) : getEntitySet(uriInfo, accept, "People", top, skip, format, count, filter, orderby, skiptoken, type); }
From source file:org.apache.olingo.fit.V4Services.java
@GET @Path("/People/{type:.*}") public Response getPeople(@Context final UriInfo uriInfo, @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept, @PathParam("type") final String type, @QueryParam("$top") @DefaultValue(StringUtils.EMPTY) final String top, @QueryParam("$skip") @DefaultValue(StringUtils.EMPTY) final String skip, @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format, @QueryParam("$inlinecount") @DefaultValue(StringUtils.EMPTY) final String count, @QueryParam("$filter") @DefaultValue(StringUtils.EMPTY) final String filter, @QueryParam("$search") @DefaultValue(StringUtils.EMPTY) final String search, @QueryParam("$orderby") @DefaultValue(StringUtils.EMPTY) final String orderby, @QueryParam("$skiptoken") @DefaultValue(StringUtils.EMPTY) final String skiptoken) { return StringUtils.isBlank(filter) && StringUtils.isBlank(search) ? NumberUtils.isNumber(type) ? super.getEntityInternal(uriInfo.getRequestUri().toASCIIString(), accept, "People", type, format, null, null) : super.getEntitySet(accept, "People", type) : super.getEntitySet(uriInfo, accept, "People", top, skip, format, count, filter, orderby, skiptoken);//from w ww.j a v a 2 s . com }
From source file:org.bonitasoft.engine.api.impl.LoginAPIImpl.java
@Override @CustomTransactions/*from w w w.j a v a 2s .co m*/ @AvailableWhenTenantIsPaused public APISession login(final Map<String, Serializable> credentials) throws LoginException { checkCredentialsAreNotNullOrEmpty(credentials); try { final Long tenantId = NumberUtils .isNumber(String.valueOf(credentials.get(AuthenticationConstants.BASIC_TENANT_ID))) ? NumberUtils.toLong( String.valueOf(credentials.get(AuthenticationConstants.BASIC_TENANT_ID))) : null; return loginInternal(tenantId, credentials); } catch (final LoginException e) { throw e; } catch (final Exception e) { throw new LoginException(e); } }
From source file:org.briljantframework.data.reader.CsvEntryReader.java
@Override public List<Class<?>> getTypes() { if (!hasNext()) { throw new NoSuchElementException(); }/*from ww w .ja v a 2 s . c o m*/ if (types == null) { types = new ArrayList<>(); for (String repr : current) { if (repr != null) { repr = repr.trim(); } if (repr == null || repr.equals(missingValue)) { types.add(Object.class); } else if (NumberUtils.isNumber(repr)) { Number number = NumberUtils.createNumber(repr); types.add(number.getClass()); } else { // Finally, try to resolve the value using the registered resolvers Resolver<?> resolver = null; Object data; if ((resolver = Resolve.find(LocalDate.class)) != null) { data = resolver.resolve(repr); } else { data = null; } if (data == null) { types.add(Object.class); } else { types.add(data.getClass()); } } } } return Collections.unmodifiableList(types); }
From source file:org.briljantframework.data.reader.StringDataEntry.java
@Override public int nextInt() { String repr = nextString();/*from w w w . j a va 2s. c om*/ if (repr == null || !NumberUtils.isNumber(repr)) { return Na.INT; } return NumberUtils.createNumber(repr).intValue(); }
From source file:org.briljantframework.data.reader.StringDataEntry.java
@Override public double nextDouble() { String repr = nextString();// w w w . j a va 2 s . c o m if (repr == null || !NumberUtils.isNumber(repr)) { return Na.DOUBLE; } return NumberUtils.createNumber(repr).doubleValue(); }
From source file:org.briljantframework.data.resolver.Resolve.java
private static Number toNumber(String str) { return NumberUtils.isNumber(str) ? NumberUtils.createNumber(str) : null; }
From source file:org.broadleafcommerce.profile.web.core.security.RestApiCustomerStateFilter.java
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { String customerId = null;/*from w ww . j a v a 2s .c o m*/ HttpServletRequest request = (HttpServletRequest) servletRequest; //If someone already set the customer on the request then we don't need to do anything. if (request.getAttribute(CustomerStateRequestProcessor.getCustomerRequestAttributeName()) == null) { //First check to see if someone already put the customerId on the request if (request.getAttribute(customerIdAttributeName) != null) { customerId = String.valueOf(request.getAttribute(customerIdAttributeName)); } if (customerId == null) { //If it's not on the request attribute, try the parameter customerId = servletRequest.getParameter(customerIdAttributeName); } if (customerId == null) { //If it's not on the request parameter, look on the header customerId = request.getHeader(customerIdAttributeName); } if (customerId != null && customerId.trim().length() > 0) { if (NumberUtils.isNumber(customerId)) { //If we found it, look up the customer and put it on the request. Customer customer = customerService.readCustomerById(Long.valueOf(customerId)); if (customer != null) { CustomerState.setCustomer(customer); } } else { LOG.warn(String.format("The customer id passed in '%s' was not a number", customerId)); } } if (customerId == null) { if (LOG.isDebugEnabled()) { LOG.debug( "No customer ID was found for the API request. In order to look up a customer for the request" + " send a request parameter or request header for the '" + customerIdAttributeName + "' attribute"); } } } filterChain.doFilter(request, servletResponse); }
From source file:org.cirdles.ambapo.userInterface.AmbapoUIController.java
private void checkUTMToLatLongCorrect() { if ((zoneLetterChooser.getSelectionModel().getSelectedIndex() > 0 || hemisphereChooser.getSelectionModel().getSelectedIndex() > 0) && !eastingText.getText().isEmpty() && !northingText.getText().isEmpty() && NumberUtils.isNumber(eastingText.getText()) && NumberUtils.isNumber(northingText.getText()) && Double.parseDouble(eastingText.getText()) >= UTM.MIN_EASTING && Double.parseDouble(eastingText.getText()) <= UTM.MAX_EASTING && Double.parseDouble(northingText.getText()) >= UTM.MIN_NORTHING && Double.parseDouble(northingText.getText()) <= UTM.MAX_NORTHING && datumChooserUTMAndLatLong.getSelectionModel().getSelectedIndex() > 0) { convertToLatLongButton.setDisable(false); } else//from w ww . j a v a 2 s .c o m convertToLatLongButton.setDisable(true); }