keywordCont.setKeywordName(keywordName);
TypeVisitor keywordFinder = new AbstractTypeVisitor() {
public void visitKeywords(Keywords visitee, Object obj) {
KeywordSearchContainer ksc =
(KeywordSearchContainer) obj;
Keyword keyword =
visitee.getKeyword(ksc.getKeywordName());
if (keyword != null) {
ksc.setKeyword(keyword);
}
}
public void visitTypeRef(TypeRef visitee, Object obj) {
TypeDefinition td = getTypeDef(visitee.getReference());
if (td != null) {
Type t = td.getType();
if (t != null) {
t.accept(this, obj);
}
}
}
};
type.accept(keywordFinder, keywordCont);
if (keywordCont.getKeyword() == null) {
System.out.println("Keyword " + keywordName
+ " not found in property "
+ property.getName());
} else {
KeywordReference reference
= definitionsFactory.createKeywordReference();
reference.setKeyword(keywordCont.getKeyword());
container.addValue(reference);
}
} else {
System.out.println(
"Property has no type: could not find keywords");
}
} else if (name.equals("themeDefinition")) {
// Process all the children.
processThemePropertyChildren(element);
} else if (name.equals("choiceType")) {
ChoiceType choiceType = definitionsFactory.createChoiceType();
TypeList typeList = new TypeList();
pushObject(choiceType);
pushObject(typeList);
processThemePropertyChildren(element);
popObject();
popObject();
Iterator it = typeList.getList().iterator();
while (it.hasNext()) {
choiceType.addType((Type) it.next());
}
storeType(choiceType);
} else if (name.equals("pairType")) {
PairType pairType = definitionsFactory.createPairType();
pushObject(pairType);
processThemePropertyChildren(element);
popObject();
storeType(pairType);
} else if (name.equals("fractionType")) {
FractionType fractionType = definitionsFactory.createFractionType();
pushObject(fractionType);
processThemePropertyChildren(element);
popObject();
storeType(fractionType);
} else if (name.equals("first")) {
TypeList typeList = new TypeList();
NameHolder nameHolder = new NameHolder();
pushObject(typeList);
pushObject(nameHolder);
processThemePropertyChildren(element);
popObject();
popObject();
if (!typeList.getList().isEmpty()) {
PairType pair = (PairType) findObject(PairType.class);
pair.setFirst((Type) typeList.getList().get(0));
}
} else if (name.equals("second")) {
TypeList typeList = new TypeList();
NameHolder nameHolder = new NameHolder();
pushObject(typeList);
pushObject(nameHolder);
processThemePropertyChildren(element);
popObject();
popObject();
if (!typeList.getList().isEmpty()) {
PairType pair = (PairType) findObject(PairType.class);
pair.setSecond((Type) typeList.getList().get(0));
}
} else if (name.equals("numerator")) {
TypeList typeList = new TypeList();
NameHolder nameHolder = new NameHolder();
pushObject(typeList);
pushObject(nameHolder);
processThemePropertyChildren(element);
popObject();
popObject();
if (!typeList.getList().isEmpty()) {
FractionType fraction = (FractionType) findObject(FractionType.class);
fraction.setNumerator((Type) typeList.getList().get(0));
}
} else if (name.equals("denominator")) {
TypeList typeList = new TypeList();
NameHolder nameHolder = new NameHolder();
pushObject(typeList);
pushObject(nameHolder);
processThemePropertyChildren(element);
popObject();
popObject();
if (!typeList.getList().isEmpty()) {
FractionType fraction = (FractionType) findObject(FractionType.class);
fraction.setDenominator((Type) typeList.getList().get(0));
}
}else if (name.equals("type")) {
// Process the children in order to find the keyword definitions.
processThemePropertyChildren(element);
} else if (name.equals("typeRef")) {
TypeRef typeRef = definitionsFactory.createTypeRef();
typeRef.setReference(element.getText());
Property property = (Property) findObject(Property.class);
property.setType(typeRef);
} else if (name.equals("keywords")) {
Keywords keywords = definitionsFactory.createKeywords();
pushObject(keywords);
processThemePropertyChildren(element);
popObject();
storeType(keywords);
} else if (name.equals("keyword")) {
// Define a new keyword and add it into the containing set.
Keyword keyword = definitionsFactory.createKeyword();
pushObject(keyword);
processThemePropertyChildren(element);