if (null != label) return new Title(label);
Resource focusType = (Resource) FresnelUtilities.getType(in, focus);
// this is ugly, but to not waste resources, it really needs the 'return' statements to
// return ASAP
LensMatchSet lenses = this._conf.getLensMatches().getMatch(focus);
LensMatchSet instanceLenses = this._conf.getInstanceLensMatches().getMatch(focus);
LensMatchSet classLenses = this._conf.getClassLensMatches().getMatch(focusType);
if (lens) {
if (null != lenses) {
// find label lens for resource
Iterator<Lens> instancesIt = lenses.getInstanceLenses().iterator();
while (instancesIt.hasNext()) {
Lens check = instancesIt.next();
if (check.hasPurpose(new Purpose(FresnelCore.labelLens))) {
AggregateLabel labels = new AggregateLabel(applyLabelLens(check, in, focus, 0, MAXIMUM_LENS_DEPTH));
if (labels.getString().trim().equals(""))
continue;
else
return new Title(labels);
}
}
// find label lens for resource's type
Iterator<Lens> classesIt = lenses.getClassLenses().iterator();
while (classesIt.hasNext()) {
Lens check = classesIt.next();
if (check.hasPurpose(new Purpose(FresnelCore.labelLens))) {
AggregateLabel labels = new AggregateLabel(applyLabelLens(check, in, focus, 0, MAXIMUM_LENS_DEPTH));
if (labels.getString().trim().equals(""))
continue;
else
return new Title(labels);
}
}
}
if (null != instanceLenses) {
// find label lens for resource
Iterator<Lens> instancesIt = instanceLenses.getInstanceLenses().iterator();
while (instancesIt.hasNext()) {
Lens check = instancesIt.next();
if (check.hasPurpose(new Purpose(FresnelCore.labelLens))) {
AggregateLabel labels = new AggregateLabel(applyLabelLens(check, in, focus, 0, MAXIMUM_LENS_DEPTH));
if (labels.getString().trim().equals(""))
continue;
else
return new Title(labels);
}
}
}
if (null != classLenses) {
// find label lens for resource
Iterator<Lens> classesIt = classLenses.getClassLenses().iterator();
while (classesIt.hasNext()) {
Lens check = classesIt.next();
if (check.hasPurpose(new Purpose(FresnelCore.labelLens))) {
AggregateLabel labels = new AggregateLabel(applyLabelLens(check, in, focus, 0, MAXIMUM_LENS_DEPTH));
if (labels.getString().trim().equals(""))