當前位置: 首頁>>代碼示例>>Java>>正文


Java JavaType類代碼示例

本文整理匯總了Java中org.codehaus.jackson.type.JavaType的典型用法代碼示例。如果您正苦於以下問題:Java JavaType類的具體用法?Java JavaType怎麽用?Java JavaType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JavaType類屬於org.codehaus.jackson.type包,在下文中一共展示了JavaType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: DifficultyTestSuite

import org.codehaus.jackson.type.JavaType; //導入依賴的package包/類
public DifficultyTestSuite(String json) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    JavaType type = mapper.getTypeFactory().
            constructMapType(HashMap.class, String.class, DifficultyTestCase.class);

    Map<String, DifficultyTestCase> caseMap = new ObjectMapper().readValue(json, type);

    for (Map.Entry<String, DifficultyTestCase> e : caseMap.entrySet()) {
        e.getValue().setName(e.getKey());
        testCases.add(e.getValue());
    }

    Collections.sort(testCases, new Comparator<DifficultyTestCase>() {
        @Override
        public int compare(DifficultyTestCase t1, DifficultyTestCase t2) {
            return t1.getName().compareTo(t2.getName());
        }
    });
}
 
開發者ID:talentchain,項目名稱:talchain,代碼行數:20,代碼來源:DifficultyTestSuite.java

示例2: json2Object

import org.codehaus.jackson.type.JavaType; //導入依賴的package包/類
@SuppressWarnings("deprecation")
   public static Object json2Object(String jsonString, JavaType type) {

	if (jsonString == null || "".equals(jsonString)) {
		return "";
	} else {
		try {
			objectMapper.getDeserializationConfig().set(org.codehaus.jackson.map.DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
			return objectMapper.readValue(jsonString, type);
		} catch (Exception e) {
			log.warn("json error:" + e.getMessage());
		}

	}
	return "";
}
 
開發者ID:neoremind,項目名稱:fountain,代碼行數:17,代碼來源:JsonUtils.java

示例3: _findRootDeserializer

import org.codehaus.jackson.type.JavaType; //導入依賴的package包/類
/**
 * Method called to locate deserializer for the passed root-level value.
 */
protected JsonDeserializer<Object> _findRootDeserializer(DeserializationConfig cfg, JavaType valueType)
        throws JsonMappingException {

    // Sanity check: must have actual type...
    if (valueType == null) {
        throw new JsonMappingException("No value type configured for ObjectReader");
    }

    // First: have we already seen it?
    JsonDeserializer<Object> deser = _rootDeserializers.get(valueType);
    if (deser != null) {
        return deser;
    }

    // es-hadoop: findType with 2 args have been removed since 1.9 so this code compiles on 1.8 (which has the fallback method)
    // es-hadoop: on 1.5 only the 2 args method exists, since 1.9 only the one with 3 args hence the if

    // Nope: need to ask provider to resolve it
    deser = _provider.findTypedValueDeserializer(cfg, valueType);
    if (deser == null) { // can this happen?
        throw new JsonMappingException("Can not find a deserializer for type " + valueType);
    }
    _rootDeserializers.put(valueType, deser);
    return deser;
}
 
開發者ID:xushjie1987,項目名稱:es-hadoop-v2.2.0,代碼行數:29,代碼來源:BackportedObjectReader.java

示例4: BackportedJacksonMappingIterator

import org.codehaus.jackson.type.JavaType; //導入依賴的package包/類
@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();
        }
    }
}
 
開發者ID:xushjie1987,項目名稱:es-hadoop-v2.2.0,代碼行數:19,代碼來源:BackportedJacksonMappingIterator.java

示例5: createFromEventBody

