本文整理汇总了Java中com.fasterxml.jackson.databind.node.ObjectNode.size方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectNode.size方法的具体用法?Java ObjectNode.size怎么用?Java ObjectNode.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.node.ObjectNode
的用法示例。
在下文中一共展示了ObjectNode.size方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJsonBufferPadded
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private ByteBuffer getJsonBufferPadded(ObjectNode jsonValue, int byteOffset) {
if (jsonValue == null || jsonValue.size() == 0) {
return ByteBuffer.allocate(0);
}
String jsonStr = jsonValue.toString();
int boundary = 8;
int byteLength = jsonStr.getBytes().length;
int remainder = (byteOffset + byteLength) % boundary;
int padding = (remainder == 0) ? 0 : boundary - remainder;
ByteBuffer result = ByteBuffer.allocate(byteLength + padding);
result.put(jsonStr.getBytes());
for (int i = 0; i < padding; ++i) result.put((byte) 0x20);
// String s = new String(result.array());
return result;
}
示例2: health
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@CsapDoc ( notes = "Health of host" )
@RequestMapping ( "/health" )
public ObjectNode health ()
throws Exception {
ObjectNode healthJson = jacksonMapper.createObjectNode();
ObjectNode errorNode = csapApp.buildErrorsForAdminOrAgent( ServiceAlertsEnum.ALERT_LEVEL );
if ( errorNode.size() == 0 ) {
healthJson.put( "Healthy", true );
} else {
healthJson.put( "Healthy", false );
healthJson.set( "errors", errorNode );
}
return healthJson;
}
示例3: health
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@CsapDoc ( notes = "Summary of Application health" )
@RequestMapping ( "/health" )
public ObjectNode health ()
throws Exception {
ObjectNode healthJson = jacksonMapper.createObjectNode();
ObjectNode errorNode = csapApp.buildErrorsForAdminOrAgent( ServiceAlertsEnum.ALERT_LEVEL );
if ( errorNode.size() == 0 ) {
healthJson.put( "Healthy", true );
} else {
healthJson.put( "Healthy", false );
healthJson.set( "errors", errorNode );
}
return healthJson;
}
示例4: getComponentMeta
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的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;
}
示例5: emanStatus
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@CsapDoc ( notes = {
"Health Check for eman. Alert Level can be used to customize thresholds.",
CsapDoc.INDENT + "A configured limit of 100, with alertLevel=1.5 will become 150"
} , produces = "plain/txt" )
@RequestMapping ( "/emanStatus" )
public String emanStatus (
@RequestParam ( value = "alertLevel" , required = false , defaultValue = "1.0" ) double alertLevelForFiltering ) {
logger.debug( "AlertLevel : {}", alertLevelForFiltering );
String result = "Failure";
try {
// check vm connections
ObjectNode errorNode = csapApp.buildErrorsForAdminOrAgent( alertLevelForFiltering );
if ( errorNode.size() == 0 ) {
result = "Success";
} else {
ObjectWriter writer = jacksonMapper.writerWithDefaultPrettyPrinter();
result = "Failure\n" + writer.writeValueAsString( errorNode );
}
} catch (Exception e) {
logger.error( "Failed: ", e );
}
return result;
}
示例6: addConnectorMeta
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private void addConnectorMeta(ObjectNode root, ClassLoader classLoader) {
ObjectNode node = new ObjectNode(JsonNodeFactory.instance);
addOptionalNode(classLoader, node, "meta", "camel-connector.json");
addOptionalSchemaAsString(classLoader, node, "schema", "camel-connector-schema.json");
if (node.size() > 0) {
root.set("connector", node);
}
}
示例7: addComponentMeta
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private void addComponentMeta(ObjectNode root, ClassLoader classLoader) {
// is there any custom Camel components in this library?
ObjectNode component = new ObjectNode(JsonNodeFactory.instance);
ObjectNode componentMeta = getComponentMeta(classLoader);
if (componentMeta != null) {
component.set("meta", componentMeta);
}
addOptionalSchemaAsString(classLoader, component, "schema", "camel-component-schema.json");
if (component.size() > 0) {
root.set("component", component);
}
}
示例8: toJson
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Override
public JsonNode toJson(SerializationOptions options) {
ObjectNode obj = jsonObject();
for (Entry<String, IJsonOverlay<V>> entry : overlays.entrySet()) {
obj.set(entry.getKey(), entry.getValue().toJson(options.plus(Option.KEEP_ONE_EMPTY)));
}
return obj.size() > 0 || options.isKeepThisEmpty() ? obj : jsonMissing();
}
示例9: execute
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Override
public void execute() throws MojoExecutionException {
try {
JavaProjectBuilder builder = new JavaProjectBuilder();
builder.addSourceTree(new File(srcDirectory, "src/main/java"));
ObjectNode root = initializeRoot();
ArrayNode tags = mapper.createArrayNode();
ObjectNode paths = mapper.createObjectNode();
ObjectNode definitions = mapper.createObjectNode();
root.set("tags", tags);
root.set("paths", paths);
root.set("definitions", definitions);
builder.getClasses().forEach(jc -> processClass(jc, paths, tags, definitions));
if (paths.size() > 0) {
getLog().info("Generating ONOS REST API documentation...");
genCatalog(root);
if (!isNullOrEmpty(apiPackage)) {
genRegistrator();
}
}
project.addCompileSourceRoot(new File(dstDirectory, GEN_SRC).getPath());
} catch (Exception e) {
getLog().warn("Unable to generate ONOS REST API documentation", e);
throw e;
}
}
示例10: resolveObjectNode
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private JsonNode resolveObjectNode(LogEvent event, JsonNode srcNode) {
ObjectNode dstNode = objectMapper.createObjectNode();
Iterator<Map.Entry<String, JsonNode>> srcNodeFieldIterator = srcNode.fields();
while (srcNodeFieldIterator.hasNext()) {
Map.Entry<String, JsonNode> srcNodeField = srcNodeFieldIterator.next();
String key = srcNodeField.getKey();
JsonNode value = srcNodeField.getValue();
JsonNode resolvedValue = resolveNode(event, value);
if (resolvedValue != null) {
dstNode.set(key, resolvedValue);
}
}
return dstNode.size() > 0 ? dstNode : null;
}
示例11: statusForAdminOrAgent
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
public ObjectNode statusForAdminOrAgent ( double alertLevel ) {
ObjectNode healthJson = jacksonMapper.createObjectNode();
ObjectNode errorNode = buildErrorsForAdminOrAgent( alertLevel );
ObjectNode vmNode = healthJson.putObject( "vm" );
if ( errorNode.size() == 0 ) {
healthJson.put( "Healthy", true );
} else {
healthJson.put( "Healthy", false );
healthJson.set( VALIDATION_ERRORS, errorNode );
}
ObjectNode serviceToRuntimeNode = getHostLoadCpuAndMore();
;
vmNode.put( "cpuCount", Integer.parseInt(
serviceToRuntimeNode
.path( "cpuCount" )
.asText() ) );
double newKB = Math.round( Double.parseDouble(
serviceToRuntimeNode
.path( "cpuLoad" )
.asText() )
* 10.0 )
/ 10.0;
vmNode.put( "cpuLoad", newKB );
vmNode.put( "host", Application.getHOST_NAME() );
vmNode.put( "packageName", getActiveModel().getReleasePackageName() );
vmNode.put( "capabilityName", getName() );
vmNode.put( "lifecycle", getCurrentLifeCycle() );
int totalServicesActive = 0;
int totalServices = 0;
for ( ServiceInstance instance : getServicesOnHost() ) {
if ( !instance.isScript() ) { // Scripts should be ignored
totalServices++;
if ( instance.isRunning() ) {
totalServicesActive++;
}
}
}
ObjectNode serviceNode = healthJson.putObject( "services" );
serviceNode.put( "total", totalServices );
serviceNode.put( "active", totalServicesActive );
return healthJson;
}
示例12: execute
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Override
@SuppressWarnings("PMD.EmptyCatchBlock")
public void execute() throws MojoExecutionException, MojoFailureException {
ArrayNode root = new ArrayNode(JsonNodeFactory.instance);
URLClassLoader classLoader = null;
try {
PluginDescriptor desc = (PluginDescriptor) getPluginContext().get("pluginDescriptor");
List<Artifact> artifacts = desc.getArtifacts();
ProjectBuildingRequest buildingRequest =
new DefaultProjectBuildingRequest(session.getProjectBuildingRequest());
buildingRequest.setRemoteRepositories(remoteRepositories);
for (Artifact artifact : artifacts) {
ArtifactResult result = artifactResolver.resolveArtifact(buildingRequest, artifact);
File jar = result.getArtifact().getFile();
classLoader = createClassLoader(jar);
if (classLoader == null) {
throw new IOException("Can not create classloader for " + jar);
}
ObjectNode entry = new ObjectNode(JsonNodeFactory.instance);
addConnectorMeta(entry, classLoader);
addComponentMeta(entry, classLoader);
if (entry.size() > 0) {
addGav(entry, artifact);
root.add(entry);
}
}
if (root.size() > 0) {
saveCamelMetaData(root);
}
} catch (ArtifactResolverException | IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
} finally {
if (classLoader != null) {
try {
classLoader.close();
} catch (IOException ignored) {
}
}
}
}
示例13: requireMetadata
import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private void requireMetadata() {
final ObjectNode metadata = getMetadata();
if (metadata == null || metadata.size() == 0) {
throw new IllegalStateException("CREATE transaction cannot have empty metadata.");
}
}