當前位置: 首頁>>代碼示例>>Java>>正文


Java JSONObject.optString方法代碼示例

本文整理匯總了Java中net.sf.json.JSONObject.optString方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONObject.optString方法的具體用法?Java JSONObject.optString怎麽用?Java JSONObject.optString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.sf.json.JSONObject的用法示例。


在下文中一共展示了JSONObject.optString方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addGlobalConfigDataForSonarInstance

import net.sf.json.JSONObject; //導入方法依賴的package包/類
protected void addGlobalConfigDataForSonarInstance(JSONObject globalConfigData) {

        String name = globalConfigData.optString("name");
        int timeToWait = globalConfigData.optInt("timeToWait");
        String url = globalConfigData.optString("url");

        if (!"".equals(name)) {

            GlobalConfigDataForSonarInstance globalConfigDataForSonarInstance;
            String token = globalConfigData.optString("token");
            if (StringUtils.isNotEmpty(token)) {
                globalConfigDataForSonarInstance = new GlobalConfigDataForSonarInstance(name, url, globalConfigData.optString("token"), timeToWait);
            } else {
                globalConfigDataForSonarInstance = new GlobalConfigDataForSonarInstance(name, url, globalConfigData.optString("account"), Secret.fromString(Util.fixEmptyAndTrim(globalConfigData.optString("password"))), timeToWait);
            }

            if (!containsGlobalConfigWithName(name)) {
                listOfGlobalConfigInstances.add(globalConfigDataForSonarInstance);
            }
        }
    }
 
開發者ID:jenkinsci,項目名稱:sonar-quality-gates-plugin,代碼行數:22,代碼來源:GlobalConfigurationService.java

示例2: startOnline

import net.sf.json.JSONObject; //導入方法依賴的package包/類
public String startOnline() throws IOException {
    String uri = address + "api/active/receiver/start";
    LinkedList<FormBodyPart> partsList = new LinkedList<>();
    partsList.add(new FormBodyPart("token", new StringBody(token)));
    partsList.add(new FormBodyPart("projectKey", new StringBody(project)));
    partsList.add(new FormBodyPart("title", new StringBody(title)));
    JSONObject obj = queryObject(createPost(uri, partsList), 201);
    return address + "gui/active/" + obj.optString("OnlineID", "N/A") + "/";
}
 
開發者ID:Blazemeter,項目名稱:jmeter-bzm-plugins,代碼行數:10,代碼來源:LoadosophiaAPIClient.java

示例3: process

import net.sf.json.JSONObject; //導入方法依賴的package包/類
@Override
    public boolean process(AGContext context, JSONObject env, JavaFileObject javaFileObject, TypeDefineCodeBlock typeDefineCodeBlock, Set<? extends BaseStatement> set) {
        if (typeDefineCodeBlock.getAnnotation(IPCInvokeTaskManager.class.getSimpleName()) == null) {
            Log.i(TAG, "the TypeDefineCodeBlock do not contains 'IPCInvokeTaskManager' annotation.(%s)", javaFileObject.getFileName());
            return false;
        }
        if (set.isEmpty()) {
            Log.i(TAG, "containsSpecialAnnotationStatements is nil");
            return false;
        }
        final String outputDir = env.optString(EnvArgsConstants.KEY_OUTPUT_DIR);
        final String pkg = env.optString(EnvArgsConstants.KEY_PACKAGE);
        final String filePath = env.optString(EnvArgsConstants.KEY_FILE_PATH);

        if (Util.isNullOrNil(outputDir)) {
            Log.i(TAG, "process failed, outputDir is null or nil.(filePath : %s)", filePath);
            return false;
        }
        JSONObject args = new JSONObject();
//        args.put("template", "");
        args.put("templateTag", "ipc-invoker-gentask");
        args.put(ArgsConstants.EXTERNAL_ARGS_KEY_DEST_DIR, outputDir);
        args.put("toFile", Util.joint(File.separator, Util.exchangeToPath(pkg),
                String.format("%s$AG.java", typeDefineCodeBlock.getName().getName())));
        args.put("fileObject", javaFileObject.toJSONObject());
        args.put("methodSet", toJSONArray(set));
        context.execProcess("template-processor", args);
        return true;
    }
 
開發者ID:AlbieLiang,項目名稱:IPCInvoker,代碼行數:30,代碼來源:IPCInvokeTaskProcessor.java

示例4: process

import net.sf.json.JSONObject; //導入方法依賴的package包/類
@Override
public boolean process(AGContext context, JSONObject env, JavaFileObject javaFileObject, TypeDefineCodeBlock typeDefineCodeBlock, Set<? extends BaseStatement> set) {
    if (typeDefineCodeBlock.getAnnotation(IPCInvokeTaskManager.class.getSimpleName()) == null) {
        Log.i(TAG, "the TypeDefineCodeBlock do not contains 'IPCInvokeTaskManager' annotation.(%s)", javaFileObject.getFileName());
        return false;
    }
    if (set.isEmpty()) {
        Log.i(TAG, "containsSpecialAnnotationStatements is nil");
        return false;
    }
    final String outputDir = env.optString(EnvArgsConstants.KEY_OUTPUT_DIR);
    final String pkg = env.optString(EnvArgsConstants.KEY_PACKAGE);
    final String filePath = env.optString(EnvArgsConstants.KEY_FILE_PATH);

    if (Util.isNullOrNil(outputDir)) {
        Log.i(TAG, "process failed, outputDir is null or nil.(filePath : %s)", filePath);
        return false;
    }

    JavaFileObject fObject = new JavaFileObject();

    fObject.addTypeDefineCodeBlock(createTypeDefineCodeBlock(typeDefineCodeBlock, set));
    fObject.setPackageStatement(javaFileObject.getPackageStatement());
    fObject.copyImports(javaFileObject);
    fObject.attachEnvironmentArgs(javaFileObject.getEnvironmentArgs());

    GenCodeTaskInfo taskInfo = new GenCodeTaskInfo();
    taskInfo.FileName = fObject.getFileName();
    taskInfo.RootDir = Util.joint(File.separator, outputDir, Util.exchangeToPath(pkg));
    taskInfo.javaFileObject = fObject;

    CustomizeGenerator generator = new CodeGenerator(fObject);
    FileOperation.saveToFile(taskInfo, generator.genCode());
    Log.i(TAG, "genCode rootDir : %s, fileName : %s, suffix : %s", taskInfo.RootDir, taskInfo.FileName, taskInfo.Suffix);
    return true;
}
 
開發者ID:AlbieLiang,項目名稱:IPCInvoker,代碼行數:37,代碼來源:IPCInvokerTaskAnnotationProcessor.java


注:本文中的net.sf.json.JSONObject.optString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。