FileDocCategorySizeDatePackage
XalanExecutor.javaAPI DocApache Ant 1.705416Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.taskdefs.optional.junit

XalanExecutor

public abstract class XalanExecutor extends Object
This class is not used by the framework any more. We plan to remove it in Ant 1.8
deprecated
since Ant 1.7

Fields Summary
private static final String
PACKAGE
protected AggregateTransformer
caller
the transformer caller
Constructors Summary
Methods Summary
abstract voidexecute()
override to perform transformation

protected abstract java.lang.StringgetImplementation()
This methods should return the classname implementation of the underlying xslt processor

return
the classname of the implementation, for example: org.apache.xalan.processor.TransformerFactoryImpl
see
#getProcVersion(String)

protected final java.io.OutputStreamgetOutputStream()
get the appropriate stream based on the format (frames/noframes)

        if (AggregateTransformer.FRAMES.equals(caller.format)) {
            // dummy output for the framed report
            // it's all done by extension...
            return new ByteArrayOutputStream();
        } else {
            return new BufferedOutputStream(
                new FileOutputStream(new File(caller.toDir, "junit-noframes.html")));
        }
    
protected abstract java.lang.StringgetProcVersion(java.lang.String classNameImpl)
Try to discover the xslt processor version based on the className. There is nothing carved in stone and it can change anytime, so this is just for the sake of giving additional information if we can find it.

param
classNameImpl the classname of the underlying xslt processor
return
a string representing the implementation version.
throws
BuildException

protected final java.lang.StringgetXSLTCVersion(java.lang.String procVersionClassName)
a bit simplistic but xsltc data are conveniently private non final

        // there's a convenient xsltc class version but data are
        // private so use package information
        Class procVersion = Class.forName(procVersionClassName);
        Package pkg = procVersion.getPackage();
        return pkg.getName() + " " + pkg.getImplementationTitle()
            + " " + pkg.getImplementationVersion();
    
protected final java.lang.StringgetXalanVersion(java.lang.String procVersionClassName)
pretty useful data (Xalan version information) to display.

        Class procVersion = Class.forName(procVersionClassName);
        String pkg = procVersion.getPackage().getName();
        try {
            Field f = procVersion.getField("S_VERSION");
            return pkg + " " + f.get(null).toString();
        } catch (Exception e) {
            return pkg + " ?.?";
        }
    
static org.apache.tools.ant.taskdefs.optional.junit.XalanExecutornewInstance(AggregateTransformer caller)
Create a valid Xalan executor. It checks if Xalan2 is present. If none is available, it fails.

param
caller object containing the transformation information.
throws
BuildException thrown if it could not find a valid xalan executor.

        XalanExecutor executor = null;
        try {
            Class clazz = Class.forName(PACKAGE + "Xalan2Executor");
            executor = (XalanExecutor) clazz.newInstance();
        } catch (Exception xsltcApacheMissing) {
            caller.task.log(xsltcApacheMissing.toString());
                throw new BuildException("Could not find xstlc nor xalan2 "
                                         + "in the classpath. Check "
                                         + "http://xml.apache.org/xalan-j");
        }
        String classNameImpl = executor.getImplementation();
        String version = executor.getProcVersion(classNameImpl);
        caller.task.log("Using " + version, Project.MSG_VERBOSE);
        executor.setCaller(caller);
        return executor;
    
private voidsetCaller(AggregateTransformer caller)
set the caller for this object.

    // CheckStyle:VisibilityModifier ON

           
        
        this.caller = caller;