Class ASCIIFileUpdate


  • public class ASCIIFileUpdate
    extends java.lang.Object
    Allows modification of ASCII files. This class is intended to provide the functionality of the update ASCII file modifications in ISMP 11.5 for the update installer.
    • Constructor Summary

      Constructors 
      Constructor Description
      ASCIIFileUpdate​(java.lang.String filename)
      Class constructor that takes a filename to make replacements on.
      ASCIIFileUpdate​(java.lang.String filename, java.lang.String[] matches, java.lang.String[] replace)
      Class constructor that takes a filename to make replacements on, an array of matches, and an array of replacements.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPattern​(java.lang.String search, java.lang.String replace)
      Adds a search and replace term to the array of items to search for
      void alterFile()
      Performs the actual alteration of the file.
      void setMode​(int mode)
      Sets the mode for this replacement.
      static int simpleModify​(java.lang.String[] args)
      Performs a modification to a file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ASCIIFileUpdate

        public ASCIIFileUpdate​(java.lang.String filename)
                        throws java.lang.Exception
        Class constructor that takes a filename to make replacements on. Searches and replacements must be added.
        Parameters:
        filename - The file that will be altered
        Throws:
        java.lang.Exception - If there is an error processing the file
      • ASCIIFileUpdate

        public ASCIIFileUpdate​(java.lang.String filename,
                               java.lang.String[] matches,
                               java.lang.String[] replace)
                        throws java.lang.Exception
        Class constructor that takes a filename to make replacements on, an array of matches, and an array of replacements.
        Parameters:
        filename - The file that will be altered
        matches - An array of regular expressions to search for
        replace - A parallel array to matches which represents the replacements
        Throws:
        java.lang.Exception - If there is an error processing the file
    • Method Detail

      • setMode

        public void setMode​(int mode)
        Sets the mode for this replacement.
        Parameters:
        mode - LINE_MODE or TEXT_MODE; the default is LINE_MODE
      • addPattern

        public void addPattern​(java.lang.String search,
                               java.lang.String replace)
        Adds a search and replace term to the array of items to search for
        Parameters:
        search - A regexp to search for
        replace - A replacement for the corresponding search
      • alterFile

        public void alterFile()
                       throws java.lang.Exception
        Performs the actual alteration of the file.
        Throws:
        java.lang.Exception - if an error is encountered when reading or writing to the file
      • simpleModify

        public static int simpleModify​(java.lang.String[] args)
        Performs a modification to a file. If the modification to be made only takes one search and replace term, use this method instead of instantiating an object.
        Parameters:
        args - An array of arguments for this modification: file search replacement [LINE|TEXT]
        If the last argument is omitted, LINE_MODE is used.
        Returns:
        0 if the modification was successful, nonzero otherwise