Class 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 Detail

      • EditorVariables

        public EditorVariables()
    • Method Detail

      • getDescription

        public static java.lang.String getDescription​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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​(java.lang.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 java.lang.String expandEditorVariablesAsFilePath​(java.lang.String expr,
                                                                       java.lang.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 java.net.URL expandEditorVariablesAsURL​(java.lang.String path,
                                                              java.lang.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 java.lang.String expandEditorVariables​(java.lang.String expr,
                                                             java.lang.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 java.lang.String expandEditorVariables​(java.lang.String expr,
                                                             java.lang.String currentEditedFileURL,
                                                             java.util.Map<java.lang.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 java.lang.String makeURLRelative2Frameworks​(java.lang.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 java.lang.String makeFileRelative2DITAOTDir​(java.lang.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 java.lang.String makeFileRelative2Frameworks​(java.lang.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​(java.net.URL fURL)
        Set a frameworks url so it will not be computed from the home url.
        Parameters:
        fURL - The url.
      • getFrameworksUrl

        public static java.net.URL getFrameworksUrl()
                                             throws java.net.MalformedURLException
        Get the "frameworks" directory URL.
        Returns:
        The "frameworks" directory URL.
        Throws:
        java.net.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 java.net.URL getCurrentFrameworksURL()
                                                    throws java.net.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:
        java.net.MalformedURLException - If the oxygen home URL is not set.
      • getCurrentFrameworksURL

        public static java.net.URL getCurrentFrameworksURL​(ro.sync.options.NotifyableMap optionsMap)
                                                    throws java.net.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:
        java.net.MalformedURLException - If the oxygen home URL is not set.
      • getDefaultFrameworkURL

        public static java.net.URL getDefaultFrameworkURL()
                                                   throws java.net.MalformedURLException
        Get the default frameworks directory. It is relative to the oxygen installation directory.
        Returns:
        The default frameworks directory.
        Throws:
        java.net.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​(java.io.File fDir)
        Set a frameworks dir so it will not be computed from the home url. Only from tests.
        Parameters:
        fDir -
      • getFrameworksDir

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

        public static java.io.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 java.io.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 java.io.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 java.io.File[] getAdditionalFrameworksDirs()
        Get all the additional frameworks directories specified by user.
        Returns:
        The additional frameworks directories.
      • getCurrentProjectURL

        public static java.net.URL getCurrentProjectURL​(java.lang.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 java.net.URL getCurrentArchiveURL​(java.lang.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 java.lang.String getSystemPathSeparator()
        Returns:
        The system path separator. It is dependent on the platform.
      • expandFrameworksVariables

        public static java.lang.String expandFrameworksVariables​(java.lang.String expr,
                                                                 java.lang.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 java.lang.String expandFrameworksVariables​(java.lang.String expr,
                                                                 java.lang.String frameworkStoreLocation,
                                                                 java.lang.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 java.lang.String expandFrameworksVariables​(java.lang.String expr,
                                                                 EditorVariables.FrameworkRewritePolicy rewritePolicy,
                                                                 java.io.File frameworksDir,
                                                                 java.net.URL frameworksURL,
                                                                 java.io.File frameworkDir,
                                                                 java.net.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 java.lang.String makeURLRelative2Framework​(java.lang.String url,
                                                                 java.lang.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 java.lang.String makeURLRelative2Project​(java.lang.String url,
                                                               java.lang.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 java.lang.String makeFileRelative2Framework​(java.lang.String path,
                                                                  java.lang.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 java.lang.String makeFileRelative2Project​(java.lang.String path,
                                                                java.lang.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 java.util.List<EditorVariableDescription> getAllCustomResolvedEditorVariables()
        Get a list with all custom resolved editor variables.
        Returns:
        a list with all custom resolved editor variables.
      • setAdditionalFrameorksProvider

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

        public static void setUserUploadedFrameworks​(java.io.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 java.lang.String generateUniqueID()
        Returns:
        The generated Unique ID
      • isRelativizedToProject

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