Java Code Examples for org.codehaus.jackson.JsonParser#getCodec()

The following examples show how to use org.codehaus.jackson.JsonParser#getCodec() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: urule   File: AbstractJsonDeserializer.java    License: Apache License 2.0 6 votes vote down vote up
private void buildScoreRule(JsonParser jsonParser,JsonNode ruleNode,ScoreRule rule){
	rule.setScoringBean(JsonUtils.getJsonValue(ruleNode, "scoringBean"));
	AssignTargetType assignTargetType=AssignTargetType.valueOf(JsonUtils.getJsonValue(ruleNode, "assignTargetType"));
	rule.setAssignTargetType(assignTargetType);
	rule.setVariableCategory(JsonUtils.getJsonValue(ruleNode, "variableCategory"));
	rule.setVariableName(JsonUtils.getJsonValue(ruleNode, "variableName"));
	rule.setVariableLabel(JsonUtils.getJsonValue(ruleNode, "variableLabel"));
	String datatypeStr=JsonUtils.getJsonValue(ruleNode, "datatype");
	if(StringUtils.isNotBlank(datatypeStr)){
		rule.setDatatype(Datatype.valueOf(datatypeStr));
	}
	try{
		JsonNode knowledgePackageWrapperNode=ruleNode.get("knowledgePackageWrapper");
		ObjectMapper mapper = (ObjectMapper)jsonParser.getCodec();
		KnowledgePackageWrapper wrapper=mapper.readValue(knowledgePackageWrapperNode, KnowledgePackageWrapper.class);
		wrapper.buildDeserialize();
		rule.setKnowledgePackageWrapper(wrapper);			
	}catch(Exception ex){
		throw new RuleException(ex);
	}
	
}
 
Example 2
Source Project: hadoop   File: StateDeserializer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public StatePair deserialize(JsonParser parser, 
                             DeserializationContext context)
throws IOException, JsonProcessingException {
  ObjectMapper mapper = (ObjectMapper) parser.getCodec();
  // set the state-pair object tree
  ObjectNode statePairObject = (ObjectNode) mapper.readTree(parser);
  Class<?> stateClass = null;
  
  try {
    stateClass = 
      Class.forName(statePairObject.get("className").getTextValue().trim());
  } catch (ClassNotFoundException cnfe) {
    throw new RuntimeException("Invalid classname!", cnfe);
  }
  
  String stateJsonString = statePairObject.get("state").toString();
  State state = (State) mapper.readValue(stateJsonString, stateClass);
  
  return new StatePair(state);
}
 
Example 3
Source Project: jwala   File: JsonUpdateWebServer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public JsonUpdateWebServer deserialize(final JsonParser jp, final DeserializationContext ctxt)
        throws IOException {

    final ObjectCodec obj = jp.getCodec();
    final JsonNode node = obj.readTree(jp).get(0);

    final Set<String> groupIds = deserializeGroupIdentifiers(node);
    return new JsonUpdateWebServer(node.get("webserverId").getValueAsText(),
                                   node.get("webserverName").getTextValue(),
                                   node.get("hostName").getTextValue(),
                                   node.get("portNumber").getValueAsText(),
                                   node.get("httpsPort").getValueAsText(),
                                   groupIds,
                                   node.get("statusPath").getTextValue(),
                                   node.get("apacheHttpdMediaId").getTextValue());
}
 
Example 4
Source Project: jwala   File: JsonCreateWebServer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public JsonCreateWebServer deserialize(final JsonParser jp, final DeserializationContext ctxt)
        throws IOException {

    final ObjectCodec obj = jp.getCodec();
    final JsonNode node = obj.readTree(jp).get(0);

    final JsonNode apacheHttpdMediaId = node.get("apacheHttpdMediaId");
    final JsonCreateWebServer jcws = new JsonCreateWebServer(node.get("webserverName").getTextValue(),
            node.get("hostName").getTextValue(),
            node.get("portNumber").asText(),
            node.get("httpsPort").asText(),
               deserializeGroupIdentifiers(node),
            node.get("statusPath").getTextValue(),
            apacheHttpdMediaId == null ? null : apacheHttpdMediaId.asText());
    return jcws;
}
 
Example 5
Source Project: big-c   File: StateDeserializer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public StatePair deserialize(JsonParser parser, 
                             DeserializationContext context)
