public Object convert(String id) throws ConverterException {
    Whois whois = null;

    try {
      Socket socket = new Socket(WHOIS_SERVER, WHOIS_SERVER_PORT);
      BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));

      PrintStream out = new PrintStream(socket.getOutputStream());
      out.println(_domain);

      FastStringBuffer sb = new FastStringBuffer();
      String line = null;

      while ((line = br.readLine()) != null) {
        if (line.startsWith("Results ")) {
          break;
        }

        sb.append(line).append("\n");
      }

      br.close();
      socket.close();

      whois = new Whois(_domain, StringUtil.replace(sb.toString().trim(), "\n\n", "\n"));
    } catch (Exception e) {
      throw new ConverterException(_domain + " " + e.toString());
    }

    return whois;
  }
  public static void openNode(HttpServletRequest req, String treeId, String nodeId) {

    Map openNodes = _getOpenNodes(req, treeId);

    String openNodesString = (String) openNodes.get(treeId);

    openNodesString = StringUtil.add(openNodesString, nodeId);

    openNodes.put(treeId, openNodesString);
  }
Exemple #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;
  }
Exemple #4
0
  private WCUtil() {
    Document doc = null;

    try {
      doc =
          new SAXReader()
              .read(
                  getClass()
                      .getClassLoader()
                      .getResource("content/en_US/westminster_catechism.xml"));
    } catch (DocumentException de) {
      de.printStackTrace();
    }

    _shorter = new ArrayList();

    Element root = doc.getRootElement();

    Iterator itr1 = root.element("shorter").elements("entry").iterator();

    while (itr1.hasNext()) {
      Element entry = (Element) itr1.next();

      List proofs = new ArrayList();

      Iterator itr2 = entry.element("proofs").elements("scriptures").iterator();

      while (itr2.hasNext()) {
        Element scriptures = (Element) itr2.next();

        proofs.add(StringUtil.split(scriptures.getText(), StringPool.SEMICOLON));
      }

      _shorter.add(
          new WCEntry(
              entry.elementText("question"),
              entry.elementText("answer"),
              (String[][]) proofs.toArray(new String[0][0])));
    }

    _shorter = Collections.unmodifiableList(_shorter);

    _larger = new ArrayList();

    itr1 = root.element("larger").elements("entry").iterator();

    while (itr1.hasNext()) {
      Element entry = (Element) itr1.next();

      List proofs = new ArrayList();

      Iterator itr2 = entry.element("proofs").elements("scriptures").iterator();

      while (itr2.hasNext()) {
        Element scriptures = (Element) itr2.next();

        proofs.add(StringUtil.split(scriptures.getText(), StringPool.SEMICOLON));
      }

      _larger.add(
          new WCEntry(
              entry.elementText("question"),
              entry.elementText("answer"),
              (String[][]) proofs.toArray(new String[0][0])));
    }

    _larger = Collections.unmodifiableList(_larger);
  }
Exemple #5
0
 public static String translate(String text) {
   return StringUtil.replace(
       text, new String[] {" doth ", " hath "}, new String[] {" does ", " has "});
 }