/** * Annotations with meta-annotation {@link JacksonAnnotationsInside} * are considered bundles. */ @Override public boolean isAnnotationBundle(Annotation ann) { // 22-Sep-2015, tatu: Caching here has modest effect on JavaSE, and only // mostly in degenerate cases where introspection used more often than // it should (like recreating ObjectMapper once per read/write). // But it may be more beneficial on platforms like Android (should verify) Class<?> type = ann.annotationType(); Boolean b = _annotationsInside.get(type); if (b == null) { b = type.getAnnotation(JacksonAnnotationsInside.class) != null; _annotationsInside.putIfAbsent(type, b); } return b.booleanValue(); }
@Override public BasicBeanDescription forClassAnnotations(MapperConfig<?> config, JavaType type, MixInResolver r) { BasicBeanDescription desc = _findStdTypeDesc(type); if (desc == null) { desc = _cachedFCA.get(type); if (desc == null) { desc = BasicBeanDescription.forOtherUse(config, type, _resolveAnnotatedClass(config, type, r)); _cachedFCA.put(type, desc); } } return desc; }
public PropertyName findRootName(Class<?> rootType, MapperConfig<?> config) { ClassKey key = new ClassKey(rootType); PropertyName name = _rootNames.get(key); if (name != null) { return name; } BeanDescription beanDesc = config.introspectClassAnnotations(rootType); AnnotationIntrospector intr = config.getAnnotationIntrospector(); AnnotatedClass ac = beanDesc.getClassInfo(); name = intr.findRootName(ac); // No answer so far? Let's just default to using simple class name if (name == null || !name.hasSimpleName()) { // Should we strip out enclosing class tho? For now, nope: name = PropertyName.construct(rootType.getSimpleName()); } _rootNames.put(key, name); return name; }
key = bindings.asKey(rawType); result = _typeCache.get(key); // ok, cache object is synced if (result != null) { return result;
/** * Check whether this CachedTranslator's cache contains a translation of the text from the * source language to the target language. * * @param text What string to check for. * @param sourceLanguage The source language of translation. * @param targetLanguage The target language of translation. * @return true if the cache contains a translation of the text, false otherwise. */ public boolean contains(String text, String sourceLanguage, String targetLanguage) { LRUMap<String, String> translationCache = getTranslationCache(sourceLanguage, targetLanguage); return translationCache.get(text) != null; }
@Override public String translate(String text, String sourceLanguage, String targetLanguage) throws TikaException, IOException { if (translator == null) { return text; } LRUMap<String, String> translationCache = getTranslationCache(sourceLanguage, targetLanguage); String translatedText = translationCache.get(text); if (translatedText == null) { translatedText = translator.translate(text, sourceLanguage, targetLanguage); translationCache.put(text, translatedText); } return translatedText; }
/** * Check whether this CachedTranslator's cache contains a translation of the text from the * source language to the target language. * * @param text What string to check for. * @param sourceLanguage The source language of translation. * @param targetLanguage The target language of translation. * @return true if the cache contains a translation of the text, false otherwise. */ public boolean contains(String text, String sourceLanguage, String targetLanguage) { LRUMap<String, String> translationCache = getTranslationCache(sourceLanguage, targetLanguage); return translationCache.get(text) != null; }
/** * Annotations with meta-annotation {@link JacksonAnnotationsInside} * are considered bundles. */ @Override public boolean isAnnotationBundle(Annotation ann) { // 22-Sep-2015, tatu: Caching here has modest effect on JavaSE, and only // mostly in degenerate cases where introspection used more often than // it should (like recreating ObjectMapper once per read/write). // But it may be more beneficial on platforms like Android (should verify) Class<?> type = ann.annotationType(); Boolean b = _annotationsInside.get(type); if (b == null) { b = type.getAnnotation(JacksonAnnotationsInside.class) != null; _annotationsInside.putIfAbsent(type, b); } return b.booleanValue(); }
/** * Annotations with meta-annotation {@link JacksonAnnotationsInside} * are considered bundles. */ @Override public boolean isAnnotationBundle(Annotation ann) { // 22-Sep-2015, tatu: Caching here has modest effect on JavaSE, and only // mostly in degenerate cases where introspection used more often than // it should (like recreating ObjectMapper once per read/write). // But it may be more beneficial on platforms like Android (should verify) Class<?> type = ann.annotationType(); Boolean b = _annotationsInside.get(type); if (b == null) { b = type.getAnnotation(JacksonAnnotationsInside.class) != null; _annotationsInside.putIfAbsent(type, b); } return b.booleanValue(); }
@Override public String translate(String text, String sourceLanguage, String targetLanguage) throws TikaException, IOException { if (translator == null) { return text; } LRUMap<String, String> translationCache = getTranslationCache(sourceLanguage, targetLanguage); String translatedText = translationCache.get(text); if (translatedText == null) { translatedText = translator.translate(text, sourceLanguage, targetLanguage); translationCache.put(text, translatedText); } return translatedText; }
public QName findRootName(Class<?> rootType, MapperConfig<?> config) { ClassKey key = new ClassKey(rootType); QName name; synchronized (_rootNames) { name = _rootNames.get(key); } if (name != null) { return name; } name = _findRootName(rootType, config); synchronized (_rootNames) { _rootNames.put(key, name); } return name; }
@Override public BasicBeanDescription forClassAnnotations(MapperConfig<?> config, JavaType type, MixInResolver r) { BasicBeanDescription desc = _findStdTypeDesc(type); if (desc == null) { desc = _cachedFCA.get(type); if (desc == null) { desc = BasicBeanDescription.forOtherUse(config, type, _resolveAnnotatedClass(config, type, r)); _cachedFCA.put(type, desc); } } return desc; }
@Override public BasicBeanDescription forClassAnnotations(MapperConfig<?> config, JavaType type, MixInResolver r) { BasicBeanDescription desc = _findStdTypeDesc(type); if (desc == null) { desc = _cachedFCA.get(type); if (desc == null) { AnnotatedClass ac = AnnotatedClass.construct(type, config, r); desc = BasicBeanDescription.forOtherUse(config, type, ac); _cachedFCA.put(type, desc); } } return desc; }
public PropertyName findRootName(Class<?> rootType, MapperConfig<?> config) { ClassKey key = new ClassKey(rootType); PropertyName name = _rootNames.get(key); if (name != null) { return name; } BeanDescription beanDesc = config.introspectClassAnnotations(rootType); AnnotationIntrospector intr = config.getAnnotationIntrospector(); AnnotatedClass ac = beanDesc.getClassInfo(); name = intr.findRootName(ac); // No answer so far? Let's just default to using simple class name if (name == null || !name.hasSimpleName()) { // Should we strip out enclosing class tho? For now, nope: name = new PropertyName(rootType.getSimpleName()); } _rootNames.put(key, name); return name; }
public PropertyName findRootName(Class<?> rootType, MapperConfig<?> config) { ClassKey key = new ClassKey(rootType); PropertyName name = _rootNames.get(key); if (name != null) { return name; } BeanDescription beanDesc = config.introspectClassAnnotations(rootType); AnnotationIntrospector intr = config.getAnnotationIntrospector(); AnnotatedClass ac = beanDesc.getClassInfo(); name = intr.findRootName(ac); // No answer so far? Let's just default to using simple class name if (name == null || !name.hasSimpleName()) { // Should we strip out enclosing class tho? For now, nope: name = new PropertyName(rootType.getSimpleName()); } _rootNames.put(key, name); return name; }
public PropertyName findRootName(Class<?> rootType, MapperConfig<?> config) { ClassKey key = new ClassKey(rootType); PropertyName name = _rootNames.get(key); if (name != null) { return name; } BeanDescription beanDesc = config.introspectClassAnnotations(rootType); AnnotationIntrospector intr = config.getAnnotationIntrospector(); AnnotatedClass ac = beanDesc.getClassInfo(); name = intr.findRootName(ac); // No answer so far? Let's just default to using simple class name if (name == null || !name.hasSimpleName()) { // Should we strip out enclosing class tho? For now, nope: name = PropertyName.construct(rootType.getSimpleName()); } _rootNames.put(key, name); return name; }
public PropertyName findRootName(Class<?> rootType, MapperConfig<?> config) { ClassKey key = new ClassKey(rootType); PropertyName name = _rootNames.get(key); if (name != null) { return name; } BeanDescription beanDesc = config.introspectClassAnnotations(rootType); AnnotationIntrospector intr = config.getAnnotationIntrospector(); AnnotatedClass ac = beanDesc.getClassInfo(); name = intr.findRootName(ac); // No answer so far? Let's just default to using simple class name if (name == null || !name.hasSimpleName()) { // Should we strip out enclosing class tho? For now, nope: name = PropertyName.construct(rootType.getSimpleName()); } _rootNames.put(key, name); return name; }
public synchronized SerializedString findRootName(Class<?> rootType, MapperConfig<?> config) { ClassKey key = new ClassKey(rootType); if (_rootNames == null) { _rootNames = new LRUMap<ClassKey,SerializedString>(20, 200); } else { SerializedString name = _rootNames.get(key); if (name != null) { return name; } } BeanDescription beanDesc = config.introspectClassAnnotations(rootType); AnnotationIntrospector intr = config.getAnnotationIntrospector(); AnnotatedClass ac = beanDesc.getClassInfo(); String nameStr = intr.findRootName(ac); // No answer so far? Let's just default to using simple class name if (nameStr == null) { // Should we strip out enclosing class tho? For now, nope: nameStr = rootType.getSimpleName(); } SerializedString name = new SerializedString(nameStr); _rootNames.put(key, name); return name; } }
@Override public BasicBeanDescription forClassAnnotations(MapperConfig<?> cfg, JavaType type, MixInResolver r) { BasicBeanDescription desc = _findStdTypeDesc(type); if (desc == null) { desc = _cachedFCA.get(type); if (desc == null) { boolean useAnnotations = cfg.isAnnotationProcessingEnabled(); AnnotatedClass ac = AnnotatedClass.construct(type.getRawClass(), (useAnnotations ? cfg.getAnnotationIntrospector() : null), r); desc = BasicBeanDescription.forOtherUse(cfg, type, ac); _cachedFCA.put(type, desc); } } return desc; }
@Override public BasicBeanDescription forClassAnnotations(MapperConfig<?> cfg, JavaType type, MixInResolver r) { BasicBeanDescription desc = _findStdTypeDesc(type); if (desc == null) { desc = _cachedFCA.get(type); if (desc == null) { boolean useAnnotations = cfg.isAnnotationProcessingEnabled(); AnnotatedClass ac = AnnotatedClass.construct(type.getRawClass(), (useAnnotations ? cfg.getAnnotationIntrospector() : null), r); desc = BasicBeanDescription.forOtherUse(cfg, type, ac); _cachedFCA.put(type, desc); } } return desc; }