hudson.plugins.covcomplplot.util
Class CovComplPlotUtil

java.lang.Object
  extended by hudson.plugins.covcomplplot.util.CovComplPlotUtil

public class CovComplPlotUtil
extends Object

Utility Class for various data process

Author:
JunHo Yoon

Field Summary
static org.dom4j.DocumentFactory factory
          DocumentFactory to handler namespace in the xml file
static Map<String,String> templateCache
           
 
Constructor Summary
CovComplPlotUtil()
           
 
Method Summary
static int compareVersion(String v1, String v2)
          Compare version string
static hudson.FilePath[] findFile(hudson.FilePath basePath, String pattern)
          Find files matching given pattern from given base path
static String getClassResourcePath(Class<?> clazz, String extension)
          get corresponding class resource file path from the folder where the class is in.
static String getFileAsString(String location)
          Read file from given location and return string.
static org.dom4j.Document getXmlFileDocument(InputStream stream)
          Get Document instance by parsing given stream.
static org.dom4j.Document getXmlFileDocument(InputStream stream, org.dom4j.DocumentFactory factory)
          Get Document instance by parsing given stream.
static org.dom4j.Element getXPathNode(org.dom4j.Node node, String xpathStr)
          Get single xpath matching nodes.
static List<org.dom4j.Element> getXPathNodeList(org.dom4j.Node node, String xpathStr)
          Get all xpath matching nodes.
static String getXPathNodeText(org.dom4j.Node node, String xpathStr)
          Get first matching string value from the given node by searching given xpath.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

public static org.dom4j.DocumentFactory factory
DocumentFactory to handler namespace in the xml file


templateCache

public static Map<String,String> templateCache
Constructor Detail

CovComplPlotUtil

public CovComplPlotUtil()
Method Detail

getXPathNodeText

public static String getXPathNodeText(org.dom4j.Node node,
                                      String xpathStr)
                               throws NoXPathContentException
Get first matching string value from the given node by searching given xpath.

Parameters:
node - the node from which xpath search starts.
xpathStr - XPath String
Returns:
found string
Throws:
NoXPathContentException - occurs XPath is incorrect or nothing can be found.

getXPathNodeList

public static List<org.dom4j.Element> getXPathNodeList(org.dom4j.Node node,
                                                       String xpathStr)
Get all xpath matching nodes.

Parameters:
node - node from which xpath search starts
xpathStr - XPath String
Returns:
found node list

getXPathNode

public static org.dom4j.Element getXPathNode(org.dom4j.Node node,
                                             String xpathStr)
                                      throws NoXPathContentException
Get single xpath matching nodes.

Parameters:
node - node from which xpath search starts
xpathStr - XPath String
Returns:
found node
Throws:
NoXPathContentException - occurs when no matching.

getXmlFileDocument

public static org.dom4j.Document getXmlFileDocument(InputStream stream,
                                                    org.dom4j.DocumentFactory factory)
                                             throws org.dom4j.DocumentException
Get Document instance by parsing given stream.

Parameters:
stream - inputStream
factory - DocumentFactory instance to handle namespace
Returns:
Document instance
Throws:
org.dom4j.DocumentException - occurs when wrong xml is provided.

getXmlFileDocument

public static org.dom4j.Document getXmlFileDocument(InputStream stream)
                                             throws org.dom4j.DocumentException
Get Document instance by parsing given stream.

Parameters:
stream - inputStream
Returns:
Document instance
Throws:
org.dom4j.DocumentException - occurs when wrong xml is provided.

findFile

public static hudson.FilePath[] findFile(hudson.FilePath basePath,
                                         String pattern)
Find files matching given pattern from given base path

Parameters:
basePath - base path from which the search starts
pattern - file matching pattern
Returns:
matched FilePath array.

getClassResourcePath

public static String getClassResourcePath(Class<?> clazz,
                                          String extension)
get corresponding class resource file path from the folder where the class is in.

Parameters:
clazz - class
extension - file extension to be added
Returns:
resource path

compareVersion

public static int compareVersion(String v1,
                                 String v2)
Compare version string

Parameters:
v1 - version1
v2 - version2
Returns:
-1 if less, 0 if same, 1 if more

getFileAsString

public static String getFileAsString(String location)
Read file from given location and return string. In this method, the cache is used if more than 1 time.

Parameters:
location - file location
Returns:
file content as string


Copyright © 2004-2011. All Rights Reserved.