public String buildInterfaceTable(String rule, String[] serviceList) throws FilterParseException {
    StringBuffer buffer = new StringBuffer();
    Filter filter = new Filter();
    Map interfaces = filter.getIPServiceMap(rule);

    Iterator i = interfaces.keySet().iterator();
    while (i.hasNext()) {
      String key = (String) i.next();
      buffer.append("<tr><td valign=\"top\">").append(key).append("</td>");
      buffer.append("<td>");

      if (serviceList != null && serviceList.length != 0) {
        Map services = (Map) interfaces.get(key);
        Iterator j = services.keySet().iterator();
        while (j.hasNext()) {
          String svc = (String) j.next();
          for (int idx = 0; idx < serviceList.length; idx++) {
            if (svc.equals(serviceList[idx])) {
              buffer.append(svc).append("<br>");
            }
          }
        }
      } else {
        buffer.append("All services");
      }
      buffer.append("</td>");

      buffer.append("</tr>");
    }

    return buffer.toString();
  }
Exemplo n.º 2
0
  protected Properties convertProperties(Map<String, Object> m) {
    Properties res = null;

    {
      if (m != null) {
        res = new Properties();

        Set<String> keys = m.keySet();
        for (String key : keys) {
          String value = null;

          // Set 'value':
          {
            Object o = m.get(key);
            if (o != null) {
              value = o.toString();
            }
          }

          res.setProperty(key, value);
        }
      }
    }

    return res;
  }
Exemplo n.º 3
0
  public List<String> getSessionIds() throws IOException {
    List<String> res = null;

    {
      synchronized (lookupSessionById) {
        Set<String> keySet = lookupSessionById.keySet();
        if (keySet != null) {
          res = new ArrayList<String>();
          res.addAll(keySet);
        }
      }
    }

    return res;
  }
Exemplo n.º 4
0
 /**
  * 获取所得到的k个最近邻元组的多数类
  *
  * @param pq 存储k个最近近邻元组的优先级队列
  * @return 多数类的名称
  */
 private String getMostClass(PriorityQueue<KNNNode> pq) {
   Map<Double, Integer> classCount = new HashMap<Double, Integer>();
   for (int i = 0; i < pq.size(); i++) {
     KNNNode node = pq.remove();
     double c = node.getC();
     if (classCount.containsKey(c)) {
       classCount.put(c, classCount.get(c) + 1);
     } else {
       classCount.put(c, 1);
     }
   }
   int maxIndex = -1;
   int maxCount = 0;
   Object[] classes = classCount.keySet().toArray();
   for (int i = 0; i < classes.length; i++) {
     if (classCount.get(classes[i]) > maxCount) {
       maxIndex = i;
       maxCount = classCount.get(classes[i]);
     }
   }
   return classes[maxIndex].toString();
 }
  public String buildPathSelect(String currentPath) throws ServletException {
    StringBuffer buffer = new StringBuffer("<select NAME=\"path\">");

    Map pathsMap = null;

    try {
      pathsMap = new TreeMap(DestinationPathFactory.getInstance().getPaths());
      Iterator iterator = pathsMap.keySet().iterator();
      while (iterator.hasNext()) {
        String key = (String) iterator.next();
        if (key.equals(currentPath)) {
          buffer.append("<option SELECTED VALUE=" + key + ">" + key + "</option>");
        } else {
          buffer.append("<option VALUE=" + key + ">" + key + "</option>");
        }
      }
    } catch (Exception e) {
      throw new ServletException("couldn't get destination path list.", e);
    }
    buffer.append("</select>");

    return buffer.toString();
  }
