use of org.openntf.domino.types.CaseInsensitiveString in project org.openntf.domino by OpenNTF.
the class DocumentScanner method processValue.
public void processValue(final CaseInsensitiveString name, final Object value, final String address) {
if (value instanceof CharSequence) {
String chkVal = value.toString();
if (DominoUtils.isUnid(chkVal) || DominoUtils.isReplicaId(chkVal) || DominoUtils.isMetaversalId(chkVal) || DominoUtils.isNumber(chkVal)) {
// System.out.println("TEMP DEBUG skipping processing on value of '" + chkVal + "'");
return;
}
}
if (value instanceof String) {
String val = (String) value;
Scanner s = new Scanner(val);
s.useDelimiter(REGEX_NONALPHANUMERIC);
while (s.hasNext()) {
CharSequence token = scrubToken(s.next(), caseSensitive_);
if (token != null && (token.length() > 2) && !isStopped(token)) {
tokenCount_++;
processToken(token, name, address);
}
}
s.close();
}
if (isTrackFieldValues()) {
Map<CharSequence, NavigableSet<Comparable>> vmap = getFieldValueMap();
NavigableSet<Comparable> valueSet = null;
if (!vmap.containsKey(name)) {
valueSet = new ConcurrentSkipListSet<Comparable>();
vmap.put(name, valueSet);
} else {
valueSet = vmap.get(name);
}
Comparable c = TypeUtils.toComparable(value);
if (c != null) {
valueSet.add(c);
}
}
if (isTrackValueLocation()) {
Map<CharSequence, Set<CharSequence>> tlval = getValueLocationMap(String.valueOf(value));
if (tlval.containsKey(name)) {
Set<CharSequence> tllist = tlval.get(name);
tllist.add(address);
} else {
Set<CharSequence> tllist = new ConcurrentSkipListSet<CharSequence>();
tllist.add(address);
tlval.put(name, tllist);
}
}
}
use of org.openntf.domino.types.CaseInsensitiveString in project org.openntf.domino by OpenNTF.
the class DocumentScanner method processName.
protected void processName(final CharSequence name, final CharSequence itemName, final Session session, final String address) {
Map<CharSequence, Integer> tfmap = getTokenFreqMap();
Map<CharSequence, NavigableSet<CharSequence>> tmap = getFieldTokenMap();
NavigableSet<CharSequence> tokenSet = null;
if (!tmap.containsKey(itemName)) {
tokenSet = new ConcurrentSkipListSet<CharSequence>();
tmap.put(itemName, tokenSet);
} else {
tokenSet = tmap.get(itemName);
}
tokenSet.add(name);
if (DominoUtils.isHierarchicalName(name.toString())) {
CharSequence cn = caseSensitive_ ? DominoUtils.toCommonName(name.toString()) : new CaseInsensitiveString(DominoUtils.toCommonName(name.toString()));
tokenSet.add(cn);
if (tfmap.containsKey(cn)) {
tfmap.put(cn, tfmap.get(cn) + 1);
} else {
tfmap.put(cn, 1);
}
if (isTrackNameLocation()) {
Map<CharSequence, Set<CharSequence>> tlval = getNameLocationMap(name.toString());
if (tlval.containsKey(itemName)) {
Set<CharSequence> tllist = tlval.get(itemName);
tllist.add(address);
} else {
Set<CharSequence> tllist = new ConcurrentSkipListSet<CharSequence>();
tllist.add(address);
tlval.put(itemName, tllist);
}
}
} else {
CharSequence lname = caseSensitive_ ? name : new CaseInsensitiveString(name);
if (tfmap.containsKey(lname)) {
tfmap.put(lname, tfmap.get(lname) + 1);
} else {
tfmap.put(lname, 1);
}
}
if (this.isSplitNameTokens()) {
if (name instanceof String) {
String val = (String) name;
try (Scanner s = new Scanner(val)) {
s.useDelimiter(REGEX_NONALPHANUMERIC);
while (s.hasNext()) {
CharSequence token = scrubToken(s.next(), caseSensitive_);
if (token != null && (token.length() > 2) && !isStopped(token)) {
tokenCount_++;
processToken(token, itemName, address);
}
}
}
}
}
if (isTrackFieldValues()) {
Map<CharSequence, NavigableSet<Comparable>> vmap = getFieldValueMap();
NavigableSet<Comparable> valueSet = null;
if (!vmap.containsKey(name)) {
valueSet = new ConcurrentSkipListSet<Comparable>();
vmap.put(name, valueSet);
} else {
valueSet = vmap.get(name);
}
valueSet.add(name.toString());
}
}
use of org.openntf.domino.types.CaseInsensitiveString in project org.openntf.domino by OpenNTF.
the class DocumentScanner method scrubToken.
public static CharSequence scrubToken(final String token, final boolean caseSensitive) {
// Matcher puncMatch = REGEX_PUNCTUATION.matcher(token);
// String result = puncMatch.replaceAll("");
Matcher pMatch = REGEX_PREFIX_TRIM.matcher(token);
// $NON-NLS-1$
String result = pMatch.replaceAll("");
Matcher sMatch = REGEX_SUFFIX_TRIM.matcher(result);
// $NON-NLS-1$
result = sMatch.replaceAll("");
result = result.trim();
if (DominoUtils.isHex(result)) {
return null;
}
return caseSensitive ? result : new CaseInsensitiveString(result.toLowerCase());
}
use of org.openntf.domino.types.CaseInsensitiveString in project org.openntf.domino by OpenNTF.
the class IndexDatabase method restoreTokenLocationMap.
/* (non-Javadoc)
* @see org.openntf.domino.big.impl.IIndexDatabase#restoreTokenLocationMap(java.lang.CharSequence, java.lang.Object)
*/
@Override
public Map<CharSequence, Set<CharSequence>> restoreTokenLocationMap(final CharSequence token, final Object mapKey) {
Map result = null;
Document doc = getTermDocument(token.toString());
String itemName = TERM_MAP_PREFIX + String.valueOf(mapKey);
if (doc.hasItem(itemName)) {
result = doc.getItemValue(itemName, Map.class);
} else {
result = new ConcurrentHashMap<CaseInsensitiveString, Set<String>>(8, 0.9f, 1);
}
return result;
}
use of org.openntf.domino.types.CaseInsensitiveString in project org.openntf.domino by OpenNTF.
the class IndexDatabase method getTermUnidInItems.
/* (non-Javadoc)
* @see org.openntf.domino.big.impl.IIndexDatabase#getTermUnidInItems(java.lang.CharSequence, java.util.Collection)
*/
@Override
public Set<CharSequence> getTermUnidInItems(final CharSequence term, final Collection<String> itemNames) {
Set<CharSequence> unids = new HashSet<CharSequence>();
Document doc = getTermDocument(term);
for (Item item : doc.getItems()) {
String itemName = item.getName();
if (itemName.startsWith(TERM_MAP_PREFIX)) {
// String dbid = itemName.substring(TERM_MAP_PREFIX.length());
Map termMap = doc.getItemValue(itemName, Map.class);
for (String key : itemNames) {
CaseInsensitiveString ciskey = new CaseInsensitiveString(key);
Object termObj = termMap.get(ciskey);
if (termObj != null) {
if (termObj instanceof Collection) {
unids.addAll((Collection) termObj);
} else if (termObj instanceof CharSequence) {
unids.add(((CharSequence) termObj).toString());
} else {
unids.add(String.valueOf(termObj));
}
}
}
}
}
return unids;
}
Aggregations