本文整理汇总了Java中com.redhat.lightblue.util.Path.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java Path.isEmpty方法的具体用法?Java Path.isEmpty怎么用?Java Path.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.redhat.lightblue.util.Path
的用法示例。
在下文中一共展示了Path.isEmpty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}