Class EditorVariables

java.lang.Object
ro.sync.util.editorvars.EditorVariablesBase
ro.sync.util.editorvars.EditorVariables
All Implemented Interfaces:
EditorVariablesConstants

@API(type=NOT_EXTENDABLE, src=PRIVATE) public final class EditorVariables extends EditorVariablesBase
Holds constants representing all editor variables defined in Oxygen.
  • Constructor Details

    • EditorVariables

      public EditorVariables()
  • Method Details

    • getDescription

      public static String getDescription(String editorVariable)
      Returns a description of the editor variable.
      Parameters:
      editorVariable - The editor variable to get description for.
      Returns:
      The description for the editor variable.
    • possiblyContainsEditorVariable

      public static boolean possiblyContainsEditorVariable(String expression)
      Checks if the given expression potentially contains editor variables. The method is very fast but it does not guarantee the expression actually contains editor variables which are understood by the application.
      Parameters:
      expression - The expression to check.
      Returns:
      true if the expression potentially contains editor variables.
    • containsXPathEvalEditorVariable

      public static boolean containsXPathEvalEditorVariable(String expression)
      Checks if the given expression contains the xpath_eval editor variables.
      Parameters:
      expression - The expression to check.
      Returns:
      true if the expression contains the xpath_eval editor variable.
    • containsInteractiveVariable

      public static boolean containsInteractiveVariable(String expression)
      Checks if the given expression contains at least an interactive editor variable ($ask, $answer).
      Parameters:
      expression - The expression to check.
      Returns:
      true if the expression contains at least an interactive editor variable.
    • containsEditorVariable

      public static boolean containsEditorVariable(String expression)
      Checks if the given expression contains editor variables.
      Parameters:
      expression - The expression to check.
      Returns:
      true if the expression contains one of the available editor variables.
    • expandEditorVariablesAsFilePath

      public static String expandEditorVariablesAsFilePath(String expr, String currentEditedFileURL)
      Expand the editor variables. The returned value will attempt to be a file path. So even if the editor variables expand to an URL, the file path will be returned. The currently known editor variables are declared in this class.
      Parameters:
      expr - The expresion containing editor variables.
      currentEditedFileURL - The full path of the current edited file, as an URI.
      Returns:
      The expresion with the editor variables expanded, possibly an URI.
    • expandEditorVariablesAsURL

      public static URL expandEditorVariablesAsURL(String path, String baseSystemID)
      Expand the editor variables. The returned value will be an URL, or null if it cannot be built.
      Parameters:
      path - the path to be resolved, may be relative to the baseSystemID
      baseSystemID - the system ID of the base file.
      Returns:
      the resolved path as URL, or null
    • expandEditorVariables

      public static String expandEditorVariables(String expr, String currentEditedFileURL)
      Expand the editor variables in the output file name. The currently known editor variables are declared in this class.
      Parameters:
      expr - The expresion containing editor variables.
      currentEditedFileURL - The full path of the current edited file, as an URI.
      Returns:
      The expresion with the editor variables expanded, possibly an URI.
    • expandEditorVariables

      public static String expandEditorVariables(String expr, String currentEditedFileURL, Map<String,ro.sync.util.editorvars.expander.EditorVariableResolver> additionalResolvers, ro.sync.util.editorvars.expander.ErrorListener errorListener) throws ro.sync.util.editorvars.parser.ParseException, ro.sync.util.editorvars.expander.OperationCancelledException
      Expand the editor variables in the output file name. The currently known editor variables are declared in this class.
      Parameters:
      expr - The expression containing editor variables.
      currentEditedFileURL - The full path of the current edited file, as an URI.
      additionalResolvers - Some additional variables resolvers.
      errorListener - Error listener.
      Returns:
      The expression with the editor variables expanded, possibly an URI.
      Throws:
      ro.sync.util.editorvars.expander.OperationCancelledException
      ro.sync.util.editorvars.parser.ParseException
    • makeURLRelative2Frameworks

      public static String makeURLRelative2Frameworks(String url)
      Make an URL relative to the "frameworks" directory.
      Parameters:
      url - The original URL.
      Returns:
      The relative URL to the "frameworks" if possible, otherwise the original URL.
    • makeFileRelative2DITAOTDir

      public static String makeFileRelative2DITAOTDir(String fileOrDir)
      Make a file or directory relative to the configured DITA OT directory.
      Parameters:
      fileOrDir - The original file or directory.
      Returns:
      The relative path to the configured DITA OT directory or null if could not make it relative.
    • makeFileRelative2Frameworks

      public static String makeFileRelative2Frameworks(String fileOrDir)
      Make a file or directory relative to the "frameworks" directory.
      Parameters:
      fileOrDir - The original file or directory.
      Returns:
      The relative path to the "frameworks" if possible, otherwise the original file or directory path.
    • setFrameworksURLForTest

      public static void setFrameworksURLForTest(URL fURL)
      Set a frameworks url so it will not be computed from the home url.
      Parameters:
      fURL - The url.
    • getFrameworksUrl

      public static URL getFrameworksUrl() throws MalformedURLException
      Get the "frameworks" directory URL.
      Returns:
      The "frameworks" directory URL.
      Throws:
      MalformedURLException - If the oxygen home URL is not set.
    • resetFrameworksDir

      public static void resetFrameworksDir()
      Reset the computed value for the framework location. The next time it will be requested it will be recomputed.
    • getCurrentFrameworksURL

      public static URL getCurrentFrameworksURL() throws MalformedURLException
      Get the current frameworks directory.
      Returns:
      The current frameworks URL. Can be a custom one if it was set in options, or the default one.
      Throws:
      MalformedURLException - If the oxygen home URL is not set.
    • getCurrentFrameworksURL

      public static URL getCurrentFrameworksURL(ro.sync.options.NotifyableMap optionsMap) throws MalformedURLException
      Get the current frameworks directory.
      Parameters:
      optionsMap - The Oxygen options.
      Returns:
      The current frameworks URL. Can be a custom one if it was set in options, or the default one.
      Throws:
      MalformedURLException - If the oxygen home URL is not set.
    • getDefaultFrameworkURL

      public static URL getDefaultFrameworkURL() throws MalformedURLException
      Get the default frameworks directory. It is relative to the oxygen installation directory.
      Returns:
      The default frameworks directory.
      Throws:
      MalformedURLException - If the oxygen home URL is not set.
    • resetDefaultFrameworkURL

      public static void resetDefaultFrameworkURL()
      Reset the cached value of the default frameworks directory property.
    • setFrameworksDirForTest

      public static void setFrameworksDirForTest(File fDir)
      Set a frameworks dir so it will not be computed from the home url. Only from tests.
      Parameters:
      fDir -
    • getFrameworksDir

      public static File getFrameworksDir() throws MalformedURLException
      Get the File representing the "frameworks" directory.
      Returns:
      The "frameworks" directory File.
      Throws:
      MalformedURLException - If the oxygen home URL is not set.
    • getBaseUserFrameworksDir

      public static File getBaseUserFrameworksDir()
      Get the base frameworks directory from the user preferences directory like: Users\***\AppData\Roaming\com.oxygenxml\extensions\v14.0\frameworks Note: This is not the actual directory with frameworks but the directory which contains all frameworks directories. A directory for each update site: - extensions\v14.0\frameworks\{update_site_1} - extensions\v14.0\frameworks\{update_site_2}
      Returns:
      The user frameworks directory.
    • getUserFrameworksDirs

      public static File[] getUserFrameworksDirs()
      Get the frameworks directories from the user preferences directory like: Users\***\AppData\Roaming\com.oxygenxml\extensions\v14.0\frameworks\{update_site}. A new level is inserted ({update_site}) to protect against add-ons conflicts (sort of like a namespace).
      Returns:
      The user frameworks directories or null if it doesn't exists.
    • getAllFrameworksDirs

      public static File[] getAllFrameworksDirs()
      Get all the frameworks directories including default framework directory, user preferences directory and additional frameworks directories.
      Returns:
      All the frameworks directories.
    • getAdditionalFrameworksDirs

      public static File[] getAdditionalFrameworksDirs()
      Get all the additional frameworks directories specified by user.
      Returns:
      The additional frameworks directories.
    • getCurrentProjectURL

      public static URL getCurrentProjectURL(String currentFileSystemID)
      Returns the URL of the current project.
      Parameters:
      currentFileSystemID - The current file system ID.
      Returns:
      The current project URL or null if it cannot be determined.
    • getCurrentArchiveURL

      public static URL getCurrentArchiveURL(String currentFileSystemID)
      Returns the URL of the current archive.
      Parameters:
      currentFileSystemID - The current file system ID.
      Returns:
      The current archive URL or null if it cannot be determined.
    • setProjectURLProvider

      public static void setProjectURLProvider(ro.sync.util.ProjectURLProvider projectURLProvider)
      Set the project URL provider.
      Parameters:
      projectURLProvider - The new project URL provider.
    • setArchiveURLProvider

      public static void setArchiveURLProvider(ro.sync.util.ArchiveURLProvider archiveURLProvider)
      Set the archive URL provider.
      Parameters:
      archiveURLProvider - The new archive URL provider.
    • setFrameworkLocationResolver

      public static void setFrameworkLocationResolver(ro.sync.util.editorvars.FrameworkLocationResolver frameworkLocationResolver)
      Can locate a framework by using its name.
      Parameters:
      frameworkLocationResolver - Can locate a framework by using its name.
    • setPluginLocationResolver

      public static void setPluginLocationResolver(ro.sync.util.editorvars.PluginLocationResolver resolver)
      Set the plugin location resolver.
      Parameters:
      resolver - The plugin location resolver.
    • setRootMapResolver

      public static void setRootMapResolver(ro.sync.util.editorvars.DITARootMapProvider ditaRootMapProvider)
      Obtain the provider that contains information about DITA root map.
      Parameters:
      ditaRootMapProvider - The provider for the DITA root map.
    • setConditionSetNameResolver

      public static void setConditionSetNameResolver(ro.sync.util.editorvars.ConditionSetNameResolver conditionSetNameResolver)
      Set the provider for the profiling condition set name.
      Parameters:
      conditionSetNameResolver - Object which provides the profiling condition set name.
    • setArchiveExtensionsRecognizer

      public static void setArchiveExtensionsRecognizer(ro.sync.util.ArchiveExtensionsRecognizer archiveExtensionsRecognizer)
      Set an archive extensions recognizer
      Parameters:
      archiveExtensionsRecognizer - The archiveExtensionsRecognizer.
    • getSystemPathSeparator

      public static String getSystemPathSeparator()
      Returns:
      The system path separator. It is dependent on the platform.
    • expandFrameworksVariables

      public static String expandFrameworksVariables(String expr, String frameworkStoreLocation, EditorVariables.FrameworkRewritePolicy rewritePolicy)
      Expand FRAMEWORKS_DIRECTORY_URL, FRAMEWORKS_DIRECTORY, FRAMEWORK_DIRECTORY and FRAMEWORK_URL. All these variables are resolved relative to framework store location.
      Parameters:
      expr - Editor variables expression.
      frameworkStoreLocation - The framework store location as an file path.
      rewritePolicy - Rewrite FRAMEWORK_DIRECTORY and FRAMEWORK_URL using FRAMEWORKS_DIRECTORY_URL and FRAMEWORKS_DIRECTORY variables.
      Returns:
      The given expression with the framework variables expanded.
    • expandFrameworksVariables

      public static String expandFrameworksVariables(String expr, String frameworkStoreLocation, String baseStoreLocation, EditorVariables.FrameworkRewritePolicy rewritePolicy)
      Expand FRAMEWORKS_DIRECTORY_URL, FRAMEWORKS_DIRECTORY, FRAMEWORK_DIRECTORY and FRAMEWORK_URL. All these variables are resolved relative to framework store location.
      Parameters:
      expr - Editor variables expression.
      frameworkStoreLocation - The framework store location as an file path.
      baseStoreLocation - The base store location
      rewritePolicy - Rewrite FRAMEWORK_DIRECTORY and FRAMEWORK_URL using FRAMEWORKS_DIRECTORY_URL and FRAMEWORKS_DIRECTORY variables.
      Returns:
      The given expression with the framework variables expanded.
    • expandFrameworksVariables

      public static String expandFrameworksVariables(String expr, EditorVariables.FrameworkRewritePolicy rewritePolicy, File frameworksDir, URL frameworksURL, File frameworkDir, URL frameworkURL)
      Expand FRAMEWORKS_DIRECTORY_URL, FRAMEWORKS_DIRECTORY, FRAMEWORK_DIRECTORY and FRAMEWORK_URL.
      Parameters:
      expr - Editor variables expression.
      rewritePolicy - Rewrite FRAMEWORK_DIRECTORY and FRAMEWORK_URL using FRAMEWORKS_DIRECTORY_URL and FRAMEWORKS_DIRECTORY variables.
      frameworksDir - The directory where all frameworks reside.
      frameworksURL - The URL of the directory where all frameworks reside.
      frameworkDir - The directory where the specific framework reside.
      frameworkURL - The URL of the directory where the specific framework reside.
      Returns:
      The given expression with the framework variables expanded.
    • makeURLRelative2Framework

      public static String makeURLRelative2Framework(String url, String frameworkFileURL)
      Make an URL relative to $framework or that if not possible, to $frameworks (also if possible). OBS: $frameworks is the frameworks directory of the given framework frameworkFileURL.
      Parameters:
      url - The URL.
      frameworkFileURL - The URL of the ".framework" file.
      Returns:
      The relative URL to the $framework or $frameworks if possible, otherwise the original URL.
    • makeURLRelative2Project

      public static String makeURLRelative2Project(String url, String projectFileURL)
      Make an URL relative to $pdu if possible.
      Parameters:
      url - The URL.
      projectFileURL - The URL of the ".prj" file.
      Returns:
      The relative URL to the $pdu if possible, otherwise the original URL.
    • makeFileRelative2Framework

      public static String makeFileRelative2Framework(String path, String frameworkFilePath)
      Make a file or directory relative to the $framework or $frameworks directory. The $frameworks directory is the frameworks directory of the given framework file, so it might differ from the default Oxygen frameworks directory.
      Parameters:
      path - The original file or directory.
      frameworkFilePath - The URL of the ".framework" file.
      Returns:
      The relative path to the $framework or $frameworks if possible, otherwise the original file or directory path.
    • makeFileRelative2Project

      public static String makeFileRelative2Project(String path, String projectFilePath)
      Make a file or directory relative to the $pdudirectory.
      Parameters:
      path - The original file or directory.
      projectFilePath - The URL of the ".pdu" file.
      Returns:
      The relative path to the $pdu if possible, otherwise the original file or directory path.
    • setXpathEvaluator

      public static void setXpathEvaluator(ro.sync.util.editorvars.XPathEvaluator staticXpathEvaluator)
      Set an XPath evaluator.
      Parameters:
      staticXpathEvaluator - The static xpath evaluator interface.
    • getXpathEvaluator

      public static ro.sync.util.editorvars.XPathEvaluator getXpathEvaluator()
      Gets the XPath evaluator.
      Returns:
      The static xpath evaluator interface. Can be null if not previously set.
    • addCustomEditorVariablesResolver

      public static void addCustomEditorVariablesResolver(EditorVariablesResolver resolver)
      Add custom resolver.
      Parameters:
      resolver - The custom resolver to add.
    • removeCustomEditorVariablesResolver

      public static void removeCustomEditorVariablesResolver(EditorVariablesResolver resolver)
      Remove a custom resolver.
      Parameters:
      resolver - The resolver to remove.
    • getAllCustomResolvedEditorVariables

      public static List<EditorVariableDescription> getAllCustomResolvedEditorVariables()
      Get a list with all custom resolved editor variables.
      Returns:
      a list with all custom resolved editor variables.
    • setAdditionalFrameworksProvider

      public static void setAdditionalFrameworksProvider(ro.sync.exml.options.AdditionalFrameworksProvider additionalFrameworksProvider)
      Sets the referenced directory as additional framework directory.
      Parameters:
      additionalFrameworksProvider - The additionalFrameworksProvider to set.
    • setUserUploadedFrameworks

      public static void setUserUploadedFrameworks(File userFrameworksDir)
      Sets directory where the user uploaded frameworks are stored.
      Parameters:
      userFrameworksDir - The location of frameworks uploaded by the user in WA.
    • setCatalogUtilsAccess

      public static void setCatalogUtilsAccess(ro.sync.util.editorvars.CatalogManagerUtilsAccess catalogUtilsAccess)
      Set the catalogs utils access.
      Parameters:
      catalogUtilsAccess - The catalog Utils Access.
    • getCatalogUtilsAccess

      public static ro.sync.util.editorvars.CatalogManagerUtilsAccess getCatalogUtilsAccess()
      Get the catalog utils access.
      Returns:
      Returns the catalog Utils Access.
    • generateUniqueID

      public static String generateUniqueID()
      Returns:
      The generated Unique ID
    • isRelativizedToProject

      public static boolean isRelativizedToProject(String url)
      Checks if URL is relative to project
      Parameters:
      url - URL to check
      Returns:
      true if URL starts with ${pd}