当前位置: 首页>>代码示例>>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;未经允许,请勿转载。