本文整理汇总了Java中com.thetransactioncompany.jsonrpc2.JSONRPC2Error类的典型用法代码示例。如果您正苦于以下问题:Java JSONRPC2Error类的具体用法?Java JSONRPC2Error怎么用?Java JSONRPC2Error使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSONRPC2Error类属于com.thetransactioncompany.jsonrpc2包,在下文中一共展示了JSONRPC2Error类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: call
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
@Override
public void call(final Subscriber<? super EthSyncingResponse> sub) {
Callback<EthSyncingResponse> ethSyncingCallback = new Callback<EthSyncingResponse>() {
@Override
public void onResult(EthSyncingResponse ethSyncingResult) {
Timber.d("onResult(): %s", ethSyncingResult);
sub.onNext(ethSyncingResult);
// sub.onCompleted();
}
@Override
public void onError(JSONRPC2Error error) {
Timber.d("onError(): %s", error.getMessage());
}
};
while (!sub.isUnsubscribed()) {
gethService.ethSyncing(ethSyncingCallback);
SystemClock.sleep(10000);
}
}
开发者ID:biafra23,项目名称:EtherWallet,代码行数:22,代码来源:MainActivity.java
示例2: ensureEnumString
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
/**
* Throws a {@code JSONRPC2Error.INVALID_PARAMS} exception if the input
* string doesn't match a value in the specified string array.
*
* <p>This method is intended to check a string against a set of
* acceptable values.
*
* @param input The string to check.
* @param enumStrings The acceptable string values.
* @param ignoreCase {@code true} for a case insensitive match.
*
* @return The matching string value.
*
* @throws JSONRPC2Error With proper code and message if the input
* string didn't match.
*/
protected static String ensureEnumString(final String input, final String[] enumStrings, final boolean ignoreCase)
throws JSONRPC2Error {
for (String en : enumStrings) {
if (ignoreCase) {
if (en.toLowerCase().equals(input.toLowerCase()))
return en;
}
else {
if (en.equals(input))
return en;
}
}
// No match -> raise error
throw JSONRPC2Error.INVALID_PARAMS;
}
开发者ID:i2p,项目名称:i2p.plugins.i2pcontrol,代码行数:35,代码来源:ParamsRetriever.java
示例3: validateAPIVersion
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
/**
* Validate the provided I2PControl API version against the ones supported by I2PControl.
*/
private static JSONRPC2Error validateAPIVersion(Object api) {
Integer apiVersion;
try {
apiVersion = ((Long) api).intValue();
} catch (ClassCastException e) {
e.printStackTrace();
return JSONRPC2ExtendedError.UNSPECIFIED_API_VERSION;
}
if (!I2PControlVersion.SUPPORTED_API_VERSIONS.contains(apiVersion)) {
String supportedAPIVersions = "";
for (Integer i : I2PControlVersion.SUPPORTED_API_VERSIONS) {
supportedAPIVersions += ", " + i;
}
return new JSONRPC2Error(JSONRPC2ExtendedError.UNSUPPORTED_API_VERSION.getCode(),
"The provided API version \'" + apiVersion + "\' is not supported. The supported versions are" + supportedAPIVersions + ".");
}
return null;
}
开发者ID:i2p,项目名称:i2p.plugins.i2pcontrol,代码行数:24,代码来源:AuthenticateHandler.java
示例4: process
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
public JSONRPC2Response process(JSONRPC2Request req, MessageContext ctx) {
if (req.getMethod().equals("Echo")) {
JSONRPC2Error err = JSONRPC2Helper.validateParams(requiredArgs, req);
if (err != null)
return new JSONRPC2Response(err, req.getID());
HashMap inParams = (HashMap) req.getParams();
String echo = (String) inParams.get("Echo");
Map outParams = new HashMap();
outParams.put("Result", echo);
return new JSONRPC2Response(outParams, req.getID());
}
else {
// Method name not supported
return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID());
}
}
开发者ID:i2p,项目名称:i2p.plugins.i2pcontrol,代码行数:18,代码来源:EchoHandler.java
示例5: getBooleanArray
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
/**
* Retrieves the specified boolean array (maps from JSON array of
* true/false values) parameter.
*
* @param name The parameter name.
*
* @return The parameter value as a boolean array.
*
* @throws JSONRPC2Error On a missing parameter, bad type or
* {@code null} value
* ({@link JSONRPC2Error#INVALID_PARAMS}).
*/
public boolean[] getBooleanArray(final String name)
throws JSONRPC2Error {
try {
List list = getList(name);
boolean[] booleanArray = new boolean[list.size()];
for (int i = 0; i < list.size(); i++) {
booleanArray[i] = (Boolean)list.get(i);
}
return booleanArray;
} catch (ClassCastException e) {
throw JSONRPC2Error.INVALID_PARAMS;
}
}
开发者ID:i2p,项目名称:i2p.plugins.i2pcontrol,代码行数:30,代码来源:NamedParamsRetriever.java
示例6: getIntArray
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
/**
* Retrieves the specified integer array (maps from JSON array of
* integer numbers) parameter.
*
* @param name The parameter name.
*
* @return The parameter value as an int array.
*
* @throws JSONRPC2Error On a missing parameter, bad type or
* {@code null} value
* ({@link JSONRPC2Error#INVALID_PARAMS}).
*/
public int[] getIntArray(final String name)
throws JSONRPC2Error {
try {
List list = getList(name);
int[] intArray = new int[list.size()];
for (int i = 0; i < list.size(); i++) {
Number number = (Number)list.get(i);
intArray[i] = number.intValue();
}
return intArray;
} catch (ClassCastException e) {
throw JSONRPC2Error.INVALID_PARAMS;
}
}
开发者ID:i2p,项目名称:i2p.plugins.i2pcontrol,代码行数:31,代码来源:NamedParamsRetriever.java
示例7: getLongArray
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
/**
* Retrieves the specified long array (maps from JSON array of integer
* numbers) parameter.
*
* @param name The parameter name.
*
* @return The parameter value as a long array.
*
* @throws JSONRPC2Error On a missing parameter, bad type or
* {@code null} value
* ({@link JSONRPC2Error#INVALID_PARAMS}).
*/
public long[] getLongArray(final String name)
throws JSONRPC2Error {
try {
List list = getList(name);
long[] longArray = new long[list.size()];
for (int i = 0; i < list.size(); i++) {
Number number = (Number)list.get(i);
longArray[i] = number.longValue();
}
return longArray;
} catch (ClassCastException e) {
throw JSONRPC2Error.INVALID_PARAMS;
}
}
开发者ID:i2p,项目名称:i2p.plugins.i2pcontrol,代码行数:31,代码来源:NamedParamsRetriever.java
示例8: getFloatArray
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
/**
* Retrieves the specified float array (maps from JSON array of
* fraction numbers) parameter.
*
* @param name The parameter name.
*
* @return The parameter value as a float array.
*
* @throws JSONRPC2Error On a missing parameter, bad type or
* {@code null} value
* ({@link JSONRPC2Error#INVALID_PARAMS}).
*/
public float[] getFloatArray(final String name)
throws JSONRPC2Error {
try {
List list = getList(name);
float[] floatArray = new float[list.size()];
for (int i = 0; i < list.size(); i++) {
Number number = (Number)list.get(i);
floatArray[i] = number.floatValue();
}
return floatArray;
} catch (ClassCastException e) {
throw JSONRPC2Error.INVALID_PARAMS;
}
}
开发者ID:i2p,项目名称:i2p.plugins.i2pcontrol,代码行数:31,代码来源:NamedParamsRetriever.java
示例9: getDoubleArray
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
/**
* Retrieves the specified double array (maps from JSON array of
* fraction numbers) parameter.
*
* @param name The parameter name.
*
* @return The parameter value as a double array.
*
* @throws JSONRPC2Error On a missing parameter, bad type or
* {@code null} value
* ({@link JSONRPC2Error#INVALID_PARAMS}).
*/
public double[] getDoubleArray(final String name)
throws JSONRPC2Error {
try {
List list = getList(name);
double[] doubleArray = new double[list.size()];
for (int i = 0; i < list.size(); i++) {
Number number = (Number)list.get(i);
doubleArray[i] = number.doubleValue();
}
return doubleArray;
} catch (ClassCastException e) {
throw JSONRPC2Error.INVALID_PARAMS;
}
}
开发者ID:i2p,项目名称:i2p.plugins.i2pcontrol,代码行数:31,代码来源:NamedParamsRetriever.java
示例10: ensureParameter
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
/**
* Throws a {@code JSONRPC2Error.INVALID_PARAMS} exception if there is
* no parameter at the specified position or its type doesn't map to the
* specified.
*
* <p>You may use this method to fire the proper JSON-RPC 2.0 error
* on a missing or badly-typed mandatory parameter.
*
* @param position The parameter position.
* @param clazz The corresponding Java class that the parameter
* should map to (any one of the return types of the
* {@code getXXX()} getter methods. Set to
* {@code Object.class} to allow any type.
* @param allowNull If {@code true} allows a {@code null} parameter
* value.
*
* @throws JSONRPC2Error On a missing parameter or bad type
* ({@link JSONRPC2Error#INVALID_PARAMS}).
*/
public void ensureParameter(final int position, final Class clazz, final boolean allowNull)
throws JSONRPC2Error {
// First, check existence only
ensureParameter(position);
// Now check type
Object value = params.get(position);
if (value == null) {
if (allowNull)
return; // ok
else
throw JSONRPC2Error.INVALID_PARAMS;
}
if (! clazz.isAssignableFrom(value.getClass()))
throw JSONRPC2Error.INVALID_PARAMS;
}
开发者ID:i2p,项目名称:i2p.plugins.i2pcontrol,代码行数:41,代码来源:PositionalParamsRetriever.java
示例11: getDoubleArray
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
/**
* Retrieves the specified double array (maps from JSON array of fraction
* numbers) parameter.
*
* @param position The parameter position.
*
* @return The parameter value as a double array.
*
* @throws JSONRPC2Error On a missing parameter, bad type or
* {@code null} value
* ({@link JSONRPC2Error#INVALID_PARAMS}).
*/
public double[] getDoubleArray(final int position)
throws JSONRPC2Error {
try {
List list = getList(position);
double[] doubleArray = new double[list.size()];
for (int i = 0; i < list.size(); i++) {
Number number = (Number)list.get(i);
doubleArray[i] = number.doubleValue();
}
return doubleArray;
} catch (ClassCastException e) {
throw JSONRPC2Error.INVALID_PARAMS;
}
}
开发者ID:i2p,项目名称:i2p.plugins.i2pcontrol,代码行数:31,代码来源:PositionalParamsRetriever.java
示例12: getBooleanArray
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
/**
* Retrieves the specified boolean array (maps from JSON array of
* true/false values) parameter.
*
* @param position The parameter position.
*
* @return The parameter value as a boolean array.
*
* @throws JSONRPC2Error On a missing parameter, bad type or
* {@code null} value
* ({@link JSONRPC2Error#INVALID_PARAMS}).
*/
public boolean[] getBooleanArray(final int position)
throws JSONRPC2Error {
try {
List list = getList(position);
boolean[] booleanArray = new boolean[list.size()];
for (int i = 0; i < list.size(); i++) {
booleanArray[i] = (Boolean)list.get(i);
}
return booleanArray;
} catch (ClassCastException e) {
throw JSONRPC2Error.INVALID_PARAMS;
}
}
开发者ID:i2p,项目名称:i2p.plugins.i2pcontrol,代码行数:30,代码来源:PositionalParamsRetriever.java
示例13: getIntArray
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
/**
* Retrieves the specified integer array (maps from JSON array of integer
* numbers) parameter.
*
* @param position The parameter position.
*
* @return The parameter value as an int array.
*
* @throws JSONRPC2Error On a missing parameter, bad type or
* {@code null} value
* ({@link JSONRPC2Error#INVALID_PARAMS}).
*/
public int[] getIntArray(final int position)
throws JSONRPC2Error {
try {
List list = getList(position);
int[] intArray = new int[list.size()];
for (int i = 0; i < list.size(); i++) {
Number number = (Number)list.get(i);
intArray[i] = number.intValue();
}
return intArray;
} catch (ClassCastException e) {
throw JSONRPC2Error.INVALID_PARAMS;
}
}
开发者ID:i2p,项目名称:i2p.plugins.i2pcontrol,代码行数:31,代码来源:PositionalParamsRetriever.java
示例14: getLongArray
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
/**
* Retrieves the specified long array (maps from JSON array of integer
* numbers) parameter.
*
* @param position The parameter position.
*
* @return The parameter value as a long array.
*
* @throws JSONRPC2Error On a missing parameter, bad type or
* {@code null} value
* ({@link JSONRPC2Error#INVALID_PARAMS}).
*/
public long[] getLongArray(final int position)
throws JSONRPC2Error {
try {
List list = getList(position);
long[] longArray = new long[list.size()];
for (int i = 0; i < list.size(); i++) {
Number number = (Number)list.get(i);
longArray[i] = number.longValue();
}
return longArray;
} catch (ClassCastException e) {
throw JSONRPC2Error.INVALID_PARAMS;
}
}
开发者ID:i2p,项目名称:i2p.plugins.i2pcontrol,代码行数:31,代码来源:PositionalParamsRetriever.java
示例15: testSendJsonRpcRequest_ResponseIsNotSuccessful
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
@Test
public void testSendJsonRpcRequest_ResponseIsNotSuccessful() throws Exception {
String url = "http://localhost:8080/Identities.php";
Class<?> responseClass = GetEventDataVO.class;
String method = "method1";
Map<String, Object> params = new HashMap<>();
params.put("param1", "value1");
URL mockUrl = PowerMockito.mock(URL.class);
JSONRPC2Session mockJSONRPC2Session = PowerMockito.mock(JSONRPC2Session.class);
JSONRPC2SessionOptions mockOptions = Mockito.mock(JSONRPC2SessionOptions.class);
JSONRPC2Request mockJSONRPC2Request = Mockito.mock(JSONRPC2Request.class);
JSONRPC2Response mockJSONRPC2Response = Mockito.mock(JSONRPC2Response.class);
JSONRPC2Error mockJSONRPC2Error = Mockito.mock(JSONRPC2Error.class);
PowerMockito.whenNew(URL.class).withArguments(Mockito.anyString()).thenReturn(mockUrl);
PowerMockito.whenNew(JSONRPC2Session.class).withArguments(Mockito.isA(URL.class)).thenReturn(mockJSONRPC2Session);
Mockito.when(mockJSONRPC2Session.getOptions()).thenReturn(mockOptions);
PowerMockito.whenNew(JSONRPC2Request.class).withParameterTypes(String.class, Map.class, Object.class).withArguments(Mockito.anyString(), Mockito.isA(Map.class), Mockito.any()).thenReturn(mockJSONRPC2Request);
Mockito.when(mockJSONRPC2Session.send(Mockito.isA(JSONRPC2Request.class))).thenReturn(mockJSONRPC2Response);
Mockito.when(mockJSONRPC2Response.indicatesSuccess()).thenReturn(false);
Mockito.when(mockJSONRPC2Response.getError()).thenReturn(mockJSONRPC2Error);
Mockito.when(mockJSONRPC2Error.getMessage()).thenReturn("Error Message");
jsonRpcUtils = new JsonRpcUtils();
Object responseObject = jsonRpcUtils.sendJsonRpcRequest(url, responseClass, method, params);
assertThat(responseObject).isNull();
//PowerMockito.verifyNew(URL.class, Mockito.times(1)).withArguments(Mockito.anyString());
//PowerMockito.verifyNew(JSONRPC2Session.class, Mockito.times(1)).withArguments(Mockito.isA(URL.class));
//Mockito.verify(mockJSONRPC2Session, Mockito.times(1)).getOptions();
//PowerMockito.verifyNew(JSONRPC2Request.class, Mockito.times(1)).withArguments(Mockito.anyString(), Mockito.isA(Map.class), Mockito.any());
//Mockito.verify(mockJSONRPC2Session, Mockito.times(1)).send(Mockito.isA(JSONRPC2Request.class));
//Mockito.verify(mockJSONRPC2Response, Mockito.times(1)).indicatesSuccess();
//Mockito.verify(mockJSONRPC2Response, Mockito.times(1)).getError();
//Mockito.verify(mockJSONRPC2Error, Mockito.times(1)).getMessage();
}
开发者ID:enjin,项目名称:Enjin-Coin-Java-SDK,代码行数:38,代码来源:JsonRpcUtilsTest.java
示例16: process
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
public JSONRPC2Response process(JSONRPC2Request req, MessageContext ctx) {
if (req.getMethod().equals("NetworkSetting")) {
return process(req);
} else {
// Method name not supported
return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, req.getID());
}
}
开发者ID:i2p,项目名称:i2p.plugins.i2pcontrol,代码行数:9,代码来源:NetworkSettingHandler.java
示例17: handleTweetSearch
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
/**
* Twitter Search handler
*
* @param request
* @return List of Tweet in JSON
*/
private JSONRPC2Response handleTweetSearch(JSONRPC2Request request) {
Map<String, Object> param = request.getNamedParams();
if (param != null) {
String text = String.valueOf(param.get(SEARCH_TEXT));
if (!Strings.isNullOrEmpty(text)) {
List<Tweet> tweets = SearchEngine.getSearchEngine().getTopTweets(text);
return new JSONRPC2Response(tweets, request.getID());
}
}
return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, request.getID());
}
开发者ID:victor-guoyu,项目名称:Review-It,代码行数:19,代码来源:SearchTweetHandler.java
示例18: handleCommentSearch
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
private JSONRPC2Response handleCommentSearch(JSONRPC2Request request) {
Map<String, Object> param = request.getNamedParams();
if (param != null) {
String text = String.valueOf(param.get(SEARCH_TEXT));
if (!Strings.isNullOrEmpty(text)) {
List<ParsedComment> comments = SearchEngine.getSearchEngine().searchComments(text);
return new JSONRPC2Response(comments, request.getID());
}
}
return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, request.getID());
}
开发者ID:victor-guoyu,项目名称:Review-It,代码行数:12,代码来源:SearchTextHandler.java
示例19: handleVideoSearch
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
/**
* YouTube search handler
*
* @param request
* @return Top rated YouTube video
*/
private JSONRPC2Response handleVideoSearch(JSONRPC2Request request) {
Map<String, Object> param = request.getNamedParams();
if (param != null) {
String text = String.valueOf(param.get(SEARCH_TEXT));
if (!Strings.isNullOrEmpty(text)) {
Video topVideo = SearchEngine.getSearchEngine().getTopRatedVideo(text);
return new JSONRPC2Response(topVideo, request.getID());
}
}
return new JSONRPC2Response(JSONRPC2Error.INVALID_PARAMS, request.getID());
}
开发者ID:victor-guoyu,项目名称:Review-It,代码行数:18,代码来源:SearchVideoHandler.java
示例20: process
import com.thetransactioncompany.jsonrpc2.JSONRPC2Error; //导入依赖的package包/类
@Override
public JSONRPC2Response process(JSONRPC2Request request, MessageContext messageContext) {
if (request.getMethod().equalsIgnoreCase(TWEET_SEARCH)) {
return handleTweetSearch(request);
} else {
return new JSONRPC2Response(JSONRPC2Error.METHOD_NOT_FOUND, request.getID());
}
}
开发者ID:victor-guoyu,项目名称:Review-It,代码行数:9,代码来源:SearchTweetHandler.java
注:本文中的com.thetransactioncompany.jsonrpc2.JSONRPC2Error类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论