Improve documentation of reinterpret GREL function (#3315)
* add clarity for reinterpret docs Helps fix #3292 * update reinterpret docs phrasing We agreed to use "encoding" to be friendly to user exposed messaging instead of "encoder" and "decoder" that is used internally. * fix serializeReinterpret() test json
This commit is contained in:
parent
692b533f68
commit
6c9ad3f31d
@ -66,7 +66,7 @@ public class Reinterpret implements Function {
|
|||||||
return reinterpret(str, decoder, encoder);
|
return reinterpret(str, decoder, encoder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects 2 or 3 arguments");
|
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects String to reinterpret with a given target encoding and optional source encoding");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object reinterpret(String str, String decoder, String encoder) {
|
private Object reinterpret(String str, String decoder, String encoder) {
|
||||||
@ -89,7 +89,7 @@ public class Reinterpret implements Function {
|
|||||||
result = new String(bytes, encoder);
|
result = new String(bytes, encoder);
|
||||||
}
|
}
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + ": encoding '" + encoder + "' is not available or recognized.");
|
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + ": target encoding '" + encoder + "' is not available or recognized.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -97,12 +97,12 @@ public class Reinterpret implements Function {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return "Returns s reinterpreted thru the given encoder.";
|
return "Returns s reinterpreted using a target encoding and optional source encoding.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getParams() {
|
public String getParams() {
|
||||||
return "string s, string encoder";
|
return "string s, string target encoding, string source encoding";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,7 +33,7 @@ import com.google.refine.util.TestUtils;
|
|||||||
public class ReinterpretTests {
|
public class ReinterpretTests {
|
||||||
@Test
|
@Test
|
||||||
public void serializeReinterpret() {
|
public void serializeReinterpret() {
|
||||||
String json = "{\"description\":\"Returns s reinterpreted thru the given encoder.\",\"params\":\"string s, string encoder\",\"returns\":\"string\"}";
|
String json = "{\"description\":\"Returns s reinterpreted using a target encoding and optional source encoding.\",\"params\":\"string s, string target encoding, string source encoding\",\"returns\":\"string\"}";
|
||||||
TestUtils.isSerializedTo(new Reinterpret(), json);
|
TestUtils.isSerializedTo(new Reinterpret(), json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user