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


Java IDataCursor.getKey方法代码示例

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


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

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

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

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

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

示例5: clone

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
 * Returns a new IData document which is a shallow copy of the given IData document.
 *
 * @param document  An IData document to be cloned.
 * @param excluding Optional set of keys which will be excluded from the clone.
 * @return          A new IData document which is a shallow copy of the given IData document.
 */
public static IData clone(IData document, Set<String> excluding) {
    if (document == null) return null;
    if (excluding == null) excluding = Collections.emptySet();

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

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

        if (!excluding.contains(key)) {
            outputCursor.insertAfter(key, value);
        }
    }

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

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

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

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

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
private void failIfAnyMoreData(final IDataCursor cursor)
{
	if (cursor.hasMoreData())
	{
		cursor.next();
		final String unexpectedKey = cursor.getKey();
		fail(String.format("IData should not contain any more data, but contains key <%s>.", unexpectedKey));
	}
}
 
开发者ID:StefanMacke,项目名称:ao-idata-converter,代码行数:10,代码来源:ObjectConverterShould.java

示例9: substitute

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
 * Performs variable substitution on all elements of the given IData input document.
 *
 * @param document              The IData document to perform variable substitution on.
 * @param defaultValue          The value to substitute if a variable cannot be resolved.
 * @param recurse               Whether embedded IData and IData[] should have variable substitution recursively
 *                              performed on them.
 * @param substitutionTypes     The type of substitutions to be performed.
 * @param scopes                One or more IData documents containing the variables being substituted.
 * @return                      The variable substituted IData.
 * @throws ServiceException     If an error occurs retrieving a global variable.
 */
public static IData substitute(IData document, String defaultValue, boolean recurse, EnumSet<SubstitutionType> substitutionTypes, IData... scopes) throws ServiceException {
    if (document == null) return null;
    if (scopes == null || scopes.length == 0) {
        scopes = new IData[1];
        scopes[0] = document;
    }

    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 != null) {
            if (recurse && (value instanceof IData[] || value instanceof Table || value instanceof IDataCodable[] || value instanceof IDataPortable[] || value instanceof ValuesCodable[])) {
                value = substitute(IDataHelper.toIDataArray(value), defaultValue, recurse, substitutionTypes, scopes);
            } else if (recurse && (value instanceof IData || value instanceof IDataCodable || value instanceof IDataPortable || value instanceof ValuesCodable)) {
                value = substitute(IDataHelper.toIData(value), defaultValue, recurse, substitutionTypes, scopes);
            } else if (value instanceof String) {
                value = substitute((String)value, defaultValue, substitutionTypes, scopes);
            } else if (value instanceof String[]) {
                value = substitute((String[])value, defaultValue, substitutionTypes, scopes);
            } else if (value instanceof String[][]) {
                value = substitute((String[][])value, defaultValue, substitutionTypes, scopes);
            }
        }
        IDataUtil.put(outputCursor, key, value);
    }

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

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

示例10: mergeRecursivelyInto

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
 * Merges multiple IData documents recursively into a single given IData document.
 *
 * @param target    The IData document into which all the other given IData documents will be merged.
 * @param sources   One or more IData documents to be merged.
 * @return          The target IData document after being merged with the source IData documents.
 */
public static IData mergeRecursivelyInto(IData target, Iterable<IData> sources) {
    if (sources != null) {
        for (IData source : sources) {
            if (source != null) {
                IDataCursor sourceCursor = source.getCursor();
                IDataCursor targetCursor = target.getCursor();

                try {
                    while(sourceCursor.next()) {
                        String key = sourceCursor.getKey();
                        Object value = sourceCursor.getValue();
                        Object existingValue = IDataUtil.get(targetCursor, key);

                        if (value != null) {
                            if ((value instanceof IData || value instanceof IDataCodable || value instanceof IDataPortable || value instanceof ValuesCodable) &&
                                (existingValue instanceof IData || existingValue instanceof IDataCodable || existingValue instanceof IDataPortable || existingValue instanceof ValuesCodable)) {
                                IDataUtil.put(targetCursor, key, mergeRecursivelyInto(toIData(existingValue), toIData(value)));
                            } else {
                                IDataUtil.put(targetCursor, key, value);
                            }
                        }
                    }
                } finally {
                    sourceCursor.destroy();
                    targetCursor.destroy();
                }
            }
        }
    }

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

示例11: duplicate

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
 * Returns a new IData document which is a copy of the given IData document.
 *
 * @param document  An IData document to be duplicated.
 * @param recurse   When true, nested IData documents and IData[] document lists will also be duplicated.
 * @return          A new IData document which is a copy of the given IData document.
 */
public static IData duplicate(IData document, boolean recurse) {
    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 (recurse) {
            if (value instanceof IData[] || value instanceof Table || value instanceof IDataCodable[] || value instanceof IDataPortable[] || value instanceof ValuesCodable[]) {
                value = duplicate(toIDataArray(value), recurse);
            } else if (value instanceof IData || value instanceof IDataCodable || value instanceof IDataPortable || value instanceof ValuesCodable) {
                value = duplicate(toIData(value), recurse);
            }
        }

        outputCursor.insertAfter(key, value);
    }

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

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

示例12: compact

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
 * Removes all null values from the given IData document.
 *
 * @param document  The IData document to be compacted.
 * @param recurse   Whether embedded IData and IData[] objects should be recursively compacted.
 * @return          The compacted IData.
 */
public static IData compact(IData document, boolean recurse) {
    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 != null) {
            if (recurse) {
                if (value instanceof IData[] || value instanceof Table || value instanceof IDataCodable[] || value instanceof IDataPortable[] || value instanceof ValuesCodable[]) {
                    value = compact(toIDataArray(value), recurse);
                } else if (value instanceof IData || value instanceof IDataCodable || value instanceof IDataPortable || value instanceof ValuesCodable) {
                    value = compact(toIData(value), recurse);
                } else if (value instanceof Object[][]) {
                    value = TableHelper.compact((Object[][])value);
                } else if (value instanceof Object[]) {
                    value = ArrayHelper.compact((Object[])value);
                }
            }
        }

        if (value != null) IDataUtil.put(outputCursor, key, value);
    }
    inputCursor.destroy();
    outputCursor.destroy();

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

