org.tinygroup.context.Context.getParent()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(148)

本文整理了Java中org.tinygroup.context.Context.getParent()方法的一些代码示例,展示了Context.getParent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getParent()方法的具体详情如下:
包路径:org.tinygroup.context.Context
类名称:Context
方法名:getParent

Context.getParent介绍

[英]返回父上下文对象
[中]返回父上下文对象

代码示例

代码示例来源:origin: org.tinygroup/org.tinygroup.beancontext

public Context getParent() {
  return context.getParent();
}

代码示例来源:origin: org.tinygroup/org.tinygroup.tinyscriptbase

public Object execute(ScriptSegment segment, ScriptContext context)
    throws ScriptException {
  //支持多层上下文结构,设置引擎上下文为最顶层上下文
  Context nowContext = context;
  Context parentContext = nowContext.getParent();
  while(parentContext!=null){
    nowContext = parentContext;
    parentContext = nowContext.getParent();
  }
  if(!nowContext.equals(scriptContext)){
    //关联引擎上下文
    nowContext.setParent(scriptContext);
  }
  return segment.execute(context);
}

代码示例来源:origin: org.tinygroup/org.tinygroup.context

protected  void getTotalContext(Context contextNode, List<Context> list){
  if(!list.contains(contextNode)){
    list.add(contextNode);
  }else{
    return;
  }
  for (Context subContext : contextNode.getSubContextMap().values()) {
    getTotalContext(subContext,list);
  }
  if(contextNode.getParent()!=null){
    getTotalContext(contextNode.getParent(),list);
  }
}

代码示例来源:origin: org.tinygroup/org.tinygroup.tinyscriptbase

public Map<String, Object> getTotalItemMap() {
  List<Context> contextList = new ArrayList<Context>();
  
  //获取完整的上下文链
  Context parentContext = getParent();
  while(parentContext!=null){
    contextList.add(0,parentContext);
    parentContext = parentContext.getParent();
  }
  
  Map<String, Object> map = new HashMap<String, Object>();
  //合并上下文,优先级:儿子高于父亲
  for(Context context:contextList){
    map.putAll(context.getItemMap());
  }
  map.putAll(getItemMap());
  return map;
}

代码示例来源:origin: org.tinygroup/org.tinygroup.templateengine

protected Macro getMacro(TemplateContext $context) {
  Macro $macro;
  $macro = getBodyContentMacro();
  if ($macro == null) {
    $macro = (Macro) $context.getItemMap().get("bodyContent");
  }
  if ($macro == null) {
    Context context = $context;
    while (context.getParent() != null) {
      if (context.get("bodyContent") != null && context.getItemMap().size() > 0 && !context.getItemMap().containsKey("isCalled")) {
        $macro = (Macro) context.getItemMap().get("bodyContent");
        return $macro;
      }
      context = context.getParent();
    }
  }
  return $macro;
}

代码示例来源:origin: org.tinygroup/org.tinygroup.tinyscriptbase

/**
 * 自下往上递归查询包含key值的itemMap
 * @param context
 * @param key
 * @return
 */
private Map<String, Object> findItemMap(Context context,String key){
  if(context!= null){
    if(context.getItemMap().containsKey(key)){
     return context.getItemMap();
    }else{
     return findItemMap(context.getParent(),key);
    }
  }
  return null;
}

代码示例来源:origin: org.tinygroup/org.tinygroup.context

protected boolean existNodeMap(String name, Context contextNode,
                Map<Context, String> nodeMap) {
  // 如果当前不存在,则查找父亲中有没有
  // 如果已经存在,则返回之
  if (contextNode.getItemMap().containsKey(name)) {
    return true;
  } else {
    nodeMap.put(contextNode, "");
  }
  if (!contextNode.getSubContextMap().isEmpty()) {
    for (Context context : contextNode.getSubContextMap().values()) {
      if (nodeMap.get(context) == null) {
        boolean exist = existNodeMap(name, context, nodeMap);
        if (exist) {
          return true;
        }
      }
    }
  }
  Context theParent = contextNode.getParent();
  if (theParent != null && nodeMap.get(theParent) == null) {
    return existNodeMap(name, theParent, nodeMap);
  }
  return false;
}

代码示例来源:origin: org.tinygroup/org.tinygroup.context

protected Context containNodeMap(String name, Context contextNode,
                 Map<Context, String> nodeMap) {
  // 如果当前不存在,则查找父亲中有没有
  // 如果已经存在,则返回之
  if (contextNode.getItemMap().containsKey(name)) {
    return contextNode;
  } else {
    nodeMap.put(contextNode, "");
  }
  if (!contextNode.getSubContextMap().isEmpty()) {
    for (Context context : contextNode.getSubContextMap().values()) {
      if (nodeMap.get(context) == null) {
        Context con = containNodeMap(name, context, nodeMap);
        if (con != null) {
          return con;
        }
      }
    }
  }
  Context theParent = contextNode.getParent();
  if (theParent != null && nodeMap.get(theParent) == null) {
    return containNodeMap(name, theParent, nodeMap);
  }
  return null;
}

代码示例来源:origin: org.tinygroup/org.tinygroup.context

protected boolean renameKeyNodeMap(String key, String newKey,
                  Context contextNode, Map<Context, String> nodeMap) {
  boolean renamed = renameKeyOfSuper(key, newKey, contextNode);
  Context theParent = contextNode.getParent();
  if (renamed) {
    return true;
  } else {
    nodeMap.put(contextNode, "");
  }
  if (!contextNode.getSubContextMap().isEmpty()) {
    for (Context context : contextNode.getSubContextMap().values()) {
      if (nodeMap.get(context) == null) {
        renamed = renameKeyNodeMap(key, newKey, context, nodeMap);
        if (renamed) {
          return true;
        }
      }
    }
  }
  if (theParent != null && nodeMap.get(theParent) == null) {
    renamed = renameKeyNodeMap(key, newKey, theParent, nodeMap);
    if (renamed) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.tinygroup/context

protected boolean renameKeyNodeMap(String key, String newKey,
    Context contextNode, Map<Context, String> nodeMap) {
  boolean renamed = renameKeyOfSuper(key, newKey, contextNode);
  Context theParent = contextNode.getParent();
  if (renamed) {
    return true;
  } else {
    nodeMap.put(contextNode, "");
  }
  if (contextNode.getSubContextMap().size() > 0) {
    for (Context context : contextNode.getSubContextMap().values()) {
      if (nodeMap.get(context) == null) {
        renamed = renameKeyNodeMap(key, newKey, context, nodeMap);
        if (renamed) {
          return true;
        }
      }
    }
  }
  if (theParent != null && nodeMap.get(theParent) == null) {
    renamed = renameKeyNodeMap(key, newKey, theParent, nodeMap);
    if (renamed) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.tinygroup/org.tinygroup.context

Context theParent = contextNode.getParent();
if (theParent != null && nodeMap.get(theParent) == null) {
  return (T) findNodeMap(name, theParent, nodeMap);

代码示例来源:origin: org.tinygroup/context

Context theParent = contextNode.getParent();
if (theParent != null && nodeMap.get(theParent) == null) {
  return (T) findNodeMap(name, theParent, nodeMap);

相关文章