Exemplo n.º 1
0
  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;
  }
Exemplo n.º 2
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;
  }
Exemplo n.º 3
0
 public static String translate(String text) {
   return StringUtil.replace(
       text, new String[] {" doth ", " hath "}, new String[] {" does ", " has "});
 }