throws IOException, JsonProcessingException {
  ObjectMapper mapper = (ObjectMapper) parser.getCodec();
  // set the state-pair object tree
  ObjectNode statePairObject = (ObjectNode) mapper.readTree(parser);
  Class<?> stateClass = null;
  
  try {
    stateClass = 
      Class.forName(statePairObject.get("className").getTextValue().trim());
  } catch (ClassNotFoundException cnfe) {
    throw new RuntimeException("Invalid classname!", cnfe);
  }
  
  String stateJsonString = statePairObject.get("state").toString();
  State state = (State) mapper.readValue(stateJsonString, stateClass);
  
  return new StatePair(state);
}
 
Example 6
@Override
public GenericEntity deserialize(JsonParser parser, DeserializationContext context) throws IOException {
    
    ObjectMapper mapper = (ObjectMapper) parser.getCodec();
    ObjectNode root = (ObjectNode) mapper.readTree(parser);
    
    String entityType = null;
    
    if (root.has(ENTITY_TYPE_KEY)) {
        entityType = root.get(ENTITY_TYPE_KEY).getTextValue();
        root.remove(ENTITY_TYPE_KEY);
    }
    
    Map<String, Object> data = processObject(root);
    if (entityType != null) {
        return new GenericEntity(entityType, data);
    } else {
        return new GenericEntity("Generic", data);
    }
}
 
Example 7
Source Project: urule   File: RuleJsonDeserializer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<Rule> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
	ObjectCodec oc = jp.getCodec();
       JsonNode jsonNode = oc.readTree(jp);
       Iterator<JsonNode> childrenNodesIter=jsonNode.getElements();
       List<Rule> rules=new ArrayList<Rule>();
       while(childrenNodesIter.hasNext()){
       	JsonNode childNode=childrenNodesIter.next();
       	rules.add(parseRule(jp,childNode));
       }
	return rules;
}
 
Example 8
Source Project: jwala   File: JsonControlJvm.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JsonControlJvm deserialize(final JsonParser jp,
                                  final DeserializationContext ctxt) throws IOException {

    final ObjectCodec obj = jp.getCodec();
    final JsonNode rootNode = obj.readTree(jp);
    final JsonNode operation = rootNode.get("controlOperation");

    return new JsonControlJvm(operation.getTextValue());
}
 
Example 9
Source Project: jwala   File: JsonUpdateGroup.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JsonUpdateGroup deserialize(final JsonParser jp,
                                   final DeserializationContext ctxt) throws IOException {

    final ObjectCodec obj = jp.getCodec();
    final JsonNode node = obj.readTree(jp);

    return new JsonUpdateGroup(node.get("id").getTextValue(),
                               node.get("name").getTextValue());
}
 
Example 10
Source Project: jwala   File: JsonJvms.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JsonJvms deserialize(final JsonParser jp,
                            final DeserializationContext ctxt) throws IOException {

    final ObjectCodec obj = jp.getCodec();
    final JsonNode rootNode = obj.readTree(jp);
    final Set<String> rawJvmIds = deserializeJvmIdentifiers(rootNode);

    return new JsonJvms(rawJvmIds);
}
 
Example 11
Source Project: jwala   File: JsonControlGroup.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JsonControlGroup deserialize(final JsonParser jp, final DeserializationContext ctxt)
        throws IOException {

    final ObjectCodec obj = jp.getCodec();
    final JsonNode rootNode = obj.readTree(jp);
    final JsonNode operation = rootNode.get("controlOperation");

    return new JsonControlGroup(operation.getTextValue());
}
 
Example 12
@Override
public Link deserialize(JsonParser parser, DeserializationContext context) throws IOException {
    
    ObjectMapper mapper = (ObjectMapper) parser.getCodec();
    ObjectNode root = (ObjectNode) mapper.readTree(parser);
    
    JsonNode relNode = root.get("rel");
    JsonNode hrefNode = root.get("href");
    return new BasicLink(relNode.asText(), new URL(hrefNode.asText()));
}
 
Example 13
@Override
public ContainerPlacementMessage deserialize(JsonParser jsonParser, DeserializationContext context)
    throws IOException {
  ObjectCodec oc = jsonParser.getCodec();
  JsonNode node = oc.readTree(jsonParser);
  String subType = node.get("subType").getTextValue();
  String deploymentId = node.get("deploymentId").getTextValue();
  String processorId = node.get("processorId").getTextValue();
  String destinationHost = node.get("destinationHost").getTextValue();
  long timestamp = node.get("timestamp").getLongValue();
  Duration requestExpiry =
      node.get("requestExpiry") == null ? null : Duration.ofMillis(node.get("requestExpiry").getLongValue());
  ContainerPlacementMessage.StatusCode statusCode = null;
  UUID uuid = UUID.fromString(node.get("uuid").getTextValue());
  for (ContainerPlacementMessage.StatusCode code : ContainerPlacementMessage.StatusCode.values()) {
    if (code.name().equals(node.get("statusCode").getTextValue())) {
      statusCode = code;
    }
  }
  ContainerPlacementMessage message = null;
  if (subType.equals(ContainerPlacementRequestMessage.class.getSimpleName())) {
    message = new ContainerPlacementRequestMessage(uuid, deploymentId, processorId, destinationHost, requestExpiry, timestamp);
  } else if (subType.equals(ContainerPlacementResponseMessage.class.getSimpleName())) {
    String responseMessage = node.get("responseMessage").getTextValue();
    message = new ContainerPlacementResponseMessage(uuid, deploymentId, processorId, destinationHost, requestExpiry,
        statusCode, responseMessage, timestamp);
  }
  return message;
}
 