示例13: keysToLowerCase

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
 * Converts all the keys in the given IData document to lower case.
 *
 * @param input     The IData whose keys are to be converted to lower case.
 * @param recurse   Whether child IData and IData[] objects should also have their keys converted to lower case.
 * @return          The given IData duplicated with all keys converted to lower case.
 */
public static IData keysToLowerCase(IData input, boolean recurse) {
    if (input == null) return null;

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

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

        if (recurse) {
            if (value instanceof IData[] || value instanceof Table || value instanceof IDataCodable[] || value instanceof IDataPortable[] || value instanceof ValuesCodable[]) {
                value = keysToLowerCase(toIDataArray(value), recurse);
            } else if (value instanceof IData || value instanceof IDataCodable || value instanceof IDataPortable || value instanceof ValuesCodable) {
                value = keysToLowerCase(toIData(value), recurse);
            }
        }

        outputCursor.insertAfter(key.toLowerCase(), value);
    }
    inputCursor.destroy();
    outputCursor.destroy();

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

示例14: emit

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
 * Returns a MIME type string comprised of the components specified in the given IData document.
 *
 * @param document The IData document to be converted to a MIME type string.
 * @return A MIME type string representing the components specified in the given IData document.
 * @throws MimeTypeParseException If the given MIME type string is malformed.
 */
public static String emit(IData document) throws MimeTypeParseException {
    if (document == null) return null;

    IDataCursor cursor = document.getCursor();
    String type = IDataUtil.getString(cursor, "type");
    String subtype = IDataUtil.getString(cursor, "subtype");
    IData parameters = IDataUtil.getIData(cursor, "parameters");
    cursor.destroy();

    if (type == null) throw new IllegalArgumentException("type must not be null");
    if (subtype == null) throw new IllegalArgumentException("subtype must not be null");

    MimeType mimeType = new MimeType(type, subtype);

    if (parameters != null) {
        parameters = IDataHelper.sort(parameters, false, true);
        cursor = parameters.getCursor();
        while (cursor.next()) {
            String key = cursor.getKey();
            Object value = cursor.getValue();
            if (value instanceof String) {
                mimeType.setParameter(key, (String)value);
            }
        }
        cursor.destroy();
    }

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

示例15: encodeToString

import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
 * Returns an HTML representation of the given IData object.
 *
 * @param input         The IData to convert to HTML.
 * @param buffer        The StringBuilder to append the HTML to.
 * @param maxDepth      The maximum depth children will be encoded to.
 * @param currentDepth  The current depth being encoded.
 */
protected void encodeToString(IData input, StringBuilder buffer, int maxDepth, int currentDepth) {
    input = IDataHelper.normalize(input);
    int size = IDataHelper.size(input);

    if (size == 0) {
        buffer.append(HTMLEntity.EMPTY.toString());
    } else if (currentDepth >= maxDepth) {
        buffer.append(HTMLEntity.HORIZONTAL_ELLIPSIS.toString());
    } else {
        IDataCursor cursor = input.getCursor();
        IData[] array = IDataUtil.getIDataArray(cursor, "recordWithNoID");
        cursor.destroy();

        if (array != null) {
            encodeToString(array, buffer, maxDepth, currentDepth);
        } else {
            // table
            buffer.append("<table class=\"IData\">");

            // thead
            buffer.append("<thead>");
            buffer.append("<tr>");
            buffer.append("<th>Key</th>");
            buffer.append("<th>Value</th>");
            buffer.append("</tr>");
            buffer.append("</thead>");

            // tbody
            buffer.append("<tbody>");

            cursor = input.getCursor();

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

                buffer.append("<tr>");
                buffer.append("<th>");
                buffer.append(HTMLHelper.encode(key));
                buffer.append("</th>");
                buffer.append("<td>");

                if (value == null) {
                    buffer.append(HTMLEntity.NULL.toString());
                } else {
                    if (value instanceof IData[] || value instanceof Table || value instanceof IDataCodable[] || value instanceof IDataPortable[] || value instanceof ValuesCodable[]) {
                        encodeToString(IDataHelper.toIDataArray(value), buffer, maxDepth, currentDepth + 1);
                    } else if (value instanceof IData || value instanceof IDataCodable || value instanceof IDataPortable || value instanceof ValuesCodable) {
                        encodeToString(IDataHelper.toIData(value), buffer, maxDepth, currentDepth + 1);
                    } else if (value instanceof Object[][]) {
                        encodeToString((Object[][])value, buffer);
                    } else if (value instanceof Object[]) {
                        encodeToString((Object[])value, buffer);
                    } else {
                        buffer.append(HTMLHelper.encode(value.toString()));
                    }
                }
                buffer.append("</td>");
                buffer.append("</tr>");
            }

            cursor.destroy();

            buffer.append("</tbody>");
            buffer.append("</table>");
        }
    }
}
 
开发者ID:Permafrost,项目名称:TundraHTML.java,代码行数:77,代码来源:IDataHTMLParser.java


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