hudson.plugins.violations.parse
Class ViolationsDOMParser

java.lang.Object
  extended by hudson.plugins.violations.parse.ViolationsDOMParser
All Implemented Interfaces:
ViolationsParser
Direct Known Subclasses:
CPDParser

public abstract class ViolationsDOMParser
extends java.lang.Object
implements ViolationsParser


Constructor Summary
ViolationsDOMParser()
           
 
Method Summary
 java.lang.String checkNotBlank(org.w3c.dom.Element el, java.lang.String attribute)
          Get an attribute.
protected abstract  void execute()
           
protected  java.lang.String fixAbsolutePath(java.lang.String abs)
          Fix an absolute path.
 org.w3c.dom.Document getDocument()
          Get the parsed document.
protected  FullFileModel getFileModel(java.lang.String absoluteName)
          Get the full file model object for an absolute name.
protected  FullFileModel getFileModel(java.lang.String name, java.io.File sourceFile)
          Get the full file model for a particular relative name and source file.
 int getInt(org.w3c.dom.Element el, java.lang.String attribute)
          Get an int from an attribute.
protected  FullBuildModel getModel()
          Get the build model.
protected  java.io.File getProjectPath()
          Get the project path.
protected  java.lang.String[] getSourcePaths()
          Get the source paths.
 void parse(FullBuildModel model, java.io.File projectPath, java.lang.String fileName, java.lang.String[] sourcePaths)
          Parse a violations file.
protected  java.lang.String resolveName(java.lang.String absoluteName)
          Resolve an absolute name agaist the project path.
 void setModel(FullBuildModel model)
          Set the build model.
 void setProjectPath(java.io.File projectPath)
          Set the project path.
 void setSourcePaths(java.lang.String[] sourcePaths)
          Set the source paths attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViolationsDOMParser

public ViolationsDOMParser()
Method Detail

getDocument

public org.w3c.dom.Document getDocument()
Get the parsed document.

Returns:
the document.

parse

public void parse(FullBuildModel model,
                  java.io.File projectPath,
                  java.lang.String fileName,
                  java.lang.String[] sourcePaths)
           throws java.io.IOException
Description copied from interface: ViolationsParser
Parse a violations file.

Specified by:
parse in interface ViolationsParser
Parameters:
model - the model to store the violations in.
projectPath - the project path used for resolving paths.
fileName - the name of the violations file to parse (relative to the projectPath).
sourcePaths - a list of source paths to resolve classes against
Throws:
java.io.IOException - if there is an error.

execute

protected abstract void execute()
                         throws java.io.IOException,
                                java.lang.Exception
Throws:
java.io.IOException
java.lang.Exception

setModel

public void setModel(FullBuildModel model)
Set the build model.

Parameters:
model - the model.

getModel

protected FullBuildModel getModel()
Get the build model.

Returns:
the build model.

setProjectPath

public void setProjectPath(java.io.File projectPath)
Set the project path. This is used to get a relative name for files.

Parameters:
projectPath - the project path.

getProjectPath

protected java.io.File getProjectPath()
Get the project path.

Returns:
the project path.

setSourcePaths

public void setSourcePaths(java.lang.String[] sourcePaths)
Set the source paths attribute. This is used to resolve classes against.

Parameters:
sourcePaths - the value to use

getSourcePaths

protected java.lang.String[] getSourcePaths()
Get the source paths.

Returns:
the source paths.

getFileModel

protected FullFileModel getFileModel(java.lang.String name,
                                     java.io.File sourceFile)
Get the full file model for a particular relative name and source file.

Parameters:
name - the relative file name.
sourceFile - the source file for the file.
Returns:
the full file model.

getFileModel

protected FullFileModel getFileModel(java.lang.String absoluteName)
Get the full file model object for an absolute name.

Parameters:
absoluteName - the absolute name of the file.
Returns:
the file model object.

fixAbsolutePath

protected java.lang.String fixAbsolutePath(java.lang.String abs)
                                    throws java.io.IOException
Fix an absolute path. Some paths in some violations file contain a .. this causes grief.

Parameters:
abs - the absolute name.
Returns:
a fixed name.
Throws:
java.io.IOException - if there is a problem.

resolveName

protected java.lang.String resolveName(java.lang.String absoluteName)
Resolve an absolute name agaist the project path.

Parameters:
absoluteName - the absolute name.
Returns:
a path relative to the project path or an absolute name if the name cannot be resolved.

getInt

public int getInt(org.w3c.dom.Element el,
                  java.lang.String attribute)
Get an int from an attribute.

Returns:
the int or 0 if it does not exist or is malformed.

checkNotBlank

public java.lang.String checkNotBlank(org.w3c.dom.Element el,
                                      java.lang.String attribute)
                               throws java.lang.Exception
Get an attribute.

Returns:
the attribute value.
Throws:
java.lang.Exception - if the attribute is not there or is blank.


Copyright © 2004-2012. All Rights Reserved.