类com.fasterxml.jackson.databind.DatabindContext源码实例Demo

下面列出了怎么用com.fasterxml.jackson.databind.DatabindContext的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lams   文件: MinimalClassNameIdResolver.java
@Override
protected JavaType _typeFromId(String id, DatabindContext ctxt) throws IOException
{
    if (id.startsWith(".")) {
        StringBuilder sb = new StringBuilder(id.length() + _basePackageName.length());
        if  (_basePackageName.length() == 0) {
            // no package; must remove leading '.' from id
            sb.append(id.substring(1));
        } else {
            // otherwise just concatenate package, with leading-dot-partial name
            sb.append(_basePackageName).append(id);
        }
        id = sb.toString();
    }
    return super._typeFromId(id, ctxt);
}
 
源代码2 项目: caravan   文件: TypeAliasIdResolver.java
@Override
public JavaType typeFromId(DatabindContext context, String id) throws IOException {
	Class<?> type = idToClassMapping.get(id);

	if (type == null) {
		synchronized (TypeAliasIdResolver.class) {
			type = idToClassMapping.get(id);
			if (type == null) {
				int commaPos = id.indexOf(",");
				if (commaPos > 0) {
					String exactId = id.substring(0, commaPos).trim();
					type = idToClassMapping.get(exactId);
					if (type != null) {
						idToClassMapping.put(id, type);
					}
				}
			}
		}
	}

	if (type != null) {
		return context.constructType(type);
	} else {
		throw new IllegalArgumentException(String.format("Unknown type for id %s", id));
	}
}
 
源代码3 项目: registry   文件: Schema.java
@Override
public JavaType typeFromId(DatabindContext databindContext, String s) {
    Type fieldType = Schema.Type.valueOf(s);
    JavaType javaType;
    switch (fieldType) {
        case NESTED:
            javaType = TypeFactory.defaultInstance().constructType(NestedField.class);
            break;
        case ARRAY:
            javaType = TypeFactory.defaultInstance().constructType(ArrayField.class);
            break;
        default:
            javaType = TypeFactory.defaultInstance().constructType(Field.class);
    }
    return javaType;
}
 
源代码4 项目: presto   文件: AbstractTypedJacksonModule.java
@Override
public JavaType typeFromId(DatabindContext context, String id)
{
    requireNonNull(id, "id is null");
    Class<?> typeClass = classResolver.apply(id);
    checkArgument(typeClass != null, "Unknown type ID: %s", id);
    return context.getTypeFactory().constructType(typeClass);
}
 
源代码5 项目: eventeum   文件: ParameterTypeIdResolver.java
@Override
public JavaType typeFromId(DatabindContext context, String id) {
    Class<?> subType = null;

    if (id.endsWith("[]")) {
        subType = ArrayParameter.class;
    } else if (id.startsWith("byte") || id.equals("string") || id.equals("address")) {
        subType = StringParameter.class;
    } else if (id.startsWith("uint") || id.startsWith("int") || id.startsWith("bool")) {
        subType = NumberParameter.class;
    }
    return context.constructSpecializedType(superType, subType);
}
 
源代码6 项目: metanome-algorithms   文件: CPSTypeIdResolver.java
@Override
public JavaType typeFromId(DatabindContext context, String id) {
	Class<?> result = typeMap.get(id);
	if (result == null) {
		throw new IllegalStateException(
			"There is no type " + id + " for " + baseType.getTypeName() + ". Try: "
				+ getDescForKnownTypeIds());
	}
	return TypeFactory.defaultInstance().constructSpecializedType(baseType, result);
}
 
源代码7 项目: WavesJ   文件: DataEntryTypeResolver.java
@Override
public JavaType typeFromId(DatabindContext context, String id) throws IOException {
    Class t = null;

    if (id.equals("integer")) {
        t = DataEntry.LongEntry.class;
    } else if (id.equals("boolean")) {
        t = DataEntry.BooleanEntry.class;
    } else if (id.equals("binary")) {
        t = DataEntry.BinaryEntry.class;
    } else if (id.equals("string")) {
        t = DataEntry.StringEntry.class;
    }
    return context.constructType(t);
}
 
源代码8 项目: lams   文件: TypeIdResolverBase.java
@Override
public JavaType typeFromId(DatabindContext context, String id)  throws IOException {
    // 22-Dec-2015, tatu: Must be overridden by sub-classes, so let's throw
    //    an exception if not
    throw new IllegalStateException("Sub-class "+getClass().getName()+" MUST implement "
            +"`typeFromId(DatabindContext,String)");
}
 
源代码9 项目: dremio-oss   文件: EnumTypeIdResolver.java
@Override
public JavaType typeFromId(DatabindContext context, String id) {
  JavaType type = nameToType.get(id.toLowerCase());
  if (type == null) {
    throw new NullPointerException(
        format("no subtype of %s found for enum value %s. existing mappings:\n%s",
            baseType, id, description));

  }
  return type;
}
 
源代码10 项目: hono   文件: CredentialTypeResolver.java
@Override
public JavaType typeFromId(final DatabindContext context, final String id) {
    switch (id) {
    case PasswordCredential.TYPE:
        return context.constructSpecializedType(this.baseType, PasswordCredential.class);
    case PskCredential.TYPE:
        return context.constructSpecializedType(this.baseType, PskCredential.class);
    case X509CertificateCredential.TYPE:
        return context.constructSpecializedType(this.baseType, X509CertificateCredential.class);
    default:
        return context.constructSpecializedType(this.baseType, GenericCredential.class);
    }
}
 
