View Javadoc

1   /*
2       Jiffie Plugin for Jameleon - An Internet Explorer plug-in for Jameleon
3       Copyright (C) 2006 Christian W. Hargraves (engrean@hotmail.com)
4                          and Pravin Bhujbal (pravinbhujbal@gmail.com) 
5   
6       This program is free software; you can redistribute it and/or modify
7       it under the terms of the GNU General Public License as published by
8       the Free Software Foundation; either version 2 of the License, or
9       (at your option) any later version.
10  
11      This program is distributed in the hope that it will be useful,
12      but WITHOUT ANY WARRANTY; without even the implied warranty of
13      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14      GNU General Public License for more details.
15  
16      You should have received a copy of the GNU General Public License
17      along with this program; if not, write to the Free Software
18      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20  package net.sf.jameleon.plugin.jiffie.tags;
21  
22  import net.sf.jameleon.bean.MatchingTextHelper;
23  import net.sf.jameleon.util.TextMatcher;
24  
25  import net.sf.jameleon.plugin.jiffie.IEFunctionTag;
26  
27  /***
28   * Gets the matching text against the currently active IE and sets it in the context.
29   *
30   * @author Pravin Bhujbal
31   * @author Christian Hargraves
32   * @jameleon.function name="ie-get-matching-text" type="action"
33   * @jameleon.step Find the given regular expression in the current document
34   * @jameleon.step Store the matching text in the provided variable name.
35   */
36  public class IEGetMatchingTextTag extends IEFunctionTag implements TextMatcher {
37      /***
38       * The name by which a context variable will be created
39       *  
40       * @jameleon.attribute contextName="ieGetMatchinTextVarName"
41       */
42      protected String varName;
43      /***
44       * The pattern which is to be used to extract the data from the repsonse
45       * 
46       * @jameleon.attribute contextName="ieGetMatchinTextRegex"
47       */
48      protected String regex;
49      /***
50       * The group number (based on parenthesis) to extract the data from.
51       * For example, the following regex has two different groups:
52       * (Some text ([//d]+))
53       * 
54       * The first group would be the entire expression. The second group would be
55       * only the matching numbers.
56       * @jameleon.attribute contextName="ieGetMatchinTextRegexGroup"
57       */
58      protected int regexGroup;
59  
60      public void testBlock(){
61          MatchingTextHelper helper = new MatchingTextHelper(this);
62          helper.setMatchingTextInContext(varName, regex, regexGroup);
63      }
64  
65      /***
66       * Get the text representing the current screen.
67       * 
68       * @return String - the text representing the current screen.
69       */
70      public String getCurrentScreenAsText(){
71          return getHTMLSource();
72      }
73  
74  
75  }