Exemplo n.º 6
0
  public static void writeMenu(
      PrintWriter out,
      RequestProperties reqState,
      String menuID,
      boolean expandableMenu,
      boolean showIcon,
      int descriptionType,
      boolean showMenuHelp)
      throws IOException {
    PrivateLabel privLabel = reqState.getPrivateLabel();
    Locale locale = reqState.getLocale();
    String parentPageName = null;
    Account account = reqState.getCurrentAccount();

    /* disable menu help if menu description is not displayed */
    boolean showInline = false;
    if (descriptionType == ExpandMenu.DESC_NONE) {
      showMenuHelp = false;
      showInline = true;
    }

    /* sub style classes */
    String topMenuID =
        !StringTools.isBlank(menuID) ? menuID : (expandableMenu ? "expandMenu" : "fixedMenu");
    String groupClass = "menuGroup";
    String leafClass = "itemLeaf";
    String leafDescClass = "itemLeafDesc";
    String helpClass = "itemLeafHelp";
    String helpPadClass = "itemLeafHelpPad";
    String leafIconClass = "itemLeafIcon";

    /* start menu */
    out.println("<ul id='" + topMenuID + "'>");

    /* iterate through menu groups */
    Map<String, MenuGroup> menuMap = privLabel.getMenuGroupMap();
    for (String mgn : menuMap.keySet()) {
      MenuGroup mg = menuMap.get(mgn);
      if (!mg.showInTopMenu()) {
        // skip this group
        // Print.logInfo("Skipping menu group: %s", mgn);
        continue;
      }

      boolean didDisplayGroup = false;
      for (WebPage wp : mg.getWebPageList(reqState)) {
        String menuName = wp.getPageName();
        String iconURI = showIcon ? wp.getMenuIconImage() : null; // may be blank/null
        String menuHelp = wp.getMenuHelp(reqState, parentPageName);
        String url = wp.encodePageURL(reqState); // , RequestProperties.TRACK_BASE_URI());

        /* skip login page */
        if (menuName.equalsIgnoreCase(Constants.PAGE_LOGIN)) {
          // omit login
          // Print.logInfo("Skipping login page: %s", menuName);
          continue;
        }

        /* skip sysAdmin pages */
        if (wp.systemAdminOnly() && !Account.isSystemAdmin(account)) {
          continue;
        }

        /* skip pages that are not ok to display */
        if (!wp.isOkToDisplay(reqState)) {
          continue;
        }

        /* menu description */
        String menuDesc = null;
        switch (descriptionType) {
          case DESC_NONE:
            menuDesc = null;
            break;
          case DESC_SHORT:
            menuDesc = wp.getNavigationDescription(reqState);
            break;
          case DESC_LONG:
          default:
            menuDesc = wp.getMenuDescription(reqState, parentPageName);
            break;
        }

        /* skip this menu item? */
        if (StringTools.isBlank(menuDesc) && StringTools.isBlank(iconURI)) {
          // Print.logWarn("Menu name has no description: %s", menuName);
          continue;
        }

        /* start menu group */
        if (!didDisplayGroup) {
          // open Menu Group
          didDisplayGroup = true;
          out.write("<li class='" + groupClass + "'>" + mg.getTitle(locale) + "\n");
          if (showInline) {
            out.write("<br><table cellpadding='0' cellspacing='0' border='0'><tr>\n");
          } else {
            out.write("<ul>\n"); // <-- start menu sub group
          }
        }

        /* menu anchor/link */
        String anchorStart = "<a";
        if (!StringTools.isBlank(menuHelp)) {
          anchorStart += " title=\"" + menuHelp + "\"";
        }
        String target =
            StringTools.blankDefault(wp.getTarget(), "_self"); // ((WebPageURL)wp).getTarget();
        if (target.startsWith("_")) {
          anchorStart += " href=\"" + url + "\"";
          anchorStart += " target=\"" + target + "\"";
        } else {
          PixelDimension pixDim = wp.getWindowDimension();
          if (pixDim != null) {
            int W = pixDim.getWidth();
            int H = pixDim.getHeight();
            anchorStart +=
                " onclick=\"javascript:openFixedWindow('"
                    + url
                    + "','"
                    + target
                    + "',"
                    + W
                    + ","
                    + H
                    + ")\"";
            anchorStart += " style=\"text-decoration: underline; color: blue; cursor: pointer;\"";
          } else {
            anchorStart += " href=\"" + url + "\"";
            anchorStart += " target=\"" + target + "\"";
          }
        }
        anchorStart += ">";

        /* inline? */
        if (showInline) {

          /* menu icon (will not be blank here) */
          out.write("<td class='" + leafIconClass + "'>");
          if (!StringTools.isBlank(iconURI)) {
            out.write(
                anchorStart + "<img class='" + leafIconClass + "' src='" + iconURI + "'/></a>");
          } else {
            out.write("&nbsp;");
          }
          out.write("</td>");

        } else {

          /* start menu list item */
          out.write("<li class='" + leafClass + "'>");

          /* special case for non-icons */
          if (StringTools.isBlank(iconURI)) {

            /* menu description/help */
            if (!StringTools.isBlank(menuDesc)) {
              out.write(
                  "<span class='" + leafDescClass + "'>" + anchorStart + menuDesc + "</a></span>");
              if (showMenuHelp && !StringTools.isBlank(menuHelp)) {
                out.write("<br>");
                out.write("<span class='" + helpPadClass + "'>" + menuHelp + "</span>");
              }
            }

          } else {
            // this section may not appear as expected on IE

            /* start table */
            out.write("<table class='" + leafClass + "' cellpadding='0' cellspacing='0'>");
            out.write("<tr>");

            /* menu icon */
            if (!StringTools.isBlank(iconURI)) {
              out.write("<td class='" + leafIconClass + "'>");
              out.write(
                  anchorStart + "<img class='" + leafIconClass + "' src='" + iconURI + "'/></a>");
              out.write("</td>");
            }

            /* menu description/help */
            if (!StringTools.isBlank(menuDesc)) {
              out.write("<td class='" + leafDescClass + "'>");
              out.write(
                  "<span class='" + leafDescClass + "'>" + anchorStart + menuDesc + "</a></span>");
              if (showMenuHelp && !StringTools.isBlank(menuHelp)) {
                out.write("<br>");
                out.write("<span class='" + helpClass + "'>" + menuHelp + "</span>");
              }
              out.write("</td>");
            }

            /* end table */
            out.write("</tr>");
            out.write("</table>");
          }

          /* end menu list item */
          out.write("</li>\n");
        }
      }

      /* end menu group */
      if (didDisplayGroup) {
        if (showInline) {
          out.write("</tr></table>\n");
        } else {
          out.write("</ul>\n");
        }
        out.write("</li>\n");
      }
    }

    /* end of menu */
    out.write("</ul>\n");

    /* init menu if expandable */
    if (expandableMenu) {
      out.write(
          "<script type=\"text/javascript\"> new ExpandMenu('" + topMenuID + "'); </script>\n");
    }
  }
Exemplo n.º 7
0
 @Override
 public Enumeration<String> getParameterNames() {
   if (!requestParse.isParsed()) requestParse.parseParmeter();
   return new Enumerator(parameterMap.keySet());
 }
Exemplo n.º 8
0
  @Override
  public Enumeration<String> getHeaderNames() {

    return new Enumerator(headers.keySet());
  }
Exemplo n.º 9
0
 /**
  * Returns the names of all the uploaded files as an Enumeration of Strings. It returns an empty
  * Enumeration if there are no file input fields on the form. Any file input field that's left
  * empty will result in a FilePart with null contents. Each file name is the name specified by the
  * form, not by the user.
  *
  * @return the names of all the uploaded files as an Enumeration of Strings.
  */
 public Set<String> getFileNames() {
   return files.keySet();
 }
 public Enumeration getAttributeNames() {
   return Collections.enumeration(attributeMap.keySet());
 }
 public Enumeration<String> getHeaderNames() {
   return Collections.enumeration(headerMap.keySet());
 }
 public Enumeration getParameterNames() {
   return Collections.enumeration(parameterMap.keySet());
 }