in upper or lower case.
* does not deal with rowspan or colspan.
* It can't handle any grammatical errors in your HTML.
* Does not resort.
* Input from E:\temp\in.html
* Output to E:\temp\out.html all tags in lower case.
*
* @author Roedy Green, Canadian Mind Products
* @version 1.0 1998-01-01
* @since 1998-01-01
*/
public final class Unquilt extends Common
{
private static final int FIRST_COPYRIGHT_YEAR = 2003;
/**
* undisplayed copyright
*/
@SuppressWarnings( { "UnusedDeclaration" } )
private static final String EMBEDDED_COPYRIGHT =
"Copyright: (c) 2003-2017 Roedy Green, Canadian Mind Products, http://mindprod.com";
/**
* main
*
* @param args [0] byrows to unquilt by rows. No ability do undo double column quilts yet. byrows is not implemented
* either.
*
* @throws java.io.IOException if any problem reading or writing the html
*/
public static void main( String[] args ) throws IOException
{
if ( args.length > 0 && args[ 0 ].equalsIgnoreCase( "byrows" ) )
{
out.println( "byrows is not yet implemented" );
System.exit( 1 );
}
// get entire table into a string.
final String[][] matrix = getMatrix( IN_FILENAME );
final int rows = rows( matrix );
final int cols = cols( matrix );
displayRowAndColCounts( "quilted input", rows, cols );
trimMatrix( matrix );
// New result shape
final int nrows = rows * cols;
final int ncols = 1;
displayRowAndColCounts( "unquilted output", nrows, ncols );
// create new matrix with 1 columns.
String[][] grid = new String[ nrows ][ ncols ];
int targetRow = 0;
for ( int col = 0; col < cols; col++ )
{
for ( int row = 0; row < rows; row++ )
{
grid[ targetRow++ ][ 0 ] = matrix[ row ][ col ];
} // end for
} // end for
writeMatrix( grid, OUT_FILENAME );
} // end main
} // end Unquilt
|