当前位置: 首页>>代码示例>>Java>>正文


Java JSONObject.getInt方法代码示例

本文整理汇总了Java中org.apache.wink.json4j.JSONObject.getInt方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.getInt方法的具体用法?Java JSONObject.getInt怎么用?Java JSONObject.getInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.wink.json4j.JSONObject的用法示例。


在下文中一共展示了JSONObject.getInt方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
public static  SyntheticDataGenerator create(JSONObject json){

		SyntheticDataGenerator gen = new SyntheticDataGenerator();

		try{
			JSONObject beaconJSON = json.getJSONObject("Beacon");
			JSONObject motionJSON = json.getJSONObject("Motion");

			gen.beaconGen = new SyntheticBeaconDataGenerator(beaconJSON);
			gen.motionGen = new SyntheticMotionDataGenerator(motionJSON);

			JSONObject randomJSON = json.getJSONObject("Random");
			int seed =  randomJSON==null ? 1234 : randomJSON.getInt("seed");
			gen.beaconGen.setRandom(new Random(seed));
			gen.motionGen.setRandom(new Random(seed));

		}catch(JSONException e){
			e.printStackTrace();
		}
		return gen;
	}
 
开发者ID:hulop,项目名称:BLELocalization,代码行数:22,代码来源:SyntheticDataGenerator.java

示例2: setEnvironmentOption

import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
public void setEnvironmentOption(JSONObject envOptions){
	try{
		if(envOptions!=null){
			if(envOptions.containsKey(N_THREADS)){
				int nThreads = envOptions.getInt(N_THREADS);
				ExecutorServiceHolder.setNThreads(nThreads);
			}
			if(envOptions.containsKey(OUTPUT_STATES)){
				boolean outputStates = envOptions.getBoolean(OUTPUT_STATES);
				LocalizationStatus.setOutputStates(outputStates);
			}
		}
	}
	catch(JSONException e){
		e.printStackTrace();
	}
}
 
开发者ID:hulop,项目名称:BLELocalization,代码行数:18,代码来源:ObservationModelBuilder.java

示例3: convertToMatrix

import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
/**
 * Converts an input stream of a string matrix in csv or textcell format
 * into a matrix block. The meta data string is the SystemML generated
 * .mtd file including the number of rows and columns.
 * 
 * @param input InputStream to a string matrix in csv or textcell format
 * @param meta string representing SystemML matrix metadata in JSON format
 * @return matrix as a matrix block
 * @throws IOException if IOException occurs
 */
public MatrixBlock convertToMatrix(InputStream input, String meta) 
	throws IOException
{
	try {
		//parse json meta data 
		JSONObject jmtd = new JSONObject(meta);
		int rows = jmtd.getInt(DataExpression.READROWPARAM);
		int cols = jmtd.getInt(DataExpression.READCOLPARAM);
		String format = jmtd.getString(DataExpression.FORMAT_TYPE);
		
		//parse the input matrix
		return convertToMatrix(input, rows, cols, format);
	}
	catch(Exception ex) {
		throw new IOException(ex);
	}
}
 
开发者ID:apache,项目名称:systemml,代码行数:28,代码来源:Connection.java

示例4: convertToFrame

import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
/**
 * Converts an input stream of a string frame in csv or textcell format
 * into a frame block. The meta data string is the SystemML generated
 * .mtd file including the number of rows and columns.
 * 
 * @param input InputStream to a string frame in csv or textcell format
 * @param meta string representing SystemML frame metadata in JSON format
 * @return frame as a frame block
 * @throws IOException if IOException occurs
 */
public FrameBlock convertToFrame(InputStream input, String meta) 
	throws IOException
{
	try {
		//parse json meta data 
		JSONObject jmtd = new JSONObject(meta);
		int rows = jmtd.getInt(DataExpression.READROWPARAM);
		int cols = jmtd.getInt(DataExpression.READCOLPARAM);
		String format = jmtd.getString(DataExpression.FORMAT_TYPE);
		
		//parse the input frame
		return convertToFrame(input, rows, cols, format);
	}
	catch(Exception ex) {
		throw new IOException(ex);
	}
}
 
开发者ID:apache,项目名称:systemml,代码行数:28,代码来源:Connection.java

示例5: parseJsonObjectIDList

