Reads a class mapping from the stream.

@return the class mapping, or <code>null</code> to represent a null value.
339546
protected ClassMapping readClassMapping ()
        throws IOException, ClassNotFoundException
    {
        // create our classmap if necessary
        if (_classmap == null) {
            _classmap = Lists.newArrayList();
            // insert a zeroth element
            _classmap.add(null);
        }

        // read in the class code for this instance
        short code = readShort();

        // a zero code indicates a null value
        if (code == 0) {
            return null;

        // if the code is negative, that means that we've never seen it before and class
        // metadata follows
        } else if (code < 0) {
            // first swap the code into positive-land
            code *= -1;

            // read in the class metadata
            String cname = readUTF();
            // if we have a translation (used to cope when serialized classes are renamed) use
            // it
            if (_translations != null) {
                String tname = _translations.get(cname);
                if (tname != null) {
                    cname = tname;
                }
            }

            // create the class mapping
            return mapClass(code, cname);

        } else {
            ClassMapping cmap = (code < _classmap.size()) ? _classmap.get(code) : null;

            // sanity check
            if (cmap == null) {
                // this will help with debugging
                log.warning("Internal stream error, no class metadata", "code", code,
                            "ois", this, new Exception());
                log.warning("ObjectInputStream mappings", "map", _classmap);
                String errmsg = "Read object code for which we have no registered class " +
                    "metadata [code=" + code + "]";
                throw new RuntimeException(errmsg);
            }
            return cmap;
        }
    }
580566
private static Class< ? > getReaderSuperClassFor(final Class< ? > fieldType) {
        Class< ? > ret = null;
        if ( fieldType.isPrimitive() ) {
            if ( fieldType == char.class ) {
                ret = BaseCharClassFieldReader.class;
            } else if ( fieldType == byte.class ) {
                ret = BaseByteClassFieldReader.class;
            } else if ( fieldType == short.class ) {
                ret = BaseShortClassFieldReader.class;
            } else if ( fieldType == int.class ) {
                ret = BaseIntClassFieldReader.class;
            } else if ( fieldType == long.class ) {
                ret = BaseLongClassFieldReader.class;
            } else if ( fieldType == float.class ) {
                ret = BaseFloatClassFieldReader.class;
            } else if ( fieldType == double.class ) {
                ret = BaseDoubleClassFieldReader.class;
            } else if ( fieldType == boolean.class ) {
                ret = BaseBooleanClassFieldReader.class;
            }
        } else if ( Number.class.isAssignableFrom( fieldType ) ) {
            ret = BaseNumberClassFieldReader.class;
        } else if ( Date.class.isAssignableFrom( fieldType ) ) {
            ret = BaseDateClassFieldReader.class;
        } else if ( LocalDate.class.isAssignableFrom( fieldType ) ) {
            ret = BaseLocalDateClassFieldReader.class;
        } else if ( LocalDateTime.class.isAssignableFrom( fieldType ) ) {
            ret = BaseLocalDateTimeClassFieldReader.class;
        } else if ( ZonedDateTime.class.isAssignableFrom( fieldType ) ) {
            ret = BaseZonedDateTimeClassFieldReader.class;
        } else {
            ret = BaseObjectClassFieldReader.class;
        }
        return ret;
    }
1349168
public final <T> T nextValue(@NonNull Class<T> clazz) throws IOException {
      if (JsonSerializable.class.isAssignableFrom(clazz)) {
         return readReadable(clazz);
      } else if (peek() == JsonTokenType.BEGIN_OBJECT) {
         Reflect reflected = Reflect.onClass(clazz);
         Optional<Method> staticRead = reflected.getMethods("read", 1).stream()
                                                .filter(m -> JsonReader.class.isAssignableFrom(
                                                   m.getParameterTypes()[0]))
                                                .filter(m -> Modifier.isStatic(m.getModifiers()))
                                                .findFirst();

         if (staticRead.isPresent()) {
            try {
               beginObject();
               T result = Cast.as(staticRead.get().invoke(null, this));
               endObject();
               return result;
            } catch (IllegalAccessException | InvocationTargetException e) {
               throw new IOException(e);
            }
         }

         try {
            T object = Reflect.onClass(clazz).create().get();
            beginObject();
            new BeanMap(object).putAll(nextMap());
            endObject();
            return object;
         } catch (ReflectionException e) {
            throw new IOException(e);
         }
      }
      return nextValue().as(clazz);
   }
