Class PolicyParser

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

public class PolicyParser extends Object
This class is a parser for XML Execution Policy documents.
Author:
Laurent Cohen
  • Constructor Details

    • PolicyParser

      public PolicyParser() throws Exception
      Initialize this parser.
      Throws:
      Exception - if the DOM parser could not be initialized.
  • Method Details

    • parse

      public org.jppf.node.policy.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 document could not be parsed.
      Throws:
      Exception - if an error occurs while parsing the document.
    • parse

      public org.jppf.node.policy.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 document 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.