import org.codehaus.jackson.type.JavaType; //導入依賴的package包/類
public static <T> EnrichedEventBodyGeneric createFromEventBody(byte[] payload, boolean isEnriched, Class<T> clazz) throws IOException {

        EnrichedEventBodyGeneric enrichedEventBodyGeneric;

        if (isEnriched) {
            JavaType javaType = JSONStringSerializer.getJavaType(EnrichedEventBodyGeneric.class, clazz);
            enrichedEventBodyGeneric = (EnrichedEventBodyGeneric) JSONStringSerializer.fromBytes(payload, javaType);
        } else {
            // Detecting payload charset
            UniversalDetector detector = new UniversalDetector(null);
            detector.handleData(payload, 0, payload.length);
            detector.dataEnd();
            String charset = detector.getDetectedCharset();
            detector.reset();

            if (charset == null) {
                charset = DEFAULT_CHARSET;
            }
           enrichedEventBodyGeneric = new EnrichedEventBodyGeneric(new String(payload, charset), clazz);
        }

        return enrichedEventBodyGeneric;
    }
 
開發者ID:keedio,項目名稱:flume-enrichment-interceptor-skeleton,代碼行數:24,代碼來源:EnrichedEventBodyGeneric.java

示例6: readInternal

import org.codehaus.jackson.type.JavaType; //導入依賴的package包/類
@Override
protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage)
		throws IOException, HttpMessageNotReadableException {
	BufferedReader bufferedReader = new BufferedReader(
			new InputStreamReader(inputMessage.getBody(), DEFAULT_CHARSET));
	StringBuilder stringBuilder = new StringBuilder();
	String line = null;

	while ((line = bufferedReader.readLine()) != null) {
		stringBuilder.append(line + " ");
	}

	logger.debug("Middleware recieves " + clazz.getName() + " "
			+ stringBuilder.toString());
	JavaType javaType = getJavaType(clazz);
	return this.objectMapper.readValue(stringBuilder.toString(), javaType);
}
 
開發者ID:Appverse,項目名稱:appverse-server,代碼行數:18,代碼來源:CustomMappingJacksonHttpMessageConverter.java

示例7: findValueSerializer