1092068
public Class<?> getType(String key) {
      if (beanDescriptor.hasReadMethod(key)) {
         return beanDescriptor.getReadMethod(key).getReturnType();
      } else if (beanDescriptor.hasWriteMethod(key)) {
         Class<?>[] paramTypes = beanDescriptor.getWriteMethod(key).getParameterTypes();
         if (paramTypes.length > 0) {
            return paramTypes[0];
         }
      }
      return null;
   }
6705
public V get(K key) {
    Entry<V> entry = classMap.get(key);
    return entry == null ? null : entry.get();
  }
106082
@SuppressWarnings("unchecked")
    private void readObject(java.io.ObjectInputStream s)
        throws java.io.IOException, ClassNotFoundException
    {
        // Read in the key type and any hidden stuff
        s.defaultReadObject();

        keyUniverse = getKeyUniverse(keyType);
        vals = new Object[keyUniverse.length];

        // Read in size (number of Mappings)
        int size = s.readInt();

        // Read the keys and values, and put the mappings in the HashMap
        for (int i = 0; i < size; i++) {
            K key = (K) s.readObject();
            V value = (V) s.readObject();
            put(key, value);
        }
    }
435597
@SuppressWarnings({ "unchecked", "rawtypes" })
	public static final <TO, FROM> TO convert(Class<TO> to, FROM from) {

		// Convert null value
		if (from == null || to == null) {
			return null;
		}

		// Convert "null" String to null
		if ("null".equals(from)) {
			return null;
		}

		// Class is same
		if (to == Object.class || from.getClass() == to) {
			return (TO) from;
		}

		// BSON conversion
		boolean isFromMap = from != null && from instanceof Map;
		if (isFromMap) {
			Object subValue = getSubValue((Map) from);
			if (subValue != null) {
				return convert(to, subValue);
			}
		}

		// Convert FROM -> TO
		DataConverterKey<TO, FROM> key = new DataConverterKey<TO, FROM>(to, (Class<FROM>) from.getClass());
		DataConverter<TO, FROM> converter = (DataConverter<TO, FROM>) converters.get(key);
		if (converter != null) {
			return converter.convert(from);
		}

		// Convert any -> TO
		converter = (DataConverter<TO, FROM>) defaultConverters.get(to);
		if (converter != null) {
			return converter.convert(from);
		}

		// Converter not found
		throw new IllegalArgumentException("Unable to convert " + from.getClass() + " to " + to
				+ ", converter not found in DataConverterRegistry!");
	}
1207791
public <T> T read (Class<T> type) throws YamlException {
		return read(type, null);
	}
286782
public Map<String, Class<?>> getEntityNameToClassMap()
    {
        if (entityNameToClassMap == null)
        {
            entityNameToClassMap = new HashMap<String, Class<?>>();
        }
        return entityNameToClassMap;
    }
321376
public static <T> T readObject(Class<T> _class, InputStream inputStream) {
        try {
            return defaultObjectMapper.readValue(inputStream, _class);
        } catch (IOException exp) {
            throw new RuntimeException("Failed to read object from inputstream", exp);
        }
    }
