All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.lteconsulting.hexa.revrpc.client.CallDeserializerUtil Maven / Gradle / Ivy

The newest version!
package fr.lteconsulting.hexa.revrpc.client;

import com.google.gwt.json.client.JSONObject;

public class CallDeserializerUtil
{
	public static String getParameterString( JSONObject json, int index )
	{
		if( json == null )
			return null;

		JSONObject prm = getParam( json, index, "java.lang.String" );

		return prm.get( "value" ).isString().stringValue();
	}

	public static Boolean getParameterboolean( JSONObject json, int index )
	{
		if( json == null )
			return null;

		JSONObject prm = getParam( json, index, "java.lang.Boolean" );

		return prm.get( "value" ).isBoolean().booleanValue();
	}

	public static Integer getParameterint( JSONObject json, int index )
	{
		return getParameterInteger( json, index );
	}

	public static Integer getParameterInteger( JSONObject json, int index )
	{
		if( json == null )
			return null;

		JSONObject prm = getParam( json, index, "java.lang.Integer" );

		return (int) prm.get( "value" ).isNumber().doubleValue();
	}

	public static JSONObject getParam( JSONObject json, int index, String type )
	{
		JSONObject prm = json.get( "args" ).isArray().get( index ).isObject();

		assert prm.get( "type" ).isString().stringValue().equals( type );

		return prm;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy