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


Java NullNode.getInstance方法代码示例

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


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

示例1: execute

import com.fasterxml.jackson.databind.node.NullNode; //导入方法依赖的package包/类
JsonNode execute(String filename, String source, List<String> command) {
    if (!m_found) {
        return NullNode.getInstance();
    }

    String content = "";
    try {
        content = runCommand(filename, source, command);
        JsonNode jsonNode = m_objectMapper.readTree(content);
        JsonNode valueNode = extractResponse(jsonNode);
        return valueNode == null ? NullNode.getInstance() : valueNode;
    } catch (Exception ex) {
        throw new RuntimeException("An error occurred when executing a command for the file " + filename + "\n"
                + "The command is: " + Joiner.join(" ", command) + "\n"
                + "The output from merlin is: " + content, ex);
    }
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:18,代码来源:MerlinProcess3.java

示例2: kidForKeyId

import com.fasterxml.jackson.databind.node.NullNode; //导入方法依赖的package包/类
@Nonnull
public static JsonNode kidForKeyId(
  @Nonnull final JsonNode node,
  @Nonnull final String keyId){

    for(JsonNode keyNode : node){
        if(keyNode
          .get("kid")
          .asText()
          .equals(keyId)){

            return keyNode;
        }
    }
    return NullNode.getInstance();
}
 
开发者ID:Xitikit,项目名称:xitikit-blue,代码行数:17,代码来源:VerificationUtil.java

示例3: extract

import com.fasterxml.jackson.databind.node.NullNode; //导入方法依赖的package包/类
public Object extract(ObjectNode node, RakamHttpRequest request)
{
    JsonNode value = node.get(name);
    Object o;
    if (value == null) {
        o = null;
    }
    else {
        try {
            o = mapper.convertValue(value, type);
        }
        catch (IllegalArgumentException e) {
            throw new HttpRequestException(name +
                    " body parameter cannot be cast to " + type.toString() + ": "+e.getMessage(), BAD_REQUEST);
        }
    }

    if (required && (o == null || o == NullNode.getInstance())) {
        throw new HttpRequestException(name + " body parameter is required", BAD_REQUEST);
    }

    return o;
}
 
开发者ID:buremba,项目名称:netty-rest,代码行数:24,代码来源:IRequestParameter.java

示例4: trackTestProgress

import com.fasterxml.jackson.databind.node.NullNode; //导入方法依赖的package包/类
synchronized private JobRunSummary trackTestProgress(JobRunId testRunId, PrintStream logger) throws IOException, URISyntaxException {
    Lock l = new ReentrantLock();
    Condition c = l.newCondition();

    l.lock();
    StatusUpdateCheckerTask task = new StatusUpdateCheckerTask(testRunId, getDescriptor().getConnector().jobEngine, logger, l , c);
    Timer timer = new Timer();
    timer.schedule(task, 0, 10000);
    try {
        c.await();
    } catch (InterruptedException e) {
        timer.cancel();
        task.cancel();
        logger.println("Build was aborted. Signaling external test to stop.");
        //TODO actually cancel the testrun
        return new JobRunSummary(JobRunState.FAILED, "JobRun was canceled by user", NullNode.getInstance());
    }
    return task.getStatus();
}
 
开发者ID:webmate-io,项目名称:webmate-jenkins-plugin,代码行数:20,代码来源:WebmateXBrowserBuilder.java

示例5: get

import com.fasterxml.jackson.databind.node.NullNode; //导入方法依赖的package包/类
@Get("/:id/:field")
@Get("/:id/:field/")
public Payload get(String id, String field) {

	checkIfAuthorizedToRead(id);

	Class<? extends Settings> settingsClass = registeredSettingsClasses.get(id);

	ObjectNode settings = settingsClass == null ? Json8.readObject(load(id)) //
			: Json8.mapper().valueToTree(load(settingsClass));

	JsonNode value = settings.get(field);
	if (value == null)
		value = NullNode.getInstance();

	return JsonPayload.json(value, HttpStatus.OK);
}
 
开发者ID:spacedog-io,项目名称:spacedog-server,代码行数:18,代码来源:SettingsResource.java

示例6: wrap

import com.fasterxml.jackson.databind.node.NullNode; //导入方法依赖的package包/类
/**
 * Convert a Java object to a JsonNode
 *
 * @param val
 *            a List, Map, or other object
 * @return a JsonNode that corresponds to the val
 */
@SuppressWarnings("rawtypes")
public static JsonNode wrap(Object val) {
    if (val == null)
        return NullNode.getInstance();
    else if (val instanceof Map)
        return wrap((Map) val);
    else if (val instanceof List)
        return wrap((List) val);
    else {
        ArrayList<Object> o = new ArrayList<Object>(1);
        o.add(val);
        ArrayNode a = wrap(o);
        JsonNode n = a.get(0);
        return n;
    }
}
 
开发者ID:sassoftware,项目名称:unravl,代码行数:24,代码来源:Json.java

示例7: parse

import com.fasterxml.jackson.databind.node.NullNode; //导入方法依赖的package包/类
public static Map.Entry<String, JsonNode> parse(TravnyParser.AnnotationContext ctx) throws IOException {
    String key = ParserUtils.qualifiedIdentifierToString(ctx.annotationName().qualifiedIdentifier());
    TravnyParser.JsonValueContext json = ctx.jsonValue();
    if (json != null) {
        JsonNode node = new ObjectMapper().readTree(json.getText());
        return new AbstractMap.SimpleImmutableEntry<>(key, node);
    } else {
        return new AbstractMap.SimpleImmutableEntry<>(key, NullNode.getInstance());
    }
}
 
开发者ID:atlascon,项目名称:travny,代码行数:11,代码来源:AnnotationParser.java

示例8: create

import com.fasterxml.jackson.databind.node.NullNode; //导入方法依赖的package包/类
@Override
public byte[] create( final IParser parser ) throws IOException{
  JsonNode jsonNode;
  if( parser.isMap() || parser.isStruct() ){
    jsonNode = JacksonParserToJsonObject.getFromObjectParser( parser );
  }
  else if( parser.isArray() ){
    jsonNode = JacksonParserToJsonObject.getFromArrayParser( parser );
  }
  else{
    jsonNode = NullNode.getInstance();
  }

  return objectMapper.writeValueAsBytes( jsonNode );
}
 
开发者ID:yahoojapan,项目名称:dataplatform-schema-lib,代码行数:16,代码来源:JacksonMessageWriter.java

示例9: get

import com.fasterxml.jackson.databind.node.NullNode; //导入方法依赖的package包/类
public static JsonNode get( final Object obj ) throws IOException{

    if( obj instanceof PrimitiveObject ){
      return PrimitiveObjectToJsonNode.get( (PrimitiveObject)obj );
    }
    else if( obj instanceof String ){
      return new TextNode( (String)obj );
    }
    else if( obj instanceof Boolean ){
      return BooleanNode.valueOf( (Boolean)obj );
    }
    else if( obj instanceof Short ){
      return IntNode.valueOf( ( (Short)obj ).intValue() );
    }
    else if( obj instanceof Integer ){
      return IntNode.valueOf( (Integer)obj );
    }
    else if( obj instanceof Long ){
      return new LongNode( (Long)obj );
    }
    else if( obj instanceof Float ){
      return new DoubleNode( ( (Float)obj ).doubleValue() );
    }
    else if( obj instanceof Double ){
      return new DoubleNode( (Double)obj );
    }
    else if( obj instanceof byte[] ){
      return new BinaryNode( (byte[])obj );
    }
    else if( obj == null ){
      return NullNode.getInstance();
    }
    else{
      return new TextNode( obj.toString() );
    }
  }
 
开发者ID:yahoojapan,项目名称:dataplatform-schema-lib,代码行数:37,代码来源:ObjectToJsonNode.java

示例10: shouldHaveTree

import com.fasterxml.jackson.databind.node.NullNode; //导入方法依赖的package包/类
@Test
public void shouldHaveTree() throws Exception {
    HashMap<String, JsonNode> map = new HashMap<>();
    JsonNode node = NullNode.getInstance();
    map.put("key", node);
    BasicHeader header = new BasicHeader(null, null, null, null, map);

    assertThat(header.getTree(), is(notNullValue()));
    assertThat(header.getTree(), is(IsMapContaining.hasEntry("key", node)));
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:11,代码来源:BasicHeaderTest.java

示例11: shouldGetNullStringWhenParsingNullNode

import com.fasterxml.jackson.databind.node.NullNode; //导入方法依赖的package包/类
@Test
public void shouldGetNullStringWhenParsingNullNode() throws Exception {
    Map<String, JsonNode> tree = new HashMap<>();
    NullNode node = NullNode.getInstance();
    tree.put("key", node);

    String text = deserializer.getString(tree, "key");
    assertThat(text, is(nullValue()));
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:10,代码来源:HeaderDeserializerTest.java

示例12: shouldReturnBaseClaimWhenParsingNullNode

import com.fasterxml.jackson.databind.node.NullNode; //导入方法依赖的package包/类
@Test
public void shouldReturnBaseClaimWhenParsingNullNode() throws Exception {
    JsonNode value = NullNode.getInstance();
    Claim claim = claimFromNode(value);

    assertThat(claim, is(notNullValue()));
    assertThat(claim, is(instanceOf(NullClaim.class)));
    assertThat(claim.isNull(), is(true));
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:10,代码来源:JsonNodeClaimTest.java

示例13: project

import com.fasterxml.jackson.databind.node.NullNode; //导入方法依赖的package包/类
@Override
public JsonNode project(Map<String, String> context, String[] path) {
    JsonNode delta = NullNode.getInstance();

    for (String value : dimension.getAncestries(context.getOrDefault(dimension.getName(), ANY_VALUE))) {
        final LookupTree child = edges.get(value);

        if (child != null) {
            delta = mergeDelta(delta, child.project(context, path));
        }
    }

    return delta;
}
 
开发者ID:yahoo,项目名称:ycb-java,代码行数:15,代码来源:InnerNode.java

示例14: testGetSourceNode

import com.fasterxml.jackson.databind.node.NullNode; //导入方法依赖的package包/类
/**
 * Test of getSourceNode method, of class JsonObject.
 */
@Test
public void testGetSourceNode() {
    JsonNode expResult = NullNode.getInstance();
    JsonObject instance = new JsonObjectImpl(expResult);
    JsonNode result = instance.getSourceNode();
    assertEquals(expResult, result);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:11,代码来源:JsonObjectTest.java

示例15: testToJson

import com.fasterxml.jackson.databind.node.NullNode; //导入方法依赖的package包/类
/**
 * Test of toJson method, of class JsonObject.
 */
@Test
public void testToJson() {
    JsonObject instance = new JsonObjectImpl();
    JsonNode expResult = NullNode.getInstance();
    JsonNode result = instance.toJson();
    assertEquals(expResult, result);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:11,代码来源:JsonObjectTest.java


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