Example 14
Source Project: samza   File: SamzaObjectMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Config deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException, JsonProcessingException {
  ObjectCodec oc = jsonParser.getCodec();
  JsonNode node = oc.readTree(jsonParser);
  return new MapConfig(OBJECT_MAPPER.<Map<String, String>>readValue(node, new TypeReference<Map<String, String>>() {
  }));
}
 
Example 15
Source Project: samza   File: SamzaObjectMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public TaskMode deserialize(JsonParser jsonParser, DeserializationContext context)
    throws IOException, JsonProcessingException {
  ObjectCodec oc = jsonParser.getCodec();
  JsonNode node = oc.readTree(jsonParser);
  if (node == null || node.getTextValue().equals("")) {
    return TaskMode.Active;
  } else {
    return TaskMode.valueOf(node.getTextValue());
  }
}
 
Example 16
Source Project: samza   File: SamzaObjectMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public SystemStreamPartition deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException, JsonProcessingException {
  ObjectCodec oc = jsonParser.getCodec();
  JsonNode node = oc.readTree(jsonParser);
  String system = node.get("system").getTextValue();
  String stream = node.get("stream").getTextValue();
  Partition partition = new Partition(node.get("partition").getIntValue());
  return new SystemStreamPartition(system, stream, partition);
}
 
Example 17
@Override
public EventNotification deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    EventNotification notification = new EventNotification();
    ObjectMapper mapper = (ObjectMapper) jp.getCodec();
    ObjectNode root = (ObjectNode) mapper.readTree(jp);
    String actionString = root.get("action").getTextValue();
    notification.setAction(Action.valueOf(actionString));
    JsonNode data = root.get("data");
    switch (notification.getAction()) {
        case JOB_SUBMITTED:
            notification.setData(mapper.readValue(data, JobStateData.class));
            break;
        case JOB_STATE_UPDATED:
            notification.setData(mapper.readValue(data, JobInfoData.class));
            break;
        case JOB_FULL_DATA_UPDATED:
            notification.setData(mapper.readValue(data, JobStateData.class));
            break;
        case TASK_STATE_UPDATED:
            notification.setData(mapper.readValue(data, TaskInfoData.class));
            break;
        case USERS_UPDATED:
            notification.setData(mapper.readValue(data, SchedulerUserData.class));
            break;
        default:
            break;
    }
    notification.setSchedulerEvent(root.get("schedulerEvent").asText());
    return notification;

}
 
Example 18
@Override
public Object deserialize(JsonParser jp, DeserializationContext ctxt)
		throws IOException, JsonProcessingException {
	logger.info("Deserialize...");

	ObjectCodec oc = jp.getCodec();
	JsonNode node = oc.readTree(jp);
	
	for (int i = 0; i < node.size(); i++)
	{
		JsonNode child = node.get(i);
		
		if (child == null) {
			logger.info(i + "th Child node is null");
			continue;
		}
		//String
		if (child.isTextual()) {
			Iterator<String> it = child.getFieldNames();
			while (it.hasNext()) {
				String field = it.next();
				logger.info("in while loop " + field);
				if (field.startsWith("customfield")) {
					
				}
			}
		}
	}
	return null;
}
 
Example 19
Source Project: samza   File: SamzaObjectMapper.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Partition deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException, JsonProcessingException {
  ObjectCodec oc = jsonParser.getCodec();
  JsonNode node = oc.readTree(jsonParser);
  return new Partition(node.getIntValue());
}
 
Example 20
Source Project: samza   File: SamzaObjectMapper.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public TaskName deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException, JsonProcessingException {
  ObjectCodec oc = jsonParser.getCodec();
  JsonNode node = oc.readTree(jsonParser);
  return new TaskName(node.getTextValue());
}