|
Lines 32-43
Link Here
|
| 32 |
* Parser for xml bugzilla reports. |
32 |
* Parser for xml bugzilla reports. |
| 33 |
* |
33 |
* |
| 34 |
* @author Rob Elves |
34 |
* @author Rob Elves |
|
|
35 |
* @author Hiroyuki Inaba (internationalization) |
| 35 |
*/ |
36 |
*/ |
| 36 |
public class SaxMultiBugReportContentHandler extends DefaultHandler { |
37 |
public class SaxMultiBugReportContentHandler extends DefaultHandler { |
| 37 |
|
38 |
|
| 38 |
private static final String ATTRIBUTE_NAME = "name"; //$NON-NLS-1$ |
39 |
private static final String ATTRIBUTE_NAME = "name"; //$NON-NLS-1$ |
| 39 |
|
40 |
|
| 40 |
private static final String COMMENT_ATTACHMENT_STRING = Messages.SaxMultiBugReportContentHandler_CREATED_AN_ATTACHEMENT_ID; |
41 |
private static final String ID_STRING_BEGIN = " (id="; //$NON-NLS-1$ |
|
|
42 |
|
| 43 |
private static final String ID_STRING_END = ")"; //$NON-NLS-1$ |
| 41 |
|
44 |
|
| 42 |
private StringBuffer characters; |
45 |
private StringBuffer characters; |
| 43 |
|
46 |
|
|
Lines 574-588
Link Here
|
| 574 |
|
577 |
|
| 575 |
/** determines attachment id from comment */ |
578 |
/** determines attachment id from comment */ |
| 576 |
private void parseAttachment(TaskCommentMapper comment) { |
579 |
private void parseAttachment(TaskCommentMapper comment) { |
| 577 |
|
|
|
| 578 |
String attachmentID = ""; //$NON-NLS-1$ |
580 |
String attachmentID = ""; //$NON-NLS-1$ |
| 579 |
String commentText = comment.getText(); |
581 |
String commentText = comment.getText(); |
| 580 |
if (commentText.startsWith(COMMENT_ATTACHMENT_STRING)) { |
582 |
int firstDelimiter = commentText.indexOf("\n"); //$NON-NLS-1$ |
| 581 |
int endIndex = commentText.indexOf(")"); //$NON-NLS-1$ |
583 |
if (firstDelimiter < 0) { |
| 582 |
if (endIndex > 0 && endIndex < commentText.length()) { |
584 |
firstDelimiter = commentText.length(); |
| 583 |
attachmentID = commentText.substring(COMMENT_ATTACHMENT_STRING.length(), endIndex); |
585 |
} |
| 584 |
if (!attachmentID.equals("")) { //$NON-NLS-1$ |
586 |
int startIndex = commentText.indexOf(ID_STRING_BEGIN); |
| 585 |
attachIdToComment.put(attachmentID, comment); |
587 |
if (startIndex > 0 && startIndex < firstDelimiter) { |
|
|
588 |
int endIndex = commentText.indexOf(ID_STRING_END, startIndex); |
| 589 |
if (endIndex > 0 && endIndex < firstDelimiter) { |
| 590 |
startIndex += ID_STRING_BEGIN.length(); |
| 591 |
int p = startIndex; |
| 592 |
while (p < endIndex) { |
| 593 |
char c = commentText.charAt(p); |
| 594 |
if (c < '0' || c > '9') { |
| 595 |
break; |
| 596 |
} |
| 597 |
p++; |
| 598 |
} |
| 599 |
if (p == endIndex) { |
| 600 |
attachmentID = commentText.substring(startIndex, endIndex); |
| 601 |
if (!attachmentID.equals("")) { //$NON-NLS-1$ |
| 602 |
attachIdToComment.put(attachmentID, comment); |
| 603 |
} |
| 586 |
} |
604 |
} |
| 587 |
} |
605 |
} |
| 588 |
} |
606 |
} |