import org.codehaus.jackson.type.JavaType; //導入依賴的package包/類
public JsonSerializer<Object> findValueSerializer(JavaType paramJavaType, BeanProperty paramBeanProperty)
  throws JsonMappingException
{
  JsonSerializer localJsonSerializer = this._knownSerializers.untypedValueSerializer(paramJavaType);
  if (localJsonSerializer == null)
  {
    localJsonSerializer = this._serializerCache.untypedValueSerializer(paramJavaType);
    if (localJsonSerializer == null)
    {
      localJsonSerializer = _createAndCacheUntypedSerializer(paramJavaType, paramBeanProperty);
      if (localJsonSerializer == null)
        return getUnknownTypeSerializer(paramJavaType.getRawClass());
    }
  }
  if ((localJsonSerializer instanceof ContextualSerializer))
    return ((ContextualSerializer)localJsonSerializer).createContextual(this._config, paramBeanProperty);
  return localJsonSerializer;
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:19,代碼來源:StdSerializerProvider.java

示例8: createKeyDeserializer

import org.codehaus.jackson.type.JavaType; //導入依賴的package包/類
public KeyDeserializer createKeyDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType, BeanProperty paramBeanProperty)
  throws JsonMappingException
{
  if (this._factoryConfig.hasKeyDeserializers())
  {
    BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectClassAnnotations(paramJavaType.getRawClass());
    Iterator localIterator = this._factoryConfig.keyDeserializers().iterator();
    while (localIterator.hasNext())
    {
      KeyDeserializer localKeyDeserializer = ((KeyDeserializers)localIterator.next()).findKeyDeserializer(paramJavaType, paramDeserializationConfig, localBasicBeanDescription, paramBeanProperty);
      if (localKeyDeserializer != null)
        return localKeyDeserializer;
    }
  }
  return null;
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:17,代碼來源:BeanDeserializerFactory.java

示例9: MapSerializer

import org.codehaus.jackson.type.JavaType; //導入依賴的package包/類
protected MapSerializer(HashSet<String> ignoredEntries,
        JavaType keyType, JavaType valueType, boolean valueTypeIsStatic,
        TypeSerializer vts,
        JsonSerializer<Object> keySerializer, JsonSerializer<Object> valueSerializer, 
        BeanProperty property)
{
    super(Map.class, false);
    _property = property;
    _ignoredEntries = ignoredEntries;
    _keyType = keyType;
    _valueType = valueType;
    _valueTypeIsStatic = valueTypeIsStatic;
    _valueTypeSerializer = vts;
    _keySerializer = keySerializer;
    _valueSerializer = valueSerializer;
    _dynamicValueSerializers = PropertySerializerMap.emptyMap();
}
 
開發者ID:sumeetchhetri,項目名稱:test-html-generator-plugin,代碼行數:18,代碼來源:MapSerializer.java

示例10: getBeanHelper

import org.codehaus.jackson.type.JavaType; //導入依賴的package包/類
private BeanHelper getBeanHelper(Class<?> beanClass) {
    if (beanClass == null) {
        return null;
    }
    try {
        final SerializationConfig serializationConfig = objectMapper.getSerializationConfig();
        final JavaType simpleType = objectMapper.constructType(beanClass);
        final JsonSerializer<?> jsonSerializer = BeanSerializerFactory.instance.createSerializer(serializationConfig, simpleType, null);
        if (jsonSerializer == null) {
            return null;
        }
        if (jsonSerializer instanceof BeanSerializer) {
            return new BeanHelper((BeanSerializer) jsonSerializer);
        } else {
            final String jsonSerializerName = jsonSerializer.getClass().getName();
            throw new RuntimeException(String.format("Unknown serializer '%s' for class '%s'", jsonSerializerName, beanClass));
        }
    } catch (JsonMappingException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:vojtechhabarta,項目名稱:typescript-generator,代碼行數:22,代碼來源:Jackson1Parser.java

示例11: createCollectionLikeDeserializer

import org.codehaus.jackson.type.JavaType; //導入依賴的package包/類
public JsonDeserializer<?> createCollectionLikeDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, CollectionLikeType paramCollectionLikeType, BeanProperty paramBeanProperty)
  throws JsonMappingException
{
  CollectionLikeType localCollectionLikeType1 = (CollectionLikeType)mapAbstractType(paramDeserializationConfig, paramCollectionLikeType);
  BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectClassAnnotations(localCollectionLikeType1.getRawClass());
  JsonDeserializer localJsonDeserializer1 = findDeserializerFromAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), paramBeanProperty);
  if (localJsonDeserializer1 != null)
    return localJsonDeserializer1;
  CollectionLikeType localCollectionLikeType2 = (CollectionLikeType)modifyTypeByAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), localCollectionLikeType1, null);
  JavaType localJavaType = localCollectionLikeType2.getContentType();
  JsonDeserializer localJsonDeserializer2 = (JsonDeserializer)localJavaType.getValueHandler();
  TypeDeserializer localTypeDeserializer = (TypeDeserializer)localJavaType.getTypeHandler();
  if (localTypeDeserializer == null)
    localTypeDeserializer = findTypeDeserializer(paramDeserializationConfig, localJavaType, paramBeanProperty);
  return _findCustomCollectionLikeDeserializer(localCollectionLikeType2, paramDeserializationConfig, paramDeserializerProvider, localBasicBeanDescription, paramBeanProperty, localTypeDeserializer, localJsonDeserializer2);
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:17,代碼來源:BasicDeserializerFactory.java

示例12: _resolve

