org.specrunner.plugins.core.include
Class PluginInclude

java.lang.Object
  extended by org.specrunner.parameters.core.ParameterHolder
      extended by org.specrunner.plugins.core.AbstractPlugin
          extended by org.specrunner.plugins.core.include.PluginInclude
All Implemented Interfaces:
IParameterHolder, IActionType, IParalelPlugin, IPlugin, ISleepPlugin, ITestPlugin, ITimedPlugin, IWaitPlugin

public class PluginInclude
extends AbstractPlugin

Allow a file inclusion.

Example:

Perform plugin as in login.html.

The CSS annotated version:

 Perform plugin as in <a href="#" class="include">login.html</a>.
 

Author:
Thiago Santos

Nested Class Summary
protected  class PluginInclude.ResolverDefault
          Basic resolver implementation.
 
Field Summary
static String CSS_INCLUDED
          Style added to included file.
static String CSS_INCLUDED_ARGS
          Style added to args.
static String CSS_INCLUDED_CONTENT
          Style added to content file.
static String CSS_INCLUDED_FILE
          Style added to the header file.
static Integer DEFAULT_DEPTH
          Default value.
static Boolean DEFAULT_EXPANDED
          Default include expanded state.
protected  Integer depth
          Max depth of inclusion.
protected  Boolean expanded
          Expanded state.
static String FEATURE_DEPTH
          Max deep of includes.
static String FEATURE_EXPANDED
          Enable expanded mode for features.
static String FEATURE_RESOLVER
          Resolver of URIs.
static String FEATURE_TRANSFORMER
          Transformer type as feature.
protected  String href
          Link to file.
protected  IResolver resolver
          Relative URI resolver.
protected  String transformer
          Transformer to be used after loading in addiction to the general transformer.
 
Fields inherited from class org.specrunner.plugins.core.AbstractPlugin
FEATURE_CONDITION, FEATURE_NORMALIZED, FEATURE_SLEEP, FEATURE_THREADSAFE, FEATURE_TIMEOUT, FEATURE_WAIT
 
Constructor Summary
PluginInclude()
           
 
Method Summary
protected  nu.xom.Node bindParameters(IContext context)
          Normalize path removing parameters which are set as arguments.
 ENext doStart(IContext context, IResultSet result)
          Performs the start action. i.e. create a database schema.
 ActionType getActionType()
          Get the plugin type.
 Integer getDepth()
          The max depth allowed for inclusion files.
 String getDir()
          The input directory.
protected  nu.xom.Document getDocument(ISource newSource)
          Get document from source.
 Boolean getExpanded()
          Gets the status expected for inclusion.
 String getHref()
          The link reference.
protected  String getPath(IContext context)
          Normalize path removing parameters.
 IResolver getResolver()
          Resolver of relative links.
protected  ISource getSource(URI newHref)
          Get source from a URI.
 String getTransformer()
          Get the transformer field.
 void initialize(IContext context)
          Initialize the plugin.
 void setDepth(Integer depth)
          Set max depth.
 void setDir(String dir)
          Output directory file.
 void setExpanded(Boolean expanded)
          Set expanded mode.
 void setHref(String href)
          Set link reference.
 void setResolver(IResolver resolver)
          Change the resolver.
 void setTransformer(String transformer)
          Set the transformer.
protected  StringBuilder toString(IContext context)
          Cycle as string.
protected  ISource transform(ISource newSource)
          Perform source transformation.
 
Methods inherited from class org.specrunner.plugins.core.AbstractPlugin
copy, doEnd, getCondition, getConditionModel, getNormalized, getNormalized, getParent, getSleep, getSleepModel, getThreadsafe, getTimeout, getTimeoutModel, getWait, getWaitModel, setCondition, setConditionModel, setNormalized, setParent, setSleep, setSleepModel, setThreadsafe, setTimeout, setTimeoutModel, setWait, setWaitModel, toString
 
Methods inherited from class org.specrunner.parameters.core.ParameterHolder
getParameters, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.specrunner.parameters.IParameterHolder
getParameters, setParameters
 

Field Detail

CSS_INCLUDED

public static final String CSS_INCLUDED
Style added to included file.

See Also:
Constant Field Values

CSS_INCLUDED_FILE

public static final String CSS_INCLUDED_FILE
Style added to the header file.

See Also:
Constant Field Values

CSS_INCLUDED_ARGS

public static final String CSS_INCLUDED_ARGS
Style added to args.

See Also:
Constant Field Values

CSS_INCLUDED_CONTENT

public static final String CSS_INCLUDED_CONTENT
Style added to content file.

