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


Java ObjectNode類代碼示例

本文整理匯總了Java中com.fasterxml.jackson.databind.node.ObjectNode的典型用法代碼示例。如果您正苦於以下問題:Java ObjectNode類的具體用法?Java ObjectNode怎麽用?Java ObjectNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ObjectNode類屬於com.fasterxml.jackson.databind.node包,在下文中一共展示了ObjectNode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: encode

import com.fasterxml.jackson.databind.node.ObjectNode; //導入依賴的package包/類
@Override
public ObjectNode encode(Region region, CodecContext context) {
    checkNotNull(region, NULL_REGION_MSG);

    ObjectNode result = context.mapper().createObjectNode()
            .put(REGION_ID, region.id().toString())
            .put(NAME, region.name())
            .put(TYPE, region.type().toString());

    ArrayNode masters = context.mapper().createArrayNode();

    region.masters().forEach(sets -> {
        ArrayNode setsJson = context.mapper().createArrayNode();
        sets.forEach(nodeId -> setsJson.add(nodeId.toString()));
        masters.add(setsJson);
    });
    result.set(MASTERS, masters);
    return result;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:20,代碼來源:RegionCodec.java

示例2: onDeviceRpcResponse

import com.fasterxml.jackson.databind.node.ObjectNode; //導入依賴的package包/類
@Override
public void onDeviceRpcResponse(RpcCommandResponse response) {
    final int msgId = msgIdSeq.incrementAndGet();
    int requestId = response.getRequestId();
    String deviceName = response.getDeviceName();
    String data = response.getData();
    checkDeviceConnected(deviceName);

    ObjectNode node = newNode();
    node.put("id", requestId);
    node.put("device", deviceName);
    node.put("data", data);
    MqttMessage msg = new MqttMessage(toBytes(node));
    msg.setId(msgId);
    publishAsync(GATEWAY_RPC_TOPIC, msg,
            token -> {
                log.debug("[{}][{}] RPC response from device was delivered!", deviceName, requestId);
            },
            error -> {
                log.warn("[{}][{}] Failed to report RPC response from device!", deviceName, requestId, error);
            });
}
 
開發者ID:osswangxining,項目名稱:iot-edge-greengrass,代碼行數:23,代碼來源:MqttGatewayService.java

示例3: getDatasetColumnByID

import com.fasterxml.jackson.databind.node.ObjectNode; //導入依賴的package包/類
public static Result getDatasetColumnByID(int datasetId, int columnId)
{
    List<DatasetColumn> datasetColumnList = DatasetsDAO.getDatasetColumnByID(datasetId, columnId);

    ObjectNode result = Json.newObject();

    if (datasetColumnList != null && datasetColumnList.size() > 0)
    {
        result.put("status", "ok");
        result.set("columns", Json.toJson(datasetColumnList));
    }
    else
    {
        result.put("status", "error");
        result.put("message", "record not found");
    }

    return ok(result);
}
 
開發者ID:SirAeroWN,項目名稱:premier-wherehows,代碼行數:20,代碼來源:Dataset.java

示例4: getUsersByRole

import com.fasterxml.jackson.databind.node.ObjectNode; //導入依賴的package包/類
@Restrict({@Group("TEACHER"), @Group("ADMIN")})
public Result getUsersByRole(String role) {

    List<User> users = Ebean.find(User.class)
            .where()
            .eq("roles.name", role)
            .orderBy("lastName")
            .findList();

    ArrayNode array = JsonNodeFactory.instance.arrayNode();
    for (User u : users) {
        ObjectNode part = Json.newObject();
        part.put("id", u.getId());
        part.put("name", String.format("%s %s", u.getFirstName(), u.getLastName()));
        array.add(part);
    }

    return ok(Json.toJson(array));
}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:20,代碼來源:UserController.java

示例5: getModelFromRemote

import com.fasterxml.jackson.databind.node.ObjectNode; //導入依賴的package包/類
private Model getModelFromRemote(String graphQlQuery) {

        ObjectMapper mapper = new ObjectMapper();

        ObjectNode bodyParam = mapper.createObjectNode();

//        bodyParam.set("operationName", null);
//        bodyParam.set("variables", null);
        bodyParam.put("query", graphQlQuery);

        Model model = ModelFactory.createDefaultModel();

        try {
            HttpResponse<InputStream> response = Unirest.post(url)
                    .header("Accept", "application/rdf+xml")
                    .body(bodyParam.toString())
                    .asBinary();

            model.read(response.getBody(), "RDF/XML");

        } catch (UnirestException e) {
            e.printStackTrace();
        }

        return model;
    }
 
開發者ID:semantic-integration,項目名稱:hypergraphql,代碼行數:27,代碼來源:HGraphQLService.java

示例6: diskMetrics

import com.fasterxml.jackson.databind.node.ObjectNode; //導入依賴的package包/類
/**
 * Returns disk metrics of all resources.
 *
 * @return disk metrics of all resources
 * @onos.rsModel DiskMetrics
 */
@GET
@Path("disk_metrics")
@Produces(MediaType.APPLICATION_JSON)
public Response diskMetrics() {

    ArrayNode diskNodes = root.putArray("disks");
    monitorService.availableResourcesSync(localNodeId, DISK).forEach(name -> {
        ObjectNode diskNode = mapper().createObjectNode();
        ObjectNode valueNode = mapper().createObjectNode();

        metricsStats(monitorService, localNodeId, DISK_METRICS, name, valueNode);
        diskNode.put("name", name);
        diskNode.set("value", valueNode);

        diskNodes.add(diskNode);
    });

    return ok(root).build();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:26,代碼來源:ControlMetricsWebResource.java

示例7: testForwardingObjectiveEncode

import com.fasterxml.jackson.databind.node.ObjectNode; //導入依賴的package包/類
/**
 * Tests encoding of a ForwardingObjective object.
 */
@Test
public void testForwardingObjectiveEncode() {

    Criterion criterion1 = Criteria.matchVlanId(VlanId.ANY);
    Criterion criterion2 = Criteria.matchEthType((short) 0x8844);
    TrafficSelector selector = DefaultTrafficSelector.builder()
            .add(criterion1)
            .add(criterion2)
            .build();

    ForwardingObjective forwardingObj = DefaultForwardingObjective.builder()
            .makePermanent()
            .fromApp(APP_ID)
            .withPriority(60)
            .withFlag(ForwardingObjective.Flag.SPECIFIC)
            .nextStep(1)
            .withSelector(selector)
            .add();

    ObjectNode forwardingObjJson = forwardingObjectiveCodec.encode(forwardingObj, context);
    assertThat(forwardingObjJson, matchesForwardingObjective(forwardingObj));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:26,代碼來源:ForwardingObjectiveCodecTest.java

示例8: activate

import com.fasterxml.jackson.databind.node.ObjectNode; //導入依賴的package包/類
@Activate
public void activate() {
    KryoNamespace.Builder kryoBuilder = new KryoNamespace.Builder()
            .register(KryoNamespaces.API)
            .register(ConfigKey.class, ObjectNode.class, ArrayNode.class,
                      JsonNodeFactory.class, LinkedHashMap.class,
                      TextNode.class, BooleanNode.class,
                      LongNode.class, DoubleNode.class, ShortNode.class, IntNode.class,
                      NullNode.class);

    configs = storageService.<ConfigKey, JsonNode>consistentMapBuilder()
            .withSerializer(Serializer.using(kryoBuilder.build()))
            .withName("onos-network-configs")
            .withRelaxedReadConsistency()
            .build();
    configs.addListener(listener);
    log.info("Started");
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:19,代碼來源:DistributedNetworkConfigStore.java

示例9: favorite

import com.fasterxml.jackson.databind.node.ObjectNode; //導入依賴的package包/類
public static boolean favorite(int id, String user)
{
	ObjectNode resultNode = Json.newObject();
	boolean result = false;
	Integer userId = UserDAO.getUserIDByUserName(user);

	if (userId != null && userId !=0)
	{
		int row = getJdbcTemplate().update(FAVORITE_A_DATASET, userId, id);
		if (row > 0)
		{
			result = true;
		}
	}
	return result;
}
 
開發者ID:thomas-young-2013,項目名稱:wherehowsX,代碼行數:17,代碼來源:DatasetsDAO.java

示例10: encodeL1

import com.fasterxml.jackson.databind.node.ObjectNode; //導入依賴的package包/類
/**
 * Encode an L1 modification instruction.
 *
 * @param result json node that the instruction attributes are added to
 */
private void encodeL1(ObjectNode result) {
    L1ModificationInstruction l1Instruction = (L1ModificationInstruction) instruction;
    result.put(InstructionCodec.SUBTYPE, l1Instruction.subtype().name());

    switch (l1Instruction.subtype()) {
        case ODU_SIGID:
            final L1ModificationInstruction.ModOduSignalIdInstruction oduSignalIdInstruction =
                    (L1ModificationInstruction.ModOduSignalIdInstruction) l1Instruction;
            OduSignalId oduSignalId = oduSignalIdInstruction.oduSignalId();

            ObjectNode child = result.putObject("oduSignalId");

            child.put(InstructionCodec.TRIBUTARY_PORT_NUMBER, oduSignalId.tributaryPortNumber());
            child.put(InstructionCodec.TRIBUTARY_SLOT_LEN, oduSignalId.tributarySlotLength());
            child.put(InstructionCodec.TRIBUTARY_SLOT_BITMAP,
                    HexString.toHexString(oduSignalId.tributarySlotBitmap()));
            break;
        default:
            log.info("Cannot convert L1 subtype of {}", l1Instruction.subtype());
            break;
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:28,代碼來源:EncodeInstructionCodecHelper.java

示例11: getServiceRuntime

import com.fasterxml.jackson.databind.node.ObjectNode; //導入依賴的package包/類
public ObjectNode getServiceRuntime ( String hostName, String serviceName_port ) {

		if ( hostResponseMap.containsKey( hostName ) ) {

			try {
				ObjectNode hostRuntime = hostResponseMap.get( hostName );

				if ( hostRuntime.has( "error" ) ) {
					return null;
				} else {
					ObjectNode serviceNode = (ObjectNode) hostRuntime
						.path( HostKeys.services.jsonId );
					if ( serviceNode == null || !serviceNode.has( serviceName_port ) ) {
						return null;
					}
					return (ObjectNode) serviceNode.path( serviceName_port );
				}
			} catch (Exception e) {
				logger.error( "Failed reading", e );
			}
		}

		return null;
	}
 
開發者ID:csap-platform,項目名稱:csap-core,代碼行數:25,代碼來源:HostStatusManager.java

示例12: diskUsage

import com.fasterxml.jackson.databind.node.ObjectNode; //導入依賴的package包/類
@CsapDoc ( notes = { "Host disk usage", "* Agent service only" } )
@GetMapping ( "/diskUsage" )
public ObjectNode diskUsage ()
		throws JsonGenerationException, JsonMappingException,
		IOException {

	ObjectNode diskInfo = jacksonMapper.createObjectNode();

	if ( Application.isJvmInManagerMode() ) {
		diskInfo.put( "error",
			"Disk Usage is only enabled on CsAgent urls. Use /admin/api/hosts, then /CsAgent/api/diskUsage on host.  CSAP Command Runner UI can be used to run on all VMS at same time." );
	} else {
		diskInfo.set( Application.getHOST_NAME(), osManager.getCachedFileSystemInfo() );
	}

	return diskInfo;
}
 
開發者ID:csap-platform,項目名稱:csap-core,代碼行數:18,代碼來源:AgentApi.java

示例13: codecEncodeTest

import com.fasterxml.jackson.databind.node.ObjectNode; //導入依賴的package包/類
@Test
public void codecEncodeTest() {
    GroupBucket bucket1 = DefaultGroupBucket
            .createSelectGroupBucket(DefaultTrafficTreatment.emptyTreatment());
    GroupBucket bucket2 = DefaultGroupBucket
            .createIndirectGroupBucket(DefaultTrafficTreatment.emptyTreatment());
    GroupBuckets buckets = new GroupBuckets(ImmutableList.of(bucket1, bucket2));


    DefaultGroup group = new DefaultGroup(
            new DefaultGroupId(1),
            NetTestTools.did("d1"),
            GroupDescription.Type.INDIRECT,
            buckets);

    MockCodecContext context = new MockCodecContext();
    GroupCodec codec = new GroupCodec();
    ObjectNode groupJson = codec.encode(group, context);

    assertThat(groupJson, matchesGroup(group));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:22,代碼來源:GroupCodecTest.java

示例14: fromJsonNode

import com.fasterxml.jackson.databind.node.ObjectNode; //導入依賴的package包/類
public static QueryObjectProvider fromJsonNode(CatalogService catalogService, VirtualObjectService virtualObjectService, PlatformServer server, JsonNode fullQuery, Integer rid, PackageMetaData packageMetaData) throws JsonParseException, JsonMappingException, IOException, QueryException {
	if (fullQuery instanceof ObjectNode) {
		JsonQueryObjectModelConverter converter = new JsonQueryObjectModelConverter(packageMetaData);
		Query query = converter.parseJson("query", (ObjectNode) fullQuery);
		return new QueryObjectProvider(catalogService, virtualObjectService, server, query, rid, packageMetaData);
	} else {
		throw new QueryException("Query root must be of type object");
	}
}
 
開發者ID:shenan4321,項目名稱:BIMplatform,代碼行數:10,代碼來源:QueryObjectProvider.java

示例15: decode

import com.fasterxml.jackson.databind.node.ObjectNode; //導入依賴的package包/類
/**
 * {@inheritDoc}
 *
 * Note: Result of {@link Port#element()} returned Port object,
 *       is not a full Device object.
 *       Only it's DeviceId can be used.
 */
@Override
public Port decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }

    DeviceId did = DeviceId.deviceId(json.get(ELEMENT).asText());
    Device device = new DummyDevice(did);
    PortNumber number = portNumber(json.get(PORT_NAME).asText());
    boolean isEnabled = json.get(IS_ENABLED).asBoolean();
    Type type = Type.valueOf(json.get(TYPE).asText().toUpperCase());
    long portSpeed = json.get(PORT_SPEED).asLong();
    Annotations annotations = extractAnnotations(json, context);

    return new DefaultPort(device, number, isEnabled, type, portSpeed, annotations);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:24,代碼來源:PortCodec.java


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