7236
private Map<String, Entry> readEntries(String mapping, boolean ignoreCase) {
		Map<String, Entry> entries = new HashMap<>();

		try {
			// ms, 2010-10-05: try to load the file from the CLASSPATH first
			InputStream is = getClass().getClassLoader().getResourceAsStream(mapping);
			// if not found in the CLASSPATH, load from the file system
			if (is == null) is = new FileInputStream(mapping);
			BufferedReader rd = new BufferedReader(new InputStreamReader(is));

			int lineCount = 0;
			for (String line; (line = rd.readLine()) != null; ) {
				lineCount ++;
				String[] split = line.split("\t");
				if (split.length < 2 || split.length > 4)
					throw new RuntimeException("Provided mapping file is in wrong format");
				if (split[1].trim().equalsIgnoreCase("AS")) System.err.println("ERRRR " + mapping + "|" + line + " at " + lineCount);
				String stringLine = split[1].trim();
				if (ignoreCase) stringLine = stringLine.toLowerCase();
				String[] words = stringLine.split("\\s+");
				String type = split[0].trim();
				Set<String> overwritableTypes = new HashSet<String>();
				overwritableTypes.add(flags.backgroundSymbol);
				overwritableTypes.add(null);
				double priority = 0;
				List<String> tokens = new ArrayList<String>();

				try {
					if (split.length >= 3)
						overwritableTypes.addAll(Arrays.asList(split[2].trim().split(",")));
					if (split.length == 4)
						priority = Double.parseDouble(split[3].trim());

					for (String str : words) {
						tokens.add(str);
					}
				} catch(NumberFormatException e) {
					System.err.println("ERROR: Invalid line " + lineCount + " in regexner file " + mapping + ": \"" + line + "\"!");
					throw e;
				}
				addEntry(words, type, priority, overwritableTypes);
			}
			rd.close();
			is.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return entries;
	}
19285
public <T> JsonReaderI<T> getMapper(Class<T> type) {
		// look for cached Mapper
		@SuppressWarnings("unchecked")
		JsonReaderI<T> map = (JsonReaderI<T>) cache.get(type);
		if (map != null)
			return map;
		/*
		 * Special handle
		 */
		if (type instanceof Class) {
			if (Map.class.isAssignableFrom(type))
				map = new DefaultMapperCollection<T>(this, type);
			else if (List.class.isAssignableFrom(type))
				map = new DefaultMapperCollection<T>(this, type);
			if (map != null) {
				cache.put(type, map);
				return map;
			}
		}

		if (type.isArray())
			map = new ArraysMapper.GenericMapper<T>(this, type);
		else if (List.class.isAssignableFrom(type))
			map = new CollectionMapper.ListClass<T>(this, type);
		else if (Map.class.isAssignableFrom(type))
			map = new CollectionMapper.MapClass<T>(this, type);
		else
			// use bean class
			map = new BeansMapper.Bean<T>(this, type);
		cache.putIfAbsent(type, map);
		return map;
	}
815722
public static Mapping getMapping(PersistentEntity domainClass) {
        return domainClass == null ? null : MAPPING_CACHE.get(domainClass.getJavaClass());
    }
1192388
public static <T> T deserialize(byte[] input, Class<T> classType)
            throws JsonParseException, JsonMappingException, IOException {
        return mapper.readValue(input, classType);
    }
1244573
private void readObject(java.io.ObjectInputStream s)
        throws java.io.IOException, ClassNotFoundException  {
        // Read in any hidden stuff
        s.defaultReadObject();

        // Read in size (number of Mappings)
        int size = s.readInt();
        if (size < 0)
            throw new java.io.StreamCorruptedException
                ("Illegal mappings count: " + size);
        init(capacity(size));

        // Read the keys and values, and put the mappings in the table
        for (int i=0; i<size; i++) {
            @SuppressWarnings("unchecked")
                K key = (K) s.readObject();
            @SuppressWarnings("unchecked")
                V value = (V) s.readObject();
            putForCreate(key, value);
        }
    }
1201290
@Override
	@Nullable
	public String getMapping(Class<?> type, Method method) {

		Assert.notNull(type, "Type must not be null!");
		Assert.notNull(method, "Method must not be null!");

		String[] mapping = getMappingFrom(findMergedAnnotation(method, annotationType));
		String typeMapping = getMapping(type);

		if (mapping.length == 0) {
			return typeMapping;
		}

		return typeMapping == null || "/".equals(typeMapping) ? mapping[0] : join(typeMapping, mapping[0]);
	}
1346339
protected Map<String, Object> readSimpleObject() {
		log.debug("readSimpleObject");
		Map<String, Object> result = new ObjectMap<>();
		readKeyValues(result);
		storeReference(result);
		return result;
	}