private String name;
private List subPositions = new ArrayList();
public HTMLTargetGroup(HTMLParser htmlparser, HTMLTargetGroup parentGroup, Tag tag) {
int startPos;
Tag previousTag = tag.getPreviousTag();
// Get leading data
if(previousTag == null) {
Tag parentTag;
parentTag = tag.getParent(); // See if there is a parent
if(parentTag != null ) {
startPos = parentTag.getEndPosition() + 1;
this.leadingData = htmlparser.getText(startPos, tag.getStartPosition()-1);
} else {
// This is the first node so the leading data is everything from the beginining of the doc
this.leadingData = htmlparser.getText(0, tag.getStartPosition()-1);
}
} else {
if(previousTag.getEndTag() == null) {
startPos = previousTag.getEndPosition() + 1;
} else {
startPos = previousTag.getEndTag().getEndPosition() > tag.getStartPosition() ?
previousTag.getEndPosition()
: previousTag.getEndTag().getEndPosition();
startPos ++;
}
this.leadingData = htmlparser.getText(startPos, tag.getStartPosition()-1);
}
//this.leadingData = stripTag(this.leadingData, "igroup");
this.name = tag.getAttribute("name");
// Process child tags
Tag childTag;
int childCount = tag.getChildCount();
for(int i = 0; i < childCount; i++) {
addTarget(htmlparser, this, tag.getChildTag(i));
}
// Set trailing data 19/01/08
if(getPositionCount() == 0) {
this.trailingData = htmlparser.getText(tag.getEndPosition() + 1, tag.getEndTag().getStartPosition()-1);
} else {
List childtags = tag.getChildTags();
Tag lastChildTag = (Tag)childtags.get(childtags.size()-1);
//if(getType() == InjectionStreamer.FIELD) {
int start = lastChildTag.getEndTag() == null ? lastChildTag.getEndPosition() + 1 : lastChildTag.getEndTag().getEndPosition() + 1;
this.trailingData = htmlparser.getText(start, tag.getEndTag().getStartPosition()-1);
//}
}
}