Author: jdonnerstag Date: Sat Mar 19 19:49:32 2011 New Revision: 1083268 URL: http://svn.apache.org/viewvc?rev=1083268&view=rev Log: refactor: extract constant
Modified: wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/parser/XmlPullParser.java Modified: wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/parser/XmlPullParser.java URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/parser/XmlPullParser.java?rev=1083268&r1=1083267&r2=1083268&view=diff ============================================================================== --- wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/parser/XmlPullParser.java (original) +++ wicket/trunk/wicket-core/src/main/java/org/apache/wicket/markup/parser/XmlPullParser.java Sat Mar 19 19:49:32 2011 @@ -40,6 +40,12 @@ import org.apache.wicket.util.resource.R */ public final class XmlPullParser implements IXmlPullParser { + /** */ + public static final String STYLE = "style"; + + /** */ + public static final String SCRIPT = "script"; + /** * Reads the xml data from an input stream and converts the chars according to its encoding * (<?xml ... encoding="..." ?>) @@ -136,7 +142,8 @@ public final class XmlPullParser impleme lastPos = input.find('>', lastPos + tagNameLen); if (lastPos == -1) { - throw new ParseException("Script tag not closed" + getLineAndColumnText(), startIndex); + throw new ParseException(skipUntilText + " tag not closed" + getLineAndColumnText(), + startIndex); } // Reset the state variable @@ -241,21 +248,20 @@ public final class XmlPullParser impleme // It must be an open tag type = TagType.OPEN; - // If open tag and starts with "s" like "script" or "style", than - // ... - if ((tagText.length() > 5) && + // If open tag and starts with "s" like "script" or "style", than ... + if ((tagText.length() > STYLE.length()) && ((tagText.charAt(0) == 's') || (tagText.charAt(0) == 'S'))) { final String lowerCase = tagText.substring(0, 6).toLowerCase(); - if (lowerCase.startsWith("script")) + if (lowerCase.startsWith(SCRIPT)) { // prepare to skip everything between the open and close tag - skipUntilText = "script"; + skipUntilText = SCRIPT; } - else if (lowerCase.startsWith("style")) + else if (lowerCase.startsWith(STYLE)) { // prepare to skip everything between the open and close tag - skipUntilText = "style"; + skipUntilText = STYLE; } } }