import org.codehaus.jackson.type.JavaType; //導入依賴的package包/類
protected void _resolve()
{
  _resolveBindings(this._contextClass);
  if (this._contextType != null)
  {
    int i = this._contextType.containedTypeCount();
    if (i > 0)
    {
      if (this._bindings == null)
        this._bindings = new LinkedHashMap();
      for (int j = 0; j < i; j++)
      {
        String str = this._contextType.containedTypeName(j);
        JavaType localJavaType = this._contextType.containedType(j);
        this._bindings.put(str, localJavaType);
      }
    }
  }
  if (this._bindings == null)
    this._bindings = Collections.emptyMap();
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:22,代碼來源:TypeBindings.java

示例13: constructAnySetter

import org.codehaus.jackson.type.JavaType; //導入依賴的package包/類
protected SettableAnyProperty constructAnySetter(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription, AnnotatedMethod paramAnnotatedMethod)
  throws JsonMappingException
{
  if (paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS))
    paramAnnotatedMethod.fixAccess();
  JavaType localJavaType1 = paramBasicBeanDescription.bindingsForBeanType().resolveType(paramAnnotatedMethod.getParameterType(1));
  BeanProperty.Std localStd = new BeanProperty.Std(paramAnnotatedMethod.getName(), localJavaType1, paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedMethod);
  JavaType localJavaType2 = resolveType(paramDeserializationConfig, paramBasicBeanDescription, localJavaType1, paramAnnotatedMethod, localStd);
  JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationConfig, paramAnnotatedMethod, localStd);
  if (localJsonDeserializer != null)
  {
    SettableAnyProperty localSettableAnyProperty = new SettableAnyProperty(localStd, paramAnnotatedMethod, localJavaType2);
    localSettableAnyProperty.setValueDeserializer(localJsonDeserializer);
    return localSettableAnyProperty;
  }
  return new SettableAnyProperty(localStd, paramAnnotatedMethod, modifyTypeByAnnotation(paramDeserializationConfig, paramAnnotatedMethod, localJavaType2, localStd.getName()));
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:18,代碼來源:BeanDeserializerFactory.java

示例14: findDeserializationKeyType

import org.codehaus.jackson.type.JavaType; //導入依賴的package包/類
public Class<?> findDeserializationKeyType(Annotated paramAnnotated, JavaType paramJavaType, String paramString)
{
  JsonDeserialize localJsonDeserialize = (JsonDeserialize)paramAnnotated.getAnnotation(JsonDeserialize.class);
  Class localClass;
  if (localJsonDeserialize != null)
  {
    localClass = localJsonDeserialize.keyAs();
    if (localClass == NoClass.class);
  }
  do
  {
    return localClass;
    JsonKeyClass localJsonKeyClass = (JsonKeyClass)paramAnnotated.getAnnotation(JsonKeyClass.class);
    if (localJsonKeyClass == null)
      break;
    localClass = localJsonKeyClass.value();
  }
  while (localClass != NoClass.class);
  return null;
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:21,代碼來源:JacksonAnnotationIntrospector.java

示例15: idResolver

import org.codehaus.jackson.type.JavaType; //導入依賴的package包/類
protected TypeIdResolver idResolver(MapperConfig<?> paramMapperConfig, JavaType paramJavaType, Collection<NamedType> paramCollection, boolean paramBoolean1, boolean paramBoolean2)
{
  if (this._customIdResolver != null)
    return this._customIdResolver;
  if (this._idType == null)
    throw new IllegalStateException("Can not build, 'init()' not yet called");
  switch (1.$SwitchMap$org$codehaus$jackson$annotate$JsonTypeInfo$Id[this._idType.ordinal()])
  {
  default:
    throw new IllegalStateException("Do not know how to construct standard type id resolver for idType: " + this._idType);
  case 1:
    return new ClassNameIdResolver(paramJavaType, paramMapperConfig.getTypeFactory());
  case 2:
    return new MinimalClassNameIdResolver(paramJavaType, paramMapperConfig.getTypeFactory());
  case 3:
  }
  return TypeNameIdResolver.construct(paramMapperConfig, paramJavaType, paramCollection, paramBoolean1, paramBoolean2);
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:19,代碼來源:StdTypeResolverBuilder.java


注:本文中的org.codehaus.jackson.type.JavaType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。