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


Java ParseException.printStackTrace方法代码示例

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


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

示例1: handleWeatherMessage

import org.json.simple.parser.ParseException; //导入方法依赖的package包/类
/**
 * handleWeatherMessage takes received telemetry message and processes it to be printed to command line.
 * @param msg Telemetry message received through hono server.
 */
private void handleWeatherMessage(final Message msg) {
    final Section body = msg.getBody();
    //Ensures that message is Data (type of AMQP messaging). Otherwise exits method.
    if (!(body instanceof Data))
        return;
    //Gets deviceID.
    final String deviceID = MessageHelper.getDeviceId(msg);
    //Creates JSON parser to read input telemetry weather data. Prints data to console output.
    JSONParser parser = new JSONParser();
    try {
        Object obj = parser.parse(((Data) msg.getBody()).getValue().toString());
        JSONObject payload = (JSONObject) obj;
        System.out.println(new StringBuilder("Device: ").append(deviceID).append("; Location: ").
                append(payload.get("location")).append("; Temperature:").append(payload.get("temperature")));
    } catch (ParseException e) {
        System.out.println("Data was not sent in a readable way. Check telemetry input.");
        e.printStackTrace();
    }
}
 
开发者ID:rhiot,项目名称:hono-weather-demo,代码行数:24,代码来源:WeatherDataConsumer.java

示例2: mergeFiles

import org.json.simple.parser.ParseException; //导入方法依赖的package包/类
/**
 * merge source file into target
 *
 * @param target
 * @param source
 */
