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


Java IDataUtil.get方法代码示例

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


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

示例1: testNestedDoc

import com.wm.data.IDataUtil; //导入方法依赖的package包/类
@Test
public void testNestedDoc() {

	// setup
	Document nested = docFactory.create();
	nested.stringEntry("a1").put("val-a1");
	nested.stringEntry("a2").put("val-a2");

	Document top = docFactory.create();
	top.docEntry("nested").put(nested);

	// verify
	IData topIDataObj = top.getIData();
	IData topIData = (IData) topIDataObj;

	Object nestedObj = IDataUtil.get(topIData.getCursor(), "nested");
	assertTrue("Actual type was" + nestedObj.getClass(), nestedObj instanceof IData);

	IData nestedIData = (IData) nestedObj;

	assertEquals("val-a1", IDataUtil.get(nestedIData.getCursor(), "a1"));
	assertEquals("val-a2", IDataUtil.get(nestedIData.getCursor(), "a2"));
}
 
开发者ID:innodev-au,项目名称:wmboost-data,代码行数:24,代码来源:DocumentTest.java

示例2: matches

import com.wm.data.IDataUtil; //导入方法依赖的package包/类
boolean matches(IData document, IData potential, String prefix, boolean reportFail) {
	IDataCursor pc = potential.getCursor();
	IDataCursor dc = document.getCursor();
	while (pc.next()) {
		String key = pc.getKey();
		Object docObj = IDataUtil.get(dc, key);
		Object potObj = pc.getValue();
		if (docObj instanceof IData && potObj instanceof IData) {
			if (!isIDataMatch(prefix, reportFail, key, docObj, potObj)) {
				return false;
			}
		} else if (docObj instanceof IData[]) {
			if (!isIDataArrayMatch(prefix, key, docObj, potObj)) {
				return false;
			}
		} else {
			if (!isObjectMatch(prefix, reportFail, key, docObj, potObj)) {
				return false;
			}
		}
	}
	return true;
}
 
开发者ID:wmaop,项目名称:wm-jbehave,代码行数:24,代码来源:DocumentMatchStep.java

示例3: encodeToString

import com.wm.data.IDataUtil; //导入方法依赖的package包/类
/**
 * Returns a YAML representation of the given IData object.
 *
 * @param input The IData to convert to YAML.
 * @return      The YAML representation of the IData.
 */
@Override
public String encodeToString(IData input) throws IOException {
    DumperOptions options = new DumperOptions();
    options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);

    Yaml parser = new Yaml(new Representer(), options);

    IDataCursor cursor = input.getCursor();
    Object value = IDataUtil.get(cursor, "recordWithNoID");
    cursor.destroy();

    Object object;
    if (value instanceof IData[]) {
        object = IDataHelper.toList((IData[])value);
    } else if (value instanceof Object[]) {
        object = Arrays.asList((Object[])value);
    } else if (value != null) {
        object = value;
    } else {
        object = IDataHelper.toMap(input);
    }

    return parser.dump(object);
}
 
开发者ID:Permafrost,项目名称:TundraYAML.java,代码行数:31,代码来源:IDataYAMLParser.java

示例4: internalGetVal

import com.wm.data.IDataUtil; //导入方法依赖的package包/类
protected final A internalGetVal() {
	IDataCursorResource cursorRes = newCursorResource();
	try {
		Object value = IDataUtil.get(cursorRes.getCursor(), getKey());
		return convertAndNormaliseValForGet(value, accessorType);
	}
	finally {
		cursorRes.close();
	}
}
 
开发者ID:innodev-au,项目名称:wmboost-data,代码行数:11,代码来源:BaseUnitEntryImpl.java

示例5: testPutIntegerList

import com.wm.data.IDataUtil; //导入方法依赖的package包/类
@Test
public void testPutIntegerList() {
	Integer[] expected = {3, 1, 4};
	List<Integer> input = Lists.newArrayList(3, 1, 4);
	
	Document document = docFactory.create();
	document.intsEntry("value1").put(input);

	// confirm value has actually been added
	IDataCursor cursor = document.getIData().getCursor();
	Integer[] returnedValue = (Integer[]) IDataUtil.get(cursor, "value1");
	assertArrayEquals(expected, returnedValue);
}
 
开发者ID:innodev-au,项目名称:wmboost-data,代码行数:14,代码来源:DocumentTest.java

示例6: testPutCollectionListFromIntegerList

