Stricter re number of arguments for parseXml/Html and clearer err msgs
This commit is contained in:
parent
1f023b53af
commit
d144a5dccf
@ -48,7 +48,7 @@ public class InnerHtml implements Function {
|
||||
|
||||
@Override
|
||||
public Object call(Properties bindings, Object[] args) {
|
||||
if (args.length >= 1) {
|
||||
if (args.length == 1) {
|
||||
Object o1 = args[0];
|
||||
if (o1 != null && o1 instanceof Element) {
|
||||
return new InnerXml().call(bindings, args, "html");
|
||||
@ -56,7 +56,7 @@ public class InnerHtml implements Function {
|
||||
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;
|
||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects a single String as an argument");
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,7 +37,6 @@ import java.util.Properties;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONWriter;
|
||||
import org.jsoup.Jsoup;
|
||||
|
||||
import com.google.refine.expr.EvalError;
|
||||
import com.google.refine.expr.functions.xml.ParseXml;
|
||||
|
@ -47,17 +47,17 @@ public class OwnText implements Function {
|
||||
|
||||
@Override
|
||||
public Object call(Properties bindings, Object[] args) {
|
||||
if (args.length >= 1) {
|
||||
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 new EvalError(ControlFunctionRegistry.getFunctionName(this) + " failed as the first parameter is not an XML or HTML Element. Please first use parseHtml(string) and select(query) prior to using this function");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects a single XML or HTML element as an argument");
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class XmlAttr implements Function {
|
||||
|
||||
@Override
|
||||
public Object call(Properties bindings, Object[] args) {
|
||||
if (args.length >= 2) {
|
||||
if (args.length == 2) {
|
||||
Object o1 = args[0];
|
||||
Object o2 = args[1];
|
||||
if (o1 != null && o1 instanceof Element) {
|
||||
@ -59,7 +59,7 @@ public class XmlAttr implements Function {
|
||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " failed as the first parameter is not an XML or HTML Element. Please first use parseXml() or parseHtml() and select() prior to using this function");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects two arguments");
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class XmlText implements Function {
|
||||
|
||||
@Override
|
||||
public Object call(Properties bindings, Object[] args) {
|
||||
if (args.length >= 1) {
|
||||
if (args.length == 1) {
|
||||
Object o1 = args[0];
|
||||
if (o1 != null && o1 instanceof Element) {
|
||||
Element e1 = (Element)o1;
|
||||
@ -57,7 +57,7 @@ public class XmlText implements Function {
|
||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " failed as the first parameter is not an XML or HTML Element. Please first use parseXml() or parseHtml() and select(query) prior to using this function");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects a single XML or HTML element as an argument");
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user