Exemple #1
0
 public static List<Parameter> getFirstFormElements(String html) {
   Source source = new Source(html);
   List<Element> elements = source.findAllElements(Tag.FORM);
   if (elements == null || elements.size() == 0) return null;
   List<Parameter> params = new ArrayList<Parameter>();
   Element el = elements.get(0);
   List<FormControl> formControls = el.findFormControls();
   for (FormControl fc : formControls) {
     if (fc.getName() != null && fc.getName().equals("GAPCOSTS"))
       System.out.println(fc.getName() + " values size=" + fc.getValues().size());
     Collection values = fc.getValues();
     if (values.size() > 0 && fc.getName() != null) {
       Parameter p = new Parameter(fc.getName(), (String) values.iterator().next());
       params.add(p);
     }
   }
   return params;
 }
Exemple #2
0
 public static List<Parameter> getFormatFormElements(String html) {
   Source source = new Source(html);
   List<Element> elements = source.findAllElements(Tag.FORM);
   List<Parameter> params = new ArrayList<Parameter>();
   for (Element el : elements) {
     String fname = el.getAttributeValue("name");
     if (fname != null && fname.equals("RequestFormat")) {
       List<FormControl> formControls = el.findFormControls();
       for (FormControl fc : formControls) {
         Collection values = fc.getValues();
         if (values.size() > 0 && fc.getName() != null) {
           Parameter p = new Parameter(fc.getName(), (String) values.iterator().next());
           params.add(p);
         }
       }
       return params;
     }
   }
   return null;
 }
Exemple #3
0
  public static List<Parameter> getNextIterFormElements(String html) {
    Source source = new Source(html);
    List<Element> forms = source.findAllElements(Tag.FORM);

    //    System.out.println("forms.size="+forms.size());

    Element theFormWeNeed = null;
    for (Element el : forms) {
      //       System.out.println("----------------------------FORM---------------------------");
      List<FormControl> formControls = el.findFormControls();
      for (FormControl fc : formControls) {

        Collection values = fc.getValues();
        //        System.out.println(fc.getName()+"="+fc.getValues());
        if (fc.getName() != null && fc.getName().equals("NEXT_I")) {
          theFormWeNeed = el;
          break;
        }
      }
    }

    if (theFormWeNeed == null) {
      throw new RuntimeException("Could not find the iteration form needed");
    }

    List<Parameter> params = new ArrayList<Parameter>();
    List<FormControl> formControls = theFormWeNeed.findFormControls();

    for (FormControl fc : formControls) {
      //      System.out.println("name="+fc.getName() + " value="+fc.getValues());
      Collection values = fc.getValues();
      if (values.size() > 0 && fc.getName() != null) {
        Parameter p = new Parameter(fc.getName(), (String) values.iterator().next());
        params.add(p);
      }
    }
    System.out.println("params.size=" + params.size());
    return params;
  }
  private Vector getMessages(String file) throws Exception {
    file = util_format.replace(file, "//", "/");
    Vector result = new Vector();
    String sourceUrlString = file;

    PHPTagTypes.register();
    PHPTagTypes.PHP_SHORT.deregister();
    MasonTagTypes.register();
    String test = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\"/>\n";
    test += getURLContent(sourceUrlString);

    //	Source source=new Source(new URL(sourceUrlString));
    Source source = new Source(test.subSequence(0, test.length()));
    source.setLogWriter(new OutputStreamWriter(System.err)); // send log messages to stderr
    source.fullSequentialParse();
    List elementList = source.findAllElements();
    HashMap jspParamDesc = new HashMap();
    for (Iterator i = elementList.iterator(); i.hasNext(); ) {
      Element element = (Element) i.next();
      if (element.getName().indexOf("bs:message") == 0) {
        Attributes atts = element.getAttributes();
        if (atts != null && atts.get("code") != null) {
          message mes = new message();
          mes.setCD_MESS(atts.get("code").getValue());
          mes.setCD_LANG("IT");
          try {
            mes.setDESC_MESS(atts.get("defaultValue").getValue());
          } catch (Exception e) {
          }
          result.add(mes);
        }
      }
      if (element.getName().indexOf("jsp:param") == 0) {
        Attributes atts = element.getAttributes();
        if (atts != null
            && atts.get("name") != null
            && atts.get("name").getValue().indexOf("code_tab_desc") == 0) {
          jspParamDesc.put(
              util_format.replace(atts.get("name").getValue(), "code_tab_desc", "def_tab_desc"),
              atts.get("value").getValue());
        }
        if (atts != null
            && atts.get("name") != null
            && atts.get("name").getValue().indexOf("def_tab_desc") == 0) {
          String code = (String) jspParamDesc.get(atts.get("name").getValue());
          if (code != null) {
            message mes = new message();
            mes.setCD_MESS(code);
            mes.setCD_LANG("IT");
            try {
              mes.setDESC_MESS(atts.get("value").getValue());
            } catch (Exception e) {
            }
            result.add(mes);
            jspParamDesc.remove(atts.get("name").getValue());
          }
        }
      }
      if (element.getName().indexOf("bs:show_lm_actionlabel") == 0) {
        Attributes atts = element.getAttributes();
        if (atts != null && atts.get("message_code") != null) {
          message mes = new message();
          mes.setCD_MESS(atts.get("message_code").getValue());
          mes.setCD_LANG("IT");
          try {
            mes.setDESC_MESS(atts.get("message_defaultValue").getValue());
          } catch (Exception e) {
          }
          result.add(mes);
        }
      }
      if (element.getName().indexOf("element") == 0
          || element.getName().indexOf("form-redirect") == 0) {
        Attributes atts = element.getAttributes();
        if (atts != null && atts.get("mess_id") != null) {
          message mes = new message();
          mes.setCD_MESS(atts.get("mess_id").getValue());
          mes.setCD_LANG("IT");
          try {
            mes.setDESC_MESS(atts.get("descr").getValue());
          } catch (Exception e) {
          }
          result.add(mes);
        }
      }
    }

    return result;
  }