本文整理汇总了Java中com.wm.data.IDataCursor.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java IDataCursor.getValue方法的具体用法?Java IDataCursor.getValue怎么用?Java IDataCursor.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.wm.data.IDataCursor
的用法示例。
在下文中一共展示了IDataCursor.getValue方法的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;
}
示例2: 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;
}
示例3: getKeys
import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
* Returns the all keys associated with the given value.
*
* @param cursor An IDataCursor object.
* @param value The value whose first associated key is to be returned.
* @return All keys associated with the given value, or null if no association exists.
*/
private static String[] getKeys(IDataCursor cursor, Object value) {
List<String> keys;
if (cursor != null) {
keys = new ArrayList<String>();
while (cursor.next()) {
String key = cursor.getKey();
Object val = cursor.getValue();
if ((value instanceof Object[] && val instanceof Object[] && ArrayHelper.equal((Object[])value, (Object[])val)) || ObjectHelper.equal(value, cursor.getValue())) {
keys.add(key);
}
}
} else {
keys = Collections.emptyList();
}
return CollectionHelper.arrayify(keys, String.class);
}
示例4: getValueList
import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
* Returns all the top-level values that are instances of the given class from the given document.
*
* @param document An IData document.
* @param valueClass The class that the returned values are instances of.
* @return The list of top-level values that are instances of the given class from the given IData
* document.
*/
@SuppressWarnings("unchecked")
public static <V> List<V> getValueList(IData document, Class<V> valueClass) {
if (valueClass == null) throw new NullPointerException("valueClass must not be null");
List<V> values = new ArrayList<V>(size(document));
if (document != null) {
IDataCursor cursor = document.getCursor();
try {
while (cursor.next()) {
Object value = cursor.getValue();
if (valueClass.isInstance(value)) {
values.add((V)value);
}
}
} finally {
cursor.destroy();
}
}
return values;
}
示例5: 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();
}
示例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;
}
示例7: 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 required Throws an exception if true and a non-null value is not associated with the given key.
* @return The value that was associated with the key.
*/
public static Object remove(IDataCursor cursor, String key, boolean required) {
if (cursor == null || key == null) return null;
Object value = null;
if (cursor.first(key)) {
value = cursor.getValue();
cursor.delete();
}
if (value == null && required) {
throw new RuntimeException(new NoSuchFieldException(MessageFormat.format("Key \"{0}\" either does not exist or is associated with a null value", key)));
}
return value;
}
示例8: get
import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
* Returns the value associated with the given key from the IDataCursor.
*
* @param cursor The IDataCursor to add the key value association to.
* @param required Throws an exception if true and a value is not associated with any of the given keys.
* @param keys One or more keys in order of precedence.
* @return The first value found associated with a given key.
*/
public static Object get(IDataCursor cursor, boolean required, String... keys) {
if (cursor == null || keys == null || keys.length == 0 || keys[0] == null) return null;
Object value = null;
for (String key : keys) {
if (key != null) {
if (cursor.first(key)) {
value = cursor.getValue();
}
if (value != null) break;
}
}
if (value == null && required) {
if (keys.length == 1) {
throw new RuntimeException(new NoSuchFieldException(MessageFormat.format("Specified key does not exist or is associated with null value: {0}", keys[0])));
} else {
throw new RuntimeException(new NoSuchFieldException(MessageFormat.format("Specified keys do not exist or are associated with null values: {0}", ArrayHelper.join(keys, Sanitization.REMOVE_NULLS))));
}
}
return value;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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;
}
示例12: 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;
}
示例13: 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;
}
示例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();
}
示例15: denormalize
import com.wm.data.IDataCursor; //导入方法依赖的package包/类
/**
* Inserts each item of the given input IDataCursor to the end of the given output IDataCursor with the keys
* denormalized to a fully-qualified key.
*
* @param inputCursor The cursor to source items to be denormalized from.
* @param outputCursor The cursor to insert the denormalized items into.
* @param path The original path to the IData document being denormalized from the inputCursor, or null.
*/
private static void denormalize(IDataCursor inputCursor, IDataCursor outputCursor, String path) {
if (inputCursor == null || outputCursor == null) return;
while(inputCursor.next()) {
String key = inputCursor.getKey();
Object value = inputCursor.getValue();
if (value instanceof IData[] || value instanceof Table || value instanceof IDataCodable[] || value instanceof IDataPortable[] || value instanceof ValuesCodable[]) {
denormalize(toIDataArray(value), outputCursor, path == null ? key : path + "/" + key);
} else if (value instanceof IData || value instanceof IDataCodable || value instanceof IDataPortable || value instanceof ValuesCodable) {
IData child = toIData(value);
IDataCursor childCursor = child.getCursor();
denormalize(childCursor, outputCursor, path == null ? key : path + "/" + key);
childCursor.destroy();
} else if (value instanceof Object[][]) {
denormalize((Object[][])value, outputCursor, path == null ? key : path + "/" + key);
} else if (value instanceof Object[]) {
denormalize((Object[])value, outputCursor, path == null ? key : path + "/" + key);
} else {
outputCursor.insertAfter(path == null ? key : path + "/" + key, value);
}
}
inputCursor.destroy();
outputCursor.destroy();
}