當前位置: 首頁>>代碼示例>>Java>>正文


Java XsdTypeMapper.toJavaType方法代碼示例

本文整理匯總了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);
	}
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:14,代碼來源:JsonValueParser.java

示例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, "");
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:9,代碼來源:JsonNullValueParser.java

示例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);
	}
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:10,代碼來源:PrismUtil.java

示例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;
	}
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:14,代碼來源:PrismUtil.java

示例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);
	}
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:9,代碼來源:SchemaRegistryImpl.java

示例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;
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:42,代碼來源:ExpressionUtil.java

示例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);
   }
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:65,代碼來源:XPathScriptEvaluator.java

示例8: getTypeClass

import com.evolveum.midpoint.prism.xml.XsdTypeMapper; //導入方法依賴的package包/類
@Override
public Class getTypeClass() {
	return XsdTypeMapper.toJavaType(getTypeName());
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:5,代碼來源:DefinitionImpl.java

示例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;
}
 
開發者ID:Evolveum,項目名稱:midpoint,代碼行數:42,代碼來源:ExpressionUtil.java

示例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);
   }
 
開發者ID:Evolveum,項目名稱:midpoint,代碼行數:65,代碼來源:XPathScriptEvaluator.java


注:本文中的com.evolveum.midpoint.prism.xml.XsdTypeMapper.toJavaType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。