Interface UtilAccess

All Known Subinterfaces:
AuthorUtilAccess

@API(type=NOT_EXTENDABLE, src=PUBLIC) public interface UtilAccess
Provides access to utility methods.
Since:
11.2
  • Method Details

    • makeRelative

      String makeRelative(URL baseURL, URL childURL)
      Make the child URL relative to the base URL. The query and fragment identifier are preserved if the initial reference contains them.

      The child URL is relatively expressed to the base URL. If it is not possible, the child URL is returned.

      For example if the base URL is "file://c:/projects/exml/base.prx" and the child URL is "file://c:/projects/exml/test/someTest.xml" the result will be: "test/someTest.xml"

      Parameters:
      baseURL - The base URL.
      childURL - The child URL.
      Returns:
      The relative path or the childURL if a relative path cannot be computed.
    • correctURL

      String correctURL(String url)
      Corrects the given URL by converting not allowed characters to their escaped representation. The URL correction takes an URL like:
      http://path to directory/file.xml
      and escapes illegal URL characters like spaces to:
      http://path%20to%20directory/file.xml
      Parameters:
      url - The URL to be corrected.
      Returns:
      The corrected URL. It does not return null.
    • uncorrectURL

      String uncorrectURL(String url)
      Un-corrects the given URL by converting the percent encoded characters back to the original characters. The URL un-correction takes an URL like:
      http://path%20to%20directory/file.xml
      and unescapes it back to:
      http://path to directory/file.xml
      Parameters:
      url - The URL to be corrected.
      Returns:
      The corrected URL. It does not return null.
      Since:
      20.1
    • convertFileToURL

      URL convertFileToURL(File file) throws MalformedURLException
      Converts the given file to an URL by converting not allowed characters to their escaped representation. The URL correction takes a File like:
      c:\path to directory\file.xml
      and escapes illegal URL characters like spaces to:
      http://path%20to%20directory/file.xml
      Parameters:
      file - The File to be corrected.
      Returns:
      The corrected URL. It does not return null.
      Throws:
      MalformedURLException - if it fails to perform the conversion.
      Since:
      18
    • removeUserCredentials

      URL removeUserCredentials(URL url)
      Removes the user name and password from the URL if they are present.
      Parameters:
      url - The URL from which the user credentials will be removed.
      Returns:
      The URL having the user credentials removed.
      Since:
      12.1
    • locateFile

      File locateFile(URL url)
      Locate the file on disk corresponding to the URL.
      Parameters:
      url - The URL to be checked.
      Returns:
      The corresponding File from the local file system or null if the URL is remote.
    • getExtension

      String getExtension(URL url)
      Get the file extension for this URL. The extension is lower cased.
      Parameters:
      url - The URL to extract the extension for.
      Returns:
      the file extension for this URL. The extension is lower cased.
    • getFileName

      String getFileName(String urlPath)
      Get the file name from a file or URL path
      Parameters:
      urlPath - An URL path
      Returns:
      the file name from a file or URL path
    • isSupportedImageURL

      boolean isSupportedImageURL(URL url)
      Check if this URL points to a supported image. The image extension is used
      Parameters:
      url - The URL
      Returns:
      true if this URL points to a supported image. The image extension is used
    • isUnhandledBinaryResourceURL

      boolean isUnhandledBinaryResourceURL(URL url)
      Check if this URL points to a binary resource which is not handled by Oxygen in any way. The resource file extension is checked against a list of binary file patterns configured in the Oxygen options. For example ZIP-like archives are handled by Oxygen although they are binary.
      Parameters:
      url - The URL
      Returns:
      true if this URL points to a binary resource.
      Since:
      15
    • expandEditorVariables

      String expandEditorVariables(String pathWithEditorVariables, URL currentEditedURL)
      Try to expand the editor variables in a path. If there's an external framework associated with the current editor, any $framework, $frameworks, $frameworkDir or $frameworksDir variable will be expanded in the context of that framework. "ask" and "answer" editor variables are not expanded by default.
      Parameters:
      pathWithEditorVariables - The path containing editor variables
      currentEditedURL - The current edited URL. Can be null but it may be necessary to expand editor variables like "${cfd}".
      Returns:
      The path with editor variables expanded.
      Since:
      12.1
    • expandEditorVariables

      String expandEditorVariables(String pathWithEditorVariables, URL currentEditedURL, boolean expandAskEditorVariables)
      Try to expand the editor variables in a path. If there's an external framework associated with the current editor, any $framework, $frameworks, $frameworkDir or $frameworksDir variable will be expanded in the context of that framework.
      Parameters:
      pathWithEditorVariables - The path containing editor variables
      currentEditedURL - The current edited URL. Can be null but it may be necessary to expand editor variables like "${cfd}".
      expandAskEditorVariables - true to also expand "ask" and "answer" editor variables.
      Returns:
      The path with editor variables expanded. Will return the original string if there are "ask" editor variables in the content and the end user chose to cancel the prompt dialogs.
      Since:
      22
    • encrypt

      String encrypt(String toEncrypt)
      Encrypts a string using the Oxygen internal encryption system. The encryption/decryption is application-specific so a string encrypted in one Oxygen installation cannot be decrypted in another. You can use this method if you want to store user-specific data on disk with a moderate level of security.
      Parameters:
      toEncrypt - The string to encrypt.
      Returns:
      The string encrypted using the Oxygen internal encryption system.
      Since:
      12.1
    • decrypt

      String decrypt(String toDecrypt)
      Decrypts a string using the Oxygen internal encryption system. The encryption/decryption is application-specific so a string encrypted in one Oxygen installation cannot be decrypted in another. You can use this method if you want to store user-specific data on disk with a moderate level of security.
      Parameters:
      toDecrypt - The string to decrypt.
      Returns:
      The string decrypted using the Oxygen internal encryption system or NULL if the string format is not understood.
      Since:
      12.1
    • addCustomEditorVariablesResolver

      void addCustomEditorVariablesResolver(EditorVariablesResolver resolver)
      Add a custom editor variables resolver. The resolver receives a string which may or may not contain custom editor variables. It can either return the unmodified string or a modified version of the string in which certain editor variables have been expanded to certain values.
      Parameters:
      resolver - The resolver.
      Since:
      16.1
    • removeCustomEditorVariablesResolver

      void removeCustomEditorVariablesResolver(EditorVariablesResolver resolver)
      Remove a custom editor variables resolver.
      Parameters:
      resolver - The resolver to remove.
      Since:
      16.1
    • createReader

      Reader createReader(URL url, String defaultEncoding) throws IOException
      Opens a connection for the given URL, examines its contents and decides what kind of encoding should be used.
      Parameters:
      url - The URL to be opened.
      defaultEncoding - The encoding to be used when all other ways of detecting it returned null. This is used instead of creating the input stream reader with no encoding arguments. This is a JAVA encoding.
      Returns:
      A reader for the given URL.
      Throws:
      IOException - when an error occurs during the URL connection.
      Since:
      17
    • createImage

      BufferedImage createImage(String imageUrl) throws IOException
      Create the image described by the URL.
      Parameters:
      imageUrl - The URL of the image for which to return the buffered image.
      Returns:
      The BufferedImage of the image located at the provided URL.
      Throws:
      IOException - Unable to create the image.
      Since:
      17.1
    • optimizeImage

      ImageHolder optimizeImage(URL imageUrl) throws IOException
      Optimize an image to be consumed by a web browser. In case the image is too large it scales it down to fit a normal page.
      Parameters:
      imageUrl - The image URL.
      Returns:
      The holder of the image that can forward it to the browser.
      Throws:
      IOException - Unable to create the image.
      Since:
      19.1
    • getContentType

      String getContentType(String systemID)
      Get the content type for the given URL. The content type is detected from the file extension based on the file extension associations saved in the application preferences.
      Parameters:
      systemID - The systemID to get the content type for.
      Returns:
      the content type string or null if there is no mapping. The content type is returned as a mime type value, for example "text/xml" for XML documents. Can be null if the content type is unknown for the application.
      Since:
      24.0