See Also:
Constant Field Values

href

protected String href
Link to file.


FEATURE_DEPTH

public static final String FEATURE_DEPTH
Max deep of includes.


DEFAULT_DEPTH

public static final Integer DEFAULT_DEPTH
Default value.


depth

protected Integer depth
Max depth of inclusion.


FEATURE_EXPANDED

public static final String FEATURE_EXPANDED
Enable expanded mode for features.


DEFAULT_EXPANDED

public static final Boolean DEFAULT_EXPANDED
Default include expanded state.


expanded

protected Boolean expanded
Expanded state.


FEATURE_TRANSFORMER

public static final String FEATURE_TRANSFORMER
Transformer type as feature.


transformer

protected String transformer
Transformer to be used after loading in addiction to the general transformer.


FEATURE_RESOLVER

public static final String FEATURE_RESOLVER
Resolver of URIs.


resolver

protected IResolver resolver
Relative URI resolver.

Constructor Detail

PluginInclude

public PluginInclude()
Method Detail

getDir

public String getDir()
The input directory.

Returns:
The directory.

setDir

public void setDir(String dir)
Output directory file.

Parameters:
dir - The directory.

getHref

public String getHref()
The link reference.

Returns:
The link.

setHref

public void setHref(String href)
Set link reference.

Parameters:
href - The reference.

getDepth

public Integer getDepth()
The max depth allowed for inclusion files.

Returns:
The max depth on inclusion macro expansion. i.e. To perform only Google web page set depth='1', otherwise all web be be macro expanded.

setDepth

public void setDepth(Integer depth)
Set max depth.

Parameters:
depth - The depth.

getExpanded

public Boolean getExpanded()
Gets the status expected for inclusion.

Returns:
true, if node might be shown expanded after inclusion, false, if collapsed. IMPORTANT: on errors in included files the expended mode will be overridden to expanded=true.

setExpanded

public void setExpanded(Boolean expanded)
Set expanded mode.

Parameters:
expanded - The expanded value.

getTransformer

public String getTransformer()
Get the transformer field.

Returns:
The transformer.

setTransformer

public void setTransformer(String transformer)
Set the transformer.

Parameters:
transformer - The transformer.

getResolver

public IResolver getResolver()
Resolver of relative links.

Returns:
The current resolver.

setResolver

public void setResolver(IResolver resolver)
Change the resolver.

Parameters:
resolver - A resolver.

getActionType

public ActionType getActionType()
Description copied from interface: IActionType
Get the plugin type.

Returns:
The type.

initialize

public void initialize(IContext context)
                throws PluginException
Description copied from interface: IPlugin
Initialize the plugin. Performed after set parameters.

Specified by:
initialize in interface IPlugin
Overrides:
initialize in class AbstractPlugin
Parameters:
context - The test context.
Throws:
PluginException - On initialization errors.

doStart

public ENext doStart(IContext context,
                     IResultSet result)
              throws PluginException
Description copied from interface: IPlugin
Performs the start action. i.e. create a database schema. Performed after initialization.

Specified by:
doStart in interface IPlugin
Overrides:
doStart in class AbstractPlugin
Parameters:
context - The context.
result - The result set.
Returns:
SKIP, to skip node, DEEP, to go deep into the node.
Throws:
PluginException - On execution errors.

getSource

protected ISource getSource(URI newHref)
                     throws PluginException
Get source from a URI.

Parameters:
newHref - The URI.
Returns:
The corresponding source.
Throws:
PluginException - On reading errors.

getDocument

protected nu.xom.Document getDocument(ISource newSource)
                               throws PluginException
Get document from source.

Parameters:
newSource - The source.
Returns:
The corresponding document.
Throws:
PluginException - On load errors.

transform

protected ISource transform(ISource newSource)
                     throws PluginException
Perform source transformation.

Parameters:
newSource - Source to be transformed.
Returns:
Transformed source, if applied, the original source, otherwise.
Throws:
PluginException - On transform errors.

bindParameters

protected nu.xom.Node bindParameters(IContext context)
                              throws PluginException
Normalize path removing parameters which are set as arguments.

Parameters:
context - The context.
Returns:
The path to file normalized.
Throws:
PluginException - On plugin errors.

getPath

protected String getPath(IContext context)
                  throws PluginException
Normalize path removing parameters.

Parameters:
context - The context.
Returns:
The path to file normalized.
Throws:
PluginException - On plugin errors.

toString

protected StringBuilder toString(IContext context)
Cycle as string.

Parameters:
context - The context.
Returns:
The path to cycle.


Copyright © 2014. All rights reserved.