Class VarExpansion<Param>

java.lang.Object
org.omegat.util.VarExpansion<Param>
Direct Known Subclasses:
CommandVarExpansion, MatchesVarExpansion, ModificationInfoManager.ModificationInfoVarExpansion

public abstract class VarExpansion<Param> extends Object
This class is used to transform a string by expansion of variables it contains. It can expand:
  • Entries in Bundle.properties: see expandBundleEntries(String) for syntax
  • Variables: see expandVariables(Object) for syntax
Here we define variables which depends only on the project. This class should be overriden to define more specific substitutions.
  • Field Details

  • Constructor Details

    • VarExpansion

      public VarExpansion(String template)
  • Method Details

    • expandFileNames

      public String expandFileNames(String localTemplate, String[] filePaths, String baseDir)
      Expands all variables relating to file name :
      • ${filePath} = full file path
      • ${fileShortPath} = file path relative to given root
      • ${fileName} = full file name (w/o path but with extension)
      • ${fileNameOnly} = file name without extension
      • ${fileNameOnly-1}, ${fileNameOnly-2}, ... = filename with 1, 2, ... extensions
      • ${fileExtension} = all extensions after '.'
      • ${fileExtension-1}, ${fileExtension-2}, ... = ${fileExtension} after removing 1, 2, ... extensions
      Parameters:
      localTemplate - initial template. If null, use instance's template but does not modify it
      filePaths - path used by variable ${fileShortPath}
      baseDir - base directory to expand against
      Returns:
      Copy of the template with mentioned variables expanded. Other variables remain unchanged
    • expandFileName

      public String expandFileName(String localTemplate, String filePath, String baseDir)
    • expandVariables

      public abstract String expandVariables(Param param)