import com.wm.data.IDataUtil; //导入方法依赖的package包/类
@Test
public void testPutCollectionListFromIntegerList() {
	Object[] expected = {3, 1, 4};
	List<Integer> input = Lists.newArrayList(3, 1, 4);
	
	Document document = docFactory.create();
	
	// This compiles because covariants re OK as input, e.g., store Integer elements in an Object collection entry
	document.collectionEntry("value1").put(input);

	// confirm value has actually been added
	IDataCursor cursor = document.getIData().getCursor();
	Object[] returnedValue = (Object[]) IDataUtil.get(cursor, "value1");
	assertArrayEquals(expected, returnedValue);
}
 
开发者ID:innodev-au,项目名称:wmboost-data,代码行数:16,代码来源:DocumentTest.java

示例7: testPutConvertedIntegers

import com.wm.data.IDataUtil; //导入方法依赖的package包/类
@Test
public void testPutConvertedIntegers() {
	String[] expected = {"3", "1", "4"};
	List<Integer> input = Lists.newArrayList(3, 1, 4);
	
	Document document = docFactory.create();
	document.stringsEntry("value1").putConverted(input);

	// confirm value has actually been added
	IDataCursor cursor = document.getIData().getCursor();
	String[] returnedValue = (String[]) IDataUtil.get(cursor, "value1");
	assertArrayEquals(expected, returnedValue);
}
 
开发者ID:innodev-au,项目名称:wmboost-data,代码行数:14,代码来源:DocumentTest.java

示例8: testPutDocumentToObjectEntry

import com.wm.data.IDataUtil; //导入方法依赖的package包/类
@Test
public void testPutDocumentToObjectEntry() {
	IData idata = newIDataWithValue("field1");
	Document nested = docFactory.wrap(idata);		
	
	Document document = docFactory.create();
	document.entry("nestedDoc").put(nested);
	
	Object storedNestedDoc = IDataUtil.get(document.getIData().getCursor(), "nestedDoc");
	
	assertTrue(storedNestedDoc instanceof IData);
}
 
开发者ID:innodev-au,项目名称:wmboost-data,代码行数:13,代码来源:DocumentTest.java

示例9: testNestedDocs

import com.wm.data.IDataUtil; //导入方法依赖的package包/类
@Test
public void testNestedDocs() {
	Document nestedA = docFactory.create();
	nestedA.stringEntry("a1").put("val-a1");
	nestedA.stringEntry("a2").put("val-a2");

	Document nestedB = docFactory.create();
	nestedB.stringEntry("b1").put("val-b1");
	nestedB.stringEntry("b2").put("val-b2");

	List<Document> documents = Lists.newArrayList(nestedA, nestedB);
	// Document[] docArray = documents.toArray(new Document[0]);

	Document top = docFactory.create();
	top.docsEntry("table").put(documents);

	Object tableIDataObj = IDataUtil.get(top.getIData().getCursor(), "table");

	assertTrue(IData[].class.isInstance(tableIDataObj));

	IData[] iDataArray = (IData[]) tableIDataObj;
	assertEquals(2, iDataArray.length);

	assertEquals("val-a1", IDataUtil.get(iDataArray[0].getCursor(), "a1"));
	assertEquals("val-a2", IDataUtil.get(iDataArray[0].getCursor(), "a2"));

	assertEquals("val-b1", IDataUtil.get(iDataArray[1].getCursor(), "b1"));
	assertEquals("val-b2", IDataUtil.get(iDataArray[1].getCursor(), "b2"));
}
 
开发者ID:innodev-au,项目名称:wmboost-data,代码行数:30,代码来源:DocumentTest.java

示例10: testCreate

import com.wm.data.IDataUtil; //导入方法依赖的package包/类
@Test
public void testCreate() {
	Document document = Documents.create();
	document.entry("value1").put("Hello!");
	
	IDataCursor cursor = document.getIData().getCursor();
	cursor.destroy();
	Object val  = IDataUtil.get(cursor, "value1");
	assertEquals("Hello!", val);
	
	
}
 
开发者ID:innodev-au,项目名称:wmboost-data,代码行数:13,代码来源:DocumentsTest.java

示例11: testPutNew

import com.wm.data.IDataUtil; //导入方法依赖的package包/类
@Test
public void testPutNew() {
	Document document = Documents.create();
	Document nestedDoc = document.docEntry("nested1").putNew();
	nestedDoc.entry("number").put(5);
	
	IData topIData = document.getIData();
	Object nestedIDataObj = IDataUtil.get(topIData.getCursor(), "nested1");
	assertTrue(nestedIDataObj instanceof IData);
	
	IData nestedIData = ((IData)nestedIDataObj);
	assertEquals(5, IDataUtil.get(nestedIData.getCursor(), "number"));
}
 
