org.jppf.node.policy
Class PolicyParser

java.lang.Object
  extended by org.jppf.node.policy.PolicyParser

public class PolicyParser
extends Object

This class is a parser for XML Execution Policy documents.

Author:
Laurent Cohen

Constructor Summary
PolicyParser()
          Initialize this parser.
 
Method Summary
static void main(String... args)
          Test of the parser.
 PolicyDescriptor parse(Reader reader)
          Parse an XML document in a reader into a tree of option descriptors.
 PolicyDescriptor parse(String docPath)
          Parse an XML document in a file into a tree of option descriptors.
static ExecutionPolicy parsePolicy(File policyFile)
          Parse an XML document representing an execution policy from a file path.
static ExecutionPolicy parsePolicy(InputStream stream)
          Parse an XML document representing an execution policy from an input stream.
static ExecutionPolicy parsePolicy(Reader reader)
          Parse an XML document representing an execution policy from a reader.
static ExecutionPolicy parsePolicy(String policyContent)
          Parse an XML document representing an execution policy.
static ExecutionPolicy parsePolicyFile(String docPath)
          Parse an XML document representing an execution policy from a file path.
static void validatePolicy(File docPath)
          Validate an XML document representing an execution policy against the JPPF Execution Policy schema.
static void validatePolicy(InputStream stream)
          Validate an XML document representing an execution policy against the JPPF Execution Policy schema.
static void validatePolicy(Reader reader)
          Validate an XML document representing an execution policy against the JPPF Execution Policy schema.
static void validatePolicy(String policyContent)
          Validate an XML document representing an execution policy against the JPPF Execution Policy schema.
static void validatePolicyFile(String docPath)
          Validate an XML document representing an execution policy against the JPPF Execution Policy schema.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolicyParser

public PolicyParser()
             throws Exception
Initialize this parser.

Throws:
Exception - if the DOM parser could not be initialized.
Method Detail

parse

public PolicyDescriptor parse(String docPath)
                       throws Exception
Parse an XML document in a file into a tree of option descriptors.

Parameters:
docPath - the path to XML document to parse.
Returns:
an OptionDescriptor instance, root of the generated tree, or null if the docuement could not be parsed.
Throws:
Exception - if an error occurs while parsing the document.

parse

public PolicyDescriptor parse(Reader reader)
                       throws Exception
Parse an XML document in a reader into a tree of option descriptors.

Parameters:
reader - the reader providing the XML document.
Returns:
an OptionDescriptor instance, root of the generated tree, or null if the docuement could not be parsed.
Throws:
Exception - if an error occurs while parsing the document.

main

public static void main(String... args)
Test of the parser.

Parameters:
args - not used.

parsePolicy

public static ExecutionPolicy parsePolicy(String policyContent)
                                   throws Exception
Parse an XML document representing an execution policy.

Parameters:
policyContent - an XML string containing the policy.
Returns:
an ExecutionPolicy instance.
Throws:
Exception - if an error occurs during the validation or parsing.

parsePolicyFile

public static ExecutionPolicy parsePolicyFile(String docPath)
                                       throws Exception
Parse an XML document representing an execution policy from a file path.

Parameters:
docPath - path to the XML document file.
Returns:
an ExecutionPolicy instance.
Throws:
Exception - if an error occurs during the validation or parsing.

parsePolicy

public static ExecutionPolicy parsePolicy(File policyFile)
                                   throws Exception
Parse an XML document representing an execution policy from a file path.

Parameters:
policyFile - abstract path of the XML document file.
Returns:
an ExecutionPolicy instance.
Throws:
Exception - if an error occurs during the validation or parsing.

parsePolicy

public static ExecutionPolicy parsePolicy(InputStream stream)
                                   throws Exception
Parse an XML document representing an execution policy from an input stream.

Parameters:
stream - an input stream from which the XML representation of the policy is read.
Returns:
an ExecutionPolicy instance.
Throws:
Exception - if an error occurs during the validation or parsing.

parsePolicy

public static ExecutionPolicy parsePolicy(Reader reader)
                                   throws Exception
Parse an XML document representing an execution policy from a reader.

Parameters:
reader - reader from which the XML representation of the policy is read.
Returns:
an ExecutionPolicy instance.
Throws:
Exception - if an error occurs during the validation or parsing.

validatePolicy

public static void validatePolicy(String policyContent)
                           throws JPPFException,
                                  Exception
Validate an XML document representing an execution policy against the JPPF Execution Policy schema.

Parameters:
policyContent - the XML content of the policy document.
Throws:
JPPFException - if there is a validation error. The details of the errors are included in the exception message.
Exception - if an error occurs during the validation.

validatePolicyFile

public static void validatePolicyFile(String docPath)
                               throws JPPFException,
                                      Exception
Validate an XML document representing an execution policy against the JPPF Execution Policy schema.

Parameters:
docPath - path to the XML document file.
Throws:
JPPFException - if there is a validation error. The details of the errors are included in the exception message.
Exception - if an error occurs during the validation.

validatePolicy

public static void validatePolicy(File docPath)
                           throws JPPFException,
                                  Exception
Validate an XML document representing an execution policy against the JPPF Execution Policy schema.

Parameters:
docPath - abstract path of the XML document file.
Throws:
JPPFException - if there is a validation error. The details of the errors are included in the exception message.
Exception - if an error occurs during the validation.

validatePolicy

public static void validatePolicy(InputStream stream)
                           throws JPPFException,
                                  Exception
Validate an XML document representing an execution policy against the JPPF Execution Policy schema.

Parameters:
stream - an input stream from which the XML representation of the policy is read.
Throws:
JPPFException - if there is a validation error. The details of the errors are included in the exception message.
Exception - if an error occurs during the validation or parsing.

validatePolicy

public static void validatePolicy(Reader reader)
                           throws JPPFException,
                                  Exception
Validate an XML document representing an execution policy against the JPPF Execution Policy schema.

Parameters:
reader - reader from which the XML representation of the policy is read.
Throws:
JPPFException - if there is a validation error. The details of the errors are included in the exception message.
Exception - if an error occurs during the validation or parsing.


Copyright © 2005-2010 JPPF Team.