/* * [Enumerate.java] * * Summary: Sequentially numbers a column. * * Copyright: (c) 2009-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2009-01-01 */ package com.mindprod.reorg; import java.io.IOException; /** * Sequentially numbers a column. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2009-01-01 * @since 2009 */ public final class Enumerate extends Common { private static final int FIRST_COPYRIGHT_YEAR = 2009; /** * non-displaying copyright */ @SuppressWarnings( { "UnusedDeclaration" } ) private static final String EMBEDDED_COPYRIGHT = "Copyright: (c) 2009-2017 Roedy Green, Canadian Mind Products, http://mindprod.com"; // end getMatrix /** * main * * @param args arg[0] ignored * * @throws java.io.IOException if any problem reading or writing the html */ public static void main( String[] args ) throws IOException { /** * Which 0-based column we are enumerating */ final int colToSequence; if ( args.length == 0 ) { colToSequence = 0; } else { colToSequence = Integer.parseInt( args[ 0 ] ); } // get entire table into a string. final String[][] matrix = getMatrix( IN_FILENAME ); final int rows = rows( matrix ); final int cols = cols( matrix ); displayRowAndColCounts( "input", rows, cols ); trimMatrix( matrix ); int sequence = 1; for ( int row = 0; row < matrix.length; row++ ) { matrix[ row ][ colToSequence ] = Integer.toString( sequence++ ) + "."; } writeMatrix( matrix, OUT_FILENAME ); } // end main }