开发者ID:innodev-au,项目名称:wmboost-data,代码行数:14,代码来源:NestedDocEntryImplTest.java

示例12: registerFixedResponseMock

import com.wm.data.IDataUtil; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void registerFixedResponseMock(IData pipeline) throws ServiceException {
	IDataCursor pipelineCursor = pipeline.getCursor();
	String adviceId = IDataUtil.getString(pipelineCursor, ADVICE_ID);
	String interceptPoint = IDataUtil.getString(pipelineCursor, INTERCEPT_POINT);
	String serviceName = IDataUtil.getString(pipelineCursor, SERVICE_NAME);
	Object idata = IDataUtil.get(pipelineCursor, RESPONSE);
	String pipelineCondition = IDataUtil.getString(pipelineCursor, CONDITION);
	String calledBy = IDataUtil.getString(pipelineCursor, CALLED_BY);
	pipelineCursor.destroy();

	mandatory(pipeline, "{0} must exist when creating a fixed response mock", ADVICE_ID, INTERCEPT_POINT, SERVICE_NAME, RESPONSE);
	
	Interceptor interceptor;
	try {
		if (idata instanceof IData) {
			interceptor = new CannedResponseInterceptor((IData)idata);
		} else if (idata instanceof List){
			interceptor = new CannedResponseInterceptor(ResponseSequence.SEQUENTIAL, (List<String>)idata);
		} else {
			interceptor = new CannedResponseInterceptor(idata.toString());
		}
	} catch (Exception e) { // Catch ICoder exceptions
		throw new ServiceException("Unable to parse response IData for " + adviceId + " - Is the response valid IData XML? - " + e.getMessage());
	}
	registerInterceptor(adviceId, getRemit(pipeline), interceptPoint.toUpperCase(), serviceName, pipelineCondition, interceptor, calledBy);
}
 
开发者ID:wmaop,项目名称:wm-aop,代码行数:28,代码来源:MockManager.java

示例13: mandatory

import com.wm.data.IDataUtil; //导入方法依赖的package包/类
public void mandatory(IData pipeline, String message, String... params) throws ServiceException {
	IDataCursor pipelineCursor = pipeline.getCursor();
	try {
		for (String p : params) {
			Object o = IDataUtil.get(pipelineCursor, p);
			if (o == null || "".equals(o)) {
				MessageFormat mf = new MessageFormat(message);
				throw new ServiceException(mf.format(ArrayUtils.addAll(new Object[]{p}, params)));
			}
		}
	} finally {
		pipelineCursor.destroy();
	}

}
 
开发者ID:wmaop,项目名称:wm-aop,代码行数:16,代码来源:AbstractFlowManager.java

示例14: isObjectMatch

import com.wm.data.IDataUtil; //导入方法依赖的package包/类
private boolean isObjectMatch(String prefix, boolean reportFail, String key, Object docObj, Object potObj) {
	if (docObj == null && potObj == null) {
		return true;
	}
	if (docObj == null || potObj == null) {
		if (reportFail) {
			fail("Failed to locate element in pipeline: " + prefix + '.' + key);
		}
		return false;
	}
	Object docVal;
	if (docObj instanceof IData) {
		IDataCursor cursor = ((IData) docObj).getCursor();
		docVal = IDataUtil.get(cursor, "*body");
		cursor.destroy();
	} else {
		docVal = docObj;
	}
	if (!docVal.equals(potObj)) {
		if (reportFail) {
			fail("Element " + prefix + '.' + key + " has pipeline value of '" + docObj + "' but test value of '"
					+ potObj + "'");
		}
		return false;
	}
	return true;
}
 
开发者ID:wmaop,项目名称:wm-jbehave,代码行数:28,代码来源:DocumentMatchStep.java

示例15: assertIDataContains

import com.wm.data.IDataUtil; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private <T> void assertIDataContains(final IData idata, final String key, final T expectedValue)
{
	final IDataCursor cursor = idata.getCursor();
	final T actualValue = (T) IDataUtil.get(cursor, key);
	assertThat(String.format("Value for key <%s> should be <%s>, but was <%s>.",
			key, expectedValue, actualValue),
			actualValue, is(expectedValue));
	assertTypesEqual(actualValue, expectedValue);
}
 
开发者ID:StefanMacke,项目名称:ao-idata-converter,代码行数:11,代码来源:ObjectConverterShould.java


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