* @throws SearchException If the term node is null.
*/
private Query convertTermNode(AttrPlusTermNode rpnTermNode)
throws SearchException {
if (rpnTermNode == null) {
throw new SearchException("AttrPlusTermNode is null");
}
//LOGGER.finer("query attrset = " + query.toRPN().getAttrset());
LOGGER.finer("attrplus term node = " + rpnTermNode);
//unsure of if this should be true or false, determines if we quote
//phrases or not. Need to look at what our code is doing, if they help.
String term = rpnTermNode.getTermAsString(false);
if (term == null) {
throw new SearchException("term passed in is null");
}
term = term.toLowerCase();
//to lower case for case insensitivity, to mimic our Analyzer
Enumeration _enum = rpnTermNode.getAttrEnum();
String useVal = GeoProfile.Attribute.ANY; //default is any.
int relation = GeoProfile.EQUALS; //default is equals.
boolean truncation = false; //default is no truncation.
boolean matchAll = false;
while (_enum.hasMoreElements()) {
AttrTriple triple = (AttrTriple) _enum.nextElement();
String attrVal = triple.getAttrVal().toString();
switch (triple.getAttrType().intValue()) {
case GeoProfile.USE:
useVal = attrVal;
break;
case GeoProfile.RELATION:
relation = Integer.parseInt(attrVal);
break;
case GeoProfile.STRUCTURE:
if (attrVal.equals(GeoProfile.Attribute.ALWAYS)) {
matchAll = true;
}
break;
//REVISIT: currently we treat everything as
//a string, decide what to do based on the use value.
case GeoProfile.TRUNCATION:
truncation = (attrVal.equals(GeoProfile.TRUNCATE));
break;
default:
break;
}
}
LOGGER.finer("use val = " + useVal);
String searchField = attrMap.getProperty(useVal.toString());
if (searchField == null) {
throw new SearchException("Unsupported Use Attribute - " + useVal,
GeoProfile.Diag.UNSUPPORTED_ATTR);
}
LOGGER.finest("search field is " + searchField);