Remove deprecated HTML functions and tests

This commit is contained in:
Owen Stephens 2018-11-20 20:21:30 +00:00
parent bae3dbb812
commit 1f023b53af
8 changed files with 0 additions and 364 deletions

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}