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


Java TextNode类代码示例

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


TextNode类属于com.fasterxml.jackson.databind.node包,在下文中一共展示了TextNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserialize

import com.fasterxml.jackson.databind.node.TextNode; //导入依赖的package包/类
public Selector deserialize(JsonParser p, DeserializationContext ctxt)
    throws IOException {
  ObjectMapper mapper = (ObjectMapper) p.getCodec();
  ObjectNode obj = mapper.readTree(p);
  String typeName;
  if (obj.get("@type").isArray()) {
    // Find the actual selector type
    typeName = StreamSupport.stream(obj.get("@type").spliterator(), false)
        .filter(v -> !v.textValue().equals("cnt:ContentAsText"))
        .findFirst().orElse(new TextNode("UNKNOWN")).textValue();
    // Make @type a text value so that Jackson doesn't bail out further down the line
    obj.set("@type", new TextNode(typeName));
  } else {
    typeName = obj.get("@type").textValue();
  }
  if (MAPPING.containsKey(typeName)) {
    return mapper.treeToValue(obj, MAPPING.get(typeName));
  } else {
    throw new IllegalArgumentException("Cannot deserialize Selector.");
  }
}
 
开发者ID:dbmdz,项目名称:iiif-apis,代码行数:22,代码来源:SelectorDeserializer.java

示例2: applyGeneratesDate

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

    JPackage jpackage = new JCodeModel()._package(getClass().getPackage().getName());

    ObjectNode objectNode = new ObjectMapper().createObjectNode();
    objectNode.put("type", "string");

    TextNode formatNode = TextNode.valueOf("date-time");
    objectNode.set("format", formatNode);

    JType mockDateType = mock(JType.class);
    FormatRule mockFormatRule = mock(FormatRule.class);
    when(mockFormatRule.apply(eq("fooBar"), eq(formatNode), Mockito.isA(JType.class), isNull(Schema.class))).thenReturn(mockDateType);
    when(ruleFactory.getFormatRule()).thenReturn(mockFormatRule);

    JType result = rule.apply("fooBar", objectNode, jpackage, null);

    assertThat(result, equalTo(mockDateType));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:TypeRuleTest.java

示例3: getComponentMeta

