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


Java ValuesCodable类代码示例

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


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

示例1: getIDataValueList

import com.wm.util.coder.ValuesCodable; //导入依赖的package包/类
/**
 * Returns all the top-level values that are IData compatible objects, including elements in IData[] compatible
 * arrays, from the given IData document.
 *
 * @param document   An IData document.
 * @return           The list of top-level values that are IData compatible objects, including elements in IData[]
 *                   compatible arrays, from the given IData document
 */
@SuppressWarnings("unchecked")
public static List<IData> getIDataValueList(IData document) {
    List<IData> values = new ArrayList<IData>(size(document));

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

        try {
            while (cursor.next()) {
                Object value = cursor.getValue();
                if (value instanceof IData[] || value instanceof Table || value instanceof IDataCodable[] || value instanceof IDataPortable[] || value instanceof ValuesCodable[]) {
                    values.addAll(Arrays.asList(toIDataArray(value)));
                } else if (value instanceof IData || value instanceof IDataCodable || value instanceof IDataPortable || value instanceof ValuesCodable) {
                    values.add(toIData(value));
                }
            }
        } finally {
            cursor.destroy();
        }
    }

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

示例2: toMap

import com.wm.util.coder.ValuesCodable; //导入依赖的package包/类
/**
 * Converts the given object to a Map object, if possible.
 *
 * @param object    The object to be converted.
 * @return          A Map representation of the given object if its type is compatible (IData, IDataCodable,
 *                  IDataPortable, ValuesCodable), otherwise null.
 */
