Java 类org.codehaus.jackson.map.DeserializationContext 实例源码

项目:pyroclast-java    文件:WindowDeserializer.java   
@Override
public Window deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException {
    JsonNode node = jp.getCodec().readTree(jp);

    Double value = node.get("value").asDouble();
    Window window = new Window(value);

    if (node.has("bounds")) {
        long lowerBound = node.get("bounds").get(0).asLong();
        long upperBound = node.get("bounds").get(1).asLong();

        window.withLowerBound(lowerBound).withUpperBound(upperBound);
    }

    return window;
}
项目:dcs-sdk-java    文件:Directive.java   
@Override
public Directive deserialize(JsonParser jp, DeserializationContext ctx)
        throws IOException {
    ObjectReader reader = ObjectMapperUtil.instance().getObjectReader();
    ObjectNode obj = (ObjectNode) reader.readTree(jp);
    Iterator<Map.Entry<String, JsonNode>> elementsIterator = obj.getFields();

    String rawMessage = obj.toString();
    DialogRequestIdHeader header = null;
    JsonNode payloadNode = null;
    ObjectReader headerReader =
            ObjectMapperUtil.instance().getObjectReader(DialogRequestIdHeader.class);
    while (elementsIterator.hasNext()) {
        Map.Entry<String, JsonNode> element = elementsIterator.next();
        if (element.getKey().equals("header")) {
            header = headerReader.readValue(element.getValue());
        }
        if (element.getKey().equals("payload")) {
            payloadNode = element.getValue();
        }
    }
    if (header == null) {
        throw ctx.mappingException("Missing header");
    }
    if (payloadNode == null) {
        throw ctx.mappingException("Missing payload");
    }

    return createDirective(header, payloadNode, rawMessage);
}
项目:hadoop    文件:StateDeserializer.java   
@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);
}
项目:pyroclast-java    文件:ProducedEventsResponseDeserializer.java   
@Override
public ProducedEventsResult deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException {
    JsonNode node = jp.getCodec().readTree(jp);

    if (node.isArray()) {
        List<ProducedEventResult> responses = new ArrayList<>();
        Iterator<JsonNode> it = node.iterator();

        while (it.hasNext()) {
            JsonNode n = it.next();
            responses.add(new ProducedEventResult(n.get("created").asBoolean()));
        }

        return new ProducedEventsResult(responses);
    } else {
        String reason = node.get("reason").asText();
        return new ProducedEventsResult(reason);
    }
}
项目:pyroclast-java    文件:TopicRecordDeserializer.java   
@Override
public TopicRecord deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException {
    JsonNode node = jp.getCodec().readTree(jp);

    String topic = node.get("topic").asText();
    long partition = node.get("partition").asLong();
    long offset = node.get("offset").asLong();
    long timestamp = node.get("timestamp").asLong();

    String key = null;
    if (node.has("key")) {
        key = node.get("key").asText();
    }

    Map<Object, Object> value = new ObjectMapper().readValue(node.get("value").toString(), Map.class);
    return new TopicRecord(topic, key, partition, offset, timestamp, value);
}
项目:pyroclast-java    文件:SubscribeToTopicResponseDeserializer.java   
@Override
public SubscribeToTopicResult deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException {
    JsonNode node = jp.getCodec().readTree(jp);
    boolean success = false;
    String reason = null;

    if (node.has("subscribed")) {
        success = node.get("subscribed").asBoolean();
    }

    if (node.has("reason")) {
        reason = node.get("reason").asText();
    }

    return new SubscribeToTopicResult(success, reason);
}
项目:jwala    文件:JsonUpdateWebServer.java   
@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());
}
项目:jwala    文件:JsonCreateWebServer.java   
@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;
}
项目:aliyun-oss-hadoop-fs    文件:StateDeserializer.java   
@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);
}
项目:big-c    文件:StateDeserializer.java   
@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);
}
项目:es-hadoop-v2.2.0    文件:BackportedJacksonMappingIterator.java   
@SuppressWarnings("unchecked")
protected BackportedJacksonMappingIterator(JavaType type, JsonParser jp, DeserializationContext ctxt, JsonDeserializer<?> deser) {
    _type = type;
    _parser = jp;
    _context = ctxt;
    _deserializer = (JsonDeserializer<T>) deser;

    /* One more thing: if we are at START_ARRAY (but NOT root-level
     * one!), advance to next token (to allow matching END_ARRAY)
     */
    if (jp != null && jp.getCurrentToken() == JsonToken.START_ARRAY) {
        JsonStreamContext sc = jp.getParsingContext();
        // safest way to skip current token is to clear it (so we'll advance soon)
        if (!sc.inRoot()) {
            jp.clearCurrentToken();
        }
    }
}
项目:playground    文件:InstantDeserializer.java   
@Override
public Instant deserialize(final JsonParser parser, final DeserializationContext ctxt)
        throws IOException, JsonProcessingException
{
    final JsonToken jsonToken = parser.getCurrentToken();

    if (jsonToken == JsonToken.VALUE_NUMBER_INT)
    {
        return new Instant(parser.getLongValue());
    }
    else if (jsonToken == JsonToken.VALUE_STRING)
    {
        final String str = parser.getText().trim();
        if (str.length() == 0)
        {
            return null;
        }
        final DateTimeFormatter formatter = ISODateTimeFormat.dateTimeParser();
        final DateTime dateTime = formatter.parseDateTime(str);

        return new Instant(dateTime.getMillis());
    }

    throw ctxt.mappingException(Instant.class);
}
项目:playground    文件:BasicObjectMapperProvider.java   
/**
 * Search for any registered JsonDeserialize instances that have been declared using the
 * ServiceLoader. Add any found to the given mapper in a 'magic' module.
 */
