/// <summary> /// Create the appropriate RData class representing a primitive (RNumeric, RBoolean, RString) /// </summary> /// <param name="name">name of the RData instance</param> /// <param name="jparent">Parent json.net object</param> /// <returns>RData object</returns> /// <remarks></remarks> public static RData parsePrimitive(String name, JToken jparent) { RData data = null; JToken j = jparent["value"].Value <JToken>(); if ((j.Type == JTokenType.Float) || (j.Type == JTokenType.Integer)) { data = new RNumeric(name, j.Value <Double>()); } else if (j.Type == JTokenType.String) { data = new RString(name, j.Value <string>()); } else if (j.Type == JTokenType.Boolean) { data = new RBoolean(name, j.Value <bool>()); } return(data); }
private static RData checkEmptyValue(JToken jparent, String type, String rclass, String name) { RData data = null; if (!(jparent["value"] == null)) { return(null); } if (type == Constants.TYPE_MATRIX) { if (rclass == Constants.RCLASS_NUMERIC) { data = new RNumericMatrix(name, null); } else if (rclass == Constants.RCLASS_CHARACTER) { data = new RStringMatrix(name, null); } else if (rclass == Constants.RCLASS_BOOLEAN) { data = new RBooleanMatrix(name, null); } else { data = new RNumericMatrix(name, null); } } else if (type == Constants.TYPE_VECTOR) { if (rclass == Constants.RCLASS_NUMERIC) { data = new RNumericVector(name, null); } else if (rclass == Constants.RCLASS_CHARACTER) { data = new RStringVector(name, null); } else if (rclass == Constants.RCLASS_BOOLEAN) { data = new RBooleanVector(name, null); } else if (rclass == Constants.RCLASS_DATE) { data = new RDateVector(name, null, ""); } else { data = new RNumericVector(name, null); } } else if (type == Constants.TYPE_PRIMITIVE) { if (rclass == Constants.RCLASS_NUMERIC) { data = new RNumeric(name, 0); } else if (rclass == Constants.RCLASS_CHARACTER) { data = new RString(name, null); } else if (rclass == Constants.RCLASS_BOOLEAN) { data = new RBoolean(name, false); } else { data = new RNumeric(name, 0); } } else if (type == Constants.TYPE_DATE) { data = new RDate(name, null, ""); } else if (type == Constants.TYPE_FACTOR) { data = new RFactor(name, null); } else if (type == Constants.TYPE_DATAFRAME) { data = new RDataFrame(name, null); } else if (type == Constants.TYPE_LIST) { data = new RList(name, null); } return(data); }
private static RData checkEmptyValue(JToken jparent, String type, String rclass, String name) { RData data = null; if (!(jparent["value"] == null)) { return null; } if (type == Constants.TYPE_MATRIX) { if (rclass == Constants.RCLASS_NUMERIC) { data = new RNumericMatrix(name, null); } else if (rclass == Constants.RCLASS_CHARACTER) { data = new RStringMatrix(name, null); } else if (rclass == Constants.RCLASS_BOOLEAN) { data = new RBooleanMatrix(name, null); } else { data = new RNumericMatrix(name, null); } } else if (type == Constants.TYPE_VECTOR) { if (rclass == Constants.RCLASS_NUMERIC) { data = new RNumericVector(name, null); } else if (rclass == Constants.RCLASS_CHARACTER) { data = new RStringVector(name, null); } else if (rclass == Constants.RCLASS_BOOLEAN) { data = new RBooleanVector(name, null); } else if (rclass == Constants.RCLASS_DATE) { data = new RDateVector(name, null, ""); } else { data = new RNumericVector(name, null); } } else if (type == Constants.TYPE_PRIMITIVE) { if (rclass == Constants.RCLASS_NUMERIC) { data = new RNumeric(name, 0); } else if (rclass == Constants.RCLASS_CHARACTER) { data = new RString(name, null); } else if (rclass == Constants.RCLASS_BOOLEAN) { data = new RBoolean(name, false); } else { data = new RNumeric(name, 0); } } else if (type == Constants.TYPE_DATE) { data = new RDate(name, null, ""); } else if (type == Constants.TYPE_FACTOR) { data = new RFactor(name, null); } else if (type == Constants.TYPE_DATAFRAME) { data = new RDataFrame(name, null); } else if (type == Constants.TYPE_LIST) { data = new RList(name, null); } return data; }
/// <summary> /// Create the appropriate RData class representing a primitive (RNumeric, RBoolean, RString) /// </summary> /// <param name="name">name of the RData instance</param> /// <param name="jparent">Parent json.net object</param> /// <returns>RData object</returns> /// <remarks></remarks> public static RData parsePrimitive(String name, JToken jparent) { RData data = null; JToken j = jparent["value"].Value<JToken>(); if ((j.Type == JTokenType.Float) || (j.Type == JTokenType.Integer)) { data = new RNumeric(name, j.Value<Double>()); } else if (j.Type == JTokenType.String) { data = new RString(name, j.Value<string>()); } else if (j.Type == JTokenType.Boolean) { data = new RBoolean(name, j.Value<bool>()); } return data; }