private static Map<String, Object> toMap(Object object) {
    if (object == null) return null;

    Map<String, Object> output = null;

    if (object instanceof IData) {
        output = toMap((IData)object);
    } else if (object instanceof IDataCodable) {
        output = toMap((IDataCodable)object);
    } else if (object instanceof IDataPortable) {
        output = toMap((IDataPortable)object);
    } else if (object instanceof ValuesCodable) {
        output = toMap((ValuesCodable)object);
    }

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

示例3: toList

import com.wm.util.coder.ValuesCodable; //导入依赖的package包/类
/**
 * Converts an object to a List object, if possible.
 *
 * @param object    An object to be converted.
 * @return          A List representation of the given object, if the object was a compatible type (IData[],
 *                  Table, IDataCodable[], IDataPortable[], ValuesCodable[]), otherwise null.
 */
private static List<Map<String, Object>> toList(Object object) {
    if (object == null) return null;

    List<Map<String, Object>> output = null;

    if (object instanceof IData[]) {
        output = toList((IData[])object);
    } else if (object instanceof Table) {
        output = toList((Table)object);
    } else if (object instanceof IDataCodable[]) {
        output = toList((IDataCodable[])object);
    } else if (object instanceof IDataPortable[]) {
        output = toList((IDataPortable[])object);
    } else if (object instanceof ValuesCodable[]) {
        output = toList((ValuesCodable[])object);
    }

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

示例4: toIData

import com.wm.util.coder.ValuesCodable; //导入依赖的package包/类
/**
 * Returns an IData representation of the given object, if possible.
 *
 * @param object    The object to convert.
 * @return          An IData representing the given object if its type is compatible (IData, IDataCodable,
 *                  IDataPortable, ValuesCodable), otherwise null.
 */
public static IData toIData(Object object) {
    if (object == null) return null;

    IData output = null;

    if (object instanceof IData) {
        output = (IData)object;
    } else if (object instanceof IDataCodable) {
        output = toIData((IDataCodable)object);
    } else if (object instanceof IDataPortable) {
        output = toIData((IDataPortable)object);
    } else if (object instanceof ValuesCodable) {
        output = toIData((ValuesCodable)object);
    } else if (object instanceof Map) {
        output = toIData((Map)object);
    }

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

示例5: toIDataArray

import com.wm.util.coder.ValuesCodable; //导入依赖的package包/类
/**
 * Returns an IData[] representation of the given object, if possible.
 *
 * @param object    The Table object to be converted to an IData[] object.
 * @return          An IData[] representation of the give object if the object was a compatible type (IData[],
 *                  Table, IDataCodable[], IDataPortable[], ValuesCodable[]), otherwise null.
 */
public static IData[] toIDataArray(Object object) {
    if (object == null) return null;

    IData[] output = null;

    if (object instanceof Table) {
        output = toIDataArray((Table)object);
    } else if (object instanceof IDataCodable[]) {
        output = toIDataArray((IDataCodable[])object);
    } else if (object instanceof IDataPortable[]) {
        output = toIDataArray((IDataPortable[])object);
    } else if (object instanceof ValuesCodable[]) {
        output = toIDataArray((ValuesCodable[])object);
    } else if (object instanceof Map[]) {
        output = toIDataArray((Map[])object);
    } else if (object instanceof IData[]) {
        output = (IData[])object;
    }

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

示例6: of

import com.wm.util.coder.ValuesCodable; //导入依赖的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

示例7: stringify

import com.wm.util.coder.ValuesCodable; //导入依赖的package包/类
/**
 * Returns a string representation of the given object.
 *
 * @param object The object to stringify.
 * @return A string representation of the given object.
 */
public static String stringify(Object object) {
    if (object == null) return null;

    String output;

    if (object instanceof NSNode) {
        output = ((NSNode)object).getNSName().toString();
    } else if (object instanceof IData[] || object instanceof Table || object instanceof IDataCodable[] || object instanceof IDataPortable[] || object instanceof ValuesCodable[]) {
        output = ArrayHelper.stringify(IDataHelper.toIDataArray(object));
    } else if (object instanceof IData || object instanceof IDataCodable || object instanceof IDataPortable || object instanceof ValuesCodable) {
        output = IDataHelper.toIData(object).toString();
    } else if (object instanceof Object[][]) {
        output = TableHelper.stringify((Object[][])object);
    } else if (object instanceof Object[]) {
        output = ArrayHelper.stringify((Object[])object);
    } else {
        output = object.toString();
    }

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

示例8: substitute

import com.wm.util.coder.ValuesCodable; //导入依赖的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

示例9: mergeRecursivelyInto

import com.wm.util.coder.ValuesCodable; //导入依赖的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

示例10: duplicate

import com.wm.util.coder.ValuesCodable; //导入依赖的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

示例11: compact

import com.wm.util.coder.ValuesCodable; //导入依赖的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

示例12: normalize

import com.wm.util.coder.ValuesCodable; //导入依赖的package包/类
/**
 * Normalizes the given Object.
 *
 * @param value An Object to be normalized.
 * @return      A new normalized version of the given Object.
 */
private static Object normalize(Object value) {
    if (value instanceof Table) {
        value = normalize((Table)value);
    } else if (value instanceof IDataCodable[]) {
        value = normalize((IDataCodable[])value);
    } else if (value instanceof IDataPortable[]) {
        value = normalize((IDataPortable[])value);
    } else if (value instanceof ValuesCodable[]) {
        value = normalize((ValuesCodable[])value);
    } else if (value instanceof Collection) {
        value = normalize((Collection)value);
    } else if (value instanceof Map[]) {
        value = normalize((Map[]) value);
    } else if (value instanceof IData[]) {
        value = normalize((IData[])value);
    } else if (value instanceof IDataCodable) {
        value = normalize((IDataCodable)value);
    } else if (value instanceof IDataPortable) {
        value = normalize((IDataPortable)value);
    } else if (value instanceof ValuesCodable) {
        value = normalize((ValuesCodable)value);
    } else if (value instanceof Map) {
        value = normalize((Map)value);
    } else if (value instanceof IData) {
        value = normalize((IData)value);
    }

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

示例13: denormalize

import com.wm.util.coder.ValuesCodable; //导入依赖的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();
}
 
开发者ID:Permafrost,项目名称:Tundra.java,代码行数:35,代码来源:IDataHelper.java

示例14: keysToLowerCase

import com.wm.util.coder.ValuesCodable; //导入依赖的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

示例15: normalize

import com.wm.util.coder.ValuesCodable; //导入依赖的package包/类
/**
 * Returns the given value, optionally copied if required.
 *
 * @param value The value to be normalized.
 * @return      The normalized value.
 */
private Object normalize(Object value) {
    if (value instanceof IData[] || value instanceof Table || value instanceof IDataCodable[] || value instanceof IDataPortable[] || value instanceof ValuesCodable[] || value instanceof IData || value instanceof IDataCodable || value instanceof IDataPortable || value instanceof ValuesCodable) {
        if (copy()) {
            value = cursor.getValue();
        }
    }
    return value;
}
 
开发者ID:Permafrost,项目名称:Tundra.java,代码行数:15,代码来源:CopyOnWriteIDataMap.java


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