*/
public class NicoXMLReader extends DefaultHandler {
- private final Packet Packet;
+ private final Packet packet;
+ private final Pattern ngWord;
+ private final Pattern ngId;
private Chat item;
- private boolean item_kicked;
- private final Pattern NG_Word;
- private final Pattern NG_ID;
+ private boolean itemKicked;
public NicoXMLReader(Packet packet, String ng_id, String ng_word) {
- Packet = packet;
- NG_Word = makePattern(ng_word);
- NG_ID = makePattern(ng_id);
+ this.packet = packet;
+ this.ngWord = makePattern(ng_word);
+ this.ngId = makePattern(ng_id);
}
private static Pattern makePattern(String word) {
if (qName.equalsIgnoreCase("chat")) {
// System.out.println("----------");
item = new Chat();
- item_kicked = false;
+ itemKicked = false;
//マイメモリ削除対象
final String deleted = attributes.getValue("deleted");
if (deleted != null && deleted.equalsIgnoreCase("1")) {
- item_kicked = true;
+ itemKicked = true;
return;
}
item.setDate(attributes.getValue("date"));
final String mail = attributes.getValue("mail");
- if (match(NG_Word, mail)) {
- item_kicked = true;
+ if (match(ngWord, mail)) {
+ itemKicked = true;
return;
}
item.setMail(mail);
item.setNo(attributes.getValue("no"));
final String user_id = attributes.getValue("user_id");
- if (match(NG_ID, user_id)) {
- item_kicked = true;
+ if (match(ngId, user_id)) {
+ itemKicked = true;
return;
}
item.setUserID(user_id);
}
if (item != null) {
final String com = new String(input);
- if (match(NG_Word, com)) {
- item_kicked = true;
+ if (match(ngWord, com)) {
+ itemKicked = true;
return;
}
item.setComment(com);
@Override
public void endElement(final String uri, final String localName, final String qName) {
if (qName.equalsIgnoreCase("chat")) {
- if (!item_kicked) {
- Packet.addChat(item);
+ if (!itemKicked) {
+ packet.addChat(item);
}
item = null;
}