private static void addDiscoverableDeserializers(final ObjectMapper mapper) {

    final ServiceLoader<JsonDeserializer> loader = ServiceLoader.load(JsonDeserializer.class);
    final Iterator<JsonDeserializer> iterator = loader.iterator();
    final SimpleModule magic = new SimpleModule("magic", new Version(1, 0, 0, ""));

    while (iterator.hasNext()) {

        final JsonDeserializer<?> deserializer = iterator.next();

        try {
            final Method deserialeMethod = deserializer.getClass()
                    .getDeclaredMethod("deserialize", JsonParser.class, DeserializationContext.class);
            final Class<?> jsonType = deserialeMethod.getReturnType();
            //noinspection unchecked
            magic.addDeserializer(jsonType, (JsonDeserializer) deserializer);
        }
        catch(Exception e) {
            throw new IllegalStateException(e);
        }
    }

    mapper.registerModule(magic);
}
项目:Camel    文件:MultiSelectPicklistDeserializer.java   
@Override
public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {

    // validate enum class
    if (enumClass == null) {
        throw new JsonMappingException("Unable to parse unknown pick-list type");
    }

    final String listValue = jp.getText();

    try {
        // parse the string of the form value1;value2;...
        final String[] value = listValue.split(";");
        final int length = value.length;
        final Object resultArray = Array.newInstance(enumClass, length);
        for (int i = 0; i < length; i++) {
            // use factory method to create object
            Array.set(resultArray, i, factoryMethod.invoke(null, value[i].trim()));
        }

        return resultArray;
    } catch (Exception e) {
        throw new JsonParseException("Exception reading multi-select pick list value", jp.getCurrentLocation(), e);
    }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:StateDeserializer.java   
@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);
}
项目:hadoop-plus    文件:StateDeserializer.java   
@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);
}
项目:hops    文件:StateDeserializer.java   
@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);
}
项目:community-edition-old    文件:NodeRefDeserializer.java   
@Override
public NodeRef deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException
{
       JsonToken curr = jp.getCurrentToken();

       if (curr == JsonToken.VALUE_STRING)
       {
           String nodeRefString = jp.getText();
           NodeRef nodeRef = getNodeRef(nodeRefString);
           return nodeRef;
       }
       else
       {
        throw new IOException("Unable to deserialize nodeRef: " + curr.asString());
       }
}
项目:spring-open    文件:DpidDeserializer.java   
@Override
public Dpid deserialize(JsonParser jp,
                        DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    Dpid dpid = null;

    jp.nextToken();        // Move to JsonToken.START_OBJECT
    while (jp.nextToken() != JsonToken.END_OBJECT) {
        String fieldname = jp.getCurrentName();
        if ("value".equals(fieldname)) {
            String value = jp.getText();
            log.debug("Fieldname: {} Value: {}", fieldname, value);
            dpid = new Dpid(value);
        }
    }
    return dpid;
}
项目:stickypunch    文件:WebsiteDeserializer.java   
@Override
public Website deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    ObjectCodec oc = jp.getCodec();
    JsonNode nodes = oc.readTree(jp);
    String websitePushID = nodes.get("websitePushID").getTextValue();
    String websiteName = nodes.get("websiteName").getTextValue();
    List<String> allowedDomains = new ArrayList<String>();
    for (JsonNode node : nodes.get("allowedDomains")) {
        allowedDomains.add(node.getTextValue());
    }
    String urlFormatString = nodes.get("urlFormatString").getTextValue();
    String authenticationToken = nodes.get("authenticationToken").getTextValue();
    String webServiceUrl = nodes.get("webServiceURL").getTextValue();

    return new WebsiteBuilder()
            .setWebsiteName(websiteName)
            .setWebsitePushId(websitePushID)
            .setAllowedDomains(allowedDomains)
            .setUrlFormatString(urlFormatString)
            .setAuthenticationToken(authenticationToken)
            .setWebServiceUrl(webServiceUrl)
            .build();
}
项目:gwt-datatypes    文件:DateSerializationTest.java   
@Test(dataProvider = "validDates")
public void serialize( final String expectedFormat, final Date date, final RDate rDate )
  throws Exception
{
  final JsonGenerator generator = mock( JsonGenerator.class );

  new DateSerializer().serialize( date, generator, mock( SerializerProvider.class ) );
  verify( generator ).writeString( expectedFormat );

  final JsonParser parser = mock( JsonParser.class );
  when( parser.getText() ).thenReturn( expectedFormat );
  final Date result = new DateDeserializer().deserialize( parser, mock( DeserializationContext.class ) );

  assertEquals( RDate.parse( expectedFormat ), rDate );
  assertEquals( RDate.fromDate( result ), rDate );
}
项目:12306-android-Decompile    文件:Creator.java   
public Object deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  Object localObject1 = this._deserializer.deserialize(paramJsonParser, paramDeserializationContext);
  try
  {
    if (this._ctor != null)
      return this._ctor.newInstance(new Object[] { localObject1 });
    Object localObject2 = this._factoryMethod.invoke(null, new Object[] { localObject1 });
    return localObject2;
  }
  catch (Exception localException)
  {
    ClassUtil.unwrapAndThrowAsIAE(localException);
  }
  return null;
}
项目:12306-android-Decompile    文件:TypeDeserializerBase.java   
protected final JsonDeserializer<Object> _findDeserializer(DeserializationContext paramDeserializationContext, String paramString)
  throws IOException, JsonProcessingException
{
  JavaType localJavaType;
  synchronized (this._deserializers)
  {
    localJsonDeserializer = (JsonDeserializer)this._deserializers.get(paramString);
    if (localJsonDeserializer != null)
      break label125;
    localJavaType = this._idResolver.typeFromId(paramString);
    if (localJavaType == null)
      throw paramDeserializationContext.unknownTypeException(this._baseType, paramString);
  }
  if ((this._baseType != null) && (this._baseType.getClass() == localJavaType.getClass()))
    localJavaType = this._baseType.narrowBy(localJavaType.getRawClass());
  JsonDeserializer localJsonDeserializer = paramDeserializationContext.getDeserializerProvider().findValueDeserializer(paramDeserializationContext.getConfig(), localJavaType, this._property);
  this._deserializers.put(paramString, localJsonDeserializer);
  label125: monitorexit;
  return localJsonDeserializer;
}
项目:hadoop-on-lustre2    文件:StateDeserializer.java   
@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);
}
项目:12306-android-Decompile    文件:BeanDeserializer.java   
public Object deserializeFromNumber(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  if (this._numberCreator != null);
  switch (1.$SwitchMap$org$codehaus$jackson$JsonParser$NumberType[paramJsonParser.getNumberType().ordinal()])
  {
  default:
    if (this._delegatingCreator == null)
      break;
    return this._delegatingCreator.deserialize(paramJsonParser, paramDeserializationContext);
  case 1:
    return this._numberCreator.construct(paramJsonParser.getIntValue());
  case 2:
    return this._numberCreator.construct(paramJsonParser.getLongValue());
  }
  throw paramDeserializationContext.instantiationException(getBeanClass(), "no suitable creator method found to deserialize from JSON Number");
}
项目:12306-android-Decompile    文件:BeanDeserializer.java   
protected Object handlePolymorphic(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Object paramObject, TokenBuffer paramTokenBuffer)
  throws IOException, JsonProcessingException
{
  JsonDeserializer localJsonDeserializer = _findSubclassDeserializer(paramDeserializationContext, paramObject, paramTokenBuffer);
  if (localJsonDeserializer != null)
  {
    if (paramTokenBuffer != null)
    {
      paramTokenBuffer.writeEndObject();
      JsonParser localJsonParser = paramTokenBuffer.asParser();
      localJsonParser.nextToken();
      paramObject = localJsonDeserializer.deserialize(localJsonParser, paramDeserializationContext, paramObject);
    }
    if (paramJsonParser != null)
      paramObject = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext, paramObject);
    return paramObject;
  }
  if (paramTokenBuffer != null)
    paramObject = handleUnknownProperties(paramDeserializationContext, paramObject, paramTokenBuffer);
  if (paramJsonParser != null)
    paramObject = deserialize(paramJsonParser, paramDeserializationContext, paramObject);
  return paramObject;
}
项目:12306-android-Decompile    文件:ArrayDeserializers.java   
public float[] deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  if (!paramJsonParser.isExpectedStartArrayToken())
    return handleNonArray(paramJsonParser, paramDeserializationContext);
  ArrayBuilders.FloatBuilder localFloatBuilder = paramDeserializationContext.getArrayBuilders().getFloatBuilder();
  float[] arrayOfFloat = (float[])localFloatBuilder.resetAndStart();
  int j;
  for (int i = 0; paramJsonParser.nextToken() != JsonToken.END_ARRAY; i = j)
  {
    float f = _parseFloatPrimitive(paramJsonParser, paramDeserializationContext);
    if (i >= arrayOfFloat.length)
    {
      arrayOfFloat = (float[])localFloatBuilder.appendCompletedChunk(arrayOfFloat, i);
      i = 0;
    }
    j = i + 1;
    arrayOfFloat[i] = f;
  }
  return (float[])localFloatBuilder.completeAndClearBuffer(arrayOfFloat, i);
}
项目:12306-android-Decompile    文件:MapDeserializer.java   
public Map<Object, Object> deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if ((localJsonToken != JsonToken.START_OBJECT) && (localJsonToken != JsonToken.FIELD_NAME) && (localJsonToken != JsonToken.END_OBJECT))
    throw paramDeserializationContext.mappingException(getMapClass());
  if (this._propertyBasedCreator != null)
    return _deserializeUsingCreator(paramJsonParser, paramDeserializationContext);
  if (this._defaultCtor == null)
    throw paramDeserializationContext.instantiationException(getMapClass(), "No default constructor found");
  try
  {
    Map localMap = (Map)this._defaultCtor.newInstance(new Object[0]);
    _readAndBind(paramJsonParser, paramDeserializationContext, localMap);
    return localMap;
  }
  catch (Exception localException)
  {
  }
  throw paramDeserializationContext.instantiationException(getMapClass(), localException);
}
项目:12306-android-Decompile    文件:SettableBeanProperty.java   
public final void deserializeAndSet(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Object paramObject)
  throws IOException, JsonProcessingException
{
  if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_NULL)
    return;
  Object localObject;
  try
  {
    localObject = this._getter.invoke(paramObject, new Object[0]);
    if (localObject == null)
      throw new JsonMappingException("Problem deserializing 'setterless' property '" + getName() + "': get method returned null");
  }
  catch (Exception localException)
  {
    _throwAsIOE(localException);
    return;
  }
  this._valueDeserializer.deserialize(paramJsonParser, paramDeserializationContext, localObject);
}
项目:spring-open    文件:MACAddressDeserializer.java   
@Override
public MACAddress deserialize(JsonParser jp,
                              DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    MACAddress mac = null;

    jp.nextToken();        // Move to JsonToken.START_OBJECT
    while (jp.nextToken() != JsonToken.END_OBJECT) {
        String fieldname = jp.getCurrentName();
        if ("value".equals(fieldname)) {
            String value = jp.getText();
            log.debug("Fieldname: {} Value: {}", fieldname, value);
            mac = MACAddress.valueOf(value);
        }
    }
    return mac;
}
项目:gwt-datatypes    文件:DateSetDeserializer.java   
@Override
public Set<Date> deserialize( final JsonParser parser, final DeserializationContext context )
  throws IOException
{
  if ( !parser.isExpectedStartArrayToken() )
  {
    throw context.mappingException( Set.class );
  }
  final HashSet<Date> result = new HashSet<Date>();

  final DateFormat formatter = DateUtil.newDateFormatter();
  JsonToken token;
  while ( JsonToken.END_ARRAY != ( token = parser.nextToken() ) )
  {
    if ( JsonToken.VALUE_NULL == token )
    {
      throw context.mappingException( Set.class );
    }
    result.add( DateUtil.parse( formatter, parser.getText() ) );
  }
  return result;
}
项目:12306-android-Decompile    文件:ArrayDeserializers.java   
public int[] deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  if (!paramJsonParser.isExpectedStartArrayToken())
    return handleNonArray(paramJsonParser, paramDeserializationContext);
  ArrayBuilders.IntBuilder localIntBuilder = paramDeserializationContext.getArrayBuilders().getIntBuilder();
  int[] arrayOfInt = (int[])localIntBuilder.resetAndStart();
  int k;
  for (int i = 0; paramJsonParser.nextToken() != JsonToken.END_ARRAY; i = k)
  {
    int j = _parseIntPrimitive(paramJsonParser, paramDeserializationContext);
    if (i >= arrayOfInt.length)
    {
      arrayOfInt = (int[])localIntBuilder.appendCompletedChunk(arrayOfInt, i);
      i = 0;
    }
    k = i + 1;
    arrayOfInt[i] = j;
  }
  return (int[])localIntBuilder.completeAndClearBuffer(arrayOfInt, i);
}
项目:12306-android-Decompile    文件:BaseNodeDeserializer.java   
protected final ObjectNode deserializeObject(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  ObjectNode localObjectNode = paramDeserializationContext.getNodeFactory().objectNode();
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if (localJsonToken == JsonToken.START_OBJECT);
  for (localJsonToken = paramJsonParser.nextToken(); localJsonToken == JsonToken.FIELD_NAME; localJsonToken = paramJsonParser.nextToken())
  {
    String str = paramJsonParser.getCurrentName();
    paramJsonParser.nextToken();
    JsonNode localJsonNode1 = deserializeAny(paramJsonParser, paramDeserializationContext);
    JsonNode localJsonNode2 = localObjectNode.put(str, localJsonNode1);
    if (localJsonNode2 == null)
      continue;
    _handleDuplicateField(str, localObjectNode, localJsonNode2, localJsonNode1);
  }
  return localObjectNode;
}
项目:hardfs    文件:StateDeserializer.java   
@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);
}
项目:gwt-datatypes    文件:DateSetSerializationTest.java   
@Test
public void raiseExceptionOnDeserializeNonArray()
  throws Exception
{
  final JsonParser parser = mock( JsonParser.class );
  when( parser.isExpectedStartArrayToken() ).thenReturn( false );
  final DeserializationContext context = mock( DeserializationContext.class );
  final JsonMappingException exception = new JsonMappingException( "" );
  when( context.mappingException( Set.class ) ).thenReturn( exception );
  try
  {
    new DateSetDeserializer().deserialize( parser, context );
  }
  catch ( final JsonMappingException e )
  {
    assertEquals( e, exception );
    return;
  }
  fail( "Exception expected" );
}
项目:12306-android-Decompile    文件:ArrayDeserializers.java   
public double[] deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  if (!paramJsonParser.isExpectedStartArrayToken())
    return handleNonArray(paramJsonParser, paramDeserializationContext);
  ArrayBuilders.DoubleBuilder localDoubleBuilder = paramDeserializationContext.getArrayBuilders().getDoubleBuilder();
  double[] arrayOfDouble = (double[])localDoubleBuilder.resetAndStart();
  int j;
  for (int i = 0; paramJsonParser.nextToken() != JsonToken.END_ARRAY; i = j)
  {
    double d = _parseDoublePrimitive(paramJsonParser, paramDeserializationContext);
    if (i >= arrayOfDouble.length)
    {
      arrayOfDouble = (double[])localDoubleBuilder.appendCompletedChunk(arrayOfDouble, i);
      i = 0;
    }
    j = i + 1;
    arrayOfDouble[i] = d;
  }
  return (double[])localDoubleBuilder.completeAndClearBuffer(arrayOfDouble, i);
}
项目:jive-sdk-java-jersey    文件:WebhookInstance.java   
@Override
public WebhookInstance deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    JsonNode root = jsonParser.getCodec().readTree(jsonParser);

    WebhookInstance webhookInstance = new WebhookInstance();
    webhookInstance.setId(((LongNode)root.get("id")).getLongValue());
    webhookInstance.setObject(root.get("object").getTextValue());

    JsonNode resources = root.get("resources");
    JsonNode self = resources.get("self");

    webhookInstance.setSelfReference(self.get("ref").getTextValue());

    webhookInstance.setCallback(root.get("callback").getTextValue());

    self = null;
    resources = null;
    root = null;

    return webhookInstance;
}
项目:12306-android-Decompile    文件:StringCollectionDeserializer.java   
private final Collection<String> handleNonArray(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Collection<String> paramCollection)
  throws IOException, JsonProcessingException
{
  if (!paramDeserializationContext.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY))
    throw paramDeserializationContext.mappingException(this._collectionType.getRawClass());
  JsonDeserializer localJsonDeserializer = this._valueDeserializer;
  if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_NULL)
  {
    localObject = null;
    paramCollection.add(localObject);
    return paramCollection;
  }
  if (localJsonDeserializer == null);
  for (Object localObject = paramJsonParser.getText(); ; localObject = (String)localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext))
    break;
}
项目:gwt-datatypes    文件:DateListDeserializer.java   
@Override
public List<Date> deserialize( final JsonParser parser, final DeserializationContext context )
  throws IOException
{
  if ( !parser.isExpectedStartArrayToken() )
  {
    throw context.mappingException( List.class );
  }
  final ArrayList<Date> result = new ArrayList<Date>();

  final DateFormat formatter = DateUtil.newDateFormatter();
  JsonToken token;
  while ( JsonToken.END_ARRAY != ( token = parser.nextToken() ) )
  {
    if ( JsonToken.VALUE_NULL == token )
    {
      throw context.mappingException( List.class );
    }
    result.add( DateUtil.parse( formatter, parser.getText() ) );
  }
  return result;
}
项目:12306-android-Decompile    文件:StdDeserializer.java   
public Character deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
  throws IOException, JsonProcessingException
{
  JsonToken localJsonToken = paramJsonParser.getCurrentToken();
  if (localJsonToken == JsonToken.VALUE_NUMBER_INT)
  {
    int i = paramJsonParser.getIntValue();
    if ((i >= 0) && (i <= 65535))
      return Character.valueOf((char)i);
  }
  else if (localJsonToken == JsonToken.VALUE_STRING)
  {
    String str = paramJsonParser.getText();
    if (str.length() == 1)
      return Character.valueOf(str.charAt(0));
  }
  throw paramDeserializationContext.mappingException(this._valueClass);
}