}
else{
int minHitCount = 1;
int maxCount = 5;
boolean expand=false;
FacetSortSpec sort = FacetSortSpec.OrderHitsDesc;
try{
minHitCount = Integer.parseInt(valParts[0]);
}
catch(Exception e){
System.out.println("default min hitcount = 1 is applied.");
}
try{
maxCount = Integer.parseInt(valParts[1]);
}
catch(Exception e){
System.out.println("default maxCount = 5 is applied.");
}
try{
expand =Boolean.parseBoolean(valParts[2]);
}
catch(Exception e){
System.out.println("default expand=false is applied.");
}
if ("hits".equals(valParts[3])){
sort = FacetSortSpec.OrderHitsDesc;
}
else{
sort = FacetSortSpec.OrderValueAsc;
}
_reqBuilder.applyFacetSpec(name, minHitCount, maxCount, expand, sort);
}
}
catch(Exception e){
e.printStackTrace();
}
}
}
else if ("select".equalsIgnoreCase(cmd)){
if (parsed.length<2){
System.out.println("selection not defined.");
}
else{
try{
String selString = parsed[1];
String[] parts = selString.split(":");
String name = parts[0];
String selList = parts[1];
String[] sels = selList.split(",");
for (String sel : sels){
boolean isNot=false;
String val = sel;
if (sel.startsWith("!")){
isNot=true;
val = sel.substring(1);
}
if (val!=null && val.length() > 0){
_reqBuilder.addSelection(name, val, isNot);
}
}
}
catch(Exception e){
e.printStackTrace();
}
}
}
else if ("page".equalsIgnoreCase(cmd)){
try{
String pageString = parsed[1];
String[] parts = pageString.split(":");
_reqBuilder.setOffset(Integer.parseInt(parts[0]));
_reqBuilder.setCount(Integer.parseInt(parts[1]));
}
catch(Exception e){
e.printStackTrace();
}
}
else if ("clearFacetSpec".equalsIgnoreCase(cmd)){
if (parsed.length<2){
System.out.println("facet spec not defined.");
}
else{
String name = parsed[1];
_reqBuilder.clearFacetSpec(name);
}
}
else if ("clearSelection".equalsIgnoreCase(cmd)){
if (parsed.length<2){
System.out.println("selection name not defined.");
}
else{
String name = parsed[1];
_reqBuilder.clearSelection(name);
}
}
else if ("clearSelections".equalsIgnoreCase(cmd)){
_reqBuilder.clearSelections();
}
else if ("clearFacetSpecs".equalsIgnoreCase(cmd)){
_reqBuilder.clearFacetSpecs();
}
else if ("clear".equalsIgnoreCase(cmd)){
_reqBuilder.clear();
}
else if ("showReq".equalsIgnoreCase(cmd)){
BrowseRequest req = _reqBuilder.getRequest();
System.out.println(req.toString());
}
else if ("sort".equalsIgnoreCase(cmd)){
if (parsed.length == 2){
String sortString = parsed[1];
String[] sorts = sortString.split(",");
ArrayList<SortField> sortList = new ArrayList<SortField>();
for (String sort : sorts){
String[] sortParams = sort.split(":");
boolean rev = false;
if (sortParams.length>0){
String sortName = sortParams[0];
if (sortParams.length>1){
try{