in remoting/server/web/type.web.api/src/org/netbeans/modules/jackpot30/backend/type/api/Base.java [46:103]
protected <T> String doFind(String segment, String prefix, boolean casesensitive, String queryKindName, String fieldPrefix, Convertor<Document, Entry<String, T>> conv) throws IOException, InterruptedException {
//copied (and converted to NameKind) from jumpto's GoToTypeAction:
boolean exact = prefix.endsWith(" "); // NOI18N
prefix = prefix.trim();
if ( prefix.length() == 0) {
return "";
}
QueryKind queryKind = null;
if (queryKindName != null) {
for (QueryKind k : QueryKind.values()) {
if (queryKindName.equals(k.name())) {
queryKind = k;
}
}
//TODO: what to do? currently autoguess, but might also return an error
}
if (queryKind == null) {
int wildcard = Utils.containsWildCard(prefix);
if (exact) {
//nameKind = panel.isCaseSensitive() ? SearchType.EXACT_NAME : SearchType.CASE_INSENSITIVE_EXACT_NAME;
queryKind = QueryKind.EXACT;
}
else if ((Utils.isAllUpper(prefix) && prefix.length() > 1) || Queries.isCamelCase(prefix, null, null)) {
queryKind = QueryKind.CAMEL_CASE;
}
else if (wildcard != -1) {
queryKind = casesensitive ? QueryKind.REGEXP : QueryKind.CASE_INSENSITIVE_REGEXP;
}
else {
queryKind = casesensitive ? QueryKind.PREFIX : QueryKind.CASE_INSENSITIVE_PREFIX;
}
}
CategoryStorage category = CategoryStorage.forId(segment);
Index index = category.getIndex();
List<Query> queries = new ArrayList<Query>(2);
queries.add(Queries.createQuery(fieldPrefix + "SimpleName", fieldPrefix + "SimpleNameLower", prefix, queryKind));
if (queryKind == QueryKind.CAMEL_CASE) {
queries.add(Queries.createQuery(fieldPrefix + "SimpleName", fieldPrefix + "SimpleNameLower", prefix, QueryKind.CASE_INSENSITIVE_PREFIX));
}
List<Entry<String, T>> found = new ArrayList<Entry<String, T>>();
//TODO: field selector:
index.query(found, conv, null, new AtomicBoolean(), queries.toArray(new Query[queries.size()]));
return Pojson.save(Utilities.sortBySourceRoot(found, category));
}