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


Java NumberUtils.toLong方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.math.NumberUtils.toLong方法的典型用法代码示例。如果您正苦于以下问题:Java NumberUtils.toLong方法的具体用法?Java NumberUtils.toLong怎么用?Java NumberUtils.toLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.math.NumberUtils的用法示例。


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

示例1: getOidcMaxAgeFromAuthorizationRequest

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
/**
 * Gets oidc max age from authorization request.
 *
 * @param context the context
 * @return the oidc max age from authorization request
 */
public static Optional<Long> getOidcMaxAgeFromAuthorizationRequest(final WebContext context) {
    final URIBuilder builderContext = new URIBuilder(context.getFullRequestURL());
    final Optional<URIBuilder.BasicNameValuePair> parameter = builderContext.getQueryParams()
            .stream().filter(p -> OidcConstants.MAX_AGE.equals(p.getName()))
            .findFirst();

    if (parameter.isPresent()) {
        final long maxAge = NumberUtils.toLong(parameter.get().getValue(), -1);
        return Optional.of(maxAge);
    }
    return Optional.empty();
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:19,代码来源:OidcAuthorizationRequestSupport.java

示例2: getBigFileThreshold

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
public static final Long getBigFileThreshold() {
  if (bigFileThreshold == null) {
    String bigThresholdValue = configure.get("filecloud.bigfile-threshold");
    if (StringUtils.isNotBlank(bigThresholdValue) && NumberUtils.isNumber(bigThresholdValue.trim())) {
      bigFileThreshold = NumberUtils.toLong(bigThresholdValue.trim());
    } else {
      bigFileThreshold = DEFAULT_BIG_FILE_THRESHOLD;
    }
  }
  return bigFileThreshold;
}
 
开发者ID:devpage,项目名称:fastdfs-quickstart,代码行数:12,代码来源:Constants.java

示例3: getFileExpireTimeLength

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
public static final Long getFileExpireTimeLength() {
  if (fileExpireTimeLength == null) {
    String fileExpireTimeValue = configure.get("filecloud.file-expire-time-length");
    if (StringUtils.isNotBlank(fileExpireTimeValue) && NumberUtils.isNumber(fileExpireTimeValue.trim())) {
      fileExpireTimeLength = NumberUtils.toLong(fileExpireTimeValue.trim());
    } else {
      fileExpireTimeLength = DEFAULT_FILE_EXPIRE_SECONDS;
    }
  }
  return fileExpireTimeLength;
}
 
开发者ID:devpage,项目名称:fastdfs-quickstart,代码行数:12,代码来源:Constants.java

示例4: getProtocolMaxSize

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
public static final Long getProtocolMaxSize() {
  if (protocolMaxSize == null) {
    String protocolMaxsizeValue = configure.get("filecloud.protocol-maxsize");
    if (StringUtils.isNotBlank(protocolMaxsizeValue) && NumberUtils.isNumber(protocolMaxsizeValue.trim())) {
      protocolMaxSize = NumberUtils.toLong(protocolMaxsizeValue.trim());
    } else {
      protocolMaxSize = DEFAULT_PROTOCOL_MAXSIZE;
    }
  }
  return protocolMaxSize;
}
 
开发者ID:devpage,项目名称:fastdfs-quickstart,代码行数:12,代码来源:Constants.java

示例5: getMinExpireTimeLength

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
public static Long getMinExpireTimeLength() {
  if (minExpireTimeLength == null) {
    String minExpireTime = configure.get("filecloud.min-expire-time-length");
    if (StringUtils.isNotBlank(minExpireTime) && NumberUtils.isNumber(minExpireTime)) {
      minExpireTimeLength = NumberUtils.toLong(minExpireTime);
      if (minExpireTimeLength < 600) {
        minExpireTimeLength = 600L;
      }
    } else {
      minExpireTimeLength = 600L;
    }
  }
  return minExpireTimeLength;
}
 
开发者ID:devpage,项目名称:fastdfs-quickstart,代码行数:15,代码来源:Constants.java

示例6: getOrCreate

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
private BloomFilter<Seed> getOrCreate(String segment) {
    BloomFilter<Seed> seedBloomFilter = bloomFilters.get(segment);
    if (seedBloomFilter != null) {
        return seedBloomFilter;
    }
    synchronized (segment.intern()) {
        seedBloomFilter = bloomFilters.get(segment);
        if (seedBloomFilter != null) {
            return seedBloomFilter;
        }

        long expectedNumber = NumberUtils.toLong(VSCrawlerContext.vsCrawlerConfigFileWatcher.loadedProperties()
                .getProperty(VSCrawlerConstant.VSCRAWLER_SEED_MANAGER_EXPECTED_SEED_NUMBER), 1000000L);

        // any way, build a filter instance if not exist
        seedBloomFilter = BloomFilter.create(new Funnel<Seed>() {
            @Override
            public void funnel(Seed from, PrimitiveSink into) {
                into.putString(seedKeyResolver.resolveSeedKey(from), Charset.defaultCharset());
            }
        }, expectedNumber);

        bloomFilters.put(segment, seedBloomFilter);
    }
    return seedBloomFilter;
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:27,代码来源:BerkeleyDBSeedManager.java

示例7: getLong

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
public Long getLong() {
    String value = super.get();
    return value == null ? null : NumberUtils.toLong(value);
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:5,代码来源:RedisNumber.java

示例8: compareVersion

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
/**
 * Compares <code>version</code> to <code>value</code> version and value are strings like
 * 1.9.2.0 Returns <code>0</code> if either <code>version</code> or <code>value</code> is null.
 *
 * @param version String like 1.9.2.0
 * @param value   String like 1.9.2.0
 * @return the value <code>0</code> if <code>version</code> is equal to the argument
 * <code>value</code>; a value less than <code>0</code> if <code>version</code> is
 * numerically less than the argument <code>value</code>; and a value greater than
 * <code>0</code> if <code>version</code> is numerically greater than the argument
 * <code>value</code>
 * @should correctly comparing two version numbers
 * @should treat SNAPSHOT as earliest version
 */
public static int compareVersion(String version, String value) {
	try {
		if (version == null || value == null) {
			return 0;
		}
		
		List<String> versions = new Vector<String>();
		List<String> values = new Vector<String>();
		String separator = "-";
		
		// strip off any qualifier e.g. "-SNAPSHOT"
		int qualifierIndex = version.indexOf(separator);
		if (qualifierIndex != -1) {
			version = version.substring(0, qualifierIndex);
		}
		
		qualifierIndex = value.indexOf(separator);
		if (qualifierIndex != -1) {
			value = value.substring(0, qualifierIndex);
		}
		
		Collections.addAll(versions, version.split("\\."));
		Collections.addAll(values, value.split("\\."));
		
		// match the sizes of the lists
		while (versions.size() < values.size()) {
			versions.add("0");
		}
		while (values.size() < versions.size()) {
			values.add("0");
		}
		
		for (int x = 0; x < versions.size(); x++) {
			String verNum = versions.get(x).trim();
			String valNum = values.get(x).trim();
			Long ver = NumberUtils.toLong(verNum, 0);
			Long val = NumberUtils.toLong(valNum, 0);
			
			int ret = ver.compareTo(val);
			if (ret != 0) {
				return ret;
			}
		}
	}
	catch (NumberFormatException e) {
		log.error("Error while converting a version/value to an integer: " + version + "/" + value, e);
	}
	
	// default return value if an error occurs or elements are equal
	return 0;
}
 
开发者ID:openmrs,项目名称:openmrs-contrib-addonindex,代码行数:66,代码来源:OpenmrsVersionCompareUtil.java

示例9: toLong

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
/**
 * 将10进制的String安全的转化为long,当str为空或非数字字符串时,返回0
 */
public static long toLong(String str) {
	return NumberUtils.toLong(str, 0L);
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:7,代码来源:NumberUtil.java

示例10: getNumericValue

import org.apache.commons.lang3.math.NumberUtils; //导入方法依赖的package包/类
/**
 * @param v search term
 * @return the long value of v if it is a number
 */
static Object getNumericValue(String v) {
	return NumberUtils.isDigits(v) ? NumberUtils.toLong(v, 0) : v;
}
 
开发者ID:Erudika,项目名称:para-search-elasticsearch,代码行数:8,代码来源:ElasticSearchUtils.java


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