org.apache.commons.lang3.math.NumberUtils#isParsable ( )源码实例Demo

下面列出了org.apache.commons.lang3.math.NumberUtils#isParsable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private static boolean fuzzyCompare(String h2Value, String brokerValue, String connectionValue) {
  // Fuzzy compare expected value and actual value
  boolean error = false;
  if (NumberUtils.isParsable(h2Value)) {
    double expectedValue = Double.parseDouble(h2Value);
    double actualValueBroker = Double.parseDouble(brokerValue);
    double actualValueConnection = Double.parseDouble(connectionValue);
    if (!DoubleMath.fuzzyEquals(actualValueBroker, expectedValue, 1.0) || !DoubleMath
        .fuzzyEquals(actualValueConnection, expectedValue, 1.0)) {
      error = true;
    }
  } else {
    if (!h2Value.equals(brokerValue) || !h2Value.equals(connectionValue)) {
      error = true;
    }
  }
  return error;
}
 
源代码2 项目: easter_eggs_for_java_9   文件: StringUtils.java
public int safeParseInt(String s) {
    int result = Integer.MIN_VALUE;

    if (NumberUtils.isParsable(s)) {
        try {
            result = Integer.parseInt(s);
        } catch(Exception ex) {
        } 
    }

    return result;
}
 
源代码3 项目: easter_eggs_for_java_9   文件: StringUtils.java
public int safeParseInt(String s) {
    int result = Integer.MIN_VALUE;

    if (NumberUtils.isParsable(s)) {
        try {
            result = Integer.parseInt(s);
        } catch(Exception ex) {
        } 
    }

    return result;
}
 
源代码4 项目: easter_eggs_for_java_9   文件: UserServiceImpl.java
public static int safeParseInt(String s) {
    int result = Integer.MIN_VALUE;

    if (NumberUtils.isParsable(s)) {
        try {
            result = Integer.parseInt(s);
        } catch(Exception ex) {
        } 
    }

    return result;
}
 
源代码5 项目: o2oa   文件: LanguageProcessingHelper.java
private boolean label_skip_m(Item item) {
	if (!StringUtils.startsWithIgnoreCase(item.getLabel(), "m")) {
		return false;
	} else {
		return NumberUtils.isParsable(item.getValue());
	}
}
 
源代码6 项目: o2oa   文件: LanguageProcessingHelper.java
private boolean label_skip_m(Item item) {
	if (!StringUtils.startsWithIgnoreCase(item.getLabel(), "m")) {
		return false;
	} else {
		return NumberUtils.isParsable(item.getValue());
	}
}
 
源代码7 项目: o2oa   文件: ActionControl.java
private Integer getArgInteger(CommandLine cmd, String opt, Integer defaultValue) {
	Integer repeat = defaultValue;
	String r = cmd.getOptionValue(opt);
	if (NumberUtils.isParsable(r)) {
		repeat = NumberUtils.toInt(r);
	}
	if (repeat < REPEAT_MIN || repeat > REPEAT_MAX) {
		repeat = REPEAT_MIN;
	}
	return repeat;
}
 
源代码8 项目: cyberduck   文件: Permission.java
public Permission(final String mode) {
    if(NumberUtils.isParsable(mode)) {
        this.fromInteger(Integer.parseInt(mode, 8));
    }
    else {
        this.fromSymbol(mode);
    }
}
 
源代码9 项目: Plan   文件: ConfigValueParser.java
@Override
public Integer compose(String fromValue) {
    if (NumberUtils.isParsable(fromValue)) {
        return NumberUtils.createInteger(fromValue);
    }
    return null;
}
 
源代码10 项目: ModPackDownloader   文件: CurseFile.java
public CurseFile(String projectId, String projectName) {
	if (NumberUtils.isParsable(projectId)) {
		setProjectID(Integer.parseInt(projectId));
	}
	setProjectName(projectName);
	curseForge = true;
}
 
源代码11 项目: cuba   文件: UiControllerPropertyInjector.java
protected Object parseNumber(UiControllerProperty property, Class<? extends Number> numberType) {
    String stringValue = (String) property.getValue();
    if (!NumberUtils.isParsable(stringValue)) {
        throw new GuiDevelopmentException(String.format(
                "Unable to parse '%s' as '%s'. Property value '%s' will not be injected into '%s'",
                property.getValue(), numberType, property.getName(), frameOwner),
                UiControllerUtils.getScreen(frameOwner).getId());
    }
    return org.springframework.util.NumberUtils.parseNumber(stringValue, numberType);
}
 
源代码12 项目: red5-io   文件: Input.java
@Override
public Object readMap() {
    // the maximum number used in this mixed array
    int maxNumber = buf.getInt();
    log.debug("Read start mixed array: {}", maxNumber);
    ObjectMap<Object, Object> result = new ObjectMap<Object, Object>();
    // we must store the reference before we deserialize any items in it to
    // ensure that reference IDs are correct
    int reference = storeReference(result);
    while (hasMoreProperties()) {
        String key = getString();
        Object item = Deserializer.deserialize(this, Object.class);
        //log.info("key: {} item: {}", key, item);
        if (!NumberUtils.isParsable(key)) {
            result.put(key, item);
        } else {
            // map keys are either integers or strings, none will be doubles
            if (key.contains(".")) {
                result.put(key, item);
            } else {
                result.put(Integer.valueOf(key), item);
            }
        }
    }
    result.remove("length");
    // replace the original reference with the final result
    storeReference(reference, result);
    return result;
}
 
/**
 * Gets the parameters for the given pipeline element as a map from parameter
 * name to value
 *
 * @param classifier
 *            The classifier for which to get the parameters
 * @return The parameter map
 */
private Map<String, String> getParametersForPipelineElement(final Object classifier) {
	if (classifier instanceof OptionHandler) {
		OptionHandler handler = (OptionHandler) classifier;
		HashMap<String, String> parametersWithValues = new HashMap<String, String>(handler.getOptions().length);

		String optionName = null;
		boolean previousStringWasAValue = true;

		for (String option : handler.getOptions()) {
			if (option.equals("--")) {
				// TODO here all classifier parameters (i.e. for meta classifiers and such) are
				// skipped! Might want to include that in the future
				break;
			}

			if (previousStringWasAValue || (!(NumberUtils.isCreatable(option) || NumberUtils.isParsable(option))
					&& option.startsWith("-"))) {
				// Current String is option
				if (!previousStringWasAValue) {
					parametersWithValues.put(optionName, "true");
				}

				previousStringWasAValue = false;
				optionName = option.equals("") ? option : option.substring(1, option.length());
			} else {
				// Current String is value
				previousStringWasAValue = true;
				parametersWithValues.put(optionName, option);
			}

		}
		if (!previousStringWasAValue) {
			parametersWithValues.put(optionName,
					Collections.list(handler.getOptions()).get(handler.getOptions().length - 1));
		}

		return parametersWithValues;
	}

	return new HashMap<String, String>(0);
}
 
源代码14 项目: cuba   文件: ActionCustomPropertyLoader.java
protected Object parseNumber(String stringValue, Class<? extends Number> numberType) {
    if (!NumberUtils.isParsable(stringValue)) {
        throw new DevelopmentException(String.format("Unable to parse '%s' as '%s'", stringValue, numberType));
    }
    return org.springframework.util.NumberUtils.parseNumber(stringValue, numberType);
}
 
源代码15 项目: tutorials   文件: IsNumeric.java
public boolean usingNumberUtils_isParsable(String strNum) {
    return NumberUtils.isParsable(strNum);
}