本文整理匯總了Java中com.evolveum.midpoint.prism.xml.XsdTypeMapper.toJavaType方法的典型用法代碼示例。如果您正苦於以下問題:Java XsdTypeMapper.toJavaType方法的具體用法?Java XsdTypeMapper.toJavaType怎麽用?Java XsdTypeMapper.toJavaType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.evolveum.midpoint.prism.xml.XsdTypeMapper
的用法示例。
在下文中一共展示了XsdTypeMapper.toJavaType方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parse
import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
@Override
public T parse(QName typeName, XNodeProcessorEvaluationMode mode) throws SchemaException {
ObjectMapper mapper = (ObjectMapper) parser.getCodec();
Class clazz = XsdTypeMapper.toJavaType(typeName);
ObjectReader r = mapper.readerFor(clazz);
try {
return r.readValue(node);
// TODO implement COMPAT mode
} catch (IOException e) {
throw new SchemaException("Cannot parse value: " + e.getMessage(), e);
}
}
示例2: parse
import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
@Override
public T parse(QName typeName, XNodeProcessorEvaluationMode mode) throws SchemaException {
Class clazz = XsdTypeMapper.toJavaType(typeName);
if (clazz == null) {
throw new SchemaException("Unsupported type " + typeName);
}
return (T) JavaTypeConverter.convert(clazz, "");
}
示例3: convertPropertyValue
import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
public static <T,X> PrismPropertyValue<X> convertPropertyValue(PrismPropertyValue<T> srcVal, PrismPropertyDefinition<T> srcDef, PrismPropertyDefinition<X> targetDef) {
if (targetDef.getTypeName().equals(srcDef.getTypeName())) {
return (PrismPropertyValue<X>) srcVal;
} else {
Class<X> expectedJavaType = XsdTypeMapper.toJavaType(targetDef.getTypeName());
X convertedRealValue = JavaTypeConverter.convert(expectedJavaType, srcVal.getValue());
return new PrismPropertyValue<X>(convertedRealValue);
}
}
示例4: convertProperty
import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
public static <T,X> PrismProperty<X> convertProperty(PrismProperty<T> srcProp, PrismPropertyDefinition<X> targetDef) throws SchemaException {
if (targetDef.getTypeName().equals(srcProp.getDefinition().getTypeName())) {
return (PrismProperty<X>) srcProp;
} else {
PrismProperty<X> targetProp = targetDef.instantiate();
Class<X> expectedJavaType = XsdTypeMapper.toJavaType(targetDef.getTypeName());
for (PrismPropertyValue<T> srcPVal: srcProp.getValues()) {
X convertedRealValue = JavaTypeConverter.convert(expectedJavaType, srcPVal.getValue());
targetProp.add(new PrismPropertyValue<X>(convertedRealValue));
}
return targetProp;
}
}
示例5: determineClassForType
import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
@Override
public <T> Class<T> determineClassForType(QName type) {
if (XmlTypeConverter.canConvert(type)) {
return XsdTypeMapper.toJavaType(type);
} else {
return determineCompileTimeClass(type);
}
}
示例6: toOutputTriple
import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
public static <V extends PrismValue> PrismValueDeltaSetTriple<V> toOutputTriple(
PrismValueDeltaSetTriple<V> resultTriple, ItemDefinition outputDefinition,
Function<Object, Object> additionalConvertor,
final ItemPath residualPath, final Protector protector, final PrismContext prismContext) {
PrismValueDeltaSetTriple<V> clonedTriple = resultTriple.clone();
final Class<?> resultTripleValueClass = resultTriple.getRealValueClass();
if (resultTripleValueClass == null) {
// triple is empty. type does not matter.
return clonedTriple;
}
Class<?> expectedJavaType = XsdTypeMapper.toJavaType(outputDefinition.getTypeName());
if (expectedJavaType == null) {
expectedJavaType = prismContext.getSchemaRegistry()
.getCompileTimeClass(outputDefinition.getTypeName());
}
if (resultTripleValueClass == expectedJavaType) {
return clonedTriple;
}
final Class<?> finalExpectedJavaType = expectedJavaType;
clonedTriple.accept((Visitor) visitable -> {
if (visitable instanceof PrismPropertyValue<?>) {
PrismPropertyValue<Object> pval = (PrismPropertyValue<Object>) visitable;
Object realVal = pval.getValue();
if (realVal != null) {
if (Structured.class.isAssignableFrom(resultTripleValueClass)) {
if (residualPath != null && !residualPath.isEmpty()) {
realVal = ((Structured) realVal).resolve(residualPath);
}
}
if (finalExpectedJavaType != null) {
Object convertedVal = convertValue(finalExpectedJavaType, additionalConvertor, realVal, protector, prismContext);
pval.setValue(convertedVal);
}
}
}
});
return clonedTriple;
}
示例7: evaluate
import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
@Override
public <T, V extends PrismValue> List<V> evaluate(ScriptExpressionEvaluatorType expressionType,
ExpressionVariables variables, ItemDefinition outputDefinition,
Function<Object, Object> additionalConvertor,
ScriptExpressionReturnTypeType suggestedReturnType,
ObjectResolver objectResolver, Collection<FunctionLibrary> functions,
String contextDescription, Task task, OperationResult result) throws ExpressionEvaluationException,
ObjectNotFoundException, ExpressionSyntaxException {
String codeString = expressionType.getCode();
if (codeString == null) {
throw new ExpressionEvaluationException("No script code in " + contextDescription);
}
Class<T> type = null;
if (outputDefinition != null) {
QName xsdReturnType = outputDefinition.getTypeName();
type = XsdTypeMapper.toJavaType(xsdReturnType); // may return null if unknown
}
if (type == null) {
type = (Class<T>) Element.class; // actually, if outputDefinition is null, the return value is of no interest for us
}
QName returnType = determineRerturnType(type, expressionType, outputDefinition, suggestedReturnType);
Object evaluatedExpression = evaluate(returnType, codeString, variables, objectResolver, functions,
contextDescription, result);
List<V> propertyValues;
boolean scalar = !outputDefinition.isMultiValue();
if (expressionType.getReturnType() != null) {
scalar = isScalar(expressionType.getReturnType());
} else if (suggestedReturnType != null) {
scalar = isScalar(suggestedReturnType);
}
if (scalar) {
if (evaluatedExpression instanceof NodeList) {
NodeList evaluatedExpressionNodeList = (NodeList)evaluatedExpression;
if (evaluatedExpressionNodeList.getLength() > 1) {
throw new ExpressionEvaluationException("Expected scalar expression result but got a list result with "+evaluatedExpressionNodeList.getLength()+" elements in "+contextDescription);
}
if (evaluatedExpressionNodeList.getLength() == 0) {
evaluatedExpression = null;
} else {
evaluatedExpression = evaluatedExpressionNodeList.item(0);
}
}
propertyValues = new ArrayList<V>(1);
V pval = convertScalar(type, returnType, evaluatedExpression, contextDescription);
if (pval instanceof PrismPropertyValue && !isNothing(((PrismPropertyValue<T>)pval).getValue())) {
propertyValues.add(pval);
}
} else {
if (!(evaluatedExpression instanceof NodeList)) {
throw new IllegalStateException("The expression " + contextDescription + " resulted in " + evaluatedExpression.getClass().getName() + " while exprecting NodeList in "+contextDescription);
}
propertyValues = convertList(type, (NodeList) evaluatedExpression, contextDescription);
}
return (List<V>) PrismValue.cloneCollection(propertyValues);
}
示例8: getTypeClass
import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
@Override
public Class getTypeClass() {
return XsdTypeMapper.toJavaType(getTypeName());
}
示例9: toOutputTriple
import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
public static <V extends PrismValue> PrismValueDeltaSetTriple<V> toOutputTriple(
PrismValueDeltaSetTriple<V> resultTriple, ItemDefinition outputDefinition,
Function<Object, Object> additionalConvertor,
final ItemPath residualPath, final Protector protector, final PrismContext prismContext) {
PrismValueDeltaSetTriple<V> clonedTriple = resultTriple.clone();
final Class<?> resultTripleValueClass = resultTriple.getRealValueClass();
if (resultTripleValueClass == null) {
// triple is empty. type does not matter.
return clonedTriple;
}
Class<?> expectedJavaType = XsdTypeMapper.toJavaType(outputDefinition.getTypeName());
if (expectedJavaType == null) {
expectedJavaType = prismContext.getSchemaRegistry()
.getCompileTimeClass(outputDefinition.getTypeName());
}
if (resultTripleValueClass == expectedJavaType) {
return clonedTriple;
}
final Class<?> finalExpectedJavaType = expectedJavaType;
clonedTriple.accept((Visitor) visitable -> {
if (visitable instanceof PrismPropertyValue<?>) {
PrismPropertyValue<Object> pval = (PrismPropertyValue<Object>) visitable;
Object realVal = pval.getValue();
if (realVal != null) {
if (Structured.class.isAssignableFrom(resultTripleValueClass)) {
if (residualPath != null && !residualPath.isEmpty()) {
realVal = ((Structured) realVal).resolve(residualPath);
}
}
if (finalExpectedJavaType != null) {
Object convertedVal = convertValue(finalExpectedJavaType, additionalConvertor, realVal, protector, prismContext);
pval.setValue(convertedVal);
}
}
}
});
return clonedTriple;
}
示例10: evaluate
import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
@Override
public <T, V extends PrismValue> List<V> evaluate(ScriptExpressionEvaluatorType expressionType,
ExpressionVariables variables, ItemDefinition outputDefinition,
Function<Object, Object> additionalConvertor,
ScriptExpressionReturnTypeType suggestedReturnType,
ObjectResolver objectResolver, Collection<FunctionLibrary> functions,
String contextDescription, Task task, OperationResult result) throws ExpressionEvaluationException,
ObjectNotFoundException, ExpressionSyntaxException {
String codeString = expressionType.getCode();
if (codeString == null) {
throw new ExpressionEvaluationException("No script code in " + contextDescription);
}
Class<T> type = null;
if (outputDefinition != null) {
QName xsdReturnType = outputDefinition.getTypeName();
type = XsdTypeMapper.toJavaType(xsdReturnType); // may return null if unknown
}
if (type == null) {
type = (Class<T>) Element.class; // actually, if outputDefinition is null, the return value is of no interest for us
}
QName returnType = determineRerturnType(type, expressionType, outputDefinition, suggestedReturnType);
Object evaluatedExpression = evaluate(returnType, codeString, variables, objectResolver, functions,
contextDescription, result);
List<V> propertyValues;
boolean scalar = !outputDefinition.isMultiValue();
if (expressionType.getReturnType() != null) {
scalar = isScalar(expressionType.getReturnType());
} else if (suggestedReturnType != null) {
scalar = isScalar(suggestedReturnType);
}
if (scalar) {
if (evaluatedExpression instanceof NodeList) {
NodeList evaluatedExpressionNodeList = (NodeList)evaluatedExpression;
if (evaluatedExpressionNodeList.getLength() > 1) {
throw new ExpressionEvaluationException("Expected scalar expression result but got a list result with "+evaluatedExpressionNodeList.getLength()+" elements in "+contextDescription);
}
if (evaluatedExpressionNodeList.getLength() == 0) {
evaluatedExpression = null;
} else {
evaluatedExpression = evaluatedExpressionNodeList.item(0);
}
}
propertyValues = new ArrayList<V>(1);
V pval = convertScalar(type, returnType, evaluatedExpression, contextDescription);
if (pval instanceof PrismPropertyValue && !isNothing(((PrismPropertyValue<T>)pval).getValue())) {
propertyValues.add(pval);
}
} else {
if (!(evaluatedExpression instanceof NodeList)) {
throw new IllegalStateException("The expression " + contextDescription + " resulted in " + evaluatedExpression.getClass().getName() + " while exprecting NodeList in "+contextDescription);
}
propertyValues = convertList(type, (NodeList) evaluatedExpression, contextDescription);
}
return (List<V>) PrismValue.cloneCollection(propertyValues);
}