* @param e the element where {@link JavadocFragment}s will be inserted
*/
public void parseSemanticLineIntoFragments(String line, ModeldocFactory factory,
JavadocTagElement e) {
HandleInlineJavadoc inline = new HandleInlineJavadoc(factory, e);
int pos = 0;
while (true) {
// find a {
int next = line.indexOf('{', pos);
if (next != -1) {
// found one
String text = line.substring(pos, next);
inline.handleText(text);
int next2 = line.indexOf('}', next);
String tag = line.substring(next + 1, next2);
if (tag.startsWith("@") && tag.indexOf(" ") != -1) {
String tagName = tag.substring(0, tag.indexOf(" "));
String tagText = tag.substring(tag.indexOf(" ") + 1);
// if the next two characters are 's ' (i.e. making it
// a plural) then modify appropriately
// e.g. {@model Foo}s -> {@model Foo Foos}
// but not if there is a space within the tag
// '...s ', '...d '
for (char pluralChar : new char[]{'s', 'd'}) {
if (line.length() > next2 + 2) {
if (!tagText.contains(" ")) {
String s2 = line.substring( next2 + 1, next2 + 3 );
if (s2 != null && s2.length() == 2 && s2.charAt(0) == pluralChar && isWordSeperator(s2.charAt(1))) {
next2++; // keep whitespace
// {@foo x#y}s should be considered {@foo x#y ys}, not {@foo x#y x#ys}
String newTagText = tagText;
if (newTagText.contains("#")) {
newTagText = newTagText.substring(newTagText.indexOf("#") + 1);
}
tagText += " " + newTagText + pluralChar;
}
}
}
}
inline.handleTag(tagName, tagText);
} else {
inline.handleText("{" + tag + "}");
}
pos = next2 + 1;
} else {
// found the end; break
break;
}
}
// handle remaining test
String text = line.substring(pos);
inline.handleText(text);
}