@Override public Token getNextToken() { ++this.currentIndex; char ch = '\0'; while (this.page.hasNextChar()) { ch = this.page.getCurChar(); if (this.isIgnoredMode) { final TokenIgnoreTagValueImpl ignoredTagValue = this.getIgnoredTagValue(); ignoredTagValue.setIndex(this.currentIndex); return ignoredTagValue; } if (ch == '<') { final char chNext = this.page.getChar(this.page.getCurrentCursorPosition() + 1); if (chNext == '!') { final TokenCommentImpl tComment = this.getTokenComment(); tComment.setIndex(this.currentIndex); return tComment; } final TokenTagImpl tToken = this.getTag(); if (tToken != null) { if (!tToken.isClosedTag()) { this.latestTag = tToken; if (this.isIgnoreValueTag(tToken)) { this.isIgnoredMode = true; } } else if (this.latestTag != null && this.latestTag.getTagName().equalsIgnoreCase(tToken.getTagName())) { this.latestTag = null; } } tToken.setIndex(this.currentIndex); return tToken; } else if (ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t') { this.page.getNextChar(); } else { if (this.latestTag == null) { final TokenTextImpl tText = this.getTokenText(null); tText.setIndex(this.currentIndex); return tText; } if (this.latestTag.getTagName().equalsIgnoreCase("script") || this.latestTag.getTagName().equalsIgnoreCase("style")) { final TokenIgnoreTagValueImpl ignoredTagValue = this.getIgnoredTagValue(); ignoredTagValue.setIndex(this.currentIndex); return ignoredTagValue; } final TokenTextImpl tText = this.getTokenText(null); tText.setIndex(this.currentIndex); return tText; } } return null; }
@SuppressWarnings("unchecked") @Override public TokenText parse() throws CommonException { StringBuffer sb = new StringBuffer(); this.parsedText = ""; char ch; // while((ch = this.page.getNextChar()) != PageSource.EOS) while ((ch = this.page.getCurChar()) != PageSource.EOS) { if (ch == '<') { if (this.parentTokenTag != null) // script value에 의한 주석처리 { String tagName = this.parentTokenTag.getTagName(); if (tagName.equalsIgnoreCase("script")) { int startIndex = this.page.getCurrentCursorPosition() + 2; String strPreCon = this.page.getSubString(startIndex, startIndex + "/script".length()); if (strPreCon.indexOf("script") > -1 || strPreCon.indexOf("SCRIPT") > -1) { // this.page.setCursor(-1); this.parsedText = sb.toString(); // return ; break; } else { sb.append(ch); this.page.getNextChar(); } } } else // 일반 Tag는 무시처리 { // this.page.setCursor(-1); this.parsedText = sb.toString(); // return ; break; } } else { // System.out.println("CH:" + ch); sb.append(ch); this.page.getNextChar(); } } TokenTextImpl tti = new TokenTextImpl(); tti.setValueText(this.parsedText); return tti; }