import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
public static int[] parseJsonObjectIDList(JSONObject spec, String[] colnames, String group) 
	throws JSONException
{
	int[] colList = new int[0];
	boolean ids = spec.containsKey("ids") && spec.getBoolean("ids");
	
	if( spec.containsKey(group) && spec.get(group) instanceof JSONArray )
	{
		JSONArray colspecs = (JSONArray)spec.get(group);
		colList = new int[colspecs.size()];
		for(int j=0; j<colspecs.size(); j++) {
			JSONObject colspec = (JSONObject) colspecs.get(j);
			colList[j] = ids ? colspec.getInt("id") : 
				(ArrayUtils.indexOf(colnames, colspec.get("name")) + 1);
			if( colList[j] <= 0 ) {
				throw new RuntimeException("Specified column '" +
					colspec.get(ids?"id":"name")+"' does not exist.");
			}
		}
		
		//ensure ascending order of column IDs
		Arrays.sort(colList);
	}
	
	return colList;
}
 
开发者ID:apache,项目名称:systemml,代码行数:27,代码来源:TfMetaUtils.java

示例6: parseJSONFloors

import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
public static Map<String, Integer> parseJSONFloors(JSONArray floorsArray){
	Map<String, Integer> map = new LinkedHashMap<String, Integer>();
	try {
		Iterator<JSONObject> iter = uncheckedCast(floorsArray.iterator());
		while(iter.hasNext()){
			JSONObject jobj = iter.next();
			String floor = jobj.getString("floor");
			Integer floor_num  = jobj.getInt("floor_num");
			map.put(floor, floor_num);
		}
	} catch (JSONException e) {
		e.printStackTrace();
	}
	return map;
}
 
开发者ID:hulop,项目名称:BLELocalization,代码行数:16,代码来源:MapDataUtils.java

示例7: settingFromJSON

import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
public void settingFromJSON(JSONObject json){
  	// Parse json
  	try {
	Integer np = json.getInt(N_PARTICLES);
	setNumParticles(np);
	if(json.containsKey(AVERAGING_TYPE)){
		averagingType = json.getString(AVERAGING_TYPE);
		System.out.println(AVERAGING_TYPE + " is set to " + averagingType);
	}
	usesWeighted = averagingType.equals(WEIGHTED_AVERAGE)? true : false;
	if(json.containsKey(RESAMPLING_METHOD)){
		String str = json.getString(RESAMPLING_METHOD);
		resamplingMethodName = str;
		System.out.println(RESAMPLING_METHOD + " is set to " + resamplingMethodName);
	}
	alphaWeaken = json.containsKey(ALPHA_WEAKEN) ? json.getDouble(ALPHA_WEAKEN) : 1.0;
	System.out.println(this.toString());
} catch (JSONException e) {
	e.printStackTrace();
}

  	// Set up particle preprocessor
  	JSONObject prepJSON = json.optJSONObject(ParticlePreprocessor.PARTICLE_PREPROCESSOR);
  	if(prepJSON!=null){
  		ParticlePreprocessorProvider provider = new ParticlePreprocessorProvider();
  		if(provider.hasFactory(prepJSON)){
  			particlePreprocessor = provider.provide(prepJSON, this);
  			System.out.println(particlePreprocessor.toString() + " is created.");
  		}
  	}else{
  		System.out.println("The key for ["+ParticlePreprocessor.PARTICLE_PREPROCESSOR+"] was not found.");
  	}

  }
 
开发者ID:hulop,项目名称:BLELocalization,代码行数:35,代码来源:ParticleFilter.java

示例8: settingFromJSON

import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
@Override
public void settingFromJSON(JSONObject json){
	int k;
	try {
		k = json.getInt(K_BEACONS_KEY);
		doNormalize = json.getBoolean(DO_NORMALIZE_KEY);
		kBeacons = k;
		System.out.println(this.toString());
	} catch (JSONException e) {
		e.printStackTrace();
	}
}
 
开发者ID:hulop,项目名称:BLELocalization,代码行数:13,代码来源:NormedStrongestBeaconFilter.java

示例9: setJSON

import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
SyntheticMotionDataGenerator setJSON(JSONObject json){
	try{
		accStds = JSONUtils.array1DfromJSONArray(json.getJSONArray("accStds"));
		attStds = JSONUtils.array1DfromJSONArray(json.getJSONArray("attStds"));
		freq = json.getInt("freq");
		dTS = 1000/freq;
		ampG = json.getDouble("ampG");
		stepPerSec = json.getDouble("stepPerSec");
	}catch(JSONException e){
		e.printStackTrace();
	}
	return this;
}
 
开发者ID:hulop,项目名称:BLELocalization,代码行数:14,代码来源:SyntheticMotionDataGenerator.java

示例10: readDoubleMatrix

