Package org.webharvest.runtime.variables

Examples of org.webharvest.runtime.variables.NodeVariable


            if (item == null) {
                break;
            }

            XmlNodeWrapper value = new XmlNodeWrapper(item);
            listVariable.addVariable( new NodeVariable(value) );
        }

        return listVariable;
    }
View Full Code Here


            return new ListVariable(new ArrayList(collection));
        } else if (value instanceof Object[]) {
            List list = Arrays.asList( (Object[]) value );
            return new ListVariable(list);
        } else {
            return new NodeVariable(value);
        }
    }
View Full Code Here

     * before execution starts.
     * @param name
     * @param value
     */
    public void addVariableToContext(String name, Object value) {
        this.context.put(name, new NodeVariable(value));
    }
View Full Code Here

    public void addVariablesToContext(Map map) {
        if (map != null) {
            Iterator iterator = map.entrySet().iterator();
            while (iterator.hasNext()) {
                Map.Entry entry = (Map.Entry) iterator.next();
                this.context.put( entry.getKey(), new NodeVariable(entry.getValue()) );
            }
        }
    }
View Full Code Here

                if (maxLoops < index) {
                    break;
                }

              for (int i = 0; i <= groupCount; i++) {
                context.put("_"+i, new NodeVariable(matcher.group(i)));
              }

                BaseElementDef resultDef = regexpDef.getRegexpResultDef();
                Variable result = getBodyTextContent(resultDef, scraper, context, true);
                debug(resultDef, scraper, result);
               
                String currResult = (result == null) ? matcher.group(0) : result.toString();
              if (isReplace) {
                matcher.appendReplacement(buffer, currResult);
              } else {
                resultList.add(new NodeVariable(currResult));
              }
             
              for (int i = 0; i <= groupCount; i++) {
                context.remove("_"+i);
              }
            }
           
            if (isReplace) {
            matcher.appendTail(buffer);
            resultList.add(new NodeVariable(buffer.toString()));
          }
        }
       

        return new ListVariable(resultList);
View Full Code Here

        Source request  = new StreamSource( new StringReader(xmlStr.toString()) );
        StringWriter writer = new StringWriter();
        Result response = new StreamResult(writer);
        stylesheet.transform(request, response);
       
        return new NodeVariable(writer.toString());
      } catch (TransformerException e) {
        throw new XsltException("Error during XSLT transforming!", e);
      }
    }
View Full Code Here

                result = new BrowserCompactXmlSerializer(properties).getXmlAsString(node);
            else {
                result = new CompactXmlSerializer(properties).getXmlAsString(node);
            }

            return new NodeVariable(result);
        } catch (IOException e) {
            throw new ParserException(e);
        }
    }
View Full Code Here

                text = new String(responseBody, charset);
            } catch (UnsupportedEncodingException e) {
                throw new HttpException("Charset " + charset + " is not supported!", e);
            }
           
            result =  new NodeVariable(text);
        } else {
            result = new NodeVariable(responseBody);
        }

        this.setProperty("URL", url);
        this.setProperty("Method", method);
        this.setProperty("Multipart", String.valueOf(isMultipart));
View Full Code Here

        }
        ScriptEngine scriptEngine = language == null ? scraper.getScriptEngine() : scraper.getScriptEngine(language);

        String result = BaseTemplater.execute(body.toString(), scriptEngine);
       
        return new NodeVariable(result);
    }
View Full Code Here

        super(constantDef);
        this.constantDef = constantDef;
    }

    public Variable execute(Scraper scraper, ScraperContext context) {
    return new NodeVariable( constantDef.getText() );
    }
View Full Code Here

TOP

Related Classes of org.webharvest.runtime.variables.NodeVariable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.