if (!subjects.isEmpty()) {
currentSubject = subjects.get(subjects.size() - 1);
}
} else {
if ("!".equalsIgnoreCase(lexicalUnit.getValue())) {
currentObject = new BlankNodeToken(newBlankNodeId())
.resolve();
currentPredicate = getPredicate(lexicalUnits.get(++i));
this.link(currentSubject, currentPredicate,
currentObject);
currentSubject = currentObject;
nbTokens = 1;
} else if ("^".equalsIgnoreCase(lexicalUnit.getValue())) {
currentObject = currentSubject;
currentPredicate = getPredicate(lexicalUnits.get(++i));
currentSubject = new BlankNodeToken(newBlankNodeId())
.resolve();
this.link(currentSubject, currentPredicate,
currentObject);
nbTokens = 1;
} else {
currentSubject = lexicalUnit.resolve();
subjects.add(currentSubject);
}
}
break;
case 2:
if ("is".equalsIgnoreCase(lexicalUnit.getValue())) {
nbTokens--;
swapSubjectObject = true;
} else if ("has".equalsIgnoreCase(lexicalUnit.getValue())) {
nbTokens--;
} else if ("=".equalsIgnoreCase(lexicalUnit.getValue())) {
currentPredicate = RdfConstants.PREDICATE_SAME;
} else if ("=>".equalsIgnoreCase(lexicalUnit.getValue())) {
currentPredicate = RdfConstants.PREDICATE_IMPLIES;
} else if ("<=".equalsIgnoreCase(lexicalUnit.getValue())) {
swapSubjectObject = true;
currentPredicate = RdfConstants.PREDICATE_IMPLIES;
} else if ("a".equalsIgnoreCase(lexicalUnit.getValue())) {
currentPredicate = RdfConstants.PREDICATE_TYPE;
} else if ("!".equalsIgnoreCase(lexicalUnit.getValue())) {
currentObject = new BlankNodeToken(newBlankNodeId())
.resolve();
currentPredicate = getPredicate(lexicalUnits.get(++i));
this.link(currentSubject, currentPredicate, currentObject);
currentSubject = currentObject;
nbTokens = 1;
} else if ("^".equalsIgnoreCase(lexicalUnit.getValue())) {
currentObject = currentSubject;
currentPredicate = getPredicate(lexicalUnits.get(++i));
currentSubject = new BlankNodeToken(newBlankNodeId())
.resolve();
this.link(currentSubject, currentPredicate, currentObject);
nbTokens = 1;
} else {
currentPredicate = getPredicate(lexicalUnit);
}
break;
case 3:
if ("of".equalsIgnoreCase(lexicalUnit.getValue())) {
nbTokens--;
} else {
// take care of the "path" shorthands.
int j = i + 1;
if (j < lexicalUnits.size() && isPath(lexicalUnits.get(j))) {
if ("!"
.equalsIgnoreCase(lexicalUnits.get(j)
.getValue())) {
// Create a new BlankNode which is the object of the
// current link.
currentObject = new BlankNodeToken(newBlankNodeId())
.resolve();
this.link(currentSubject, currentPredicate,
currentObject);
// Interpret the "!" path
currentPredicate = getPredicate(lexicalUnits
.get(j + 1));
this.link(lexicalUnit.resolve(), currentPredicate,
currentObject);
currentSubject = currentObject;
nbTokens = 0;
i += 2;
} else if ("^".equalsIgnoreCase(lexicalUnits.get(j)
.getValue())) {
// Create a new BlankNode which is the object of the
// current link.
currentObject = new BlankNodeToken(newBlankNodeId())
.resolve();
this.link(currentSubject, currentPredicate,
currentObject);
// Interpret the "^" path