From 1f023b53af490d2a28e7cb135d8d8560a4254baa Mon Sep 17 00:00:00 2001 From: Owen Stephens Date: Tue, 20 Nov 2018 20:21:30 +0000 Subject: [PATCH] Remove deprecated HTML functions and tests --- .../refine/expr/functions/html/HtmlAttr.java | 77 ------------------- .../refine/expr/functions/html/HtmlText.java | 75 ------------------ .../refine/expr/functions/html/OwnText.java | 75 ------------------ .../expr/functions/html/SelectHtml.java | 77 ------------------- .../expr/functions/html/HtmlAttrTests.java | 15 ---- .../expr/functions/html/HtmlTextTests.java | 15 ---- .../expr/functions/html/OwnTextTests.java | 15 ---- .../expr/functions/html/SelectHtmlTests.java | 15 ---- 8 files changed, 364 deletions(-) delete mode 100644 main/src/com/google/refine/expr/functions/html/HtmlAttr.java delete mode 100644 main/src/com/google/refine/expr/functions/html/HtmlText.java delete mode 100644 main/src/com/google/refine/expr/functions/html/OwnText.java delete mode 100644 main/src/com/google/refine/expr/functions/html/SelectHtml.java delete mode 100644 main/tests/server/src/com/google/refine/tests/expr/functions/html/HtmlAttrTests.java delete mode 100644 main/tests/server/src/com/google/refine/tests/expr/functions/html/HtmlTextTests.java delete mode 100644 main/tests/server/src/com/google/refine/tests/expr/functions/html/OwnTextTests.java delete mode 100644 main/tests/server/src/com/google/refine/tests/expr/functions/html/SelectHtmlTests.java diff --git a/main/src/com/google/refine/expr/functions/html/HtmlAttr.java b/main/src/com/google/refine/expr/functions/html/HtmlAttr.java deleted file mode 100644 index 139567ef9..000000000 --- a/main/src/com/google/refine/expr/functions/html/HtmlAttr.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - -Copyright 2010, Google Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -package com.google.refine.expr.functions.html; - -import java.util.Properties; - -import org.json.JSONException; -import org.json.JSONWriter; -import org.jsoup.nodes.Element; - -import com.google.refine.expr.EvalError; -import com.google.refine.grel.ControlFunctionRegistry; -import com.google.refine.grel.Function; - -public class HtmlAttr implements Function { - - @Override - public Object call(Properties bindings, Object[] args) { - if (args.length >= 2) { - Object o1 = args[0]; - Object o2 = args[1]; - if (o1 != null && o1 instanceof Element) { - Element e1 = (Element)o1; - if(o2 != null && o2 instanceof String){ - return e1.attr(o2.toString()); - } - }else{ - return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " failed as the first parameter is not an HTML Element. Please first use parseHtml(string) and select(query) prior to using this function"); - } - } - return null; - } - - - @Override - public void write(JSONWriter writer, Properties options) - throws JSONException { - - writer.object(); - writer.key("description"); writer.value("Selects a value from an attribute on an Html Element"); - writer.key("params"); writer.value("Element e, String s"); - writer.key("returns"); writer.value("String attribute Value"); - writer.endObject(); - } -} - diff --git a/main/src/com/google/refine/expr/functions/html/HtmlText.java b/main/src/com/google/refine/expr/functions/html/HtmlText.java deleted file mode 100644 index 0f0d2b382..000000000 --- a/main/src/com/google/refine/expr/functions/html/HtmlText.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - -Copyright 2010,2011 Google Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -package com.google.refine.expr.functions.html; - -import java.util.Properties; - -import org.json.JSONException; -import org.json.JSONWriter; -import org.jsoup.nodes.Element; - -import com.google.refine.expr.EvalError; -import com.google.refine.grel.ControlFunctionRegistry; -import com.google.refine.grel.Function; - -public class HtmlText implements Function { - - @Override - public Object call(Properties bindings, Object[] args) { - if (args.length >= 1) { - Object o1 = args[0]; - if (o1 != null && o1 instanceof Element) { - Element e1 = (Element)o1; - return e1.text(); - - }else{ - return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " failed as the first parameter is not an HTML Element. Please first use parseHtml(string) and select(query) prior to using this function"); - } - } - return null; - } - - - @Override - public void write(JSONWriter writer, Properties options) - throws JSONException { - - writer.object(); - writer.key("description"); writer.value("Selects the text from within an element (including all child elements)"); - writer.key("params"); writer.value("Element e"); - writer.key("returns"); writer.value("String text"); - writer.endObject(); - } -} - diff --git a/main/src/com/google/refine/expr/functions/html/OwnText.java b/main/src/com/google/refine/expr/functions/html/OwnText.java deleted file mode 100644 index eda388251..000000000 --- a/main/src/com/google/refine/expr/functions/html/OwnText.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - -Copyright 2011, Google Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -package com.google.refine.expr.functions.html; - -import java.util.Properties; - -import org.json.JSONException; -import org.json.JSONWriter; -import org.jsoup.nodes.Element; - -import com.google.refine.expr.EvalError; -import com.google.refine.grel.ControlFunctionRegistry; -import com.google.refine.grel.Function; - -public class OwnText implements Function { - - @Override - public Object call(Properties bindings, Object[] args) { - if (args.length >= 1) { - Object o1 = args[0]; - if (o1 != null && o1 instanceof Element) { - Element e1 = (Element)o1; - return e1.ownText(); - - }else{ - return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " failed as the first parameter is not an HTML Element. Please first use parseHtml(string) and select(query) prior to using this function"); - } - } - return null; - } - - - @Override - public void write(JSONWriter writer, Properties options) - throws JSONException { - - writer.object(); - writer.key("description"); writer.value("Gets the text owned by this HTML element only; does not get the combined text of all children."); - writer.key("params"); writer.value("Element e"); - writer.key("returns"); writer.value("String ownText"); - writer.endObject(); - } -} - diff --git a/main/src/com/google/refine/expr/functions/html/SelectHtml.java b/main/src/com/google/refine/expr/functions/html/SelectHtml.java deleted file mode 100644 index 114e7bd74..000000000 --- a/main/src/com/google/refine/expr/functions/html/SelectHtml.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - -Copyright 2010, Google Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ - -package com.google.refine.expr.functions.html; - -import java.util.Properties; - -import org.json.JSONException; -import org.json.JSONWriter; -import org.jsoup.nodes.Element; - -import com.google.refine.expr.EvalError; -import com.google.refine.grel.ControlFunctionRegistry; -import com.google.refine.grel.Function; - -public class SelectHtml implements Function { - - @Override - public Object call(Properties bindings, Object[] args) { - if (args.length >= 2) { - Object o1 = args[0]; - Object o2 = args[1]; - if (o1 != null && o1 instanceof Element) { - Element e1 = (Element)o1; - if(o2 != null && o2 instanceof String){ - return e1.select(o2.toString()); - } - }else{ - return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " failed as the first parameter is not an HTML Element. Please first use parseHtml(string)"); - } - } - return null; - } - - - @Override - public void write(JSONWriter writer, Properties options) - throws JSONException { - - writer.object(); - writer.key("description"); writer.value("Selects an element from an HTML element using selector syntax"); - writer.key("params"); writer.value("Element e, String s"); - writer.key("returns"); writer.value("HTML Elements"); - writer.endObject(); - } -} - diff --git a/main/tests/server/src/com/google/refine/tests/expr/functions/html/HtmlAttrTests.java b/main/tests/server/src/com/google/refine/tests/expr/functions/html/HtmlAttrTests.java deleted file mode 100644 index a73b22ebc..000000000 --- a/main/tests/server/src/com/google/refine/tests/expr/functions/html/HtmlAttrTests.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.google.refine.tests.expr.functions.html; - -import org.testng.annotations.Test; - -import com.google.refine.expr.functions.html.HtmlAttr; -import com.google.refine.tests.util.TestUtils; - -public class HtmlAttrTests { - @Test - public void serializeHtmlAttr() { - String json = "{\"description\":\"Selects a value from an attribute on an Html Element\",\"params\":\"Element e, String s\",\"returns\":\"String attribute Value\"}"; - TestUtils.isSerializedTo(new HtmlAttr(), json); - } -} - diff --git a/main/tests/server/src/com/google/refine/tests/expr/functions/html/HtmlTextTests.java b/main/tests/server/src/com/google/refine/tests/expr/functions/html/HtmlTextTests.java deleted file mode 100644 index af0ea8678..000000000 --- a/main/tests/server/src/com/google/refine/tests/expr/functions/html/HtmlTextTests.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.google.refine.tests.expr.functions.html; - -import org.testng.annotations.Test; - -import com.google.refine.expr.functions.html.HtmlText; -import com.google.refine.tests.util.TestUtils; - -public class HtmlTextTests { - @Test - public void serializeHtmlText() { - String json = "{\"description\":\"Selects the text from within an element (including all child elements)\",\"params\":\"Element e\",\"returns\":\"String text\"}"; - TestUtils.isSerializedTo(new HtmlText(), json); - } -} - diff --git a/main/tests/server/src/com/google/refine/tests/expr/functions/html/OwnTextTests.java b/main/tests/server/src/com/google/refine/tests/expr/functions/html/OwnTextTests.java deleted file mode 100644 index 8eb8bb01e..000000000 --- a/main/tests/server/src/com/google/refine/tests/expr/functions/html/OwnTextTests.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.google.refine.tests.expr.functions.html; - -import org.testng.annotations.Test; - -import com.google.refine.expr.functions.html.OwnText; -import com.google.refine.tests.util.TestUtils; - -public class OwnTextTests { - @Test - public void serializeOwnText() { - String json = "{\"description\":\"Gets the text owned by this HTML element only; does not get the combined text of all children.\",\"params\":\"Element e\",\"returns\":\"String ownText\"}"; - TestUtils.isSerializedTo(new OwnText(), json); - } -} - diff --git a/main/tests/server/src/com/google/refine/tests/expr/functions/html/SelectHtmlTests.java b/main/tests/server/src/com/google/refine/tests/expr/functions/html/SelectHtmlTests.java deleted file mode 100644 index 351dd91bc..000000000 --- a/main/tests/server/src/com/google/refine/tests/expr/functions/html/SelectHtmlTests.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.google.refine.tests.expr.functions.html; - -import org.testng.annotations.Test; - -import com.google.refine.expr.functions.html.SelectHtml; -import com.google.refine.tests.util.TestUtils; - -public class SelectHtmlTests { - @Test - public void serializeSelectHtml() { - String json = "{\"description\":\"Selects an element from an HTML element using selector syntax\",\"params\":\"Element e, String s\",\"returns\":\"HTML Elements\"}"; - TestUtils.isSerializedTo(new SelectHtml(), json); - } -} -