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


Java Path.isIndex方法代码示例

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


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

示例1: getArrayIdentityExtractor

import com.redhat.lightblue.util.Path; //导入方法依赖的package包/类
@Override
public IdentityExtractor getArrayIdentityExtractor(Path arrayField) {
    MutablePath p = new MutablePath();
    int n = arrayField.numSegments();
    for (int i = 0; i < n; i++) {
        if (arrayField.isIndex(i)) {
            p.push(Path.ANY);
        } else {
            p.push(arrayField.head(i));
        }
    }
    if(ignoredIdentities.contains(p))
        return null;
    else {
        ArrayIdentityFields fields = getArrayIdentities().get(p);
        if (fields != null) {
            return getArrayIdentityExtractorImpl(fields);
        }
    }
    return null;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:22,代码来源:BsonMerge.java

示例2: getArray

import com.redhat.lightblue.util.Path; //导入方法依赖的package包/类
/**
 * Input is a path to an array element
 * Output is the array containing that element, and all indexes replaced with *
 */
private Path getArray(Path p) {
    int lastIndex=p.numSegments()-1;
    while(lastIndex>0) {
        if(p.isIndex(lastIndex))
            break;
        lastIndex--;
    }
    MutablePath mp=new MutablePath();
    for(int i=0;i<lastIndex;i++) {
        if(p.isIndex(i))
            mp.push(Path.ANY);
        else
            mp.push(p.head(i));
    }
    return mp.immutableCopy();
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:21,代码来源:BsonMerge.java

示例3: addField

import com.redhat.lightblue.util.Path; //导入方法依赖的package包/类
private void addField(DBObject doc,
                      List<DocComparator.Delta<Object>> delta,
                      DocComparator.Removal<Object> removedField) {
    Path field = removedField.getField1();
    // 'field' is the name of the removed field in the old document.
    // We have to find the field name it has in the new document, because array elements might have moved around

    MutablePath newFieldName = new MutablePath();
    int n = field.numSegments();
    for (int i = 0; i < n; i++) {
        if (field.isIndex(i)) {               
            // At this point, newFieldName points to an array,
            // field.prefix(i) points to an array element. If there
            // is a Move delta for the move of field.prefix(i+1)
            // -> someField, then we get the new index from
            // someField
            Path arrayElement = field.prefix(i+1);
            // arrayElement.tail(0) is an index
            Path movedTo = null;
            for (DocComparator.Delta<Object> d : delta) {
                if (d instanceof DocComparator.Move) {
                    DocComparator.Move<Object> move = (DocComparator.Move<Object>) d;
                    if (move.getField1().equals(arrayElement)) {
                        movedTo = move.getField2();
                        break;
                    }
                }
            }
            LOGGER.debug("field: {}, arrayElement: {}, movedTo:{}", field,arrayElement,movedTo);
            if (movedTo != null) {
                // arrayElement moved to somewhere else, get the new index, push it to the newFieldName
                newFieldName.push(movedTo.tail(0));
            } else {
                // ArrayElement did not move
                newFieldName.push(field.head(i));
            }
        } else {
            newFieldName.push(field.head(i));
        }
    }
    // At this point, newFieldName contains the field in the new document
    LOGGER.debug("Adding contents of {} to {}", field, newFieldName);
    DBObject parent;
    if (newFieldName.numSegments() > 1) {
        parent = (DBObject) DocTranslator.getDBObject(doc, newFieldName.prefix(-1));
    } else {
        parent = doc;
    }
    parent.put(newFieldName.tail(0), copy(removedField.getRemovedNode()));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:51,代码来源:BsonMerge.java

示例4: resolveFieldForQuery

import com.redhat.lightblue.util.Path; //导入方法依赖的package包/类
private FieldInfo resolveFieldForQuery(FieldTreeNode context,Path contextPath,Path field) {
    int n=field.numSegments();
    // Two paths: p: the full thing, s: only the relative field
    // If the field reference moves to a parent of relative field, we use p
    // otherwise, we use s
    MutablePath p=new MutablePath(contextPath);
    MutablePath s=new MutablePath();
    FieldTreeNode fieldNode=context;
    for(int i=0;i<n;i++) {
        String seg=field.head(i);
        if(field.isIndex(i)) {
            p.push(seg);
            if(s!=null)
                s.push(seg);
            if(fieldNode instanceof ArrayField) {
                fieldNode=((ArrayField)fieldNode).getElement();
            } else {
                throw Error.get(ERR_INVALID_FIELD,field.toString());
            }
        } else {
            if(Path.THIS.equals(seg)) {
                // Don't push anything
                ;
            } else if(Path.PARENT.equals(seg)) {
                p.pop();
                if(s!=null)
                    if(s.isEmpty())
                        s=null;
                    else
                        s.pop();
                fieldNode=fieldNode.getParent();
            } else {
                p.push(seg);
                if(s!=null)
                    s.push(seg);
                fieldNode=fieldNode.resolve(new Path(seg));
            }
        }
    }
    if(!contextPath.isEmpty()) {
        // If we are in a nonempty context (i.e. nested query under elemMatch), and our variable
        // refers to a field above that context, then mongo language can't handle it, and we need
        // to convert to JS
        FieldTreeNode trc=fieldNode.getParent();
        boolean fieldIsUnderContext=false;
        while(trc!=null) {
            if(trc==context) {
                fieldIsUnderContext=true;
                break;
            } else {
                trc=trc.getParent();
            }
        }
        if(!fieldIsUnderContext)
            throw new NeedsJS();
    }
    return new FieldInfo(s==null?p.immutableCopy():s.immutableCopy(),fieldNode);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:59,代码来源:ExpressionTranslator.java


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