本文整理汇总了Java中org.apache.lucene.document.NumberTools.longToString方法的典型用法代码示例。如果您正苦于以下问题:Java NumberTools.longToString方法的具体用法?Java NumberTools.longToString怎么用?Java NumberTools.longToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.document.NumberTools
的用法示例。
在下文中一共展示了NumberTools.longToString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doubleToIndexableString
import org.apache.lucene.document.NumberTools; //导入方法依赖的package包/类
/**
* Converts a double value to a String that can be indexed for search.
* @param value the value to convert
* @return the indexable string
*/
protected static String doubleToIndexableString(Double value, int precision) {
if (value == null) {
return null;
} else {
long lConversionFactor = (long)Math.pow((double)10,(double)precision);
long lValue = Math.round(lConversionFactor * value);
return NumberTools.longToString(lValue);
}
}
示例2: longToIndexableString
import org.apache.lucene.document.NumberTools; //导入方法依赖的package包/类
/**
* Converts a long value to a String that can be indexed for search.
* @param value the value to convert
* @return the indexable string
*/
protected static String longToIndexableString(Long value) {
if (value == null) {
return null;
} else {
return NumberTools.longToString(value);
}
}
示例3: getRangeQuery
import org.apache.lucene.document.NumberTools; //导入方法依赖的package包/类
/**
* This will look to see if "part1" or "part2" are strings of all digits,
* if they are, then they will be converted to a lexicographically safe string
* representation, then passed into the inherited getRangeQuery(). This is needed when
* comparing something like "4" to be less than "10".
* If the strings don't fit the pattern of all digits, then they get passed through
* to the inherited getRangeQuery().
*/
protected Query getRangeQuery(String field,
String part1,
String part2,
boolean inclusive) throws ParseException {
if (isDate(part1) && isDate(part2)) {
if (log.isDebugEnabled()) {
log.debug("Detected passed in terms are dates, creating " +
"ConstantScoreRangeQuery(" + field + ", " + part1 + ", " +
part2 + ", " + inclusive + ", " + inclusive);
}
return new ConstantScoreRangeQuery(field, part1, part2, inclusive,
inclusive);
}
String newPart1 = part1;
String newPart2 = part2;
String regEx = "(\\d)*";
Pattern pattern = Pattern.compile(regEx);
Matcher matcher1 = pattern.matcher(part1);
Matcher matcher2 = pattern.matcher(part2);
if (matcher1.matches() && matcher2.matches()) {
newPart1 = NumberTools.longToString(Long.parseLong(part1));
newPart2 = NumberTools.longToString(Long.parseLong(part2));
if (log.isDebugEnabled()) {
log.debug("NGramQueryParser.getRangeQuery() Converted " + part1 + " to " +
newPart1 + ", Converted " + part2 + " to " + newPart2);
}
}
return super.getRangeQuery(field, newPart1, newPart2, inclusive);
}
示例4: setCpuBogoMIPS
import org.apache.lucene.document.NumberTools; //导入方法依赖的package包/类
/**
* @param cpuBogoMIPSIn the cpuBogoMIPS to set
*/
public void setCpuBogoMIPS(String cpuBogoMIPSIn) {
if (cpuBogoMIPSIn != null) {
Float f = Float.parseFloat(cpuBogoMIPSIn);
this.cpuBogoMIPS = NumberTools.longToString(f.longValue());
}
else {
this.cpuBogoMIPS = null;
}
}
示例5: setCpuMHz
import org.apache.lucene.document.NumberTools; //导入方法依赖的package包/类
/**
* @param cpuMHzIn the cpuMHz to set
*/
public void setCpuMHz(String cpuMHzIn) {
if (cpuMHzIn != null) {
this.cpuMHz = NumberTools.longToString(Long.parseLong(cpuMHzIn));
}
else {
this.cpuMHz = null;
}
}
示例6: setCpuNumberOfCpus
import org.apache.lucene.document.NumberTools; //导入方法依赖的package包/类
/**
* @param cpuNumberOfCpusIn the cpuNumberOfCpus to set
*/
public void setCpuNumberOfCpus(String cpuNumberOfCpusIn) {
if (cpuNumberOfCpusIn != null) {
this.cpuNumberOfCpus =
NumberTools.longToString(Long.parseLong(cpuNumberOfCpusIn));
}
else {
this.cpuNumberOfCpus = null;
}
}
示例7: setRam
import org.apache.lucene.document.NumberTools; //导入方法依赖的package包/类
/**
* @param ramIn the ram to set
*/
public void setRam(String ramIn) {
if (ramIn != null) {
this.ram = NumberTools.longToString(Long.parseLong(ramIn));
}
else {
this.ram = null;
}
}
示例8: setSwap
import org.apache.lucene.document.NumberTools; //导入方法依赖的package包/类
/**
* @param swapIn the swap to set
*/
public void setSwap(String swapIn) {
if (swapIn != null) {
this.swap = NumberTools.longToString(Long.parseLong(swapIn));
}
else {
this.swap = null;
}
}