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


Java IDataCursor.next方法代码示例

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


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

示例1: getKeys

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
public Collection<String> getKeys() {

		// Using LinkedHashSet to preserve insertion order
		Set<String> keys = new LinkedHashSet<String>();
		
		IDataCursorResource cursorRes = newCursorResource();
		try {
			IDataCursor cursor = cursorRes.getCursor();
			boolean hasMore = cursor.first();
			while (hasMore) {
				keys.add(cursor.getKey());

				hasMore = cursor.next();
			}
			return Collections.unmodifiableSet(keys);
		}
		finally {
			cursorRes.close();
		}
	}
 
开发者ID:innodev-au,项目名称:wmboost-data,代码行数:21,代码来源:DocumentImpl.java

示例2: testPut

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
@Test
public void testPut() {
	List<String> list = Lists.newArrayList("Hello", "World");
	
	Document doc = docFactory.create();
	doc.stringsSplitEntry("words").put(list);
	IData iData = doc.getIData();
	
	IDataCursor cursor = iData.getCursor();
	
	assertEquals(2, IDataUtil.size(cursor));
	cursor.first();
	assertEquals("words", cursor.getKey());
	assertEquals("Hello", cursor.getValue());
	
	cursor.next();
	assertEquals("words", cursor.getKey());
	assertEquals("World", cursor.getValue());
	
}
 
开发者ID:innodev-au,项目名称:wmboost-data,代码行数:21,代码来源:SplitEntryTest.java

示例3: matches

import com.wm.data.IDataCursor; //导入方法依赖的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

示例4: checkWhetherFieldExists

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
private void checkWhetherFieldExists(final IData iData, final String fieldName)
		throws IDataConversionException
{
	final IDataCursor idc = iData.getCursor();
	while (idc.hasMoreData())
	{
		idc.next();
		if (idc.getKey().equals(fieldName))
		{
			return;
		}
	}
	throw new IDataConversionException(
			String.format("Field <%s> does not exist in IData: %s",
					fieldName, new IDataFormatter().format(iData)));
}
 
开发者ID:StefanMacke,项目名称:ao-idata-converter,代码行数:17,代码来源:IDataConverter.java

示例5: assertKeyExists

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
private void assertKeyExists(final IDataCursor cursor, final int keyCounter, final String expectedKey)
{
	if (cursor.next())
	{
		final String actualKey = cursor.getKey();
		assertThat(String.format("Key at position %d should be <%s>, but was <%s>.",
				keyCounter, expectedKey, actualKey),
				actualKey, is(expectedKey));
		assertTypesEqual(actualKey, expectedKey);
	}
	else
	{
		fail(String.format("Key at position %d should be <%s>, but does not exist.",
				keyCounter, expectedKey));
	}
}
 
开发者ID:StefanMacke,项目名称:ao-idata-converter,代码行数:17,代码来源:ObjectConverterShould.java

示例6: getKeyList

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
 * Returns the keys that match the given regular expression pattern in the given IData document.
 *
 * @param document  An IData document.
 * @param pattern   A regular expression pattern which the returned set of keys must match.
 * @return          The list of keys present in the given IData document that match the given regular expression
 *                  pattern.
 */
public static List<String> getKeyList(IData document, Pattern pattern) {
    List<String> keys = new ArrayList<String>(size(document));

    if (document != null) {
        IDataCursor cursor = document.getCursor();

        while(cursor.next()) {
            String key = cursor.getKey();
            if (pattern == null) {
                keys.add(key);
            } else {
                Matcher matcher = pattern.matcher(key);
                if (matcher.matches()) keys.add(key);
            }
        }

        cursor.destroy();
    }

    return keys;
}
 
开发者ID:Permafrost,项目名称:Tundra.java,代码行数:30,代码来源:IDataHelper.java

示例7: of

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
 * Creates a ConcurrentMapIData which is a recursive clone of the given IData.
 *
 * @param document  The IData to clone.
 * @param sorted    Whether to sort by keys.
 * @return          A ConcurrentMapIData clone of the given document.
 */
