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


Java DOMUtil类代码示例

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


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

示例1: testXPathSerializationToDom

import com.evolveum.midpoint.util.DOMUtil; //导入依赖的package包/类
@Test
public void testXPathSerializationToDom() {
    // GIVEN
    QName qname1 = new QName(NS_C, "extension");
    QName qname2 = new QName(NS_FOO, "foo");
    ItemPathHolder itemPathHolder1 = new ItemPathHolder(qname1, qname2);
    QName elementQName = new QName(NS_BAR, "bar");

    // WHEN
    Element element = itemPathHolder1.toElement(elementQName, DOMUtil.getDocument());
    ItemPathHolder itemPathHolder2 = new ItemPathHolder(element);

    // THEN
    System.out.println("XPath from QNames:");
    System.out.println(DOMUtil.serializeDOMToString(element));

    ItemPath xpath1 = itemPathHolder1.toItemPath();
    ItemPath xpath2 = itemPathHolder2.toItemPath();
    assertTrue("Paths are not equivalent", xpath1.equivalent(xpath2));
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:21,代码来源:XPathTest.java

示例2: testPropertyDeltaMerge10

import com.evolveum.midpoint.util.DOMUtil; //导入依赖的package包/类
@Test
   public void testPropertyDeltaMerge10() throws Exception {
	System.out.println("\n\n===[ testPropertyDeltaMerge10 ]===\n");
	
	// GIVEN
	PrismPropertyDefinition propertyDefinition = new PrismPropertyDefinitionImpl(UserType.F_DESCRIPTION, 
			DOMUtil.XSD_STRING, PrismTestUtil.getPrismContext());

	PropertyDelta<String> delta1 = new PropertyDelta<String>(propertyDefinition, PrismTestUtil.getPrismContext());
	delta1.setValuesToReplace(new PrismPropertyValue<String>("r1x"), new PrismPropertyValue<String>("r1y"));

	PropertyDelta<String> delta2 = new PropertyDelta<String>(propertyDefinition, PrismTestUtil.getPrismContext());
	delta2.addValueToAdd(new PrismPropertyValue<String>("add2"));
	
	// WHEN
	delta1.merge(delta2);
	
	// THEN
	System.out.println("Merged delta:");
	System.out.println(delta1.debugDump());

	PrismAsserts.assertReplace(delta1, "r1x", "r1y", "add2");
	PrismAsserts.assertNoAdd(delta1);
	PrismAsserts.assertNoDelete(delta1);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:26,代码来源:TestDelta.java

示例3: determineNumberType

import com.evolveum.midpoint.util.DOMUtil; //导入依赖的package包/类
QName determineNumberType(JsonParser.NumberType numberType) throws SchemaException {
	switch (numberType) {
		case BIG_DECIMAL:
			return DOMUtil.XSD_DECIMAL;
		case BIG_INTEGER:
			return DOMUtil.XSD_INTEGER;
		case LONG:
			return DOMUtil.XSD_LONG;
		case INT:
			return DOMUtil.XSD_INT;
		case FLOAT:
			return DOMUtil.XSD_FLOAT;
		case DOUBLE:
			return DOMUtil.XSD_DOUBLE;
		default:
			throw new SchemaException("Unsupported number type: " + numberType);
	}
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:19,代码来源:AbstractJsonLexicalProcessor.java

示例4: assertExchangeSchema

import com.evolveum.midpoint.util.DOMUtil; //导入依赖的package包/类
public static void assertExchangeSchema(ResourceSchema resourceSchema, PrismObject<ResourceType> resource, QName accountObjectClassQName, PrismContext prismContext) throws SchemaException {
	ObjectClassComplexTypeDefinition msExchBaseClassObjectClassDefinition = resourceSchema.findObjectClassDefinition(OBJECT_CLASS_MS_EXCH_BASE_CLASS_QNAME);
       assertNotNull("No definition for object class "+OBJECT_CLASS_MS_EXCH_BASE_CLASS_QNAME, msExchBaseClassObjectClassDefinition);
       display("Object class "+OBJECT_CLASS_MS_EXCH_BASE_CLASS_QNAME+" def", msExchBaseClassObjectClassDefinition);
       
       ResourceAttributeDefinition<String> msExchHideFromAddressListsDef = msExchBaseClassObjectClassDefinition.findAttributeDefinition(ATTRIBUTE_MS_EXCH_HIDE_FROM_ADDRESS_LISTS_NAME);
       PrismAsserts.assertDefinition(msExchHideFromAddressListsDef, new QName(MidPointConstants.NS_RI, ATTRIBUTE_MS_EXCH_HIDE_FROM_ADDRESS_LISTS_NAME), DOMUtil.XSD_BOOLEAN, 0, 1);
       assertTrue("msExchHideFromAddressLists read", msExchHideFromAddressListsDef.canRead());
       assertTrue("msExchHideFromAddressLists modify", msExchHideFromAddressListsDef.canModify());
       assertTrue("msExchHideFromAddressLists add", msExchHideFromAddressListsDef.canAdd());
       
       ObjectClassComplexTypeDefinition accountObjectClassDef = resourceSchema.findObjectClassDefinition(accountObjectClassQName);
       assertNotNull("No definition for object class "+accountObjectClassQName, accountObjectClassDef);
       display("Object class "+accountObjectClassQName+" def", accountObjectClassDef);
       
       ResourceAttributeDefinition<String> accountMsExchHideFromAddressListsDef = accountObjectClassDef.findAttributeDefinition(ATTRIBUTE_MS_EXCH_HIDE_FROM_ADDRESS_LISTS_NAME);
       PrismAsserts.assertDefinition(accountMsExchHideFromAddressListsDef, new QName(MidPointConstants.NS_RI, ATTRIBUTE_MS_EXCH_HIDE_FROM_ADDRESS_LISTS_NAME), DOMUtil.XSD_BOOLEAN, 0, 1);
       assertTrue("msExchHideFromAddressLists read", accountMsExchHideFromAddressListsDef.canRead());
       assertTrue("msExchHideFromAddressLists modify", accountMsExchHideFromAddressListsDef.canModify());
       assertTrue("msExchHideFromAddressLists add", accountMsExchHideFromAddressListsDef.canAdd());
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:22,代码来源:AdUtils.java

示例5: 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

示例6: testValueElementsRoundtripInt

import com.evolveum.midpoint.util.DOMUtil; //导入依赖的package包/类
@Test
public void testValueElementsRoundtripInt() throws Exception {
	final String TEST_NAME = "testValueElementsRoundtripInt";
	TestUtil.displayTestTile(TEST_NAME);
	
	// GIVEN
	PrismContext prismContext = PrismTestUtil.getPrismContext();
	PrismPropertyDefinitionImpl propDef = new PrismPropertyDefinitionImpl(PROP_NAME, DOMUtil.XSD_INT, prismContext);
	propDef.setMaxOccurs(-1);
	PrismProperty<Integer> origProperty = propDef.instantiate();
	origProperty.addRealValue(42);
	origProperty.addRealValue(123);
	origProperty.addRealValue(321);

	doRoundtrip(origProperty, propDef, prismContext);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:17,代码来源:TestStaticValues.java

示例7: evaluateExpression

import com.evolveum.midpoint.util.DOMUtil; //导入依赖的package包/类
private List<String> evaluateExpression(ExpressionType expressionType, ExpressionVariables expressionVariables, 
		String shortDesc, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException {

    QName resultName = new QName(SchemaConstants.NS_C, "result");
    PrismPropertyDefinition<String> resultDef = new PrismPropertyDefinitionImpl<>(resultName, DOMUtil.XSD_STRING, prismContext);

    Expression<PrismPropertyValue<String>,PrismPropertyDefinition<String>> expression = expressionFactory.makeExpression(expressionType, resultDef, shortDesc, task, result);
    ExpressionEvaluationContext params = new ExpressionEvaluationContext(null, expressionVariables, shortDesc, task, result);
    PrismValueDeltaSetTriple<PrismPropertyValue<String>> exprResult = ModelExpressionThreadLocalHolder
.evaluateExpressionInContext(expression, params, task, result);

    List<String> retval = new ArrayList<>();
    for (PrismPropertyValue<String> item : exprResult.getZeroSet()) {
        retval.add(item.getValue());
    }
    return retval;
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:18,代码来源:BaseHandler.java

示例8: toXsdElement

import com.evolveum.midpoint.util.DOMUtil; //导入依赖的package包/类
/**
     * @param val
     * @param elementName
     * @param doc
     * @param recordType
     * @return created element
     * @throws SchemaException
     */
    public static Element toXsdElement(Object val, QName elementName, Document doc, boolean recordType) throws SchemaException {
        if (val == null) {
            // if no value is specified, do not create element
            return null;
        }
        Class type = XsdTypeMapper.getTypeFromClass(val.getClass());
        if (type == null) {
            throw new IllegalArgumentException("No type mapping for conversion: " + val.getClass() + "(element " + elementName + ")");
        }
        if (doc == null) {
            doc = DOMUtil.getDocument();
        }
        Element element = doc.createElementNS(elementName.getNamespaceURI(), elementName.getLocalPart());
        //TODO: switch to global namespace prefixes map
//            element.setPrefix(MidPointNamespacePrefixMapper.getPreferredPrefix(elementName.getNamespaceURI()));
        toXsdElement(val, element, recordType);
        return element;
    }
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:27,代码来源:XmlTypeConverter.java

示例9: testExtensionString

import com.evolveum.midpoint.util.DOMUtil; //导入依赖的package包/类
@Test
public void testExtensionString() throws Exception {
    Session session = getFactory().openSession();

    QName valueName = new QName(NS_P, "floatType");
    ItemDefinition def = getDefinition(GenericObjectType.class, new ItemPath(ObjectType.F_EXTENSION, valueName));
    AssertJUnit.assertNotNull(def);

    Element value = DOMUtil.createElement(DOMUtil.getDocument(), valueName);
    value.setTextContent("example");

    Object realValue = RAnyConverter.getRealRepoValue(def, value);
    AssertJUnit.assertEquals("example", realValue);

    session.close();
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:17,代码来源:RAnyConverterStaticTest.java

示例10: testExtensionDecimal

import com.evolveum.midpoint.util.DOMUtil; //导入依赖的package包/类
@Test
public void testExtensionDecimal() throws Exception {
    Session session = getFactory().openSession();

    QName valueName = new QName(NS_P, "decimalType");
    ItemDefinition def = getDefinition(GenericObjectType.class, new ItemPath(ObjectType.F_EXTENSION, valueName));
    AssertJUnit.assertNotNull(def);

    Element value = DOMUtil.createElement(DOMUtil.getDocument(), valueName);
    value.setTextContent("1234");

    Object realValue = RAnyConverter.getRealRepoValue(def, value);
    AssertJUnit.assertEquals("1234", realValue);

    session.close();
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:17,代码来源:RAnyConverterStaticTest.java

示例11: tryConvertPrimitiveScalar

import com.evolveum.midpoint.util.DOMUtil; //导入依赖的package包/类
private static <T> T tryConvertPrimitiveScalar(NodeList valueNodes, Class<T> type) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < valueNodes.getLength(); i++) {
        Node node = valueNodes.item(i);
        if (DOMUtil.isJunk(node)) {
            continue;
        }
        if (node.getNodeType() == Node.TEXT_NODE) {
            sb.append(node.getTextContent());
        } else {
            // We have failed
            return null;
        }
    }
    if (type.equals(Object.class)) {
        // Try string as default type
        return (T) XmlTypeConverter.toJavaValue(sb.toString(), String.class);
    }
    return XmlTypeConverter.toJavaValue(sb.toString(), type);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:21,代码来源:XmlTypeConverter.java

示例12: testParseTaskDom

import com.evolveum.midpoint.util.DOMUtil; //导入依赖的package包/类
@Test
public void testParseTaskDom() throws SchemaException {
	System.out.println("===[ testParseTaskDom ]===");

	// GIVEN
	PrismContext prismContext = getPrismContext();
	
	Document document = DOMUtil.parseFile(TASK_FILE);
	Element taskElement = DOMUtil.getFirstChildElement(document);
	
	// WHEN
	PrismObject<TaskType> task = prismContext.parserFor(taskElement).parse();
	
	// THEN
	System.out.println("Parsed task:");
	System.out.println(task.debugDump());
	
	assertTask(task);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:20,代码来源:TestParseTask.java

示例13: testPropertyDeltaMerge20

import com.evolveum.midpoint.util.DOMUtil; //导入依赖的package包/类
@Test
   public void testPropertyDeltaMerge20() throws Exception {
	System.out.println("\n\n===[ testPropertyDeltaMerge20 ]===\n");
	
	// GIVEN
	PrismPropertyDefinition propertyDefinition = new PrismPropertyDefinitionImpl(UserType.F_DESCRIPTION, 
			DOMUtil.XSD_STRING, PrismTestUtil.getPrismContext());

	PropertyDelta<String> delta1 = new PropertyDelta<String>(propertyDefinition, PrismTestUtil.getPrismContext());
	delta1.addValueToAdd(new PrismPropertyValue<String>("add1"));
	delta1.addValueToDelete(new PrismPropertyValue<String>("del1"));

	PropertyDelta<String> delta2 = new PropertyDelta<String>(propertyDefinition, PrismTestUtil.getPrismContext());
	delta2.setValuesToReplace(new PrismPropertyValue<String>("r2x"), new PrismPropertyValue<String>("r2y"));
	
	// WHEN
	delta1.merge(delta2);
	
	// THEN
	System.out.println("Merged delta:");
	System.out.println(delta1.debugDump());

	PrismAsserts.assertReplace(delta1, "r2x", "r2y");
	PrismAsserts.assertNoAdd(delta1);
	PrismAsserts.assertNoDelete(delta1);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:27,代码来源:TestDelta.java

示例14: testPrismParseDomAdhoc

import com.evolveum.midpoint.util.DOMUtil; //导入依赖的package包/类
@Test
public void testPrismParseDomAdhoc() throws Exception {
	final String TEST_NAME = "testPrismParseDomAdhoc";
	PrismInternalTestUtil.displayTestTitle(TEST_NAME);
	
	// GIVEN
	Document document = DOMUtil.parseFile(getFile(USER_JACK_ADHOC_BASENAME));
	Element userElement = DOMUtil.getFirstChildElement(document);
	
	PrismContext prismContext = constructInitializedPrismContext();
	
	// WHEN
	PrismObject<UserType> user = prismContext.parserFor(userElement).parse();
	
	// THEN
	System.out.println("User:");
	System.out.println(user.debugDump());
	assertNotNull(user);
	
	assertUserAdhoc(user, true);
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:22,代码来源:TestPrismParsingXml.java

示例15: testAccessList

import com.evolveum.midpoint.util.DOMUtil; //导入依赖的package包/类
@Test
public void testAccessList() throws Exception {
	String filename = "src/test/resources/processor/resource-schema-complex.xsd";
	Document schemaDom = DOMUtil.parseFile(filename);
	ResourceSchema schema = ResourceSchemaImpl.parse(DOMUtil.getFirstChildElement(schemaDom), filename, PrismTestUtil.getPrismContext());
	
	final String defaultNS = "http://midpoint.evolveum.com/xml/ns/public/resource/instances/ef2bc95b-76e0-48e2-86d6-3d4f02d3e1a2";
	final String icfNS = "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3";
	ObjectClassComplexTypeDefinition objectDef = schema.findObjectClassDefinition(new QName(defaultNS, "AccountObjectClass"));
	assertNotNull("AccountObjectClass definition not found", objectDef);
	
	ResourceAttributeDefinition attrDef = objectDef.findAttributeDefinition(new QName(icfNS, "uid"));
	AssertJUnit.assertTrue("uid readability", attrDef.canRead());
	AssertJUnit.assertFalse("uid updateability", attrDef.canModify());
	AssertJUnit.assertFalse("uid createability", attrDef.canAdd());
	
	attrDef = objectDef.findAttributeDefinition(new QName(defaultNS, "title"));
	AssertJUnit.assertTrue(attrDef.canRead());
	AssertJUnit.assertTrue(attrDef.canModify());
	AssertJUnit.assertTrue(attrDef.canAdd());
	
	attrDef = objectDef.findAttributeDefinition(new QName(defaultNS, "photo"));
	AssertJUnit.assertFalse(attrDef.canRead());
	AssertJUnit.assertTrue(attrDef.canModify());
	AssertJUnit.assertTrue(attrDef.canAdd());
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:27,代码来源:SchemaProcessorTest.java


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