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


Java JsonObjectBuilder.addNull方法代碼示例

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


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

示例1: setProperties

import javax.json.JsonObjectBuilder; //導入方法依賴的package包/類
@Override
protected void setProperties() {
	final DirectoryNode dirNode = (DirectoryNode)entry;

	final JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
	ClassID storageClsid = dirNode.getStorageClsid();
	if (storageClsid == null) {
		jsonBuilder.addNull("storage_clsid");
	} else {
		jsonBuilder.add("storage_clsid", storageClsid.toString());
	}
	
	dirNode.forEach(e -> {
		if (e instanceof DocumentNode) {
			DocumentNode dn = (DocumentNode)e;
			jsonBuilder.add(escapeString(dn.getName()), "Size: "+dn.getSize());
		}
	});
	
	final String props = jsonBuilder.build().toString();
	if (surrugateEntry != null) {
		treeObservable.mergeProperties(props);
	} else {
		treeObservable.setProperties(props);
	}
}
 
開發者ID:kiwiwings,項目名稱:poi-visualizer,代碼行數:27,代碼來源:OLEDirEntry.java

示例2: getProperties

import javax.json.JsonObjectBuilder; //導入方法依賴的package包/類
private String getProperties() {
	final JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
	final long id = property.getID();
	jsonBuilder.add("ID", id);
	jsonBuilder.add("Type", property.getType());
	jsonBuilder.add("VariantName", id == 0 ? "dictionary" : Variant.getVariantName(property.getType()));
	switch ((int)property.getType()) {
	case Variant.VT_CF:
		jsonBuilder.add("Value", "<see binary/save entry>");
		break;
       case Variant.VT_ARRAY | Variant.VT_I2:
       case Variant.VT_ARRAY | Variant.VT_I4:
       case Variant.VT_ARRAY | Variant.VT_R4:
       case Variant.VT_ARRAY | Variant.VT_R8:
       case Variant.VT_ARRAY | Variant.VT_CY:
       case Variant.VT_ARRAY | Variant.VT_DATE:
       case Variant.VT_ARRAY | Variant.VT_BSTR:
       case Variant.VT_ARRAY | Variant.VT_ERROR:
       case Variant.VT_ARRAY | Variant.VT_BOOL:
       case Variant.VT_ARRAY | Variant.VT_VARIANT:
       case Variant.VT_ARRAY | Variant.VT_DECIMAL:
       case Variant.VT_ARRAY | Variant.VT_I1:
       case Variant.VT_ARRAY | Variant.VT_UI1:
       case Variant.VT_ARRAY | Variant.VT_UI2:
       case Variant.VT_ARRAY | Variant.VT_UI4:
       case Variant.VT_ARRAY | Variant.VT_INT:
       case Variant.VT_ARRAY | Variant.VT_UINT:
		jsonBuilder.add("Value", VariantSpy.arrayToJson(property, propertySet));
		break;
       case Variant.VT_VECTOR | Variant.VT_I2:
       case Variant.VT_VECTOR | Variant.VT_I4:
       case Variant.VT_VECTOR | Variant.VT_R4:
       case Variant.VT_VECTOR | Variant.VT_R8:
       case Variant.VT_VECTOR | Variant.VT_CY:
       case Variant.VT_VECTOR | Variant.VT_DATE:
       case Variant.VT_VECTOR | Variant.VT_BSTR:
       case Variant.VT_VECTOR | Variant.VT_ERROR:
       case Variant.VT_VECTOR | Variant.VT_BOOL:
       case Variant.VT_VECTOR | Variant.VT_VARIANT:
       case Variant.VT_VECTOR | Variant.VT_I1:
       case Variant.VT_VECTOR | Variant.VT_UI1:
       case Variant.VT_VECTOR | Variant.VT_UI2:
       case Variant.VT_VECTOR | Variant.VT_UI4:
       case Variant.VT_VECTOR | Variant.VT_I8:
       case Variant.VT_VECTOR | Variant.VT_UI8:
       case Variant.VT_VECTOR | Variant.VT_LPSTR:
       case Variant.VT_VECTOR | Variant.VT_LPWSTR:
       case Variant.VT_VECTOR | Variant.VT_FILETIME:
       case Variant.VT_VECTOR | Variant.VT_CF:
       case Variant.VT_VECTOR | Variant.VT_CLSID:
		jsonBuilder.add("Value", VariantSpy.vectorToJson(property, propertySet));
		break;
	default:
		if (property.getValue() == null) {
			jsonBuilder.addNull("Value");
		} else {
			jsonBuilder.add("Value", property.getValue().toString());
		}
		break;
	}
	return jsonBuilder.build().toString();
}
 
開發者ID:kiwiwings,項目名稱:poi-visualizer,代碼行數:63,代碼來源:HPSFProperty.java

示例3: reflectProperties

import javax.json.JsonObjectBuilder; //導入方法依賴的package包/類
public static String reflectProperties(Object obj) {
	final JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();

	for (Method m : getGetter(new ArrayList<>(), obj.getClass())) {
		if (useReturnType(m)) {
			Matcher match = getter.matcher(m.getName());
			match.matches();
			final String propName = match.group(1);
			Object retVal;
			try {
				m.setAccessible(true);
				retVal = m.invoke(obj);
			} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
				retVal = e.getMessage();
			}
			
			if (retVal == null) {
				jsonBuilder.addNull(propName);
			} else if (retVal instanceof Collection<?>) {
				final JsonArrayBuilder arrBuilder = Json.createArrayBuilder();
				for (Object o : ((Collection<?>)retVal)) {
					if (o == null) {
						arrBuilder.addNull();
					} else {
						arrBuilder.add(o.toString());
					}
				}
				jsonBuilder.add(propName, arrBuilder.build());
			} else if (retVal instanceof Double) {
				jsonBuilder.add(propName, ((Double)retVal).doubleValue());
			} else if (retVal instanceof Boolean) {
				jsonBuilder.add(propName, ((Boolean)retVal).booleanValue());
			} else if (retVal instanceof Integer || retVal instanceof Short || retVal instanceof Byte) {
				jsonBuilder.add(propName, ((Number)retVal).intValue());
			} else if (retVal instanceof Long) {
				jsonBuilder.add(propName, ((Long)retVal).longValue());
			} else if (retVal instanceof BigDecimal) {
				jsonBuilder.add(propName, (BigDecimal)retVal);
			} else if (retVal instanceof BigInteger) {
				jsonBuilder.add(propName, (BigInteger)retVal);
			} else {
				jsonBuilder.add(propName, retVal.toString());
			}
		}
	}
	return jsonBuilder.build().toString();
}
 
開發者ID:kiwiwings,項目名稱:poi-visualizer,代碼行數:48,代碼來源:TreeModelUtils.java


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