Ejemplo n.º 1
0
    public Component getTableCellEditorComponent(
        JTable table, Object value, boolean isSelected, int row, int column) {

      TableModel tableModel = table.getModel();
      if (tableModel instanceof NodeFilter) {
        NodeFilter nodeFilter = (NodeFilter) tableModel;
        editor =
            new JComboBox(
                (Vector)
                    ((Statement) (nodeFilter.get(row))).getKey().getType().getSettableOperators());
        return editor;
      }
      return (new JComboBox());
    }
Ejemplo n.º 2
0
 /* Returns whether the node is visible by the TreeWalker. */
 private boolean isNodeVisible(final Node n) {
   if (acceptNode(n) == NodeFilter.FILTER_ACCEPT) {
     if (filter_ == null || filter_.acceptNode(n) == NodeFilter.FILTER_ACCEPT) {
       if (!expandEntityReferences_) {
         if (n.getParent() != null && n.getParent().getNodeType() == Node.ENTITY_REFERENCE_NODE) {
           return false;
         }
       }
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 3
0
  private String _convert(NodeFilter filter, String content) throws IOException {

    if (content == null) {
      return StringPool.BLANK;
    }

    StringWriter out = new StringWriter();

    filter.filter(new StringReader(content), out);

    String newContent = out.toString();

    String portletURLToString = StringPool.BLANK;

    PortletURLImpl portletURL = (PortletURLImpl) filter.getPortletURL();

    if (portletURL != null) {
      portletURL.setParameter("node_id", filter.getNodeId());

      Iterator itr = filter.getTitles().keySet().iterator();

      while (itr.hasNext()) {
        String title = (String) itr.next();

        portletURL.setParameter("page_title", title, false);

        portletURLToString = portletURL.toString();

        newContent =
            StringUtil.replace(
                newContent,
                "[$BEGIN_PAGE_TITLE$]" + title + "[$END_PAGE_TITLE$]",
                portletURLToString);
      }
    }

    return newContent;
  }
Ejemplo n.º 4
0
 /* Returns whether the node is rejected by the TreeWalker. */
 private boolean isNodeRejected(final Node n) {
   if (acceptNode(n) == NodeFilter.FILTER_REJECT) {
     return true;
   }
   if (filter_ != null && filter_.acceptNode(n) == NodeFilter.FILTER_REJECT) {
     return true;
   }
   if (!expandEntityReferences_) {
     if (n.getParent() != null && n.getParent().getNodeType() == Node.ENTITY_REFERENCE_NODE) {
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 5
0
 protected void write(IXmlSerializer writer, NodeFilter filter) throws IOException {
   if (filter == null || filter.acceptNode(this) == NodeFilter.ACCEPT) {
     writer.cdsect(data);
   }
 }
Ejemplo n.º 6
0
  // 获取一个网站上的链接,filter 用来过滤链接
  public static Set<String> extracLinks(String url, NodeFilter filter) {
    Set<String> links = new HashSet<String>();
    try {
      Parser parser = new Parser(url);
      parser.setEncoding("UTF-8");

      @SuppressWarnings("serial")
      NodeFilter frameFilter =
          new NodeFilter() {
            public boolean accept(Node node) {
              if (node.getText().startsWith("frame src=")) {
                return true;
              } else {
                return false;
              }
            }
          };

      OrFilter linkFilter = new OrFilter(new NodeClassFilter(LinkTag.class), frameFilter);

      NodeList list = parser.extractAllNodesThatMatch(linkFilter);

      System.out.println("length=" + list.size());

      for (int i = 0; i < list.size(); i++) {
        Node tag = list.elementAt(i);

        if (tag instanceof LinkTag) { // <a> 标签
          LinkTag link = (LinkTag) tag;
          String linkUrl = link.getLink(); // URL

          /*
           * if (filter.accept(linkUrl)) { links.add(linkUrl); }
           */

          System.out.println("linkUrl=" + linkUrl);

          if (filter.accept(tag)) {
            links.add(linkUrl);
          }
        } else { // <frame> 标签
          // 提取 frame 里 src 属性的链接,如 <frame src="test.html"/>
          String frame = tag.getText();
          int start = frame.indexOf("src=");
          frame = frame.substring(start);
          int end = frame.indexOf(" ");

          if (end == -1) {
            end = frame.indexOf(">");
          }

          String frameUrl = frame.substring(5, end - 1);
          // if (filter.accept(frameUrl)) {
          // links.add(frameUrl);
          // }

          System.out.println("frameUrl=" + frameUrl);

          if (filter.accept(tag)) {
            links.add(frameUrl);
          }
        }
      }

      /*
       * NodeFilter filter = new TagNameFilter("DIV"); NodeList nodes =
       * parser.extractAllNodesThatMatch(filter); if(nodes!=null) { for
       * (int i = 0; i < nodes.size(); i++) { Node textnode = (Node)
       * nodes.elementAt(i);
       * System.out.println("getText:"+textnode.getText());
       * System.out.println
       * ("================================================="); } }
       */
      /*
       * for(NodeIterator i = parser.elements (); i.hasMoreNodes(); ) {
       * Node node = i.nextNode();
       * System.out.println("getText:"+node.getText());
       * System.out.println("getPlainText:"+node.toPlainTextString());
       * System.out.println("toHtml:"+node.toHtml());
       * System.out.println("toHtml(true):"+node.toHtml(true));
       * System.out.println("toHtml(false):"+node.toHtml(false));
       * System.out.println("toString:"+node.toString());
       * System.out.println
       * ("================================================="); }
       */

      /*
       * TextExtractingVisitor visitor = new TextExtractingVisitor();
       * parser.visitAllNodesWith(visitor); String textInPage =
       * visitor.getExtractedText(); System.out.println(textInPage);
       */

    } catch (ParserException e) {
      e.printStackTrace();
    }
    return links;
  }
Ejemplo n.º 7
0
 public void mapFilterModelChanged(MapFilterModelEvent e) {
   elementsModel.setElements(e.getMapFilterModel().getKeyVector());
   nodeFilter.fireTableDataChanged();
 }
Ejemplo n.º 8
0
    private void updateModelAndNotify() {

      model.fireTableDataChanged();
    }