Replace the wait with java embedding thread.sleep() function

Hi,
How to replace the wait with java embedding thread.sleep() function. Can anyone help.
Thanks.

drag and drop the java embedding component
include the following code in it.
try{ 
Thread.sleep(60000);
}catch(Exception e)
--Prasanna                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Realtime equivalent to Java's Thread.sleep()?

    I have an application that I want to guarantee that when I call Java's Thread.sleep(n) the thread will sleep for precisely that amount of time, or close to it at least. What we recently encountered though was that if the "wall clock" time is changed in one thread while a sleep is occurring in another thread, this clock change will impact when the sleeping thread will wake up.
    In our case, we had a simple Thread.sleep(1000), and during that one second period another thread set the clock back two minutes. The sleeping thread ended up sleeping roughly two minutes and a second instead of just a second. Apparently this is a "feature" of Thread.sleep(), and I can see in some cases (e.g. a task scheduler based on wall clock times) where this is exactly the behavior you'd want. However, in our case, we want the sleep function to sleep by the amount we specify, regardless of changes to the wall clock time. Is there a way to do this in Java? We are using JDK 1.5.

    You can use methods which rely on the nanoTime() (based on the number of clock cycles since the processor last reset)
    Classes such as LockSupport.parkUntil(someObject, nanoTime) may give you the accuracy/consistency you want. In this case you always wait the full delay.(and not unpack it)

  • Unable to deploy BPEL with java embedding

    Hi ,
    I have created a simple BPEL Process with java embedding for over ruling the BPELinstance name in it .But I am unable to deploy as Jdeveloper is showing that jar files should be included in the classpath ,though I had included in the class path. Below are my code and the error which is shown by the Jdeveloper.
    <bpelx:exec name="JavaSetTitle" language="java" version="1.4">
    <![CDATA[
    Element inVarElem = (Element)getVariableData("inputVariable"
    , "payload"
    , "/client:HelloWorldProcessRequest/client:input");
    try
    String inputdata = inVarElemOrpsId.getNodeValue();
    String title = "HelloWorld " + inputdata;
    setTitle(title);
    addAuditTrailEntry("New Title is: >" + title + "<");
    catch (Exception ex)
    ex.printStackTrace();
    }]]>
    </bpelx:exec>
    Error:
    Error: Java compilation failed.
    Failed to compile file(s) "TestBPEL.bpel".
    Exception reported is: TestBPEL.bpel:64: Class bpel.testbpel.Element not found.
    Element inVarElem = (Element)getVariableData("inputVariable"
    ^
    TestBPEL.bpel:64: Class bpel.testbpel.Element not found.
    Element inVarElem = (Element)getVariableData("inputVariable"
    ^
    TestBPEL.bpel:69: Undefined variable or class name: inVarElemOrpsId
    String inputdata = inVarElemOrpsId.getNodeValue();
    ^
    3 errors
    Please verify that file TestBPEL.bpel is valid java file or if all required libraries are included in your classpath.
    classpath: ..\..\..\classes;..\..\ide\lib\javax-ide.jar;..\..\ide\lib\javatools.jar;..\..\ide\lib\ide.jar;..\..\jlib\jewt4.jar;..\..\jlib\share.jar;..\..\jlib\help4.jar;..\..\jlib\inspect4.jar;..\..\lib\xmlparserv2.jar;..\..\jdbc\lib\orai18n.jar;..\lib\jdev-ep.jar;..\..\jdk\lib\tools.jar;..\..\jdk\lib\dt.jar;..\lib\ext\jaxen-1.1-beta-4.jar;..\extensions\oracle.ide.10.1.3.jar;..\..\jlib\ojmisc.jar;..\extensions\oracle.jdeveloper.10.1.3.jar;..\lib\jdev.jar;..\lib\ojc.jar;..\..\jlib\regexp.jar;..\..\ant\lib\ant.jar;..\..\ant\lib\ant-..................

    Or try removing the client: from your original code
    <bpelx:exec name="JavaSetTitle" language="java" version="1.4">
    <![CDATA[
    Element inVarElem = (Element)getVariableData("inputVariable"
    , "payload"
    , "/HelloWorldProcessRequest/input");
    try
    String inputdata = inVarElemOrpsId.getNodeValue();
    String title = "HelloWorld " + inputdata;
    setTitle(title);
    addAuditTrailEntry("New Title is: >" + title + "<");
    catch (Exception ex)
    ex.printStackTrace();
    }]]>
    </bpelx:exec>cheers
    James

  • Crawling the Web with Java

    Hi everyone.
    I've been trying to learn how to make a web crawler in java following this detailed albeit old tutorial: http://www.devarticles.com/c/a/Java/Crawling-the-Web-with-Java/
    The SearchCrawler class they feature can be found in two parts:
    First part: http://www.devarticles.com/c/a/Java/Crawling-the-Web-with-Java/3/
    Second part: http://www.devarticles.com/c/a/Java/Crawling-the-Web-with-Java/4/
    I don't want to copy and paste the code because it is really long and an eyesore if viewing here.
    I get a lot of errors when compiling of which I do not understand. The majority of the errors (62 of them to be precise) are "class, interface or enum expected" errors, with the remaining few being "illegal start of type" and "<identifier> expected" errors.
    Can someone here perhaps take a look at it and compile it and see if they also get the same errors? I realise it is an old tutorial but there are hardly any detailed resources I can find for java web crawlers.
    Thanks.

    Odd I can't seem to log into my account. Never mind.
    I have used java before, the problem here I suppose is I'm not good enough to spot what's the problem. The code seems fine bracket wise and it has really left me stumped.
    If someone code put it in their editor and attempt to compile and see if I'm not the only one that's having a problem.. that would be much appreciated.
    For your convenience... the code from the example I linked:
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.util.regex.*;
    import javax.swing.*;
    import javax.swing.table.*;
    // The Search Web Crawler
    public class SearchCrawler extends JFrame
      // Max URLs drop-down values.
      private static final String[] MAX_URLS =
        {"50", "100", "500", "1000"};
      // Cache of robot disallow lists.
      private HashMap disallowListCache = new HashMap();
      // Search GUI controls.
      private JTextField startTextField;
      private JComboBox maxComboBox;
      private JCheckBox limitCheckBox;
      private JTextField logTextField;
      private JTextField searchTextField;
      private JCheckBox caseCheckBox;
      private JButton searchButton;
      // Search stats GUI controls.
      private JLabel crawlingLabel2;
      private JLabel crawledLabel2;
      private JLabel toCrawlLabel2;
      private JProgressBar progressBar;
      private JLabel matchesLabel2;
      // Table listing search matches.
      private JTable table;
      // Flag for whether or not crawling is underway.
      private boolean crawling;
      // Matches log file print writer.
      private PrintWriter logFileWriter;
      // Constructor for Search Web Crawler.
      public SearchCrawler()
        // Set application title.
        setTitle("Search Crawler");
        // Set window size.
        setSize(600, 600);
         // Handle window closing events.
        addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           actionExit();
        // Set up File menu.
        JMenuBar menuBar = new JMenuBar();
        JMenu fileMenu = new JMenu("File"); 
        fileMenu.setMnemonic(KeyEvent.VK_F);
        JMenuItem fileExitMenuItem = new JMenuItem("Exit",
          KeyEvent.VK_X);
        fileExitMenuItem.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) { 
            actionExit();
        fileMenu.add(fileExitMenuItem);
        menuBar.add(fileMenu);
        setJMenuBar(menuBar);
        // Set up search panel.
        JPanel searchPanel = new JPanel();
        GridBagConstraints constraints;
        GridBagLayout layout = new GridBagLayout();
        searchPanel.setLayout(layout);
        JLabel startLabel = new JLabel("Start URL:");
        constraints = new GridBagConstraints();
        constraints.anchor = GridBagConstraints.EAST; 
        constraints.insets = new Insets(5, 5, 0, 0);
        layout.setConstraints(startLabel, constraints);
        searchPanel.add(startLabel);
        startTextField = new JTextField();
        constraints = new GridBagConstraints();
        constraints.fill = GridBagConstraints.HORIZONTAL;
        constraints.gridwidth = GridBagConstraints.REMAINDER;
        constraints.insets = new Insets(5, 5, 0, 5);
        layout.setConstraints(startTextField, constraints);
        searchPanel.add(startTextField);
        JLabel maxLabel = new JLabel("Max URLs to Crawl:");
        constraints = new GridBagConstraints();
        constraints.anchor = GridBagConstraints.EAST;
        constraints.insets = new Insets(5, 5, 0, 0);
        layout.setConstraints(maxLabel, constraints);
        searchPanel.add(maxLabel);
        maxComboBox = new JComboBox(MAX_URLS);
        maxComboBox.setEditable(true);
        constraints = new GridBagConstraints();
        constraints.insets = new Insets(5, 5, 0, 0);
        layout.setConstraints(maxComboBox, constraints);
        searchPanel.add(maxComboBox);
        limitCheckBox =
          new JCheckBox("Limit crawling to Start URL site");
        constraints = new GridBagConstraints();
        constraints.anchor = GridBagConstraints.WEST;
        constraints.insets = new Insets(0, 10, 0, 0);
        layout.setConstraints(limitCheckBox, constraints);
        searchPanel.add(limitCheckBox);
        JLabel blankLabel = new JLabel();
        constraints = new GridBagConstraints();
        constraints.gridwidth = GridBagConstraints.REMAINDER;
        layout.setConstraints(blankLabel, constraints);
        searchPanel.add(blankLabel);
        JLabel logLabel = new JLabel("Matches Log File:");
        constraints = new GridBagConstraints();
        constraints.anchor = GridBagConstraints.EAST;
        constraints.insets = new Insets(5, 5, 0, 0);
        layout.setConstraints(logLabel, constraints);
        searchPanel.add(logLabel);
        String file =
          System.getProperty("user.dir") +
          System.getProperty("file.separator") +
          "crawler.log";
        logTextField = new JTextField(file);
        constraints = new GridBagConstraints();
        constraints.fill = GridBagConstraints.HORIZONTAL;
        constraints.gridwidth = GridBagConstraints.REMAINDER;
        constraints.insets = new Insets(5, 5, 0, 5);
        layout.setConstraints(logTextField, constraints);
        searchPanel.add(logTextField);
        JLabel searchLabel = new JLabel("Search String:");
        constraints = new GridBagConstraints();
        constraints.anchor = GridBagConstraints.EAST; 
        constraints.insets = new Insets(5, 5, 0, 0);
        layout.setConstraints(searchLabel, constraints);
        searchPanel.add(searchLabel);
        searchTextField = new JTextField();
        constraints = new GridBagConstraints();
        constraints.fill = GridBagConstraints.HORIZONTAL;
        constraints.insets = new Insets(5, 5, 0, 0);
        constraints.gridwidth= 2;
        constraints.weightx = 1.0d;
        layout.setConstraints(searchTextField, constraints);
        searchPanel.add(searchTextField);
        caseCheckBox = new JCheckBox("Case Sensitive");
        constraints = new GridBagConstraints();
        constraints.insets = new Insets(5, 5, 0, 5);
        constraints.gridwidth = GridBagConstraints.REMAINDER;
        layout.setConstraints(caseCheckBox, constraints);
        searchPanel.add(caseCheckBox);
        searchButton = new JButton("Search");
        searchButton.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionSearch();
        constraints = new GridBagConstraints();
        constraints.gridwidth = GridBagConstraints.REMAINDER;
        constraints.insets = new Insets(5, 5, 5, 5);
        layout.setConstraints(searchButton, constraints);
        searchPanel.add(searchButton);
        JSeparator separator = new JSeparator();
        constraints = new GridBagConstraints();
        constraints.fill = GridBagConstraints.HORIZONTAL;
        constraints.gridwidth = GridBagConstraints.REMAINDER;
        constraints.insets = new Insets(5, 5, 5, 5);
        layout.setConstraints(separator, constraints);
        searchPanel.add(separator);
        JLabel crawlingLabel1 = new JLabel("Crawling:");
        constraints = new GridBagConstraints();
        constraints.anchor = GridBagConstraints.EAST;
        constraints.insets = new Insets(5, 5, 0, 0);
        layout.setConstraints(crawlingLabel1, constraints);
        searchPanel.add(crawlingLabel1);
        crawlingLabel2 = new JLabel();
        crawlingLabel2.setFont(
          crawlingLabel2.getFont().deriveFont(Font.PLAIN));
        constraints = new GridBagConstraints();
        constraints.fill = GridBagConstraints.HORIZONTAL;
        constraints.gridwidth = GridBagConstraints.REMAINDER;
        constraints.insets = new Insets(5, 5, 0, 5);
        layout.setConstraints(crawlingLabel2, constraints);
        searchPanel.add(crawlingLabel2);
        JLabel crawledLabel1 = new JLabel("Crawled URLs:");
        constraints = new GridBagConstraints();
        constraints.anchor = GridBagConstraints.EAST;
        constraints.insets = new Insets(5, 5, 0, 0);
        layout.setConstraints(crawledLabel1, constraints);
        searchPanel.add(crawledLabel1);
        crawledLabel2 = new JLabel();
        crawledLabel2.setFont(
          crawledLabel2.getFont().deriveFont(Font.PLAIN));
        constraints = new GridBagConstraints();
        constraints.fill = GridBagConstraints.HORIZONTAL;
        constraints.gridwidth = GridBagConstraints.REMAINDER;
        constraints.insets = new Insets(5, 5, 0, 5);
        layout.setConstraints(crawledLabel2, constraints);
        searchPanel.add(crawledLabel2);
        JLabel toCrawlLabel1 = new JLabel("URLs to Crawl:");
        constraints = new GridBagConstraints();
        constraints.anchor = GridBagConstraints.EAST;
        constraints.insets = new Insets(5, 5, 0, 0);
        layout.setConstraints(toCrawlLabel1, constraints);
        searchPanel.add(toCrawlLabel1);
        toCrawlLabel2 = new JLabel();
        toCrawlLabel2.setFont(
          toCrawlLabel2.getFont().deriveFont(Font.PLAIN));
        constraints = new GridBagConstraints();
        constraints.fill = GridBagConstraints.HORIZONTAL;
        constraints.gridwidth = GridBagConstraints.REMAINDER;
        constraints.insets = new Insets(5, 5, 0, 5);
        layout.setConstraints(toCrawlLabel2, constraints);
        searchPanel.add(toCrawlLabel2);
        JLabel progressLabel = new JLabel("Crawling Progress:");
        constraints = new GridBagConstraints();
        constraints.anchor = GridBagConstraints.EAST;
        constraints.insets = new Insets(5, 5, 0, 0);
        layout.setConstraints(progressLabel, constraints);
        searchPanel.add(progressLabel);
        progressBar = new JProgressBar();
        progressBar.setMinimum(0);
        progressBar.setStringPainted(true);
        constraints = new GridBagConstraints();
        constraints.fill = GridBagConstraints.HORIZONTAL;
        constraints.gridwidth = GridBagConstraints.REMAINDER;
        constraints.insets = new Insets(5, 5, 0, 5);
        layout.setConstraints(progressBar, constraints);
        searchPanel.add(progressBar);
        JLabel matchesLabel1 = new JLabel("Search Matches:");
        constraints = new GridBagConstraints();
        constraints.anchor = GridBagConstraints.EAST;
        constraints.insets = new Insets(5, 5, 10, 0);
        layout.setConstraints(matchesLabel1, constraints);
        searchPanel.add(matchesLabel1);
        matchesLabel2 = new JLabel();
        matchesLabel2.setFont(
          matchesLabel2.getFont().deriveFont(Font.PLAIN));
        constraints = new GridBagConstraints();
        constraints.fill = GridBagConstraints.HORIZONTAL;
        constraints.gridwidth = GridBagConstraints.REMAINDER;
        constraints.insets = new Insets(5, 5, 10, 5);
        layout.setConstraints(matchesLabel2, constraints);
        searchPanel.add(matchesLabel2);
        // Set up matches table.
        table =
          new JTable(new DefaultTableModel(new Object[][]{},
            new String[]{"URL"}) {
          public boolean isCellEditable(int row, int column)
            return false;
        // Set up Matches panel.
        JPanel matchesPanel = new JPanel();
        matchesPanel.setBorder(
          BorderFactory.createTitledBorder("Matches"));
        matchesPanel.setLayout(new BorderLayout());
        matchesPanel.add(new JScrollPane(table),
          BorderLayout.CENTER);
        // Add panels to display.
        getContentPane().setLayout(new BorderLayout());
        getContentPane().add(searchPanel, BorderLayout.NORTH);
        getContentPane().add(matchesPanel,BorderLayout.CENTER);
      // Exit this program.
      private void actionExit() {
        System.exit(0);
      // Handle Search/Stop button being clicked.
      private void actionSearch() {
        // If stop button clicked, turn crawling flag off.
        if (crawling) {
          crawling = false;
          return;
      ArrayList errorList = new ArrayList();
      // Validate that start URL has been entered.
      String startUrl = startTextField.getText().trim();
      if (startUrl.length() < 1) {
        errorList.add("Missing Start URL.");
      // Verify start URL.
      else if (verifyUrl(startUrl) == null) {
        errorList.add("Invalid Start URL.");
      // Validate that Max URLs is either empty or is a number.
      int maxUrls = 0;
      String max = ((String) maxComboBox.getSelectedItem()).trim();
      if (max.length() > 0) {
        try {
          maxUrls = Integer.parseInt(max);
        } catch (NumberFormatException e) {
        if (maxUrls < 1) {
          errorList.add("Invalid Max URLs value.");
      // Validate that matches log file has been entered.
      String logFile = logTextField.getText().trim();
      if (logFile.length() < 1) {
        errorList.add("Missing Matches Log File.");
      // Validate that search string has been entered.
      String searchString = searchTextField.getText().trim();
      if (searchString.length() < 1) {
        errorList.add("Missing Search String.");
      // Show errors, if any, and return.
      if (errorList.size() > 0) {
        StringBuffer message = new StringBuffer();
        // Concatenate errors into single message.
        for (int i = 0; i < errorList.size(); i++) {
          message.append(errorList.get(i));
          if (i + 1 < errorList.size()) {
            message.append("\n");
        showError(message.toString());
        return;
      // Remove "www" from start URL if present.
      startUrl = removeWwwFromUrl(startUrl);
      // Start the Search Crawler.
      search(logFile, startUrl, maxUrls, searchString);
    private void search(final String logFile, final String startUrl,
      final int maxUrls, final String searchString)
      // Start the search in a new thread.
      Thread thread = new Thread(new Runnable() {
        public void run() {
          // Show hour glass cursor while crawling is under way.
          setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
          // Disable search controls.
          startTextField.setEnabled(false);
          maxComboBox.setEnabled(false);
          limitCheckBox.setEnabled(false);
          logTextField.setEnabled(false);
          searchTextField.setEnabled(false);
          caseCheckBox.setEnabled(false);
          // Switch Search button to "Stop."
          searchButton.setText("Stop");
          // Reset stats.
          table.setModel(new DefaultTableModel(new Object[][]{},
            new String[]{"URL"}) {
            public boolean isCellEditable(int row, int column)
              return false;
           updateStats(startUrl, 0, 0, maxUrls);
          // Open matches log file.
          try {
            logFileWriter = new PrintWriter(new FileWriter(logFile));
          } catch (Exception e) {
            showError("Unable to open matches log file.");
            return;
          // Turn crawling flag on.
          crawling = true;
          // Perform the actual crawling.
          crawl(startUrl, maxUrls, limitCheckBox.isSelected(),
            searchString, caseCheckBox.isSelected());
          // Turn crawling flag off.
          crawling = false;
          // Close matches log file.
          try {
            logFileWriter.close();
          } catch (Exception e) {
            showError("Unable to close matches log file.");
          // Mark search as done.
          crawlingLabel2.setText("Done");
          // Enable search controls.
          startTextField.setEnabled(true);
          maxComboBox.setEnabled(true);
          limitCheckBox.setEnabled(true);
          logTextField.setEnabled(true);
          searchTextField.setEnabled(true);
          caseCheckBox.setEnabled(true);
          // Switch search button back to "Search."
          searchButton.setText("Search");
          // Return to default cursor.
          setCursor(Cursor.getDefaultCursor());
          // Show message if search string not found.
          if (table.getRowCount() == 0) {
            JOptionPane.showMessageDialog(SearchCrawler.this,
              "Your Search String was not found. Please try another.",
              "Search String Not Found",
              JOptionPane.WARNING_MESSAGE);
      thread.start();
    // Show dialog box with error message.
    private void showError(String message) {
      JOptionPane.showMessageDialog(this, message, "Error",
        JOptionPane.ERROR_MESSAGE);
    // Update crawling stats.
    private void updateStats(
      String crawling, int crawled, int toCrawl, int maxUrls)
      crawlingLabel2.setText(crawling);
      crawledLabel2.setText("" + crawled);
      toCrawlLabel2.setText("" + toCrawl);
      // Update progress bar.
      if (maxUrls == -1) {
        progressBar.setMaximum(crawled + toCrawl);
      } else {
        progressBar.setMaximum(maxUrls);
      progressBar.setValue(crawled);
      matchesLabel2.setText("" + table.getRowCount());
    // Add match to matches table and log file.
    private void addMatch(String url) {
      // Add URL to matches table.
      DefaultTableModel model =
        (DefaultTableModel) table.getModel();
      model.addRow(new Object[]{url});
      // Add URL to matches log file.
      try {
        logFileWriter.println(url);
      } catch (Exception e) {
        showError("Unable to log match.");
    // Verify URL format.
    private URL verifyUrl(String url) {
      // Only allow HTTP URLs.
      if (!url.toLowerCase().startsWith("http://"))
        return null;
      // Verify format of URL.
      URL verifiedUrl = null;
      try {
        verifiedUrl = new URL(url);
      } catch (Exception e) {
        return null;
      return verifiedUrl;
    // Check if robot is allowed to access the given URL. private boolean isRobotAllowed(URL urlToCheck) {
      String host = urlToCheck.getHost().toLowerCase();
      // Retrieve host's disallow list from cache.
      ArrayList disallowList =
        (ArrayList) disallowListCache.get(host);
      // If list is not in the cache, download and cache it.
      if (disallowList == null) {
        disallowList = new ArrayList();
        try {
          URL robotsFileUrl =
            new URL("http://" + host + "/robots.txt");
          // Open connection to robot file URL for reading.
          BufferedReader reader =
            new BufferedReader(new InputStreamReader(
              robotsFileUrl.openStream()));
          // Read robot file, creating list of disallowed paths.
          String line;
          while ((line = reader.readLine()) != null) {
            if (line.indexOf("Disallow:") == 0) {
              String disallowPath =
                line.substring("Disallow:".length());
              // Check disallow path for comments and remove if present.
              int commentIndex = disallowPath.indexOf("#");
              if (commentIndex != -1) {
                disallowPath =
                  disallowPath.substring(0, commentIndex);
              // Remove leading or trailing spaces from disallow path.
              disallowPath = disallowPath.trim();
              // Add disallow path to list.
              disallowList.add(disallowPath);
          // Add new disallow list to cache.
          disallowListCache.put(host, disallowList);
        catch (Exception e) {
          /* Assume robot is allowed since an exception
             is thrown if the robot file doesn't exist. */
          return true;
      /* Loop through disallow list to see if
         crawling is allowed for the given URL. */
      String file = urlToCheck.getFile();
      for (int i = 0; i < disallowList.size(); i++) {
        String disallow = (String) disallowList.get(i);
        if (file.startsWith(disallow)) {
          return false;
      return true;
    // Download page at given URL.
    private String downloadPage(URL pageUrl) {
      try {
        // Open connection to URL for reading.
        BufferedReader reader =
          new BufferedReader(new InputStreamReader(
            pageUrl.openStream()));
        // Read page into buffer.
        String line;
        StringBuffer pageBuffer = new StringBuffer();
        while ((line = reader.readLine()) != null) {
          pageBuffer.append(line);
        return pageBuffer.toString();
      } catch (Exception e) {
      return null;
    // Remove leading "www" from a URL's host if present.
    private String removeWwwFromUrl(String url) {
      int index = url.indexOf("://www.");
      if (index != -1) {
        return url.substring(0, index + 3) +
          url.substring(index + 7);
      return (url);
    // Parse through page contents and retrieve links.
    private ArrayList retrieveLinks(
      URL pageUrl, String pageContents, HashSet crawledList,
      boolean limitHost)
      // Compile link matching pattern.
      Pattern p =
        Pattern.compile("<a\\s+href\\s*=\\s*\"?(.*?)[\"|>]",
          Pattern.CASE_INSENSITIVE);
      Matcher m = p.matcher(pageContents);
      // Create list of link matches.
      ArrayList linkList = new ArrayList();
      while (m.find()) {
        String link = m.group(1).trim();
        // Skip empty links.
        if (link.length() < 1) {
          continue;
        // Skip links that are just page anchors.
        if (link.charAt(0) == '#') {
          continue;
        // Skip mailto links.
        if (link.indexOf("mailto:") != -1) {
          continue;
        // Skip JavaScript links.
        if (link.toLowerCase().indexOf("javascript") != -1) {
          continue;
        // Prefix absolute and relative URLs if necessary.
        if (link.indexOf("://") == -1) {
          // Handle absolute URLs.
          if (link.charAt(0) == '/') {
            link = "http://" + pageUrl.getHost() + link;
          // Handle relative URLs.
          } else {
            String file = pageUrl.getFile();
            if (file.indexOf('/') == -1) {
              link = "http://" + pageUrl.getHost() + "/" + link;
            } else {
              String path =
                file.substring(0, file.lastIndexOf('/') + 1);
              link = "http://" + pageUrl.getHost() + path + link;
        // Remove anchors from link.
        int index = link.indexOf('#');
        if (index != -1) {
          link = link.substring(0, index);
        // Remove leading "www" from URL's host if present.
        link = removeWwwFromUrl(link);
        // Verify link and skip if invalid.
        URL verifiedLink = verifyUrl(link);
        if (verifiedLink == null) {
          continue;
        /* If specified, limit links to those
          having the same host as the start URL. */
        if (limitHost &&
            !pageUrl.getHost().toLowerCase().equals(
              verifiedLink.getHost().toLowerCase())) 
          continue;
        // Skip link if it has already been crawled.
        if (crawledList.contains(link)) {
          continue;
        // Add link to list.
        linkList.add(link);
      return (linkList);
    /* Determine whether or not search string is
       matched in the given page contents. */
    private boolean searchStringMatches(
      String pageContents, String searchString,
      boolean caseSensitive)
      String searchContents = pageContents;
      /* If case-sensitive search, lowercase
         page contents for comparison. */
      if (!caseSensitive) {
        searchContents = pageContents.toLowerCase();
      // Split search string into individual terms.
      Pattern p = Pattern.compile("[\\s]+");
      String[] terms = p.split(searchString);
      // Check to see if each term matches.
      for (int i = 0; i < terms.length; i++) {
        if (caseSensitive) {
          if (searchContents.indexOf(terms) == -1) {
    return false;
    } else {
    if (searchContents.indexOf(terms[i].toLowerCase()) == -1) {
    return false;
    return true;
    // Perform the actual crawling, searching for the search string.
    public void crawl(
    String startUrl, int maxUrls, boolean limitHost,
    String searchString, boolean caseSensitive)
    // Set up crawl lists.
    HashSet crawledList = new HashSet();
    LinkedHashSet toCrawlList = new LinkedHashSet();
    // Add start URL to the to crawl list.
    toCrawlList.add(startUrl);
    /* Perform actual crawling by looping
    through the To Crawl list. */
    while (crawling && toCrawlList.size() > 0)
    /* Check to see if the max URL count has
    been reached, if it was specified.*/
    if (maxUrls != -1) {
    if (crawledList.size() == maxUrls) {
    break;
    // Get URL at bottom of the list.
    String url = (String) toCrawlList.iterator().next();
    // Remove URL from the To Crawl list.
    toCrawlList.remove(url);
    // Convert string url to URL object.
    URL verifiedUrl = verifyUrl(url);
    // Skip URL if robots are not allowed to access it.
    if (!isRobotAllowed(verifiedUrl)) {
    continue;
    // Update crawling stats.
    updateStats(url, crawledList.size(), toCrawlList.size(),
    maxUrls);
    // Add page to the crawled list.
    crawledList.add(url);
    // Download the page at the given URL.
    String pageContents = downloadPage(verifiedUrl);
    /* If the page was downloaded successfully, retrieve all its
    links and then see if it contains the search string. */
    if (pageContents != null && pageContents.length() > 0)
    // Retrieve list of valid links from page.
    ArrayList links =
    retrieveLinks(verifiedUrl, pageContents, crawledList,
    limitHost);
    // Add links to the To Crawl list.
    toCrawlList.addAll(links);
    /* Check if search string is present in
    page, and if so, record a match. */
    if (searchStringMatches(pageContents, searchString,
    caseSensitive))
    addMatch(url);
    // Update crawling stats.
    updateStats(url, crawledList.size(), toCrawlList.size(),
    maxUrls);
    // Run the Search Crawler.
    public static void main(String[] args) {
    SearchCrawler crawler = new SearchCrawler();
    crawler.show();
    }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Since i got the new Iphone 4s it constantly drops calls. Apple have replaced the phone with another new iphone 4s but i am still having the same problem. I have checked with vodapohe that there is no issue from there end, given a new sim, still drops out

    Since i got the new Iphone 4s it constantly drops calls. Apple have replaced the phone with another new iphone 4s but i am still having the same problem. I have checked with vodapohe that there is no issue from there end, given a new sim, still drops out

    Have a look at this it might help
    http://support.apple.com/kb/TS4148

  • I have a Mac book pro with regular drive, I want to replace the drive with SSD, so can I do t for Mac book pro purchased in 2012 and which SSD is recommended. I am looking for 500 to 700GB SSD.

    I have a Mac book pro(13 inch non-retina, i7) with regular drive, I want to replace the drive with SSD, so can I do it for Mac book pro purchased in 2012 and which SSD is recommended.
    I am looking for 500 to 700GB SSD.
    Thanks

    Upgrading your MacBook Pro with a Solid State Drive...
    ...call back with any questions.
    Clinton

  • Replacing the bapi with the new bapi for purchase order creation

    Hi,
       In the customised code call is there for the bapi function module  'BAPII_PO_CREATE'.
       Iam trying to replace the call with the code that calls function module 'BAPI_PO_CREATE1'.
       Please help me about what changes I needed to do in the code . As there is much mismatch in the import and export parameters
    and tables in both the function modules.
       Thanks in advance.
    Edited by: anwar.indya on Mar 25, 2011 2:18 PM
    Edited by: anwar.indya on Mar 25, 2011 2:19 PM

    Hi,
    As per  u r requirement
    you can use  : BAPI =>    BAPI_PO_CREATE  with suitable Document  Type ( Stock trasnfert : STO )
    IF  u want to auto po must be created after each delivry in this case you need to use BADI
    'MB_MIGO_BADI; In This BAPI  There is method : POST_DOCUMENT
    In this method u can write code for Auto PO Creation by using BAPI .
    Hope This will Resolve u r query.
    Thanks and Regads
    Santosh

  • How to replace the '&' character with '&' in xi

    Hi,
    i need to replace the '&' character with ' &amp;'.but i f i am converting it is displaying as '&' because internally '&amp;' = '&'.
    beacuse of this it is not converting.
    is there any possiblity to change the  standard conversion in xi.

    Graphical mapping does not support special character like & , <,> to be mapped.
    You can encode & as and in UTF-8 only.
    if you want the special character to be used, Opt XSLT mapping with ISO-8859-1 encoding
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" encoding="ISO-8859-1"/>
    <xsl:template match="/">
    <xsl:copy-of select="*" />
    </xsl:template>
    </xsl:stylesheet>
    How to Work with Character Encodings in Process Integration (NW7.0)
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/502991a2-45d9-2910-d99f-8aba5d79fb42

  • How do I replace the organiser with a new one

    How do I replace the organiser with a new one

    The problem is to understand your question (or your two questions : do you both mean the same thing ?)
    An answer to Hatstead question would help.
    1 - Do you really mean using another software to organize your workflow ?
    2 - Do you mean using other softwares based on folders rather than databases ?
    3 - Or do you mean working with different catalogs ?
    If you don't want to use the Organizer, it's not possible to 'delete' it, but it is simple not to use it.
    Most other organizing solutions include the choice of selecting PSE editor as the external editor
    There are various solutions depending on your platform : Windows, Mac, Linux...
    It's important to know if you prefer the folders or database organization to suggest possible solutions.

  • Can I replace the LCD with an LED on Early 2009 24" model?

    I have an old 2009 (okay, so not that old) iMac and the LCD has some serious burn-in and it's to the point where I can't use the computer without it hurting my eyes. I'm looking to replace the screen, but the computer still works great and I don't want to have to do this again in four to five years. Any chance I can take an LED display from a 24" Cinema Display and put it in the iMac, or are the connections different?

    Personally I would use a Mini DisplayPort to DVI Adapter, DVI cable and a $130 DVI monitor, before shelling out for a $500 to $600 for a replacement panel. Or at least until your 100% sure, that there is nothing wrong with the logicboard or graphic's chip.
    Optionally a Belkin Mini DisplayPort to HDMI Cable would be an even cheaper setup, if you already have an HDMI TV.
    Addtitionally I would probably just replace the iMac with another iMac or Mac Mini, because it is real hard to justify spending anything at all on a 5 year old system.

  • How can I remove a person's face from a photo and then replace the spot with a person's face from another photo?

    How can I remove a person's face from a photo and then replace the spot with a person's face from another photo?

    In Editor, go to the expert tab.
    Open picture B, the one you wish to select the "replacement" face from to add to another picture.
    Use one of the selection tools, e.g. selection brush, lasso tool, to select the face. You will see an outline ("marching ants") once the selection is complete
    Go to Edit menu>copy to copy the selection to the clipboard
    Open picture A, then go to Edit>paste
    Use the move tool to position the face from picture B to cover the face on A
    In the layers palette you should see picture A as the background layer, and face B on a separate layer

  • How can I replace the Portal with completely new Flash website?

    Can I replace the Portal with completely new Flash website? My customer do not want the JSP UI. Instead, he wants a completely new designed Flash site. Is it possible to do it? How can I deploy a new portal to cover the current one?

    If you have a look at some of the code examples which do the equivalent of site maps, you could in theory replace the whole portal desktop with some sort of Flash framework which reads the user's role structure at run time.
    I think it is useful to remember that the SAP portal is primarily a business application launchpad. It does that very well. Trying to make it into a Flash launchpad will be challenging.

  • My iphone has fallen into the water 6months ago and there is no apple store in my country so i gave the phone s technical service.but they couldnt repair the phone.and now the battery is swollen.can i replace the phone with the new one in spain?

    My iphone has fallen into the water 6months ago and there is no apple store in my country so i gave the phone s technical service.but they couldnt repair the phone.and now the battery is swollen.can i replace the phone with the new one in spain?

    You can only obtain warranty OR post warranty service in the country of original purchase
    As your iPhone has user damage it has no warranty
    IF the iPhone originated from Spain or another EU country you can get out of warranty service in any EU country

  • Qosmio X500-10W - Can I replace the HDD with another one?

    Hello
    I have a Qosmio X500-10W with two HDD Toshiba MK5055GSX 500GB 5400RPM 8MB ??SATA II but is one of hs so I wonder if I can be replaced by a more powerful style HDD 750GB 7200tr / min 16MB Toshiba course?
    merci

    Hey,
    Your question is a little bit hard to understand but I think you want to replace the HDD with another (faster) model, right?
    Well, thats no problem. HDDs with 7200rpm will work, they are a little bit louder but they are faster so if you need more performance no problem.
    Also 750GB or more is no problem because SATA interface is not capacity limited. Theoretically 1TB or more should also work.
    Anyway, you can buy the 750GB you mentioned it will work. :)

  • Since Mavericks, the scroll-with-modifier-key-to-zoom functionality often fails, and I have to deselect it and reselect it in the accessibility pref-pane to get it working again.

    Since Mavericks, the scroll-with-modifier-key-to-zoom functionality often fails, and I have to deselect it and reselect it in the accessibility pref-pane to get it working again.

    Take it to your local Apple Store or AASP, it's covered by a 1 year hardware warranty. If you have AppleCare then give them a call but I'm pretty sure they will advise the same. If you have not purchased AppleCare yet please do, this will extend the warranty to 3 years however it MUST be purchased within the first  year of ownership. Let it go 366 days and you are out of luck. AppleCare will also include telephone support too.
    Good luck.

Maybe you are looking for

  • External backup of iTunes Library

    My itunes library is on an external drive. I would like to move it back to my iMac internal drive so carbonite can back it up, BUT..I believe there are two files I need to relocate, or do I just indicate in iTunes that there is a new location for the

  • File Dates

    I wanted to share my experiences with Windows 7 and the writing of different types of file. I was writing a LabVIEW application for generating a HTMP report, consisting of a HTML file individial PNG files for each chart. Whenever I run my report gene

  • Quest

    Hi, What is the main diff between  Select options and ranges? Thanks in advance Rgds venugopal

  • Submission to App Store Doesn't show Bundle ID from Flex iOS App

    We built an iOS app using Flashbuilder 4.6 and Air 3.6.  We provisioned iPads successfully and deployed to the devices. Everything worked great.  When we attempted to submit the app to the Apple iTunes Connect didn't show our Bundle ID in it's drop d

  • Troubles with first Gen ipad

    Hello all, I just received a first generation ipad and I'm having a few problems with it. The ipad was sitting in an office drawer for a long time. Today, I plugged it into an ipad charger, and it was charging super slow (after about 6 hours, was at