public static ConcurrentMapIData<String, Object> of(IData document, boolean sorted) {
    if (document == null) return null;

    ConcurrentMapIData<String, Object> map = new ConcurrentMapIData<String, Object>(sorted);

    IDataCursor cursor = document.getCursor();
    try {
        while(cursor.next()) {
            String key = cursor.getKey();
            Object value = cursor.getValue();

            if (value instanceof IData[] || value instanceof Table || value instanceof IDataCodable[] || value instanceof IDataPortable[] || value instanceof ValuesCodable[]) {
                value = of(IDataHelper.toIDataArray(value), sorted);
            } else if (value instanceof IData || value instanceof IDataCodable || value instanceof IDataPortable || value instanceof ValuesCodable) {
                value = of(IDataHelper.toIData(value), sorted);
            }

            map.put(key, value);
        }
    } finally {
        cursor.destroy();
    }

    return map;
}
 
开发者ID:Permafrost,项目名称:Tundra.java,代码行数:33,代码来源:ConcurrentMapIData.java

示例8: remove

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
 * Removes the given key and its associated value from the given cursor.
 *
 * @param cursor    The cursor to remove the key from.
 * @param key       The key to be removed.
 * @param klass     The class the associated value is required to be an instance of.
 * @param required  Throws an exception if true and a value with the required class is not associated with the
 *                  given key.
 * @param <T>       The class the associated value is required to be an instance of.
 * @return          The value that was associated with the key.
 */
@SuppressWarnings("unchecked")
public static <T> T remove(IDataCursor cursor, String key, Class<T> klass, boolean required) {
    if (cursor == null || key == null) return null;

    T value = null;

    if (cursor.first(key)) {
        do {
            value = ObjectHelper.convert(cursor.getValue(), klass);
        } while(value == null && cursor.next(key));
        cursor.delete();
    }

    if (value == null && required) {
        throw new RuntimeException(new NoSuchFieldException(MessageFormat.format("Key \"{0}\" either does not exist or is not associated with a value compatible with the required class {1}", key, klass == null ? "null" : klass.getName())));
    }

    return value;
}
 
开发者ID:Permafrost,项目名称:Tundra.java,代码行数:31,代码来源:IDataHelper.java

示例9: get

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
 *
 * @param document  The IData document to return the value from.
 * @param key       The key whose associated value is to be returned.
 * @param n         Determines which occurrence of the key to return the value for.
 * @param klass     The class of the value to be returned.
 * @param <T>       The type of value to be returned.
 * @return          The value associated with the nth occurrence of the given key in the given IData document.
 */
@SuppressWarnings("unchecked")
private static <T> T get(IData document, String key, int n, Class<T> klass) {
    if (klass == null) throw new NullPointerException("class must not be null");
    if (document == null || key == null || n < 0) return null;

    Object value = null;
    int i = 0;

    IDataCursor cursor = document.getCursor();
    while (cursor.next(key) && i++ < n) ;
    if (i > n) value = cursor.getValue();
    cursor.destroy();

    return klass.isInstance(value) ? (T)value : null;
}
 
开发者ID:Permafrost,项目名称:Tundra.java,代码行数:25,代码来源:IDataHelper.java

示例10: emit

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
 * Emits a query string given an IData containing name value pairs.
 *
 * @param input   An IData containing keys and values to serialized as a query string.
 * @param charset The character set to use when URI encoding the parameters.
 * @param encode  True if the query string parameters should be URI encoded.
 * @return A query string containing the parameters in the given IData.
 */
public static String emit(IData input, Charset charset, boolean encode) {
    if (input == null) return null;

    StringBuilder output = new StringBuilder();

    input = IDataHelper.denormalize(input);

    IDataCursor cursor = input.getCursor();
    while (cursor.next()) {
        String key = cursor.getKey();
        Object value = cursor.getValue();

        if (value != null) {
            if (output.length() > 0) output.append(QUERY_STRING_KEY_VALUE_PAIR_TOKEN_SEPARATOR);
            if (value instanceof Object[]) {
                output.append(emit(key, (Object[])value, charset, encode));
            } else {
                output.append(emit(key, value, charset, encode));
            }
        }
    }

    return output.toString();
}
 
开发者ID:Permafrost,项目名称:Tundra.java,代码行数:33,代码来源:URIQueryHelper.java

