Java 类org.codehaus.jackson.node.TextNode 实例源码

项目:datacollector    文件:AvroSchemaGenerator.java   
private JsonNode convertToJsonNode(AvroDefaultConfig defaultConfig) {
  switch (defaultConfig.avroType) {
    case BOOLEAN:
      return Boolean.parseBoolean(defaultConfig.defaultValue) ? BooleanNode.TRUE : BooleanNode.FALSE;
    case INTEGER:
      return new IntNode(Integer.parseInt(defaultConfig.defaultValue));
    case LONG:
      return new LongNode(Long.parseLong(defaultConfig.defaultValue));
    case FLOAT:
      // FloatNode is fairly recent and our Jackson version does not have it yet
      return new DoubleNode(Float.parseFloat(defaultConfig.defaultValue));
    case DOUBLE:
      return new DoubleNode(Double.parseDouble(defaultConfig.defaultValue));
    case STRING:
      return new TextNode(defaultConfig.defaultValue);
    default:
      throw new IllegalArgumentException("Unknown type: " + defaultConfig.avroType);
  }
}
项目:kaa    文件:ConfigurationSchemaFormAvroConverter.java   
/**
 * Creates the override strategy field.
 *
 * @return the field
 */
private Field createOverrideStrategyField() {
  List<String> overrideStrategySymbols = Arrays.asList(OverrideStrategy.APPEND.name(),
      OverrideStrategy.REPLACE.name());
  Schema overrideStrategyEnum = Schema.createEnum(OVERRIDE_STRATEGY_TYPE_NAME, null,
      BASE_SCHEMA_FORM_NAMESPACE, overrideStrategySymbols);
  Field overrideStrategyField = new Field(OVERRIDE_STRATEGY, Schema.createUnion(Arrays.asList(
      overrideStrategyEnum, Schema.create(Type.NULL))), null, null);
  overrideStrategyField.addProp(DISPLAY_NAME, "Override strategy");
  JsonNodeFactory jsonFactory = JsonNodeFactory.instance;
  ArrayNode displayNamesNode = jsonFactory.arrayNode();
  displayNamesNode.add(TextNode.valueOf("Append"));
  displayNamesNode.add(TextNode.valueOf("Replace"));
  overrideStrategyField.addProp(DISPLAY_NAMES, displayNamesNode);
  overrideStrategyField.addProp(DISPLAY_PROMPT, "Select array override strategy");
  return overrideStrategyField;
}
项目:kaa    文件:EcfSchemaFormAvroConverter.java   
/**
 * Creates the class type field.
 *
 * @return the field
 */
private Field createClassTypeField() {
  List<String> classTypeSymbols = Arrays.asList(OBJECT, EVENT);
  Schema classTypeEnum = Schema.createEnum(CLASS_TYPE_TYPE_NAME, null,
      BASE_SCHEMA_FORM_NAMESPACE, classTypeSymbols);
  Field classTypeField = new Field(CLASS_TYPE, classTypeEnum, null, null);
  classTypeField.addProp(DISPLAY_NAME, "Class type");
  JsonNodeFactory jsonFactory = JsonNodeFactory.instance;
  ArrayNode displayNamesNode = jsonFactory.arrayNode();
  displayNamesNode.add(TextNode.valueOf("Object"));
  displayNamesNode.add(TextNode.valueOf("Event"));
  classTypeField.addProp(DISPLAY_NAMES, displayNamesNode);
  classTypeField.addProp(DISPLAY_PROMPT, "Select class type");
  classTypeField.addProp(BY_DEFAULT, OBJECT);
  return classTypeField;
}
项目:helix    文件:WorkflowAccessor.java   
@GET
@Path("{workflowId}")
public Response getWorkflow(@PathParam("clusterId") String clusterId,
    @PathParam("workflowId") String workflowId) {
  TaskDriver taskDriver = getTaskDriver(clusterId);
  WorkflowConfig workflowConfig = taskDriver.getWorkflowConfig(workflowId);
  WorkflowContext workflowContext = taskDriver.getWorkflowContext(workflowId);

  ObjectNode root = JsonNodeFactory.instance.objectNode();
  TextNode id = JsonNodeFactory.instance.textNode(workflowId);
  root.put(Properties.id.name(), id);

  ObjectNode workflowConfigNode = JsonNodeFactory.instance.objectNode();
  ObjectNode workflowContextNode = JsonNodeFactory.instance.objectNode();

  if (workflowConfig != null) {
    getWorkflowConfigNode(workflowConfigNode, workflowConfig.getRecord());
  }

  if (workflowContext != null) {
    getWorkflowContextNode(workflowContextNode, workflowContext.getRecord());
  }

  root.put(WorkflowProperties.WorkflowConfig.name(), workflowConfigNode);
  root.put(WorkflowProperties.WorkflowContext.name(), workflowContextNode);

  JobDag jobDag = workflowConfig.getJobDag();
  ArrayNode jobs = OBJECT_MAPPER.valueToTree(jobDag.getAllNodes());
  ObjectNode parentJobs = OBJECT_MAPPER.valueToTree(jobDag.getParentsToChildren());
  root.put(WorkflowProperties.Jobs.name(), jobs);
  root.put(WorkflowProperties.ParentJobs.name(), parentJobs);

  return JSONRepresentation(root);
}