本文整理汇总了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);
}
}
示例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();
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
}
示例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());
}
}
示例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 );
}
示例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() );
}
}
示例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)));
}
示例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()));
}
示例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));
}
示例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;
}
示例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);
}
示例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);
}