import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
/**
 * Reads an input matrix in arbitrary format from HDFS into a dense double array.
 * NOTE: this call currently only supports default configurations for CSV.
 * 
 * @param fname the filename of the input matrix
 * @return matrix as a two-dimensional double array
 * @throws IOException if IOException occurs
 */
public double[][] readDoubleMatrix(String fname) 
	throws IOException
{
	try {
		//read json meta data 
		String fnamemtd = DataExpression.getMTDFileName(fname);
		JSONObject jmtd = new DataExpression().readMetadataFile(fnamemtd, false);
		
		//parse json meta data 
		long rows = jmtd.getLong(DataExpression.READROWPARAM);
		long cols = jmtd.getLong(DataExpression.READCOLPARAM);
		int brlen = jmtd.containsKey(DataExpression.ROWBLOCKCOUNTPARAM)?
				jmtd.getInt(DataExpression.ROWBLOCKCOUNTPARAM) : -1;
		int bclen = jmtd.containsKey(DataExpression.COLUMNBLOCKCOUNTPARAM)?
				jmtd.getInt(DataExpression.COLUMNBLOCKCOUNTPARAM) : -1;
		long nnz = jmtd.containsKey(DataExpression.READNUMNONZEROPARAM)?
				jmtd.getLong(DataExpression.READNUMNONZEROPARAM) : -1;
		String format = jmtd.getString(DataExpression.FORMAT_TYPE);
		InputInfo iinfo = InputInfo.stringExternalToInputInfo(format);			
	
		//read matrix file
		return readDoubleMatrix(fname, iinfo, rows, cols, brlen, bclen, nnz);
	}
	catch(Exception ex) {
		throw new IOException(ex);
	}
}
 
开发者ID:apache,项目名称:systemml,代码行数:36,代码来源:Connection.java

示例11: settingFromJSON

import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
public void settingFromJSON(JSONObject json){
	jsonParams = json;
	try {
		JSONObject ldplParams = json.getJSONObject(LDPLParameters);
		JSONObject gpParams = json.getJSONObject(GPParameters);
		JSONObject optJSON = json.getJSONObject(OPTIONS);

		//LDPLParameters
		double n = ldplParams.getDouble("n");
		double A = ldplParams.getDouble("A");
		double fa = ldplParams.getDouble("fa");
		double fb = ldplParams.getDouble("fb");
		if(ldplParams.containsKey(HDIFF)){
			double hDiff = ldplParams.getDouble(HDIFF);
			this.setParams(new double[]{n,A,fa,fb});
			this.setHDiff(hDiff);
		}

		//GPParamters
		JSONArray jarray = gpParams.getJSONArray("lengthes");
		lengthes = JSONUtils.array1DfromJSONArray(jarray);
		stdev = gpParams.getDouble("sigmaP");
		sigmaN = gpParams.getDouble("sigmaN");

		boolean useMask = (gpParams.getInt("useMask") == 1);
		int optConstVar = gpParams.getInt("constVar");

		gpLDPL.setUseMask(useMask);
		gpLDPL.setOptConstVar(optConstVar);

		// Options
		doHyperParameterOptimize = optJSON.optBoolean("optimizeHyperParameters");
		if(! doHyperParameterOptimize){
			doHyperParameterOptimize = optJSON.optInt("optimizeHyperParameters")==1;
		}

		// Optional variables
		if(gpParams.containsKey(ARRAYS)){
			JSONObject jobjArrays = gpParams.getJSONObject(ARRAYS);
			gpLDPL.fromJSON(jobjArrays);
		}
		if(json.containsKey(LIKELIHOOD_MODEL)){
			JSONObject likelihoodJSON = json.getJSONObject(LIKELIHOOD_MODEL);
			LikelihoodModel likelihoodModel = LikelihoodModelFactory.create(likelihoodJSON);
			gpLDPL.setLikelihoodModel(likelihoodModel);
		}else{
			System.out.println("The key for ["+LIKELIHOOD_MODEL +"] was not found.");
		}

		if(json.containsKey(BEACON_FILTER)){
			JSONObject bfJSON = json.getJSONObject(BEACON_FILTER);
			BeaconFilter bf = BeaconFilterFactory.create(bfJSON);
			beaconFilter = bf;
		}else{
			System.out.println("The key for ["+BEACON_FILTER +"] was not found.");
		}

	} catch (JSONException e) {
		e.printStackTrace();
	}
}
 
开发者ID:hulop,项目名称:BLELocalization,代码行数:62,代码来源:GaussianProcessLDPLMeanModel.java


注:本文中的org.apache.wink.json4j.JSONObject.getInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。