本文整理汇总了Java中org.apache.lucene.document.NumberTools类的典型用法代码示例。如果您正苦于以下问题:Java NumberTools类的具体用法?Java NumberTools怎么用?Java NumberTools使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NumberTools类属于org.apache.lucene.document包,在下文中一共展示了NumberTools类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFieldValue
import org.apache.lucene.document.NumberTools; //导入依赖的package包/类
/**
*
* @return value most responsible for this document being a match
*/
public String getFieldValue() {
String fieldName = getFieldName();
Field f = doc.getField(fieldName);
if (f == null) {
StringBuffer sb = new StringBuffer();
sb.append("[length=" + terms.length + "; ");
for (Object o : terms) {
sb.append(o + ", ");
}
sb.append("]");
log.info("Unable to get matchingFieldValue for field : " + fieldName +
" with query: " + query + ", and terms = " + sb.toString());
log.info("Document = " + doc);
return "";
}
String value = f.stringValue();
if (needNumberToolsAdjust.containsKey(fieldName)) {
Long temp = NumberTools.stringToLong(value);
value = temp.toString();
}
return value;
}
示例2: doubleFromIndexableString
import org.apache.lucene.document.NumberTools; //导入依赖的package包/类
/**
* Reverts an indexable String back to a double value.
* @param value the indexable string to revert
* @return the double value
*/
protected static Double doubleFromIndexableString(String value, int precision) {
try {
long lValue = NumberTools.stringToLong(value);
long lConversionFactor = (long)Math.pow((double)10,(double)precision);
return (double)lValue / lConversionFactor;
} catch (NumberFormatException e) {
return null;
}
}
示例3: 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);
}
}
示例4: longFromIndexableString
import org.apache.lucene.document.NumberTools; //导入依赖的package包/类
/**
* Reverts an indexable String back to a long value.
* @param value the indexable string to revert
* @return the long value
*/
protected static Long longFromIndexableString(String value) {
try {
long lValue = NumberTools.stringToLong(value);
return lValue;
} catch (NumberFormatException e) {
return null;
}
}
示例5: 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);
}
}
示例6: 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);
}
示例7: 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;
}
}
示例8: 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;
}
}
示例9: 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;
}
}
示例10: 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;
}
}
示例11: 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;
}
}