Map mdhMap = new HashMap();
Iterator mdhItr = mdhCol.iterator();
while (mdhItr.hasNext())
{
MetaDataHit mdh = (MetaDataHit) mdhItr.next();
for (int i = 0; i < iv_textMetaFieldNames.length; i++)
{
String text = mdh.getMetaFieldValue(iv_textMetaFieldNames[i]);
if (text != null)
{
text = text.toLowerCase();
Set mdhSet = (Set) mdhMap.get(text);
if (mdhSet == null)
{
mdhSet = new HashSet();
}
mdhSet.add(mdh);
mdhMap.put(text, mdhSet);
}
else
{
if (iv_logger.isDebugEnabled())
{
iv_logger.debug("MetaField "
+ iv_textMetaFieldNames[i]
+ " contains no data.");
}
}
}
}
LookupToken firstWordLookupToken = (LookupToken) wLookupTokenList.get(firstTokenIndex.intValue());
Iterator permItr = permCol.iterator();
while (permItr.hasNext())
{
// convert permutation idx back into LookupTokens
List tempList = new ArrayList();
List permutation = (List) permItr.next();
Iterator idxItr = permutation.iterator();
while (idxItr.hasNext())
{
int idx = ((Integer) idxItr.next()).intValue();
if (idx <= firstTokenIndex.intValue())
{
idx--;
}
LookupToken lt = (LookupToken) wLookupTokenList.get(idx);
tempList.add(lt);
}
List singleTokenList = new ArrayList();
singleTokenList.add(firstWordLookupToken);
String[] fwPerms = iv_phrBuilder.getPhrases(singleTokenList);
String[] phrArr = iv_phrBuilder.getPhrases(tempList);
for (int i = 0; i < phrArr.length; i++)
{
for (int fwPermIdx = 0; fwPermIdx < fwPerms.length; fwPermIdx++)
{
StringBuffer phraseSB = new StringBuffer();
phraseSB.append(fwPerms[fwPermIdx]);
phraseSB.append(' ');
phraseSB.append(phrArr[i]);
String phrase = phraseSB.toString().trim().toLowerCase();
Set mdhSet = (Set) mdhMap.get(phrase);
if (mdhSet != null)
{
Iterator mdhIterator = mdhSet.iterator();
while (mdhIterator.hasNext())
{
MetaDataHit mdh = (MetaDataHit) mdhIterator.next();
// figure out start and end offsets
Collections.sort(permutation);
int startOffset;
if (permutation.size() > 0)