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


Java JSONObject.has方法代码示例

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


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

示例1: exportUsers

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
public JSONObject exportUsers(JSONArray usernames) throws EngineException {
	try {
		JSONObject users;
		JSONObject export = new JSONObject();
		
		synchronized (this) {
			users = load();
		}

		for (int i = 0; i < usernames.length(); i++) {
			String name = usernames.getJSONObject(i).getString("name");
			if (users.has(name)) {
				export.put(name, users.get(name));
			}
		}
		return export;
	} catch (Exception exception) {
		throw new EngineException("Failed to update Users", exception);
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:21,代码来源:AuthenticatedSessionManager.java

示例2: addSequences

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
private void addSequences(Map<String, Set<String>> map, TVObject tvs, Object object, boolean isReferenced) {
	if (object != null) {
		if (object instanceof Project) {
			Project project = (Project)object;
			for (Sequence s : project.getSequencesList()) {
				String label = isReferenced ? s.getQName():s.getName();

				tvs.add(new TVObject(label, s));
				
				Set<String> infos = map.get(s.getQName());
				if (infos != null) {
					for (String info: infos) {
						try {
							JSONObject jsonInfo = new JSONObject(info);
							if (jsonInfo.has("marker")) {
								String marker = jsonInfo.getString("marker");
								if (!marker.isEmpty()) {
									tvs.add(new TVObject(label + "#" + marker, s, jsonInfo));
								}
							}
						} catch (JSONException e) {
							e.printStackTrace();
						}
					}
				}
			}
		}
	}
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:30,代码来源:MobilePickerContentProvider.java

示例3: hasUser

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
public boolean hasUser(String username) throws EngineException {
	try {
		JSONObject db;
		synchronized (this) {
			db = load();
		}
		return db.has(username);
	} catch (Exception e) {
		return false;
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:12,代码来源:AuthenticatedSessionManager.java

示例4: IonProperty

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
public IonProperty(JSONObject jsonOb) {
	this();
	for (Key k: Key.values()) {
		if (jsonOb.has(k.name())) {
			try {
				jsonProperty.put(k.name(), jsonOb.get(k.name()));
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:13,代码来源:IonProperty.java

示例5: IonEvent

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
public IonEvent(JSONObject jsonOb) {
	this();
	for (Key k: Key.values()) {
		if (jsonOb.has(k.name())) {
			try {
				jsonEvent.put(k.name(), jsonOb.get(k.name()));
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:13,代码来源:IonEvent.java

示例6: IonBean

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
public IonBean(String jsonString) throws JSONException {
	this();
	JSONObject jsonOb = new JSONObject(jsonString);
	for (Key k: Key.values()) {
		if (jsonOb.has(k.name())) {
			try {
				jsonBean.put(k.name(), jsonOb.get(k.name()));
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:14,代码来源:IonBean.java

示例7: IonConfig

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
public IonConfig(JSONObject jsonOb) {
	this();
	for (Key k: Key.values()) {
		if (jsonOb.has(k.name())) {
			try {
				jsonConfig.put(k.name(), jsonOb.get(k.name()));
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:13,代码来源:IonConfig.java

示例8: invoke

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
@Override
protected JSONObject invoke() throws Exception {
	JSONObject response = super.invoke();
	if ((response.has("ok") && response.getBoolean("ok"))
		|| response.has("error") && "not_found".equals(response.getString("error"))) {
		CouchDbManager.syncDocument(getConnector());
		if (response.has("error")) {
			response.remove("error");
			response.remove("reason");
			response.put("ok", true);
		}
	}
	return response;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:15,代码来源:ResetDatabaseTransaction.java

示例9: getDelegationTokenFromJson

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
public static DelegationToken getDelegationTokenFromJson(JSONObject json)
    throws JSONException {
  DelegationToken ret = new DelegationToken();
  if (json.has("token")) {
    ret.setToken(json.getString("token"));
  } else if (json.has("expiration-time")) {
    ret.setNextExpirationTime(json.getLong("expiration-time"));
  }
  return ret;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestRMWebServicesDelegationTokens.java

示例10: verifyHsJob

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
public static void verifyHsJob(JSONObject info, Job job) throws JSONException {
  assertEquals("incorrect number of elements", 25, info.length());

  // everyone access fields
  verifyHsJobGeneric(job, info.getString("id"), info.getString("user"),
      info.getString("name"), info.getString("state"),
      info.getString("queue"), info.getLong("startTime"),
      info.getLong("finishTime"), info.getInt("mapsTotal"),
      info.getInt("mapsCompleted"), info.getInt("reducesTotal"),
      info.getInt("reducesCompleted"));

  String diagnostics = "";
  if (info.has("diagnostics")) {
    diagnostics = info.getString("diagnostics");
  }

  // restricted access fields - if security and acls set
  verifyHsJobGenericSecure(job, info.getBoolean("uberized"), diagnostics,
      info.getLong("avgMapTime"), info.getLong("avgReduceTime"),
      info.getLong("avgShuffleTime"), info.getLong("avgMergeTime"),
      info.getInt("failedReduceAttempts"),
      info.getInt("killedReduceAttempts"),
      info.getInt("successfulReduceAttempts"),
      info.getInt("failedMapAttempts"), info.getInt("killedMapAttempts"),
      info.getInt("successfulMapAttempts"));

  // acls not being checked since
  // we are using mock job instead of CompletedJob
}
 
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:VerifyJobsUtils.java

示例11: collectComponentTypes

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
private static void collectComponentTypes(JSONObject componentProperties,
    Set<String> componentTypes) throws JSONException {
  String componentType = componentProperties.getString("$Type");
  componentTypes.add(componentType);

  // Recursive call to collect nested components.
  if (componentProperties.has("$Components")) {
    JSONArray components = componentProperties.getJSONArray("$Components");
    for (int i = 0; i < components.length(); i++) {
      collectComponentTypes(components.getJSONObject(i), componentTypes);
    }
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:14,代码来源:FormPropertiesAnalyzer.java

示例12: getExecutorId

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
private String getExecutorId(final JSONObject executor) throws JSONException {
    return executor.has("id") ? executor.getString("id") : executor.getString("executor_id");
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:4,代码来源:MesosStateService.java

示例13: verifySubQueue

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
private void verifySubQueue(JSONObject info, String q, 
    float parentAbsCapacity, float parentAbsMaxCapacity)
    throws JSONException, Exception {
  int numExpectedElements = 13;
  boolean isParentQueue = true;
  if (!info.has("queues")) {
    numExpectedElements = 25;
    isParentQueue = false;
  }
  assertEquals("incorrect number of elements", numExpectedElements, info.length());

  QueueInfo qi = isParentQueue ? new QueueInfo() : new LeafQueueInfo();
  qi.capacity = (float) info.getDouble("capacity");
  qi.usedCapacity = (float) info.getDouble("usedCapacity");
  qi.maxCapacity = (float) info.getDouble("maxCapacity");
  qi.absoluteCapacity = (float) info.getDouble("absoluteCapacity");
  qi.absoluteMaxCapacity = (float) info.getDouble("absoluteMaxCapacity");
  qi.absoluteUsedCapacity = (float) info.getDouble("absoluteUsedCapacity");
  qi.numApplications = info.getInt("numApplications");
  qi.queueName = info.getString("queueName");
  qi.state = info.getString("state");

  verifySubQueueGeneric(q, qi, parentAbsCapacity, parentAbsMaxCapacity);

  if (isParentQueue) {
    JSONArray arr = info.getJSONObject("queues").getJSONArray("queue");
    // test subqueues
    for (int i = 0; i < arr.length(); i++) {
      JSONObject obj = arr.getJSONObject(i);
      String q2 = q + "." + obj.getString("queueName");
      verifySubQueue(obj, q2, qi.absoluteCapacity, qi.absoluteMaxCapacity);
    }
  } else {
    LeafQueueInfo lqi = (LeafQueueInfo) qi;
    lqi.numActiveApplications = info.getInt("numActiveApplications");
    lqi.numPendingApplications = info.getInt("numPendingApplications");
    lqi.numContainers = info.getInt("numContainers");
    lqi.maxApplications = info.getInt("maxApplications");
    lqi.maxApplicationsPerUser = info.getInt("maxApplicationsPerUser");
    lqi.userLimit = info.getInt("userLimit");
    lqi.userLimitFactor = (float) info.getDouble("userLimitFactor");
    verifyLeafQueueGeneric(q, lqi);
    // resourcesUsed and users (per-user resources used) are checked in
    // testPerUserResource()
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:47,代码来源:TestRMWebServicesCapacitySched.java

示例14: verifyAMJob

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
public void verifyAMJob(JSONObject info, Job job) throws JSONException {

    assertEquals("incorrect number of elements", 30, info.length());

    // everyone access fields
    verifyAMJobGeneric(job, info.getString("id"), info.getString("user"),
        info.getString("name"), info.getString("state"),
        info.getLong("startTime"), info.getLong("finishTime"),
        info.getLong("elapsedTime"), info.getInt("mapsTotal"),
        info.getInt("mapsCompleted"), info.getInt("reducesTotal"),
        info.getInt("reducesCompleted"),
        (float) info.getDouble("reduceProgress"),
        (float) info.getDouble("mapProgress"));

    String diagnostics = "";
    if (info.has("diagnostics")) {
      diagnostics = info.getString("diagnostics");
    }

    // restricted access fields - if security and acls set
    verifyAMJobGenericSecure(job, info.getInt("mapsPending"),
        info.getInt("mapsRunning"), info.getInt("reducesPending"),
        info.getInt("reducesRunning"), info.getBoolean("uberized"),
        diagnostics, info.getInt("newReduceAttempts"),
        info.getInt("runningReduceAttempts"),
        info.getInt("failedReduceAttempts"),
        info.getInt("killedReduceAttempts"),
        info.getInt("successfulReduceAttempts"), info.getInt("newMapAttempts"),
        info.getInt("runningMapAttempts"), info.getInt("failedMapAttempts"),
        info.getInt("killedMapAttempts"), info.getInt("successfulMapAttempts"));

    Map<JobACL, AccessControlList> allacls = job.getJobACLs();
    if (allacls != null) {

      for (Map.Entry<JobACL, AccessControlList> entry : allacls.entrySet()) {
        String expectName = entry.getKey().getAclName();
        String expectValue = entry.getValue().getAclString();
        Boolean found = false;
        // make sure ws includes it
        if (info.has("acls")) {
          JSONArray arr = info.getJSONArray("acls");

          for (int i = 0; i < arr.length(); i++) {
            JSONObject aclInfo = arr.getJSONObject(i);
            if (expectName.matches(aclInfo.getString("name"))) {
              found = true;
              WebServicesTestUtils.checkStringMatch("value", expectValue,
                  aclInfo.getString("value"));
            }
          }
        } else {
          fail("should have acls in the web service info");
        }
        assertTrue("acl: " + expectName + " not found in webservice output",
            found);
      }
    }

  }
 
开发者ID:naver,项目名称:hadoop,代码行数:60,代码来源:TestAMWebServicesJobs.java


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