public List<Item> findExistingElements(final String hashmapKey,
final String hashmapValue, final int indexBeforeCurrentWord,
final LuposDocumentReader r, final ILuposParser p) {
final ArrayList<Item> arrayList = new ArrayList<Item>();
if (hashmapKey.equals("<ANON>") || hashmapKey.equals("<NIL>")) {
arrayList.add(new Item(hashmapValue, true));
return arrayList;
}
String description;
if (hashmapKey.equals("<IRI_REF>")) {
description = "URI";
} else if (hashmapKey.equals("<PNAME_LN>")) {
description = "QUALIFIEDURI";
} else if (hashmapKey.startsWith("<STRING_LITERAL")) {
description = "LITERAL";
} else if (hashmapKey.equals("<BLANKNODELABEL>")) {
description = "BLANKNODE";
} else if (hashmapKey.equals("<VAR>")) {
description = "VARIABLE";
} else if (hashmapKey.equals("<INTEGER>")) {
description = "INTEGER";
} else if (hashmapKey.equals("<DECIMAL>")
|| hashmapKey.equals("<DOUBLE>")) {
description = "DECIMAL";
} else {
description = null;
}
if (description != null) {
final String content = r.getText().substring(0,
indexBeforeCurrentWord);
p.setReaderTokenFriendly(r, 0, content.length());
ILuposToken token;
String[] splittedToken;
String tokenElement;
int pos;
while ((token = p.getNextToken(content)) != null) {
splittedToken = token.toString().split(" ");
if (!splittedToken[2].equals("ERROR")) {
if (!splittedToken[9].startsWith("\"")) {
tokenElement = splittedToken[9].toLowerCase();
} else {
pos = token.toString().indexOf("\"");
tokenElement = token
.toString()
.substring(pos,
token.toString().length())
.toLowerCase();
}
if (splittedToken[2].equals(description)
&& !(arrayList.contains(tokenElement))) {
arrayList.add(new Item(tokenElement, true));
}
}
}