List<ReplacerComponent<?,?>> replacerComps =
componentManager.getReplacerComponents();
do{
//get the text
EditableText inputText = inputComp.getInput(uiComp);
if (inputText != null){
/* TODO: change to collection,
* decide: all or only one given to next replacer?
* (currently only the one with index #0)
*/
EditableText[] textArray = new EditableText[1];
textArray[0] = inputText;
//perform replacements
for (ReplacerComponent replacer : replacerComps) {
if (textArray != null && textArray.length > 0) {
EditableText[] resultArray
= replacer.edit(textArray[0], uiComp);
if (resultArray == null) {
textArray = null; //quit replacement chain
break;
} else {
EditableText[] newTextArray
= new EditableText[textArray.length-1+resultArray.length];
for (int i=0; i<textArray.length-1; i++) {
newTextArray[i] = textArray[i+1];
}
for (int j=0; j<resultArray.length; j++) {
newTextArray[textArray.length-1+j] = resultArray[j];
}
textArray = newTextArray;
}
}
}
if (textArray != null) {
for (EditableText textFromArray : textArray) {
if (outputUnchangedTexts
|| !textFromArray.getText()
.equals(inputText.getText())
){
//output results
((OutputComponent<EditableText>)outputComp).output(textFromArray, uiComp);