本文整理汇总了Java中com.evolveum.midpoint.util.DOMUtil.getQName方法的典型用法代码示例。如果您正苦于以下问题:Java DOMUtil.getQName方法的具体用法?Java DOMUtil.getQName怎么用?Java DOMUtil.getQName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.evolveum.midpoint.util.DOMUtil
的用法示例。
在下文中一共展示了DOMUtil.getQName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例2: addContent
import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
private boolean addContent(Object newObject) {
if (newObject instanceof String){
String s = (String) newObject;
if (StringUtils.isNotBlank(s)) {
clearValue = (T) s;
}
return true;
} else
if (newObject instanceof JAXBElement<?>) {
JAXBElement<?> jaxbElement = (JAXBElement<?>)newObject;
if (QNameUtil.match(F_ENCRYPTED_DATA, jaxbElement.getName())) {
encryptedDataType = (EncryptedDataType) jaxbElement.getValue();
return true;
} else if (QNameUtil.match(F_HASHED_DATA, jaxbElement.getName())) {
hashedDataType = (HashedDataType) jaxbElement.getValue();
return true;
} else {
throw new IllegalArgumentException("Attempt to add unknown JAXB element "+jaxbElement);
}
} else if (newObject instanceof Element) {
Element element = (Element)newObject;
QName elementName = DOMUtil.getQName(element);
if (QNameUtil.match(F_XML_ENC_ENCRYPTED_DATA, elementName)) {
encryptedDataType = convertXmlEncToEncryptedDate(element);
return true;
} else if (QNameUtil.match(F_CLEAR_VALUE, elementName)){
clearValue = (T) element.getTextContent();
return true;
} else {
throw new IllegalArgumentException("Attempt to add unknown DOM element "+elementName);
}
} else {
throw new IllegalArgumentException("Attempt to add unknown object "+newObject+" ("+newObject.getClass()+")");
}
}
示例3: toTypedJavaValueWithDefaultType
import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
/**
* Try to locate element type from xsi:type, fall back to specified default
* type.
*
* @param element
* @param defaultType
* @return converted java value
* @throws JAXBException
* @throws SchemaException if no xsi:type or default type specified
*/
public static TypedValue toTypedJavaValueWithDefaultType(Element xmlElement, QName defaultType) throws SchemaException {
QName xsiType = DOMUtil.resolveXsiType(xmlElement);
if (xsiType == null) {
xsiType = defaultType;
if (xsiType == null) {
QName elementQName = JAXBUtil.getElementQName(xmlElement);
throw new SchemaException("Cannot convert element " + elementQName + " to java, no type information available", elementQName);
}
}
return new TypedValue(toJavaValue(xmlElement, xsiType), xsiType, DOMUtil.getQName(xmlElement));
}
示例4: read
import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
@NotNull
public RootXNode read(Element rootElement) throws SchemaException {
RootXNode xroot = new RootXNode(DOMUtil.getQName(rootElement));
extractCommonMetadata(rootElement, xroot);
XNode xnode = parseElementContent(rootElement, false);
xroot.setSubnode(xnode);
return xroot;
}
示例5: parseMultiplicity
import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
private int parseMultiplicity(String maxOccursString, Element element) throws SchemaException {
if (PrismConstants.MULTIPLICITY_UNBONUNDED.equals(maxOccursString)) {
return -1;
}
if (maxOccursString.startsWith("-")) {
return -1;
}
if (StringUtils.isNumeric(maxOccursString)) {
return Integer.valueOf(maxOccursString);
} else {
throw new SchemaException("Expected numeric value for " + PrismConstants.A_MAX_OCCURS.getLocalPart()
+ " attribute on " + DOMUtil.getQName(element) + " but got " + maxOccursString);
}
}
示例6: parseElementContentToMap
import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
private MapXNode parseElementContentToMap(Element element) throws SchemaException {
MapXNode xmap = new MapXNode();
// Attributes
for (Attr attr: DOMUtil.listApplicationAttributes(element)) {
QName attrQName = DOMUtil.getQName(attr);
XNode subnode = parseAttributeValue(attr);
xmap.put(attrQName, subnode);
}
// Sub-elements
QName lastElementQName = null;
List<Element> lastElements = null;
for (Element childElement: DOMUtil.listChildElements(element)) {
QName childQName = DOMUtil.getQName(childElement);
if (match(childQName, lastElementQName)) {
lastElements.add(childElement);
} else {
parseSubElementsGroupAsMapEntry(xmap, lastElementQName, lastElements);
lastElementQName = childQName;
lastElements = new ArrayList<>();
lastElements.add(childElement);
}
}
parseSubElementsGroupAsMapEntry(xmap, lastElementQName, lastElements);
return xmap;
}
示例7: parseWsdlResource
import com.evolveum.midpoint.util.DOMUtil; //导入方法依赖的package包/类
public static List<SchemaDescription> parseWsdlResource(final String resourcePath) throws SchemaException {
List<SchemaDescription> schemaDescriptions = new ArrayList<>();
InputStream inputStream = SchemaRegistry.class.getClassLoader().getResourceAsStream(resourcePath);
if (inputStream == null) {
throw new IllegalStateException("Cannot fetch system resource for schema " + resourcePath);
}
Node node;
try {
node = DOMUtil.parse(inputStream);
} catch (IOException e) {
throw new SchemaException("Cannot parse schema from system resource " + resourcePath, e);
}
Element rootElement = node instanceof Element ? (Element)node : DOMUtil.getFirstChildElement(node);
QName rootElementQName = DOMUtil.getQName(rootElement);
if (WSDLConstants.QNAME_DEFINITIONS.equals(rootElementQName)) {
Element types = DOMUtil.getChildElement(rootElement, WSDLConstants.QNAME_TYPES);
if (types == null) {
LOGGER.warn("No <types> section in WSDL document in system resource " + resourcePath);
return schemaDescriptions;
}
List<Element> schemaElements = DOMUtil.getChildElements(types, DOMUtil.XSD_SCHEMA_ELEMENT);
if (schemaElements.isEmpty()) {
LOGGER.warn("No schemas in <types> section in WSDL document in system resource " + resourcePath);
return schemaDescriptions;
}
int number = 1;
for (Element schemaElement : schemaElements) {
SchemaDescription desc = new SchemaDescription("schema #" + (number++) + " in system resource " + resourcePath);
desc.node = schemaElement;
desc.fetchBasicInfoFromSchema();
schemaDescriptions.add(desc);
LOGGER.trace("Schema registered from {}", desc.getSourceDescription());
}
return schemaDescriptions;
} else {
throw new SchemaException("WSDL system resource "+resourcePath+" does not start with wsdl:definitions element");
}
}