/** * For a given URL (optionally quoted), produces CSS URL * where relative paths are fixed and prefixed with offsetPath. */ protected String fixRelativeUrl(String url, final String offsetPath) { url = StringUtil.removeChars(url, "'\""); // remove quotes StringBuilder res = new StringBuilder(); res.append("url('"); if (!url.startsWith(StringPool.SLASH)) { res .append("../") .append(offsetPath); } res.append(url).append("')"); return res.toString(); }
@Override public void comment(CharSequence commentM) { String comment = commentM.toString(); comment = StringUtil.removeChars(comment, "\r\n\t\b"); result.append("com:[").append(comment).append(']').append(NEWLINE); }
@Override public void cdata(CharSequence cdataM) { String cdata = cdataM.toString(); cdata = StringUtil.removeChars(cdata, "\r\n\t\b"); result.append("cdt:[").append(cdata).append(']').append(NEWLINE); }
@Override public void text(CharSequence text) { String t = text.toString(); t = StringUtil.removeChars(t, "\r\n\t\b"); if (t.length() != 0) { result.append("txt:[").append(t).append(']').append(NEWLINE); } }
public PseudoFunctionExpression(String expression) { expression = StringUtil.removeChars(expression, "+ \t\n\r\n"); if (expression.equals("odd")) { a = 2;
protected String html1(Document document) { String html = document.getHtml(); html = StringUtil.removeChars(html, " \r\n\t"); return html; }
protected String strip(String string) { string = StringUtil.removeChars(string, " \r\n\t"); string = StringUtil.replace(string, ">", ">\n"); return string; }
expression = StringUtil.removeChars(expression, "()"); expression = expression.substring(3);
@Override public void script(Tag tag, CharSequence bodyM) { result.append("scr:").append(tag.getDeepLevel()); if (tag.getAttributeCount() > 0) { tag.writeTo(result); } String body = bodyM.toString(); body = StringUtil.removeChars(body, "\r\n\t\b"); result.append('[').append(body).append(']'); result.append(NEWLINE); }
content = StringUtil.removeChars(content, '\r'); String expectedResult = FileUtil.readString(new File(file.getAbsolutePath() + ".txt")); formatted = StringUtil.removeChars(formatted, '\r'); String result2 = results[1]; // tag writer expectedResult = StringUtil.removeChars(expectedResult, '\r'); result = StringUtil.removeChars(result, '\r').trim(); result2 = StringUtil.removeChars(result2, '\r').trim();
@Test void testRemove() { String s = "qwertyq"; assertEquals("qwertyq", StringUtil.remove(s, "W")); assertEquals("qertyq", StringUtil.remove(s, "w")); assertEquals("", StringUtil.remove(s, "qwertyq")); assertEquals("qwertyq", StringUtil.remove(s, "")); assertEquals("werty", StringUtil.remove(s, "q")); assertEquals("qq", StringUtil.remove(s, "werty")); assertEquals("werty", StringUtil.removeChars(s, "q")); assertEquals("werty", StringUtil.remove(s, 'q')); assertEquals(s, StringUtil.remove(s, 'x')); assertEquals("qeryq", StringUtil.removeChars(s, "wt")); assertEquals("qeryq", StringUtil.removeChars(s, 'w', 't')); assertEquals("", StringUtil.removeChars(s, "qwerty".toCharArray())); assertEquals("", StringUtil.removeChars(s, "qwerty")); }
@Test void testUpheaWebXml() throws IOException { File file = new File(testDataRoot, "uphea-web.xml"); String xmlContent = FileUtil.readString(file); LagartoDOMBuilder lagartoDOMBuilder = new LagartoDOMBuilder(); lagartoDOMBuilder.enableXmlMode(); Document doc = lagartoDOMBuilder.parse(xmlContent); xmlContent = StringUtil.removeChars(xmlContent, "\n\r\t"); assertEquals(xmlContent, doc.getHtml()); assertTrue(doc.check()); }
@Test void testConditionalTags() { Jerry.JerryParser jerry = new Jerry.JerryParser(); ((LagartoDOMBuilder) jerry.getDOMBuilder()).getConfig().setIgnoreComments(true); Jerry doc = jerry.parse( "<html>" + " <!--[if lt IE 7]> <body class=\"ie ie6 ie_lte_9 ie_lte_8 ie_lte_7\"> <![endif]-->\n" + " <!--[if IE 7]> <body class=\"ie ie7 ie_lte_9 ie_lte_8 ie_lte_7\"> <![endif]-->\n" + " <!--[if IE 8]> <body class=\"ie ie8 ie_lte_9 ie_lte_8\"> <![endif]-->\n" + " <!--[if IE 9]> <body class=\"ie ie9 ie_lte_9\"> <![endif]-->\n" + " <!--[if gt IE 9]> <body class=\"ie\"> <![endif]-->\n" + " <!--[if !IE]>xxx--><body><!--<![endif]-->\n" + "</body></html>" ); String html = doc.html(); html = StringUtil.removeChars(html, " \n\r"); assertEquals("<html><body></body></html>", html); }
@Test void testConditionalTags2() { Jerry.JerryParser jerry = new Jerry.JerryParser(); ((LagartoDOMBuilder) jerry.getDOMBuilder()).getConfig() .setIgnoreComments(true) .setEnableConditionalComments(true) .setCondCommentIEVersion(8); Jerry doc = jerry.parse( "<html>" + " <!--[if lt IE 7]> <body class=\"ie ie6 ie_lte_9 ie_lte_8 ie_lte_7\"> <![endif]-->\n" + " <!--[if IE 7]> <body class=\"ie ie7 ie_lte_9 ie_lte_8 ie_lte_7\"> <![endif]-->\n" + " <!--[if IE 8]> <body class=\"ie ie8 ie_lte_9 ie_lte_8\"> <![endif]-->\n" + " <!--[if IE 9]> <body class=\"ie ie9 ie_lte_9\"> <![endif]-->\n" + " <!--[if gt IE 9]> <body class=\"ie\"> <![endif]-->\n" + " <!--[if !IE]>xxx--><body><!--<![endif]-->\n" + "</body></html>" ); String html = doc.html(); html = StringUtil.removeChars(html, " \n\r"); assertEquals("<html><bodyclass=\"ieie8ie_lte_9ie_lte_8\"></body></html>", html); }
@Test void testConditionalTags3() { Jerry.JerryParser jerry = new Jerry.JerryParser(); ((LagartoDOMBuilder) jerry.getDOMBuilder()).getConfig() .setIgnoreComments(true) .setEnableConditionalComments(true) .setCondCommentIEVersion(10); Jerry doc = jerry.parse( "<html>" + " <!--[if lt IE 7]> <body class=\"ie ie6 ie_lte_9 ie_lte_8 ie_lte_7\"> <![endif]-->\n" + " <!--[if IE 7]> <body class=\"ie ie7 ie_lte_9 ie_lte_8 ie_lte_7\"> <![endif]-->\n" + " <!--[if IE 8]> <body class=\"ie ie8 ie_lte_9 ie_lte_8\"> <![endif]-->\n" + " <!--[if IE 9]> <body class=\"ie ie9 ie_lte_9\"> <![endif]-->\n" + " <!--[if gt IE 9]> <body class=\"ie\"> <![endif]-->\n" + " <!--[if !IE]><!--> <body> <!--<![endif]--> \n" + "</body></html>" ); String html = doc.html(); html = StringUtil.removeChars(html, " \n\r"); assertEquals("<html><bodyclass=\"ie\"></body></html>", html); } }
@Test void testPeopleXml() throws IOException { File file = new File(testDataRoot, "people.xml"); String xmlContent = FileUtil.readString(file); LagartoDOMBuilder lagartoDOMBuilder = new LagartoDOMBuilder(); lagartoDOMBuilder.enableXmlMode(); Document doc = lagartoDOMBuilder.parse(xmlContent); assertEquals(2, doc.getChildNodesCount()); // not 3! XmlDeclaration xml = (XmlDeclaration) doc.getFirstChild(); assertEquals(0, xml.getAttributesCount()); Element peopleList = (Element) doc.getChild(1); assertEquals(1, peopleList.getChildNodesCount()); Element person = peopleList.getFirstChildElement(); assertEquals(3, person.getChildNodesCount()); Element name = (Element) person.getChild(0); assertEquals("Fred Bloggs", name.getTextContent()); assertEquals("Male", person.getChild(2).getTextContent()); xmlContent = StringUtil.removeChars(xmlContent, "\n\r\t"); assertEquals(xmlContent, doc.getHtml()); assertTrue(doc.check()); }
/** * For a given URL (optionally quoted), produces CSS URL * where relative paths are fixed and prefixed with offsetPath. */ protected String fixRelativeUrl(String url, String offsetPath) { url = StringUtil.removeChars(url, "'\""); // remove quotes StringBuilder res = new StringBuilder(); res.append("url('"); if (url.startsWith(StringPool.SLASH) == false) { res.append("../"); res.append(offsetPath); } res.append(url); res.append("')"); return res.toString(); }
/** * For a given URL (optionally quoted), produces CSS URL * where relative paths are fixed and prefixed with offsetPath. */ protected String fixRelativeUrl(String url, final String offsetPath) { url = StringUtil.removeChars(url, "'\""); // remove quotes StringBuilder res = new StringBuilder(); res.append("url('"); if (!url.startsWith(StringPool.SLASH)) { res .append("../") .append(offsetPath); } res.append(url).append("')"); return res.toString(); }
/** * Returns cause message of a throwable. */ public static String causeMessage(Throwable throwable) { if (throwable == null) { return StringPool.EMPTY; } String message = throwable.getMessage(); if (StringUtil.isEmpty(message)) { return throwable.toString(); } return StringUtil.removeChars(message, '\n', '\r'); }
public PseudoFunctionExpression(String expression) { expression = StringUtil.removeChars(expression, "+ \t\n\r\n"); if (expression.equals("odd")) { a = 2;