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

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

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

Context.getItemMap介绍

[英]返回当前上下文(不包含子上下文)中所有内容
[中]返回当前上下文(不包含子上下文)中所有内容

代码示例

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

public Map<String, Object> getItemMap() {
  return context.getItemMap();
}

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

public Object[] getKeys() {
  return context.getItemMap().keySet().toArray();
}

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

public Object[] getKeys() {
  return context.getItemMap().keySet().toArray();
}

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

private boolean renameKeyOfSuper(String key, String newKey, Context context) {
    Map<String, Object> itemMap = context.getItemMap();
    if (itemMap.containsKey(key)) {
      itemMap.put(newKey, itemMap.get(key));
      itemMap.remove(key);
      return true;
    }
    return false;
  }
}

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

private boolean renameKeyOfSuper(String key, String newKey, Context context) {
  Map<String, Object> itemMap = context.getItemMap();
  if (itemMap.containsKey(key)) {
    itemMap.put(newKey, itemMap.get(key));
    itemMap.remove(key);
    return true;
  }
  return false;
}

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

public Map<String, Object> getTotalItemMap() {
//        Map<String, Object> map = new HashMap<String, Object>();
//        for (Context subContext : subContextMap.values()) {
//            map.putAll(subContext.getItemMap());
//        }
//        map.putAll(getItemMap());
    List<Context> list = new ArrayList<Context>();
    getTotalContext(this,list);
    Map<String, Object> map = new HashMap<String,Object>();
    for(int i=list.size()-1;i>=0;i--){
      map.putAll(list.get(i).getItemMap());
    }
    return map;
  }

代码示例来源: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.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

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/context

if (contextNode.getItemMap().containsKey(name)) {// 如果已经存在,则返回之
  Object object = contextNode.getItemMap().get(name);
  if (object == null) {
    return null;
T result = (T) contextNode.getItemMap().get(name);
if (result != null) {
  return result;

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

if (contextNode.getItemMap().containsKey(name)) {
  Object object = contextNode.getItemMap().get(name);
  if (object == null) {
    return null;
T result = (T) contextNode.getItemMap().get(name);
if (result != null) {
  return result;

代码示例来源: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.pageflowbasiccomponent

public void doExecute(Context context) throws
    Exception {
  boolean isPagelet = false;
  if (path.endsWith(template)) {
    isPagelet = true;
    path = path.substring(0,
        path.length() - template.length())
        + templeteWithLayout;
  }
  FileObject fileObject = fullContextFileRepository.getFileObject(path);
  WebContext webContent = null;
  if (context instanceof WebContext)
    webContent = (WebContext) context;
  else
    return;
  if (fileObject != null && fileObject.isExist()) {
    TemplateContext templateContext = new TemplateContextDefault(context.getItemMap());
    if (isPagelet) {
      engine.renderTemplateWithOutLayout(path, templateContext, webContent.getResponse().getOutputStream());
    } else {
      engine.renderTemplate(path, templateContext, webContent.getResponse().getOutputStream());
    }
    return;
  } else {
    webContent.getResponse()
        .sendError(HttpServletResponse.SC_NOT_FOUND);
  }
}

相关文章