public void mergeFiles(File target, File source) throws Throwable {
    String targetReport = FileUtils.readFileToString(target);
    String sourceReport = FileUtils.readFileToString(source);

    JSONParser jp = new JSONParser();

    try {
        JSONArray parsedTargetJSON = (JSONArray) jp.parse(targetReport);
        JSONArray parsedSourceJSON = (JSONArray) jp.parse(sourceReport);
        // Merge two JSON reports
        parsedTargetJSON.addAll(parsedSourceJSON);
        // this is a new writer that adds JSON indentation.
        Writer writer = new JSONWriter();
        // convert our parsedJSON to a pretty form
        parsedTargetJSON.writeJSONString(writer);
        // and save the pretty version to disk
        FileUtils.writeStringToFile(target, writer.toString());
    } catch (ParseException pe) {
        pe.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:usman-h,项目名称:Habanero,代码行数:30,代码来源:JSONReportMerger.java

示例3: createStartingCollection

import org.json.simple.parser.ParseException; //导入方法依赖的package包/类
private JSONObject createStartingCollection() {
	try {
		JSONObject collection = new JSONObject();
		for (String card: JSonReader.getCollection()) {
			Card c = new Card(card);
			if (!c.getType().equals("hero")) {
				if (c.getSet().equals("BASIC")) {
					collection.put(card, 2);
				} else {
					collection.put(card, 0);
				}
			}
		}
		return collection;
	} catch (ParseException e1) {
		e1.printStackTrace();
	}
	return null;
}
 
开发者ID:ikhaliq15,项目名称:JHearthstone,代码行数:20,代码来源:UserDataManager.java

示例4: validateSession

import org.json.simple.parser.ParseException; //导入方法依赖的package包/类
public JSONObject validateSession(String sessionid) {
	String cSession = getSession(sessionid);
	if (cSession == null) {
		return null;
	}

	try{
		Date now = new Date();
		JSONObject sessionJson = (JSONObject) new JSONParser().parse(cSession);
		String timeoutString = sessionJson.get("timeoutTime").toString();
		JSONObject timeJson = (JSONObject) new JSONParser().parse(timeoutString);
		
		if (now.getTime() > (Long)timeJson.get("$date")) {
			removeSession(cSession);
			return null;
		}
		
		return sessionJson;
	}catch (ParseException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		return null;
	}		
}
 
开发者ID:ibmruntimes,项目名称:acmeair-modular,代码行数:25,代码来源:AuthService.java

示例5: getWeather

import org.json.simple.parser.ParseException; //导入方法依赖的package包/类
public double getWeather(boolean inCelsius){
      double temperature=0;
      String url = URL;
      if(inCelsius) url += "&units=metric";
      else url += "&units=imperial";
      doLogging("Request came for getWeather", "INFO");
      String response = fetchWeather(url);
      System.out.println(response);
      JSONParser parser = new JSONParser();
      try {
      	
	JSONObject jo=(JSONObject)parser.parse(response);
	// maintain cache of this JSONObject
	temperature = Double.parseDouble((((JSONObject)jo.get("main")).get("temp")).toString());
} catch (ParseException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}
      return temperature; 
  }
 
开发者ID:hemantverma1,项目名称:ServerlessPlatform,代码行数:21,代码来源:ClimateService.java

示例6: getKarma

import org.json.simple.parser.ParseException; //导入方法依赖的package包/类
/**
 * Gets your karma
 * @return The requestResponse of type JodelRequestResponse
 */
public JodelRequestResponse getKarma() {
    JodelRequestResponse requestResponse = new JodelRequestResponse();
    this.updateHTTPParameter();
    JodelHTTPResponse karmaResponse = this.httpAction.getKarma();
    requestResponse.httpResponseCode = karmaResponse.responseCode;
    if (requestResponse.httpResponseCode == 200) {
        String responseKarma = karmaResponse.responseMessage;
        requestResponse.rawResponseMessage = responseKarma;
        JSONParser parserCaptcha = new JSONParser();
        try {
            JSONObject responseCaptchaJson = (JSONObject) parserCaptcha.parse(responseKarma);
            String karma = responseCaptchaJson.get("karma").toString();
            requestResponse.responseValues.put("karma", karma);

        } catch (ParseException e) {
            requestResponse.rawErrorMessage = e.getMessage();
            e.printStackTrace();
            requestResponse.error = true;
            requestResponse.errorMessage = "Could not parse response JSON!";
        }
    } else {
        requestResponse.error = true;
    }
    return requestResponse;
}
 
开发者ID:fr31b3u73r,项目名称:JodelAPI,代码行数:30,代码来源:JodelAccount.java

示例7: getHumidity

import org.json.simple.parser.ParseException; //导入方法依赖的package包/类
public long getHumidity(){
      long humidity=0;
      String response = fetchWeather(URL);
      JSONParser parser = new JSONParser();
      doLogging("Request came for getHumidity", "INFO");
      try {
	JSONObject jo=(JSONObject)parser.parse(response);
	//long speed = (long)((JSONObject)jo.get("wind")).get("speed");
	humidity = (long)((JSONObject)jo.get("main")).get("humidity");
} catch (ParseException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
	doLogging("Error in getHumidity "+e.getStackTrace(), "ERROR");
}
      return humidity;
  }
 
开发者ID:hemantverma1,项目名称:ServerlessPlatform,代码行数:17,代码来源:ClimateService.java

示例8: getEffect

import org.json.simple.parser.ParseException; //导入方法依赖的package包/类
public JSONObject getEffect() {
    try {
        return new org.json.JSONObject(reader.getEffect(name).toJSONString());
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return new org.json.JSONObject();
}
 
开发者ID:ikhaliq15,项目名称:JHearthstone,代码行数:9,代码来源:Spell.java

示例9: renameFeatureIDsAndNames

import org.json.simple.parser.ParseException; //导入方法依赖的package包/类
/**
 * Prepend parent directory name to all feature names for easier report analysis
 *
 * @param reportFile
 */
public void renameFeatureIDsAndNames(File reportFile) throws Throwable {
    String reportDirName = reportFile.getParentFile().getName();
    String fileAsString = FileUtils.readFileToString(reportFile);
    JSONParser jp = new JSONParser();

    try {
        JSONArray parsedJSON = (JSONArray) jp.parse(fileAsString);

        for (Object o : parsedJSON) {
            JSONObject jo = (JSONObject) o;
            String curFeatureID = jo.get("id").toString();
            String curFeatureName = jo.get("name").toString();

            String newFeatureID = String.format("%s - %s", reportDirName, curFeatureID);
            String newFeatureName = String.format("%s - %s", reportDirName, curFeatureName);

            log.info("Changing feature ID and Name from: " + curFeatureID + " / " + curFeatureName + " to: " + newFeatureID + " / " + newFeatureName);

            jo.put("id", newFeatureID);
            jo.put("name", newFeatureName);
        }
        // this is a new writer that adds JSON indentation.
        Writer writer = new JSONWriter();
        // convert our parsedJSON to a pretty form
        parsedJSON.writeJSONString(writer);
        // and save the pretty version to disk
        FileUtils.writeStringToFile(reportFile, writer.toString());
    } catch (ParseException pe) {
        pe.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:usman-h,项目名称:Habanero,代码行数:39,代码来源:JSONReportMerger.java

示例10: heal

import org.json.simple.parser.ParseException; //导入方法依赖的package包/类
public void heal (int h) throws org.json.simple.parser.ParseException {
	if (this.health < this.maxHealth && h != 0) {
		HashMap<String, Object> arguments = new HashMap<>();
		arguments.put("targetEntityType", "MINION");
		try {
			game.trigger("HealingTrigger", arguments);
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}
		this.health += h;
	if (this.health > this.getMaxHealth()) {
		this.health = this.getMaxHealth();
	}
}
 
开发者ID:ikhaliq15,项目名称:JHearthstone,代码行数:16,代码来源:Minion.java

示例11: getBattleCry

import org.json.simple.parser.ParseException; //导入方法依赖的package包/类
public org.json.JSONObject getBattleCry() {
	try {
		return new org.json.JSONObject(reader.getBattlecry(name).toJSONString());
	} catch (ParseException e) {
		e.printStackTrace();
	}
	return new org.json.JSONObject();
}
 
开发者ID:ikhaliq15,项目名称:JHearthstone,代码行数:9,代码来源:Card.java

示例12: getAura

import org.json.simple.parser.ParseException; //导入方法依赖的package包/类
public org.json.JSONObject getAura() {
	try {
		return new org.json.JSONObject(reader.getAura(name).toJSONString());
	} catch (ParseException e) {
		e.printStackTrace();
	}
	return new org.json.JSONObject();
}
 
开发者ID:ikhaliq15,项目名称:JHearthstone,代码行数:9,代码来源:Card.java

示例13: heal

import org.json.simple.parser.ParseException; //导入方法依赖的package包/类
public void heal (int value){
	if (this.health < this.maxHealth && value != 0) {
		HashMap<String, Object> arguments = new HashMap<>();
		arguments.put("targetEntityType", "HERO");
		try {
			game.trigger("HealingTrigger", arguments);
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}
	this.health += value;
	if (this.health > this.maxHealth) {
		this.health = this.maxHealth;
	}
}
 
开发者ID:ikhaliq15,项目名称:JHearthstone,代码行数:16,代码来源:Player.java

示例14: execute

import org.json.simple.parser.ParseException; //导入方法依赖的package包/类
private String execute(String tweetLine) {
	ReadTwitterJSON readJson = null;
	try {
		readJson = new ReadTwitterJSON(tweetLine);
	} catch (ParseException e) {
		e.printStackTrace();
	}

	System.out.println(" Before ----->" + readJson.getTweet());
	readJson.removeUrl();
	System.out.println(" After ----->" + readJson.getTweet());

	return readJson.getTweet();
}
 
开发者ID:CCWI,项目名称:keywordEntityApiRankService,代码行数:15,代码来源:ReadFileTest.java

示例15: doAuthentication

import org.json.simple.parser.ParseException; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
JSONObject doAuthentication(JSONObject svcReq, String reqId){
	JSONObject reply = null;
	JSONObject authReq = new JSONObject();
	communicateWithMQ mqHandler = new communicateWithMQ();
	mqHandler.connectToBroker();
	String replyMq = mqHandler.createMq("svcQueueServiceGatewayAuthnReply");

	authReq.put("svcName", "AuthenticationService");
	authReq.put("funcName", "authenticateUser");
	authReq.put("usrId", svcReq.get("usrId").toString());
	authReq.put("reqId", reqId);

	JSONArray params = new JSONArray();
	JSONObject tmp = new JSONObject();
	tmp.put("name", "param1");	//usrId
	tmp.put("type", "String");
	tmp.put("value", svcReq.get("usrId").toString());
	params.add(tmp);
	JSONObject tmp1 = new JSONObject();
	tmp1.put("name", "param2");	//passwd
	tmp1.put("type", "String");
	tmp1.put("value", svcReq.get("passwd").toString());
	params.add(tmp1);
	authReq.put("params", params);
	System.out.println(authReq);
	mqHandler.send("svcQueueAuthenticationService", authReq, replyMq);
	JSONParser parser = new JSONParser();
	try {
		String str = mqHandler.listenAndFilter().get("response").toString();
		mqHandler.disconnect();
		System.out.println("Response from Auth svc "+str);
		reply = (JSONObject) parser.parse(str);
	} catch (ParseException e) {
		e.printStackTrace();
	}
	return reply;
}
 
开发者ID:hemantverma1,项目名称:ServerlessPlatform,代码行数:39,代码来源:ServiceGateway.java


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