예제 #1
0
  /**
   * Creates and registers {@link BinaryClassDescriptor} for the given {@code class}.
   *
   * @param cls Class.
   * @return Class descriptor.
   */
  private BinaryClassDescriptor registerClassDescriptor(Class<?> cls, boolean deserialize) {
    BinaryClassDescriptor desc;

    String clsName = cls.getName();

    if (marshCtx.isSystemType(clsName)) {
      desc =
          new BinaryClassDescriptor(
              this,
              cls,
              false,
              clsName.hashCode(),
              clsName,
              null,
              BinaryInternalIdMapper.defaultInstance(),
              null,
              false,
              true /* registered */);

      BinaryClassDescriptor old = descByCls.putIfAbsent(cls, desc);

      if (old != null) desc = old;
    } else desc = registerUserClassDescriptor(cls, deserialize);

    return desc;
  }
예제 #2
0
  /**
   * Check whether class must be deserialized anyway.
   *
   * @param cls Class.
   * @return {@code True} if must be deserialized.
   */
  public boolean mustDeserialize(Class cls) {
    BinaryClassDescriptor desc = descByCls.get(cls);

    if (desc == null)
      return marshCtx.isSystemType(cls.getName()) || serializerForClass(cls) == null;
    else return desc.useOptimizedMarshaller();
  }
예제 #3
0
  /**
   * @param typeName Type name.
   * @return Type ID.
   */
  public int typeId(String typeName) {
    String typeName0 = typeName(typeName);

    Integer id = predefinedTypeNames.get(typeName0);

    if (id != null) return id;

    if (marshCtx.isSystemType(typeName)) return typeName.hashCode();

    return userTypeIdMapper(typeName0).typeId(typeName0);
  }