import com.fasterxml.jackson.databind.node.TextNode; //导入依赖的package包/类
private ObjectNode getComponentMeta(ClassLoader classLoader) {
    Properties properties = loadComponentProperties(classLoader);
    if (properties == null) {
        return null;
    }
    String components = (String) properties.get("components");
    if (components == null) {
        return null;
    }
    String[] part = components.split("\\s");
    ObjectNode componentMeta = new ObjectNode(JsonNodeFactory.instance);
    for (String scheme : part) {
        // find the class name
        String javaType = extractComponentJavaType(classLoader, scheme);
        if (javaType == null) {
            continue;
        }
        String schemeMeta = loadComponentJSonSchema(classLoader, scheme, javaType);
        if (schemeMeta == null) {
            continue;
        }
        componentMeta.set(scheme, new TextNode(schemeMeta));
    }
    return componentMeta.size() > 0 ? componentMeta : null;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:26,代码来源:ExtractConnectorDescriptorsMojo.java

示例4: get

import com.fasterxml.jackson.databind.node.TextNode; //导入依赖的package包/类
public static JsonNode get( final PrimitiveObject obj ) throws IOException{
  switch( obj.getPrimitiveType() ){
    case BOOLEAN:
      return BooleanNode.valueOf( obj.getBoolean() );
    case BYTE:
      return IntNode.valueOf( obj.getInt() );
    case SHORT:
      return IntNode.valueOf( obj.getInt() );
    case INTEGER:
      return IntNode.valueOf( obj.getInt() );
    case LONG:
      return new LongNode( obj.getLong() );
    case FLOAT:
      return new DoubleNode( obj.getDouble() );
    case DOUBLE:
      return new DoubleNode( obj.getDouble() );
    case STRING:
      return new TextNode( obj.getString() );
    case BYTES:
      return new BinaryNode( obj.getBytes() );
    default:
      return new TextNode( null );
  }
}
 
开发者ID:yahoojapan,项目名称:dataplatform-schema-lib,代码行数:25,代码来源:PrimitiveObjectToJsonNode.java

示例5: testMappingException

import com.fasterxml.jackson.databind.node.TextNode; //导入依赖的package包/类
@Test(expected = WebApplicationException.class)
public void testMappingException() throws Exception {
    final ObjectMapper om = mock(ObjectMapper.class);
    when(om.writeValueAsString(any())).thenThrow(new JsonProcessingException("ignore me") {
        private static final long serialVersionUID = 1L;

        @Override
        public StackTraceElement[] getStackTrace() {
            return new StackTraceElement[] {};
        }
    });
    uut = new FactsTransactionsResource(mock(FactStore.class), om);

    final FactTransactionJson tx = new FactTransactionJson();
    tx.facts(Arrays.asList(new FactJson().payload(TextNode.valueOf("buh"))));
    uut.newTransaction(tx);
}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:18,代码来源:FactsTransactionsResource0Test.java

示例6: activate

import com.fasterxml.jackson.databind.node.TextNode; //导入依赖的package包/类
@Activate
public void activate() {
    Serializer serializer = Serializer.using(KryoNamespaces.API,
                    ObjectNode.class, ArrayNode.class,
                    JsonNodeFactory.class, LinkedHashMap.class,
                    TextNode.class, BooleanNode.class,
                    LongNode.class, DoubleNode.class, ShortNode.class,
                    IntNode.class, NullNode.class);

    prefsConsistentMap = storageService.<String, ObjectNode>consistentMapBuilder()
            .withName(ONOS_USER_PREFERENCES)
            .withSerializer(serializer)
            .withRelaxedReadConsistency()
            .build();
    prefsConsistentMap.addListener(prefsListener);
    prefs = prefsConsistentMap.asJavaMap();
    register(core);
    log.info("Started");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:UiExtensionManager.java

示例7: activate

import com.fasterxml.jackson.databind.node.TextNode; //导入依赖的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

示例8: getDetails

import com.fasterxml.jackson.databind.node.TextNode; //导入依赖的package包/类
/**
 * Gets the details of an input or output
 * @param inputOutput The node of the particular input or output
 * @return An CWLElement object with the label, doc and type extracted
 */
private CWLElement getDetails(JsonNode inputOutput) {
    if (inputOutput != null) {
        CWLElement details = new CWLElement();

        // Shorthand notation "id: type" - no label/doc/other params
        if (inputOutput.getClass() == TextNode.class) {
            details.setType(inputOutput.asText());
        } else {
            details.setLabel(extractLabel(inputOutput));
            details.setDoc(extractDoc(inputOutput));
            extractSource(inputOutput).forEach(details::addSourceID);
            details.setDefaultVal(extractDefault(inputOutput));

            // Type is only for inputs
            if (inputOutput.has(TYPE)) {
                details.setType(extractTypes(inputOutput.get(TYPE)));
            }
        }

        return details;
    }
    return null;
}
 
开发者ID:common-workflow-language,项目名称:cwlviewer,代码行数:29,代码来源:CWLService.java

示例9: map

import com.fasterxml.jackson.databind.node.TextNode; //导入依赖的package包/类
/**
 * Map existing JsonRpcRequest to Jackson JsonNode.
 *
 * @param request the JsonRpcRequest
 * @return the ObjectNode
 */
public static ObjectNode map(JsonRpcRequest request) {
  if (request == null) {
    return null;
  }
  ObjectNode node = new ObjectNode(JsonNodeFactory.instance);
  // Set protocol version
  node.set("jsonrpc", JSON_RPC_VERSION);
  // Set method
  node.set("method", new TextNode(request.getMethod()));

  // Set id
  if (request.getId() != null) {
    node.set("id", new TextNode(request.getId()));
  }

  // Set Params
  Map<String, String> params = request.getParams();
  if (params != null && !params.isEmpty()) {
    ObjectMapper mapper = new ObjectMapper();
    node.set("params", mapper.valueToTree(params));
  }
  return node;
}
 
开发者ID:resourcepool,项目名称:jarpic-client,代码行数:30,代码来源:RequestMapper.java

示例10: shouldUpdateNameSuccessfully

import com.fasterxml.jackson.databind.node.TextNode; //导入依赖的package包/类
@Test
public void shouldUpdateNameSuccessfully() throws Exception {
    String serviceId = randomUuid();
    String nameToUpdate = "new-name";
    ServiceUpdateRequest request = ServiceUpdateRequest.from(new ObjectNode(JsonNodeFactory.instance, ImmutableMap.of(
            "path", new TextNode("name"),
            "value", new TextNode(nameToUpdate),
            "op", new TextNode("replace"))));
    ServiceEntity serviceEntity = mock(ServiceEntity.class);

    when(serviceDao.findByExternalId(serviceId)).thenReturn(Optional.of(serviceEntity));
    when(serviceEntity.toService()).thenReturn(Service.from());

    Optional<Service> maybeService = updater.doUpdate(serviceId, request);

    assertThat(maybeService.isPresent(), is(true));
    verify(serviceEntity, times(1)).setName(nameToUpdate);
    verify(serviceDao, times(1)).merge(serviceEntity);
}
 
开发者ID:alphagov,项目名称:pay-adminusers,代码行数:20,代码来源:ServiceUpdaterTest.java

示例11: testEntityCreationSuccess

import com.fasterxml.jackson.databind.node.TextNode; //导入依赖的package包/类
@Test
public void testEntityCreationSuccess() {
    String collectionName = "ect" + System.currentTimeMillis();
    String entityName = "testEntity1";

    HashMap<String,JsonNode> map = new HashMap<>();
    map.put("name",new TextNode(entityName));
    map.put("color",new TextNode("red"));
    map.put("shape",new TextNode("square"));

    UsergridEntity entity = new UsergridEntity(collectionName,null,map);
    UsergridResponse response = entity.save();
    assertNull(response.getResponseError());

    UsergridEntity eLookUp = Usergrid.GET(collectionName, entityName).first();
    assertNotNull("The returned entity is null!", eLookUp);
    assertEquals("entities has the correct type", eLookUp.getType(),collectionName);
    assertEquals("entities has the correct name", eLookUp.getName(),entityName);
    assertEquals("entities has the correct color", eLookUp.getStringProperty("color"),"red");
    assertEquals("entities has the correct shape", eLookUp.getStringProperty("shape"),"square");
}
 
开发者ID:apache,项目名称:usergrid-java,代码行数:22,代码来源:EntityTestCase.java

示例12: deserialize

import com.fasterxml.jackson.databind.node.TextNode; //导入依赖的package包/类
@Override
public GoalState deserialize(
        JsonParser p, DeserializationContext ctxt) throws IOException, JsonParseException {
    String value = ((TextNode) p.getCodec().readTree(p)).textValue();

    if (value.equals("FINISHED") || value.equals("ONCE")) {
        return referenceTerminalGoalState;
    } else if (value.equals("FINISH")) {
        return GoalState.FINISH;
    } else if (value.equals("RUNNING")) {
        return GoalState.RUNNING;
    } else {
        logger.warn("Found unknown goal state in config store: {}", value);
        return GoalState.UNKNOWN;
    }
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:17,代码来源:DefaultServiceSpec.java

示例13: getSharedDevice

import com.fasterxml.jackson.databind.node.TextNode; //导入依赖的package包/类
@NotNull
public static UsergridDevice getSharedDevice(@NotNull final Context context) {
    if (sharedDevice == null) {
        sharedDevice = UsergridSharedDevice.getStoredSharedDevice(context);
        if (sharedDevice == null) {
            String sharedDeviceId = UsergridSharedDevice.getSharedDeviceUUID(context);
            HashMap<String, JsonNode> map = new HashMap<String, JsonNode>();
            map.put("uuid", new TextNode(sharedDeviceId));
            sharedDevice = new UsergridDevice(map);
            sharedDevice.setModel(Build.MODEL);
            sharedDevice.setPlatform("android");
            sharedDevice.setOsVersion(Build.VERSION.RELEASE);
        }
    }
    return sharedDevice;
}
 
开发者ID:apache,项目名称:usergrid-android,代码行数:17,代码来源:UsergridSharedDevice.java

示例14: deserialize

import com.fasterxml.jackson.databind.node.TextNode; //导入依赖的package包/类
@Test
public void deserialize() throws Exception {
    StratumMessage m1 = readValue("{\"id\":123, \"method\":\"a.b\", \"params\":[1, \"x\", null]}");
    assertEquals(123L, (long)m1.id);
    assertEquals("a.b", m1.method);
    assertEquals(Lists.newArrayList(new IntNode(1), new TextNode("x"), NullNode.getInstance()), m1.params);
    StratumMessage m2 = readValue("{\"id\":123, \"result\":{\"x\": 123}}");
    assertTrue(m2.isResult());
    assertEquals(123L, (long)m2.id);
    assertEquals(mapper.createObjectNode().put("x", 123), m2.result);

    StratumMessage m3 = readValue("{\"id\":123, \"result\":[\"x\"]}");
    assertEquals(123L, (long)m3.id);
    //noinspection AssertEqualsBetweenInconvertibleTypes
    assertEquals(mapper.createArrayNode().add("x"), m3.result);
}
 
开发者ID:devrandom,项目名称:java-stratum,代码行数:17,代码来源:StratumMessageTest.java

示例15: createActitvityExtract

import com.fasterxml.jackson.databind.node.TextNode; //导入依赖的package包/类
@Test
public void createActitvityExtract() throws Exception
{
    MarketoResponse<ObjectNode> marketoResponse = new MarketoResponse<>();
    marketoResponse.setSuccess(true);
    Date startDate = new Date(1506865856000L);
    Date endDate = new Date(1507297856000L);
    ObjectNode bulkExtractResult = OBJECT_MAPPER.createObjectNode();
    bulkExtractResult.set("exportId", new TextNode("bulkExtractId"));
    marketoResponse.setResult(Arrays.asList(bulkExtractResult));
    ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
    Mockito.doReturn(marketoResponse).when(marketoRestClient).doPost(Mockito.eq(END_POINT + MarketoRESTEndpoint.CREATE_ACTIVITY_EXTRACT.getEndpoint()), Mockito.isNull(Map.class), Mockito.isNull(ImmutableListMultimap.class), argumentCaptor.capture(), Mockito.any(MarketoResponseJetty92EntityReader.class));
    String bulkExtractId = marketoRestClient.createActivityExtract(startDate, endDate);
    Assert.assertEquals("bulkExtractId", bulkExtractId);
    String postContent = argumentCaptor.getValue();
    ObjectNode marketoBulkExtractRequest = (ObjectNode) OBJECT_MAPPER.readTree(postContent);
    ObjectNode filter = (ObjectNode) marketoBulkExtractRequest.get("filter");
    Assert.assertTrue(filter.has("createdAt"));
}
 
开发者ID:treasure-data,项目名称:embulk-input-marketo,代码行数:20,代码来源:MarketoRestClientTest.java


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