本文整理匯總了Java中com.fasterxml.jackson.core.TreeNode.size方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeNode.size方法的具體用法?Java TreeNode.size怎麽用?Java TreeNode.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.fasterxml.jackson.core.TreeNode
的用法示例。
在下文中一共展示了TreeNode.size方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: deserialize
import com.fasterxml.jackson.core.TreeNode; //導入方法依賴的package包/類
@Override
public CompoundOperation deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException
{
// Add mapper
if (jp.getCodec() == null)
jp.setCodec(new ObjectMapper());
jp.nextToken();
// Read whole tree
TreeNode tree = jp.readValueAsTree();
Operation[] operations = new Operation[tree.size() - 1];
// tree.get(0) is always zero
// Read operations
for (int i = 1; i < tree.size(); i++) {
JsonParser ojp = tree.get(i).traverse();
ojp.setCodec(new ObjectMapper());
operations[i - 1] = ojp.readValueAs(Operation.class);
}
return new CompoundOperation(operations);
}
示例2: compareArrays
import com.fasterxml.jackson.core.TreeNode; //導入方法依賴的package包/類
protected void compareArrays(TreeNode a, TreeNode b) {
assertThat(a.isArray()).isEqualTo(b.isArray());
assertThat(a.size()).isEqualTo(b.size());
for (int i = 0; i < a.size(); i++) {
assertThat(a.get(i)).isEqualTo(b.get(i));
}
}
示例3: parse
import com.fasterxml.jackson.core.TreeNode; //導入方法依賴的package包/類
public boolean parse() throws IOException, JsonProcessingException {
JsonParser parser=factory.createParser(input);
boolean done=false;
do {
TreeNode t=parser.readValueAsTree();
if(t==null) {
done=true;
} else {
if(t instanceof ObjectNode) {
if(!documentCompleted((ObjectNode)t))
return false;
} else if(t instanceof ArrayNode) {
int n=t.size();
for(int i=0;i<n;i++) {
TreeNode elem=t.path(i);
if(elem!=null) {
if(!documentCompleted((ObjectNode)elem))
return false;
}
}
} else {
throw new RuntimeException("Ill formed stream");
}
}
} while(!done);
return true;
}
示例4: isEmpty
import com.fasterxml.jackson.core.TreeNode; //導入方法依賴的package包/類
protected boolean isEmpty(TreeNode node) {
return node.isContainerNode() && node.size() == 0;
}