示例11: mapify

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
 * Converts the given IData document to a Map.
 *
 * @param document              The IData document to be converted.
 * @param sorted                Whether the Map should maintain keys sorted in natural ascending order.
 * @param klass                 The class of Map values.
 * @param <V>                   The class of Map values.
 * @return                      A newly created Map which contains the top-level key value elements from the
 *                              given document.
 */
@SuppressWarnings("unchecked")
public static <V> ConcurrentMap<String, V> mapify(IData document, boolean sorted, Class<V> klass) {
    ConcurrentMap<String, V> map = create(sorted);

    if (document != null) {
        IDataCursor cursor = document.getCursor();
        try {
            while (cursor.next()) {
                String key = cursor.getKey();
                V value = (V)cursor.getValue();
                // ignore null values, as they are not supported by either ConcurrentHashMap or ConcurrentSkipListMap
                if (value != null) map.put(key, value);
            }
        } finally {
            cursor.destroy();
        }
    }

    return map;
}
 
开发者ID:Permafrost,项目名称:Tundra.java,代码行数:31,代码来源:ConcurrentMapHelper.java

示例12: flip

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
 * Flips the given IData document so the keys become the values and the values become the keys.
 *
 * @param document  The IData document to be flipped.
 * @return          The flipped IData document.
 */
public static IData flip(IData document) {
    if (document == null) return null;

    IData output = IDataFactory.create();
    IDataCursor inputCursor = document.getCursor();
    IDataCursor outputCursor = output.getCursor();

    while(inputCursor.next()) {
        String key = inputCursor.getKey();
        Object value = inputCursor.getValue();

        if (value instanceof String) {
            outputCursor.insertAfter((String)value, key);
        }
    }

    inputCursor.destroy();
    outputCursor.destroy();

    return output;
}
 
开发者ID:Permafrost,项目名称:Tundra.java,代码行数:28,代码来源:IDataHelper.java

示例13: testRemove

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
@Test
public void testRemove() {
	IData iData = IDataFactory.create();
	{
	IDataCursor cursor = iData.getCursor();
	cursor.insertAfter("first", "A");
	cursor.insertAfter("words", "Word to replace");
	cursor.insertAfter("middle", "M");
	cursor.insertAfter("words", "Another word to replace");
	cursor.insertAfter("last", "Z");
	}
	Document doc = docFactory.wrap(iData);
	doc.stringsSplitEntry("words").remove();
	
	IDataCursor cursor2 = doc.getIData().getCursor();
	
	assertEquals(3, IDataUtil.size(cursor2));
	cursor2.first();
	assertEquals("first", cursor2.getKey());
	assertEquals("A", cursor2.getValue());
	
	cursor2.next();
	assertEquals("middle", cursor2.getKey());
	assertEquals("M", cursor2.getValue());
	
	cursor2.next();
	assertEquals("last", cursor2.getKey());
	assertEquals("Z", cursor2.getValue());
	
}
 
开发者ID:innodev-au,项目名称:wmboost-data,代码行数:31,代码来源:SplitEntryTest.java

示例14: shouldReturnRandom

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
@Test
public void shouldReturnRandom() {
	CannedResponseInterceptor cri = new CannedResponseInterceptor(ResponseSequence.RANDOM, getIData(new String[][]{{"akey", "avalue"}}), getIData(new String[][]{{"bkey", "bvalue"}}), getIData(new String[][]{{"ckey", "cvalue"}}));
	
	Set<String> keys = new HashSet<String>();
	for (int i = 0; i < 20; i++) {
		IDataCursor cursor = cri.getResponse().getCursor();
		cursor.next();
		keys.add(cursor.getKey());
	}
	assertTrue(keys.contains("akey"));
	assertTrue(keys.contains("bkey"));
	assertTrue(keys.contains("ckey"));
}
 
开发者ID:wmaop,项目名称:wm-aop,代码行数:15,代码来源:CannedResponseInterceptorTest.java

示例15: clearPipeline

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
private void clearPipeline(final IData pipeline)
{
	final IDataCursor cursor = pipeline.getCursor();
	while (cursor.next())
	{
		IDataUtil.remove(cursor, cursor.getKey());
	}
}
 
开发者ID:StefanMacke,项目名称:ao-integrationserver,代码行数:9,代码来源:JavaService.java


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