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


Java ParseException类代码示例

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


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

示例1: Card

import org.json.simple.parser.ParseException; //导入依赖的package包/类
public Card(String n) throws ParseException{
	reader = new JSonReader(new File(GetExecutionPath()).getParent() + "/all-cards.json");
	name = n;
	cost =  (int)(reader.getCost(n));
	attack = (int)(reader.getAttack(n));
	health = (int)(reader.getHealth(n));
	setRarity(JSonReader.getRarity(n));
	set = JSonReader.getSet(n);
	canAttack = false;
	//effects = reader.getEffects(n);
	attributes = reader.getAttributes(n);
	type = reader.getType(n);
	attribute_values = reader.getAttributeValues(n, type);
	triggers = reader.getTriggers(n, type);
	trigger_object = reader.getTriggerObject(n, type);
	hasTaunt = attributes.contains("TAUNT");
	hasDivineShield = attributes.contains("DIVINE_SHIELD");
	hasWindfury = attributes.contains("WINDFURY");
	containsAura = reader.hasAura(n);
	race = reader.getRace(n, type);
}
 
开发者ID:ikhaliq15,项目名称:JHearthstone,代码行数:22,代码来源:Card.java

示例2: testRandomStateGitHub

import org.json.simple.parser.ParseException; //导入依赖的package包/类
@Test // testing full suite
public void testRandomStateGitHub() throws ParseException, IOException {

    String sha = "99db6f4f5fea3aa5cfbe8436feba8e213d06d1e8";
    List<String> fileNames = JSONReader.getFileNamesForTreeSha(sha);
    List<String> includedFiles =
            Arrays.asList(
                    "st201504081841JAVA.json",
                    "st201504081842JAVA.json",
                    "st201504081843JAVA.json"
            );

    for (String fileName : fileNames) {
        if (includedFiles.contains(fileName)) {
          System.out.println("Running: " + fileName);
          String json = JSONReader.loadJSON("StateTests//RandomTests/" + fileName);
          GitHubJSONTestSuite.runStateTest(json);
        }
    }

}
 
开发者ID:talentchain,项目名称:talchain,代码行数:22,代码来源:GitHubStateTest.java

示例3: getName

import org.json.simple.parser.ParseException; //导入依赖的package包/类
public static String getName(int id) {
    String name;
    if ((name = names.get(id)) != null) {
        return name;
    } else {
        try {
            String content = WebUtil.getContents(Configuration.ITEM_API + id);
            if (content.length() > 0) {
                JSONObject jsonObject      = (JSONObject) jsonParser.parse(content);
                JSONObject itemInformation = (JSONObject) jsonObject.get("result");
                if (itemInformation.get("name") != null && !((String) itemInformation.get("name")).equalsIgnoreCase("null")) {
                    name = (String) itemInformation.get("name");
                    names.put(id, name);
                    return name;
                }
            }
        } catch (MalformedURLException | ParseException e) {
            e.printStackTrace();
        }
    }

    return null;
}
 
开发者ID:Parabot,项目名称:Parabot-317-API-Minified-PkHonor,代码行数:24,代码来源:Items.java

示例4: getM15

import org.json.simple.parser.ParseException; //导入依赖的package包/类
public long getM15(String json) throws ParseException {
    long m15 = 0;
    if (json != null) {
        JSONParser parser = new JSONParser();
        JSONObject battleNetCharacter = (JSONObject) parser.parse(json);
        JSONObject achivements = (JSONObject) battleNetCharacter.get("achievements");
        JSONArray criteriaObject = (JSONArray) achivements.get("criteria");
        int criteriaNumber = -1;
        for (int i = 0; i < criteriaObject.size(); i++) {
            if ((long)criteriaObject.get(i) == 32028    ) {
                criteriaNumber = i;
            }
        }

        if (criteriaNumber != -1) {
            m15 = (long) ((JSONArray)achivements.get("criteriaQuantity")).get(criteriaNumber);
            if (m15 >= 1) {
                m15 += 1;
            }
        }
    }
    return m15;
}
 
开发者ID:greatman,项目名称:legendarybot,代码行数:24,代码来源:IlvlCommand.java

示例5: executeImpl