源代码11 项目: haven-platform   文件: CustomTypeIdResolver.java
@Override
public JavaType typeFromId(DatabindContext context, String id) throws IOException {
    try {
        Class<?> type = Class.forName(id);
        return context.constructType(type);
    } catch (ClassNotFoundException e) {
        if(!(context instanceof DeserializationContext)) {
            throw new RuntimeException(e);
        }
        //see magic from ClassNameIdResolver._typeFromId()
        return ((DeserializationContext) context).handleUnknownTypeId(_baseType, id, this,
          "Class '" + id + "' not found.");
    }
}
 
源代码12 项目: logsniffer   文件: ConfiguredBean.java
@SuppressWarnings("unchecked")
@Override
public JavaType typeFromId(final DatabindContext context,
		final String id) {
	return context.constructType(beanTypeResolver.resolveTypeClass(id,
			(Class<ConfiguredBean>) baseType.getRawClass()));
}
 
源代码13 项目: archie   文件: OpenEHRTypeNaming.java
@Override
protected JavaType _typeFromId(String typeName, DatabindContext ctxt) {
    Class result = rmInfoLookup.getClass(typeName);
    if(result == null) {
        //AOM class?
        result = aomInfoLookup.getClass(typeName);
    }
    if(result != null) {
        TypeFactory typeFactory = (ctxt == null) ? _typeFactory : ctxt.getTypeFactory();
        return typeFactory.constructSpecializedType(_baseType, result);
    }
    return super._typeFromId(typeName, ctxt);
}
 
源代码14 项目: omise-java   文件: ModelTypeResolver.java
@Override
public JavaType typeFromId(DatabindContext context, String id) {
    Class klass = getKnownTypes().get(id);
    if (klass == null) {
        return null;
    }

    JavaType[] typeArgs = klass.equals(Event.class) ?
            new JavaType[]{context.getTypeFactory().constructSimpleType(Model.class, new JavaType[]{})} :
            new JavaType[]{};

    return context.getTypeFactory().constructSimpleType(klass, typeArgs);
}
 
源代码15 项目: components   文件: NsTypeIdResolver.java
@Override
public JavaType typeFromId(DatabindContext context, String id) {
    Class<?> clazz = basicMetaData.getTypeClass(id);
    if (clazz == null) {
        return null;
    }
    JavaType javaType = SimpleType.construct(clazz);
    return javaType;
}
 
源代码16 项目: depgraph-maven-plugin   文件: NodeTypeResolver.java
@Override
public JavaType typeFromId(DatabindContext context, String id) {
  try {
    return SimpleType.constructUnsafe(Class.forName(getClass().getPackage().getName() + "." + id.substring(0, 1).toUpperCase() + id.substring(1)));
  } catch (ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
}
 
@Override
protected JavaType _typeFromId(final String id, final DatabindContext ctxt) throws IOException {
    Class<?> clazz = idToClass.get(id);
    if (clazz != null) {
        return _typeFactory.constructSpecializedType(_baseType, clazz);
    }

    return super._typeFromId(id, ctxt);
}
 
源代码18 项目: ovsdb   文件: OvsdbTypesIdResolver.java
@Override
public JavaType typeFromId(DatabindContext context, String id) {
    if ("set".equals(id)) {
        return context.getTypeFactory().constructCollectionType(OvsdbSet.class, Object.class);
    } else if ("uuid".equals(id) || "named-uuid".equals(id)) {
        return context.constructType(UUID.class);
    }
    return null;
}
 
源代码19 项目: tutorials   文件: TypeIdResolverStructure.java
@Override
public JavaType typeFromId(DatabindContext context, String id) {
    Class<?> subType = null;
    switch (id) {
    case "bean1":
        subType = FirstBean.class;
        break;
    case "bean2":
        subType = LastBean.class;
    }
    return context.constructSpecializedType(superType, subType);
}
 
源代码20 项目: data-highway   文件: DestinationTypeIdResolver.java
@Override
public JavaType typeFromId(DatabindContext context, String id) throws IOException {
  return TypeFactory.defaultInstance().constructSpecializedType(baseType, TYPES.get(id));
}
 
@Override
public JavaType typeFromId(DatabindContext context, String id) {
	return null;
}
 
@Override
public JavaType typeFromId(DatabindContext context, String id) {
	return null;
}
 
源代码23 项目: lams   文件: TypeNameIdResolver.java
@Override
public JavaType typeFromId(DatabindContext context, String id) {
    return _typeFromId(id);
}
 
源代码24 项目: dremio-oss   文件: DataJsonOutput.java
public static final boolean isNumberAsString(DatabindContext context) {
  Object attr = context.getAttribute(DataJsonOutput.DREMIO_JOB_DATA_NUMBERS_AS_STRINGS_ATTRIBUTE);
  return attr instanceof Boolean && ((Boolean)attr).booleanValue();
}
 
源代码25 项目: dremio-oss   文件: TestDataJsonOutput.java
public TestDataJsonOutput(final Object inputValue, final boolean expectedValue) {
   this.context = Mockito.mock(DatabindContext.class);
   this.inputValue = inputValue;
   this.expectedValue = expectedValue;
}
 
public JavaType typeFromId(DatabindContext context, String id) {
	return null;
}
 
@Override
public Validity validateBaseType(DatabindContext ctxt, JavaType baseType) {
    return Validity.ALLOWED;
}
 
源代码28 项目: jackson-modules-java8   文件: DefaultTypingTest.java
@Override
public Validity validateBaseType(DatabindContext ctxt, JavaType baseType) {
    return Validity.ALLOWED;
}
 
@Override
public Validity validateBaseType(DatabindContext ctxt, JavaType baseType) {
    return Validity.INDETERMINATE;
}
 
@Override
public Validity validateSubClassName(DatabindContext ctxt,
        JavaType baseType, String subClassName) {
    return Validity.ALLOWED;
}
 
 同包方法