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


Java ObjectNode.objectNode方法代码示例

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


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

示例1: createItemObject

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private ObjectNode createItemObject(String collectionUuid, PropBagEx metadata, boolean withAttachment)
{
	ObjectNode item = mapper.createObjectNode();

	ObjectNode collection = item.objectNode();
	collection.put("uuid", collectionUuid);
	item.put("collection", collection);
	item.put("metadata", metadata.toString());
	if( withAttachment )
	{
		ArrayNode attachments = item.arrayNode();
		ObjectNode attachment = item.objectNode();
		attachment.put("type", "url");
		attachment.put("description", "Google");
		attachment.put("url", "http://google.com.au/");
		attachment.put("uuid", "uuid:0");
		attachments.add(attachment);
		item.put("attachments", attachments);
	}
	return item;
}
 
开发者ID:equella,项目名称:Equella,代码行数:22,代码来源:ItemApiEditTest.java

示例2: dumpState

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@SuppressWarnings("uncheked")
public static void dumpState(ObjectNode statesNode, String address, AccountState state, ContractDetails details) {

    List<DataWord> storageKeys = new ArrayList<>(details.getStorage().keySet());
    Collections.sort(storageKeys);

    ObjectNode account = statesNode.objectNode();
    ObjectNode storage = statesNode.objectNode();

    for (DataWord key : storageKeys) {
        storage.put("0x" + Hex.toHexString(key.getData()),
                "0x" + Hex.toHexString(details.getStorage().get(key).getNoLeadZeroesData()));
    }

    if (state == null) {
        state = AccountState.EMPTY;
    }

    account.put("balance", state.getBalance() == null ? "0" : state.getBalance().toString());
    account.put("code", details.getCode() == null ? "0x" : "0x" + Hex.toHexString(details.getCode()));
    account.put("nonce", state.getNonce() == null ? "0" : state.getNonce().toString());
    account.set("storage", storage);
    account.put("storage_root", state.getStateRoot() == null ? "" : Hex.toHexString(state.getStateRoot()));

    statesNode.set(address, account);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:27,代码来源:JSONHelper.java

示例3: createSimpleCollection

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private String createSimpleCollection(String schemaUuid) throws IOException
{
	ObjectNode collection = mapper.createObjectNode();
	collection.put("name", "Simple collection");
	collection.with("schema").put("uuid", schemaUuid);

	ArrayNode rules = collection.with("security").putArray("rules");
	ObjectNode rule = collection.objectNode();
	rule.put("granted", false);
	rule.put("override", true);
	rule.put("privilege", "EDIT_ITEM");
	rule.put("who", "$OWNER NOT");
	rules.add(rule);

	return createCollection(collection);
}
 
开发者ID:equella,项目名称:Equella,代码行数:17,代码来源:SecurityTest.java

示例4: dumpState

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@SuppressWarnings("uncheked")
    public static void dumpState(ObjectNode statesNode, String address, AccountState state, ContractDetails details) {

        List<DataWord> storageKeys = new ArrayList<>(details.getStorage().keySet());
        Collections.sort(storageKeys);

        ObjectNode account = statesNode.objectNode();
        ObjectNode storage = statesNode.objectNode();

        for (DataWord key : storageKeys) {
            storage.put("0x" + Hex.toHexString(key.getData()),
                    "0x" + Hex.toHexString(details.getStorage().get(key).getNoLeadZeroesData()));
        }

        if (state == null)
            state = new AccountState(SystemProperties.getDefault().getBlockchainConfig().getCommonConstants().getInitialNonce(),
                    BigInteger.ZERO);

        account.put("balance", state.getBalance() == null ? "0" : state.getBalance().toString());
//        account.put("codeHash", details.getCodeHash() == null ? "0x" : "0x" + Hex.toHexString(details.getCodeHash()));
        account.put("code", details.getCode() == null ? "0x" : "0x" + Hex.toHexString(details.getCode()));
        account.put("nonce", state.getNonce() == null ? "0" : state.getNonce().toString());
        account.set("storage", storage);
        account.put("storage_root", state.getStateRoot() == null ? "" : Hex.toHexString(state.getStateRoot()));

        statesNode.set(address, account);
    }
 
开发者ID:talentchain,项目名称:talchain,代码行数:28,代码来源:JSONHelper.java

示例5: dumpBlock

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
public static void dumpBlock(ObjectNode blockNode, Block block,
                                 long gasUsed, byte[] state, List<ByteArrayWrapper> keys,
                                 Repository repository) {

        blockNode.put("coinbase", Hex.toHexString(block.getCoinbase()));
        blockNode.put("difficulty", new BigInteger(1, block.getDifficulty()).toString());
        blockNode.put("extra_data", "0x");
        blockNode.put("gas_used", String.valueOf(gasUsed));
        blockNode.put("nonce", "0x" + Hex.toHexString(block.getNonce()));
        blockNode.put("number", String.valueOf(block.getNumber()));
        blockNode.put("prevhash", "0x" + Hex.toHexString(block.getParentHash()));

        ObjectNode statesNode = blockNode.objectNode();
        for (ByteArrayWrapper key : keys) {
            byte[] keyBytes = key.getData();
            AccountState accountState = repository.getAccountState(keyBytes);
            ContractDetails details = repository.getContractDetails(keyBytes);
            dumpState(statesNode, Hex.toHexString(keyBytes), accountState, details);
        }
        blockNode.set("state", statesNode);

        blockNode.put("state_root", Hex.toHexString(state));
        blockNode.put("timestamp", String.valueOf(block.getTimestamp()));

        ArrayNode transactionsNode = blockNode.arrayNode();
        blockNode.set("transactions", transactionsNode);

        blockNode.put("tx_list_root", ByteUtil.toHexString(block.getTxTrieRoot()));
        blockNode.put("uncles_hash", "0x" + Hex.toHexString(block.getUnclesHash()));

//      JSONHelper.dumpTransactions(blockNode,
//              stateRoot, codeHash, code, storage);
    }
 
开发者ID:talentchain,项目名称:talchain,代码行数:34,代码来源:JSONHelper.java

示例6: createContractNode

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private ObjectNode createContractNode(ContractDetails contractDetails, ObjectNode accountNode) {
    ObjectNode contractNode = accountNode.objectNode();
    contractNode.put("code", Hex.toHexString(contractDetails.getCode()));
    ObjectNode dataNode = contractNode.objectNode();
    for (DataWord key : contractDetails.getStorageKeys()) {
        byte[] value = contractDetails.getBytes(key);
        dataNode.put(Hex.toHexString(key.getData()), Hex.toHexString(value));
    }
    contractNode.set("data", dataNode);
    return contractNode;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:12,代码来源:NetworkStateExporter.java

示例7: createAccountNode

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private ObjectNode createAccountNode(ObjectNode mainNode, byte[] address, Repository frozenRepository) {
    ObjectNode accountNode = mainNode.objectNode();
    AccountState accountState = frozenRepository.getAccountState(address);
    BigInteger balance = accountState.getBalance();
    accountNode.put("balance", balance.toString());
    BigInteger nonce = accountState.getNonce();
    accountNode.put("nonce", nonce.toString());
    ContractDetails contractDetails = frozenRepository.getContractDetails(address);
    RskAddress addWrapper = new RskAddress(address);
    if (!contractDetails.isNullObject() && !PrecompiledContracts.REMASC_ADDR.equals(addWrapper)) {
        accountNode.set("contract", createContractNode(contractDetails, accountNode));
    }
    return accountNode;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:15,代码来源:NetworkStateExporter.java

示例8: dumpBlock

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
public static void dumpBlock(ObjectNode blockNode, Block block,
                             long gasUsed, byte[] state, List<ByteArrayWrapper> keys,
                             Repository repository) {

    blockNode.put("coinbase", Hex.toHexString(block.getCoinbase()));
    blockNode.put("difficulty", new BigInteger(1, block.getDifficulty()).toString());
    blockNode.put("extra_data", "0x");
    blockNode.put("gas_used", String.valueOf(gasUsed));

    blockNode.put("bitcoin_merged_mining_header", "0x" + Hex.toHexString(block.getBitcoinMergedMiningHeader()));
    blockNode.put("bitcoin_merged_mining_merkle_proof", "0x" + Hex.toHexString(block.getBitcoinMergedMiningMerkleProof()));
    blockNode.put("bitcoin_merged_mining_coinbase_transaction", "0x" + Hex.toHexString(block.getBitcoinMergedMiningCoinbaseTransaction()));

    blockNode.put("number", String.valueOf(block.getNumber()));
    blockNode.put("prevhash", "0x" + Hex.toHexString(block.getParentHash()));

    ObjectNode statesNode = blockNode.objectNode();
    for (ByteArrayWrapper key : keys) {
        byte[] keyBytes = key.getData();
        AccountState accountState = repository.getAccountState(keyBytes);
        ContractDetails details = repository.getContractDetails(keyBytes);
        dumpState(statesNode, Hex.toHexString(keyBytes), accountState, details);
    }
    blockNode.set("state", statesNode);

    blockNode.put("state_root", Hex.toHexString(state));
    blockNode.put("timestamp", String.valueOf(block.getTimestamp()));

    ArrayNode transactionsNode = blockNode.arrayNode();
    blockNode.set("transactions", transactionsNode);

    blockNode.put("tx_list_root", ByteUtil.toHexString(block.getTxTrieRoot()));
    blockNode.put("uncles_hash", "0x" + Hex.toHexString(block.getUnclesHash()));
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:35,代码来源:JSONHelper.java

示例9: slashDelimitedWordsResolveToChildNodes

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Test
public void slashDelimitedWordsResolveToChildNodes() {

    ObjectNode root = new ObjectMapper().createObjectNode();

    ObjectNode a = root.objectNode();
    ObjectNode b = root.objectNode();
    ObjectNode c = root.objectNode();

    root.set("a", a);
    root.set("b", b);
    root.set("c", c);

    ObjectNode x = root.objectNode();
    ObjectNode y = root.objectNode();
    ObjectNode z = root.objectNode();

    a.set("x", x);
    a.set("y", y);
    a.set("z", z);

    ObjectNode _0 = root.objectNode();
    ObjectNode _1 = root.objectNode();
    ObjectNode _2 = root.objectNode();

    z.set("0", _0);
    z.set("1", _1);
    z.set("2", _2);

    assertThat((ObjectNode) resolver.resolve(root, "#/a", "#/."), is(sameInstance(a)));
    assertThat((ObjectNode) resolver.resolve(root, "#/b", "#/."), is(sameInstance(b)));
    assertThat((ObjectNode) resolver.resolve(root, "#/c", "#/."), is(sameInstance(c)));

    assertThat((ObjectNode) resolver.resolve(root, "#/a/x", "#/."), is(sameInstance(x)));
    assertThat((ObjectNode) resolver.resolve(root, "#/a/y", "#/."), is(sameInstance(y)));
    assertThat((ObjectNode) resolver.resolve(root, "#/a/z", "#/."), is(sameInstance(z)));

    assertThat((ObjectNode) resolver.resolve(root, "#/a/z/0", "#/."), is(sameInstance(_0)));
    assertThat((ObjectNode) resolver.resolve(root, "#/a/z/1", "#/."), is(sameInstance(_1)));
    assertThat((ObjectNode) resolver.resolve(root, "#/a/z/2", "#/."), is(sameInstance(_2)));

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:43,代码来源:FragmentResolverTest.java

示例10: enumAsRootIsGeneratedCorrectly

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Test
public void enumAsRootIsGeneratedCorrectly() throws URISyntaxException, JClassAlreadyExistsException {

    ObjectNode schemaContent = new ObjectMapper().createObjectNode();
    ObjectNode enumNode = schemaContent.objectNode();
    enumNode.put("type", "string");
    schemaContent.set("enum", enumNode);

    JDefinedClass jclass = new JCodeModel()._class(TARGET_CLASS_NAME);

    Schema schema = mock(Schema.class);
    when(schema.getContent()).thenReturn(schemaContent);
    schema.setJavaTypeIfEmpty(jclass);

    EnumRule enumRule = mock(EnumRule.class);
    when(mockRuleFactory.getEnumRule()).thenReturn(enumRule);

    when(enumRule.apply(NODE_NAME, enumNode, jclass, schema)).thenReturn(jclass);

    rule.apply(NODE_NAME, schemaContent, jclass, schema);

    verify(enumRule).apply(NODE_NAME, schemaContent, jclass, schema);
    verify(schema, atLeastOnce()).setJavaTypeIfEmpty(jclass);

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:SchemaRuleTest.java

示例11: testEditEverything

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Test
public void testEditEverything() throws Exception
{
	final String token = getToken();
	ItemId itemId = createItem(token);
	// get item
	ObjectNode item = getItem(itemId, "all", token);

	// check all nodes
	assertNameVersionStatus(item, "ItemApiEditTest - All attachments from JSON", 1, "live");
	assertMetadata(item, "item/name", "ItemApiEditTest - All attachments from JSON");
	asserter.assertUser(item.get("owner"), USERID_AUTOTEST);
	asserter.assertUser(item.get("collaborators").get(0), USERID_RESTNOPRIV);
	asserter.assertCollection(item.get("collection"), COLLECTION_ATTACHMENTS);
	assertUrlAttachment(item.get("attachments").get(2), itemId);
	assertFirstNavNode(item.get("navigation").get("nodes"), "avatar.png");

	// modify metadata
	PropBagEx metadata = new PropBagEx(item.get("metadata").textValue());
	metadata.setNode("item/name", "ItemApiEditTest - All attachments from JSON - Edited");
	item.put("metadata", metadata.toString());

	// modify owner
	ObjectNode owner = item.objectNode();
	owner.put("id", USERID_RESTNOPRIV);
	item.put("owner", owner);

	// modify collaborators
	ArrayNode collaborators = item.arrayNode();
	ObjectNode collaborator = item.objectNode();
	collaborator.put("id", USERID_AUTOTEST);
	collaborators.add(collaborator);
	item.put("collaborators", collaborators);

	// Future enhancement
	// modify collection
	// ObjectNode collection = item.objectNode();
	// collection.put("uuid", PERMISSIONS_COLLECTION);
	// item.put("collection", collection);

	// modify attachments
	ObjectNode attachment = (ObjectNode) item.get("attachments").get(2);
	attachment.put("description", "Yahoo");
	attachment.put("url", "http://www.yahoo.com");

	// modify navigation
	ObjectNode node = (ObjectNode) item.get("navigation").get("nodes").get(0);
	node.put("name", "An awesome image");

	// save
	HttpResponse response = putItem(itemId, item.toString(), token);
	assertResponse(response, 200, "Save should work");

	// check that its correct
	item = getItem(itemId, "all", token);
	assertNameVersionStatus(item, "ItemApiEditTest - All attachments from JSON - Edited", 1, "live");
	assertMetadata(item, "item/name", "ItemApiEditTest - All attachments from JSON - Edited");
	asserter.assertUser(item.get("owner"), USERID_RESTNOPRIV);
	asserter.assertUser(item.get("collaborators").get(0), USERID_AUTOTEST);

	// Future enhancement
	// asserter.assertCollection(item.get("collection"),
	// PERMISSIONS_COLLECTION);

	assertUrlAttachment(item.get("attachments").get(2), itemId, "Yahoo", "http://www.yahoo.com");
	assertFirstNavNode(item.get("navigation").get("nodes"), "An awesome image");

}
 
开发者ID:equella,项目名称:Equella,代码行数:69,代码来源:ItemApiEditTest.java


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