Class DocUtil

java.lang.Object
org.opencastproject.util.doc.DocUtil

public final class DocUtil extends Object
This provides methods for handling documentation generation The is mainly for generating REST documentation but it could be used for other things as well
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    generate(DocData data, String template)
    Use this method to generate the documentation using passed in document data, allows the user to specify the template that is used
    static String
    Loads a template based on the given path
    static String
    processTextTemplate(String templateName, String textTemplate, Map<String,Object> data)
    Handles the replacement of the variable strings within textual templates and also allows the setting of variables for the control of logical branching within the text template as well
    Uses and expects freemarker (http://freemarker.org/) style templates (that is using ${name} as the marker for a replacement)
    NOTE: These should be compatible with Velocity (http://velocity.apache.org/) templates if you use the formal notation (formal: ${variable}, shorthand: $variable)
    static void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • reset

      public static void reset()
    • processTextTemplate

      public static String processTextTemplate(String templateName, String textTemplate, Map<String,Object> data)
      Handles the replacement of the variable strings within textual templates and also allows the setting of variables for the control of logical branching within the text template as well
      Uses and expects freemarker (http://freemarker.org/) style templates (that is using ${name} as the marker for a replacement)
      NOTE: These should be compatible with Velocity (http://velocity.apache.org/) templates if you use the formal notation (formal: ${variable}, shorthand: $variable)
      Parameters:
      templateName - this is the key to cache the template under
      textTemplate - a freemarker/velocity style text template, cannot be null or empty string
      data - a set of replacement values which are in the map like so:
      key => value (String => Object)
      "username" => "aaronz"
      Returns:
      the processed template
    • generate

      public static String generate(DocData data, String template)
      Use this method to generate the documentation using passed in document data, allows the user to specify the template that is used
      Parameters:
      data - any populated DocData object
      template - any freemarker template which works with the DocData data structure
      Returns:
      the documentation (e.g. REST html) as a string
      Throws:
      IllegalArgumentException - if the input data is invalid in some way
      See Also:
    • loadTemplate

      public static String loadTemplate(String path)
      Loads a template based on the given path
      Parameters:
      path - the path to load the template from (uses the current classloader)
      Returns:
      the template as a string