util
Class PartReplace

java.lang.Object
  extended by util.PartReplace

public class PartReplace
extends Object

Reads an ascii-file, keeps all the lines. Then it searches for a number of lines occuring in the file, replaces them with the argument and writes the updated file.


Nested Class Summary
static class PartReplace.Insert
          Inserts lines.
static class PartReplace.Lines
          Replaces part of a file.
 
Constructor Summary
PartReplace()
           
 
Method Summary
static List<String> getAllLines(File ascii)
          Read in an ascii-file and returns all files read as a list of strings.
private static boolean hasHead(List<String> in, List<String> check)
          Returns true if all the elements at the first list at the end index are equal to the second list.
static List<String> insertIf(List<String> input, String scan, List<String> head)
          Scans the list for a line, if the lines before are not the equal to the head list, the head list is inserted before the scan line.
static List<String> replace(List<String> input, List<String> scan, List<String> replace)
          Converts a list of strings to a new one by comparing element-by-element if the occurence of the search argument is within the input list.
private static boolean scanFor(List<String> test, int index, List<String> scan)
          Scans if the next n-elements of the string list are equal to the string array.
static void writeAllLines(File ascii, List<String> output)
          Writes an ascii-file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PartReplace

public PartReplace()
Method Detail

getAllLines

public static List<String> getAllLines(File ascii)
Read in an ascii-file and returns all files read as a list of strings.


writeAllLines

public static void writeAllLines(File ascii,
                                 List<String> output)
Writes an ascii-file.


replace

public static List<String> replace(List<String> input,
                                   List<String> scan,
                                   List<String> replace)
Converts a list of strings to a new one by comparing element-by-element if the occurence of the search argument is within the input list. If it is found, the replacement is inserted in the return list instead of the old elements.


insertIf

public static List<String> insertIf(List<String> input,
                                    String scan,
                                    List<String> head)
Scans the list for a line, if the lines before are not the equal to the head list, the head list is inserted before the scan line.


hasHead

private static boolean hasHead(List<String> in,
                               List<String> check)
Returns true if all the elements at the first list at the end index are equal to the second list.


scanFor

private static boolean scanFor(List<String> test,
                               int index,
                               List<String> scan)
Scans if the next n-elements of the string list are equal to the string array.