当前位置: 首页>>代码示例>>Java>>正文


Java DOMUtil.getQNameValue方法代码示例

本文整理汇总了Java中com.evolveum.midpoint.util.DOMUtil.getQNameValue方法的典型用法代码示例。如果您正苦于以下问题:Java DOMUtil.getQNameValue方法的具体用法?Java DOMUtil.getQNameValue怎么用?Java DOMUtil.getQNameValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.evolveum.midpoint.util.DOMUtil的用法示例。


在下文中一共展示了DOMUtil.getQNameValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toJavaValue

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
public static <T> T toJavaValue(Element xmlElement, Class<T> type) throws SchemaException {
    if (type.equals(Element.class)) {
        return (T) xmlElement;
    } else if (type.equals(QName.class)) {
        return (T) DOMUtil.getQNameValue(xmlElement);
    } else if (PolyString.class.isAssignableFrom(type)) {
    	return (T) polyStringToJava(xmlElement);
    } else {
        String stringContent = xmlElement.getTextContent();
        if (stringContent == null) {
            return null;
        }
        T javaValue = toJavaValue(stringContent, type);
        if (javaValue == null) {
            throw new IllegalArgumentException("Unknown type for conversion: " + type + "(element " + DOMUtil.getQName(xmlElement) + ")");
        }
        return javaValue;
    }
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:20,代码来源:XmlTypeConverter.java

示例2: parsePrimitiveElementValue

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
private static <T> T parsePrimitiveElementValue(Element element, QName typeName, XNodeProcessorEvaluationMode mode) throws SchemaException {
	try {
		if (ItemPathType.COMPLEX_TYPE.equals(typeName)) {
			return (T) parsePath(element);
		} else if (DOMUtil.XSD_QNAME.equals(typeName)) {
			return (T) DOMUtil.getQNameValue(element);
		} else if (XmlTypeConverter.canConvert(typeName)) {
			return (T) XmlTypeConverter.toJavaValue(element, typeName);
		} else if (DOMUtil.XSD_ANYTYPE.equals(typeName)) {
			return (T) element.getTextContent();                // if parsing primitive as xsd:anyType, we can safely parse it as string
		} else {
			throw new SchemaException("Cannot convert element '" + element + "' to " + typeName);
		}
	} catch (IllegalArgumentException e) {
		return processIllegalArgumentException(element.getTextContent(), typeName, e, mode);		// primitive way of ensuring compatibility mode
	}
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:18,代码来源:DomLexicalProcessor.java

示例3: assertDomSchema

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
private void assertDomSchema(Element xsdElement) {
	assertPrefix("xsd", xsdElement);
	Element displayNameAnnotationElement = DOMUtil.findElementRecursive(xsdElement, PrismConstants.A_DISPLAY_NAME);
	assertPrefix(PrismConstants.PREFIX_NS_ANNOTATION, displayNameAnnotationElement);
	Element kindAnnotationElement = DOMUtil.findElementRecursive(xsdElement, MidPointConstants.RA_KIND);
	assertPrefix("ra", kindAnnotationElement);
	assertEquals(ShadowKindType.ACCOUNT.value(), kindAnnotationElement.getTextContent());
	Element identifierAnnotationElement = DOMUtil.findElementRecursive(xsdElement, MidPointConstants.RA_IDENTIFIER);
	assertPrefix("ra", identifierAnnotationElement);
	QName identifier = DOMUtil.getQNameValue(identifierAnnotationElement);
	assertEquals("Wrong <a:identifier> value namespace", SchemaTestConstants.ICFS_UID.getNamespaceURI(), identifier.getNamespaceURI());
	assertEquals("Wrong <a:identifier> value localname", SchemaTestConstants.ICFS_UID.getLocalPart(), identifier.getLocalPart());
	assertEquals("Wrong <a:identifier> value prefix", "icfs", identifier.getPrefix());
	Element dnaAnnotationElement = DOMUtil.findElementRecursive(xsdElement, MidPointConstants.RA_DISPLAY_NAME_ATTRIBUTE);
	assertPrefix("ra", dnaAnnotationElement);
	QName dna = DOMUtil.getQNameValue(dnaAnnotationElement);
	assertEquals("Wrong <a:identifier> value prefix", "tns", dna.getPrefix());
	
	assertEquals("Wrong 'tns' prefix declaration", SCHEMA_NAMESPACE, xsdElement.lookupNamespaceURI("tns"));
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:21,代码来源:TestResourceSchema.java

示例4: getAnnotationQName

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
public static QName getAnnotationQName(XSAnnotation annotation, QName qname) {
	Element element = getAnnotationElement(annotation, qname);
	if (element == null) {
		return null;
	}
	return DOMUtil.getQNameValue(element);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:8,代码来源:SchemaProcessorUtil.java

示例5: processObjectReferenceDefinition

import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
private PrismReferenceDefinitionImpl processObjectReferenceDefinition(XSType xsType, QName elementName,
		XSAnnotation annotation, ComplexTypeDefinition containingCtd, XSParticle elementParticle,
		boolean inherited) throws SchemaException {
	QName typeName = new QName(xsType.getTargetNamespace(), xsType.getName());
	QName primaryElementName = elementName;
	Element objRefAnnotationElement = SchemaProcessorUtil.getAnnotationElement(annotation,
			A_OBJECT_REFERENCE);
	boolean hasExplicitPrimaryElementName = (objRefAnnotationElement != null
			&& !StringUtils.isEmpty(objRefAnnotationElement.getTextContent()));
	if (hasExplicitPrimaryElementName) {
		primaryElementName = DOMUtil.getQNameValue(objRefAnnotationElement);
	}
	PrismReferenceDefinitionImpl definition = null;
	if (containingCtd != null) {
		definition = (PrismReferenceDefinitionImpl) containingCtd.findItemDefinition(primaryElementName, PrismReferenceDefinition.class);
	}
	if (definition == null) {
		SchemaDefinitionFactory definitionFactory = getDefinitionFactory();
		definition = (PrismReferenceDefinitionImpl) definitionFactory.createReferenceDefinition(primaryElementName, typeName,
				containingCtd, prismContext, annotation, elementParticle);
		definition.setInherited(inherited);
		if (containingCtd != null) {
			((ComplexTypeDefinitionImpl) containingCtd).add(definition);
		}
	}
	if (hasExplicitPrimaryElementName) {
		// The elements that have explicit type name determine the target
		// type name (if not yet set)
		if (definition.getTargetTypeName() == null) {
			definition.setTargetTypeName(typeName);
		}
		if (definition.getCompositeObjectElementName() == null) {
			definition.setCompositeObjectElementName(elementName);
		}
	} else {
		// The elements that use default element names override type
		// definition
		// as there can be only one such definition, therefore the behavior
		// is deterministic
		definition.setTypeName(typeName);
	}
	Element targetTypeAnnotationElement = SchemaProcessorUtil.getAnnotationElement(annotation,
			A_OBJECT_REFERENCE_TARGET_TYPE);
	if (targetTypeAnnotationElement != null
			&& !StringUtils.isEmpty(targetTypeAnnotationElement.getTextContent())) {
		// Explicit definition of target type overrides previous logic
		QName targetType = DOMUtil.getQNameValue(targetTypeAnnotationElement);
		definition.setTargetTypeName(targetType);
	}
	setMultiplicity(definition, elementParticle, annotation, false);
	Boolean composite = SchemaProcessorUtil.getAnnotationBooleanMarker(annotation, A_COMPOSITE);
	if (composite != null) {
		definition.setComposite(composite);
	}

	parseItemDefinitionAnnotations(definition, annotation);
	// extractDocumentation(definition, annotation);
	return definition;
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:60,代码来源:DomToSchemaProcessor.java


注:本文中的com.evolveum.midpoint.util.DOMUtil.getQNameValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。