private static bool seek(IDataCursor ic, int position) { int curPos = 0; if (ic.first()) { while (curPos < position) { if (!ic.next()) { return(false); } curPos++; } return(true); } return(false); }
public static void append(IData src, IData dst) { if ((src == null) || (dst == null) || (src == dst)) { return; } IDataCursor srcC = src.getCursor(); IDataCursor dstC = dst.getCursor(); dstC.last(); while (srcC.next()) { dstC.insertAfter(srcC.getKey(), srcC.getValue()); } srcC.destroy(); dstC.destroy(); }
private static bool seek(IDataCursor ic, int position) { int curPos = 0; if (ic.first()) { while (curPos < position) { if (!ic.next()) { return false; } curPos++; } return true; } return false; }
public static object get(IData parent, WmPathItem pathItem, bool bestEffort, IData origPipe) { if ((parent == null) || (pathItem == null)) { return(null); } Object value = null; if (pathItem.pathType == 0) { IDataCursor cursor = parent.getCursor(); String name = pathItem.name; if (cursor.first(name)) { value = cursor.getValue(); } cursor.destroy(); } else if (pathItem.pathType == 1) { if (pathItem.position < 0) { return(null); } IDataCursor cursor = parent.getCursor(); if (seek(cursor, pathItem.position)) { value = cursor.getValue(); } cursor.destroy(); } else if (pathItem.pathType == 2) { if (pathItem.position < 0) { return(null); } IDataCursor cursor = parent.getCursor(); String name = pathItem.name; int position = pathItem.position; bool find = true; for (int i = 0; i <= position; i++) { if (!cursor.next(name)) { find = false; break; } } if (find) { value = cursor.getValue(); } cursor.destroy(); } else if (pathItem.pathType == 3) { return(null); } if ((!bestEffort) && (!dataCheck(value, pathItem))) { value = null; } if ((value is WmIDataList)) { value = ((WmIDataList)value).getItems(); } if (pathItem.arrayIndex == -1) { return(value); } return(getByArrayIndex(value, pathItem, origPipe)); }