import org.json.simple.parser.ParseException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public JSONArray executeImpl(String userId, WebScriptRequest req, WebScriptResponse res) throws IOException,
        ParseException
{
    JSONArray jsonUsers = (JSONArray) JSONValue.parseWithException(req.getContent().getContent());

    JSONArray result = new JSONArray();

    for (Object o : jsonUsers)
    {
        String user = (o == null ? null : o.toString());
        if (user != null)
        {
            JSONObject item = new JSONObject();
            item.put(user, subscriptionService.follows(userId, user));
            result.add(item);
        }
    }

    return result;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:22,代码来源:SubscriptionServiceFollowsPost.java

示例6: testEIP155TransactionTestFromGitHub

import org.json.simple.parser.ParseException; //导入依赖的package包/类
@Test
public void testEIP155TransactionTestFromGitHub() throws ParseException, IOException {
    Set<String> excluded = new HashSet<>();
    SystemProperties.getDefault().setBlockchainConfig(new BaseNetConfig() {{
        add(0, new FrontierConfig());
        add(1_150_000, new HomesteadConfig());
        add(2_457_000, new Eip150HFConfig(new DaoHFConfig()));
        add(2_675_000, new Eip160HFConfig(new DaoHFConfig()){
            @Override
            public Integer getChainId() {
                return null;
            }
        });
    }});
    String json = JSONReader.loadJSONFromCommit("TransactionTests/EIP155/ttTransactionTest.json", shacommit);
    GitHubJSONTestSuite.runGitHubJsonTransactionTest(json, excluded);
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:18,代码来源:GitHubTransactionTest.java

示例7: getIdsContain

import org.json.simple.parser.ParseException; //导入依赖的package包/类
/**
 * Returns an int array based on the string it contains. getIdsContain(dragon) will return an int array with all items containingdragon
 *
 * @param name
 *
 * @return
 */
public static int[] getIdsContain(String name) {
    try {
        String content = WebUtil.getContents(Configuration.ITEM_API + "contains/" + name);
        if (content.length() > 0) {
            JSONObject jsonObject = (JSONObject) jsonParser.parse(content);
            JSONArray  array      = (JSONArray) jsonObject.get("result");
            if (array.size() > 0) {
                int[] ids = new int[array.size()];
                for (int i = 0; i < array.size(); i++) {
                    ids[i] = Integer.parseInt((String) array.get(i));
                }
                return ids;
            }
        }
    } catch (MalformedURLException | ParseException e) {
        e.printStackTrace();
    }

    return new int[0];
}
 
开发者ID:Parabot,项目名称:Parabot-317-API-Minified-Dreamscape,代码行数:28,代码来源:Items.java

示例8: testRandomStateGitHub

import org.json.simple.parser.ParseException; //导入依赖的package包/类
@Test // testing full suite
public void testRandomStateGitHub() throws ParseException, IOException {

    String sha = "99db6f4f5fea3aa5cfbe8436feba8e213d06d1e8";
    List<String> fileNames = getFileNamesForTreeSha(sha);
    List<String> includedFiles =
            Arrays.asList(
                    "st201504081841JAVA.json",
                    "st201504081842JAVA.json",
                    "st201504081843JAVA.json"
            );

    for (String fileName : fileNames) {
        if (includedFiles.contains(fileName)) {
          System.out.println("Running: " + fileName);
          String json = JSONReader.loadJSON("StateTests//RandomTests/" + fileName);
          GitHubJSONTestSuite.runStateTest(json);
        }
    }

}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:22,代码来源:GitHubStateTest.java

示例9: stWalletTest

import org.json.simple.parser.ParseException; //导入依赖的package包/类
@Test
public void stWalletTest() throws ParseException, IOException {
    Set<String> excluded = new HashSet<>();

    String json = JSONReader.loadJSONFromCommit("StateTests/stWalletTest.json", shacommit);
    GitHubJSONTestSuite.runStateTest(json, excluded);

    json = JSONReader.loadJSONFromCommit("StateTests/Homestead/stWalletTest.json", shacommit);
    GitHubJSONTestSuite.runStateTest(json, excluded);

    json = JSONReader.loadJSONFromCommit("StateTests/EIP150/Homestead/stWalletTest.json", shacommit);
    GitHubJSONTestSuite.runStateTest(json, excluded);

    json = JSONReader.loadJSONFromCommit("StateTests/EIP158/Homestead/stWalletTest.json", shacommit);
    GitHubJSONTestSuite.runStateTest(json, excluded);
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:17,代码来源:GitHubStateTest.java

示例10: shouldReturnServerErrorAndReasonWhenMisconfigured

import org.json.simple.parser.ParseException; //导入依赖的package包/类
@Test
public void shouldReturnServerErrorAndReasonWhenMisconfigured() throws ParseException {
    ApiGatewayProxyRequest request = new ApiGatewayProxyRequestBuilder()
            .withHttpMethod(METHOD)
            .build();
    LambdaProxyHandler<Configuration> handlerWithFailingConguration = new TestLambdaProxyHandlerWithFailingConguration();
    handlerWithFailingConguration.registerMethodHandler(METHOD, c -> methodHandler);

    ApiGatewayProxyResponse actual = handlerWithFailingConguration.handleRequest(request, context);

    assertThat(actual).isNotNull();
    assertThat(actual.getStatusCode()).isEqualTo(INTERNAL_SERVER_ERROR.getStatusCode());
    JSONParser jsonParser = new JSONParser();
    JSONObject jsonObject = (JSONObject) jsonParser.parse(actual.getBody());
    assertThat(jsonObject.keySet()).contains("message", "cause");
    assertThat((String) jsonObject.get("message")).contains("This service is mis-configured. Please contact your system administrator.");
    assertThat((String) jsonObject.get("cause")).contains("NullPointerException");
}
 
开发者ID:gabrielle-anderson,项目名称:aws-lambda-proxy-java,代码行数:19,代码来源:LambdaProxyHandlerTest.java

示例11: testRandomVMGitHub

import org.json.simple.parser.ParseException; //导入依赖的package包/类
@Test // testing full suite
public void testRandomVMGitHub() throws ParseException {

    String shacommit = "c5eafb85390eee59b838a93ae31bc16a5fd4f7b1";
    List<String> fileNames = getFileNamesForTreeSha(shacommit);
    List<String> excludedFiles =
            Collections.singletonList(
                    ""
            );

    for (String fileName : fileNames) {

        if (excludedFiles.contains(fileName)) continue;
        System.out.println("Running: " + fileName);
        String json = JSONReader.loadJSON("VMTests//RandomTests/" + fileName);
        GitHubJSONTestSuite.runGitHubJsonVMTest(json);
    }

}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:20,代码来源:GitHubVMTest.java

示例12: getAllMenuJson

import org.json.simple.parser.ParseException; //导入依赖的package包/类
/**
 * 네트워크 연결을 통한 모든 메뉴 JSON 파싱
 * @param reqAddress 모든 파라미터가 포함된 리퀘스트 주소
 * @return 모든 메뉴가 담긴 JSONObject
 * @throws IOException
 * @throws ParseException
 */
private JSONObject getAllMenuJson(String reqAddress) throws IOException, ParseException {
	HttpURLConnection conn = (HttpURLConnection)new URL(reqAddress).openConnection();
	conn.setRequestMethod("GET");
	conn.setRequestProperty("User-Agent", "Mozilla/5.0");
	conn.setConnectTimeout(5000);
	
	BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
	String line;
	StringBuilder sb = new StringBuilder();
	
	while((line = br.readLine()) != null){
		sb.append(line);
	}
	br.close();
	
	
	JSONParser parser = new JSONParser();
	JSONObject allMenu = (JSONObject)parser.parse(replace(sb.toString()));

	return allMenu;
}
 
开发者ID:occidere,项目名称:KMUC,代码行数:29,代码来源:Carte.java

示例13: runHomestead

import org.json.simple.parser.ParseException; //导入依赖的package包/类
private void runHomestead(String name) throws IOException, ParseException {
    String json = JSONReader.loadJSONFromCommit("BlockchainTests/Homestead/" + name + ".json", shacommit);
    ConfigHelper.CONFIG.setBlockchainConfig(new GenesisConfig());
    try {
        GitHubJSONTestSuite.runGitHubJsonBlockTest(json, Collections.EMPTY_SET);
    } finally {
        ConfigHelper.CONFIG.setBlockchainConfig(MainNetConfig.INSTANCE);
    }
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:10,代码来源:GitHubBlockTest.java

示例14: 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

示例15: sendMessage

import org.json.simple.parser.ParseException; //导入依赖的package包/类
protected Result sendMessage(Constants.RequestPath requestPath, StringBuilder body, int retries) throws IOException, ParseException {
    int attempt = 0;
    Result result = null;
    int backoff = 1000;
    boolean tryAgain = false;

    do {
        ++attempt;
        if(logger.isLoggable(Level.FINE)) {
            logger.fine("Attempt #" + attempt + " to send " + body + " to url " + requestPath.getPath());
        }

        String bodyStr = body.toString();
        if(bodyStr.charAt(0) == 38) {
            bodyStr = body.toString().substring(1);
        }

        result = this.sendMessage(requestPath, bodyStr);
        tryAgain = result == null && attempt <= retries;
        if(tryAgain) {
            int sleepTime = backoff / 2 + this.random.nextInt(backoff);
            this.sleep((long)sleepTime);
            if(2 * backoff < 1024000) {
                backoff *= 2;
            }
        }
    } while(tryAgain);

    if(result == null) {
        throw this.exception(attempt);
    } else {
        return result;
    }
}
 
开发者ID:marlonwang,项目名称:raven,代码行数:35,代码来源:MessageTool.java


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