Download Latest Version row-comparator-1.1.jar (16.8 kB)
Email in envelope

Get an email when there's a new version of Multi-Column Row Comparator

Home
Name Modified Size InfoDownloads / Week
latest 2013-12-30
README.txt 2014-03-02 4.6 kB
row-comparator-1.1.jar 2014-03-02 16.8 kB
ExternalSort.zip 2014-01-05 8.0 MB
Totals: 4 Items   8.0 MB 0
===========================================================================
README
===========================================================================
This small library may be used to sort rows of delimited Strings.

It was created to add multi-column sort capabilities for external sorting 
routines, specifically the ones found here: 

https://code.google.com/p/externalsortinginjava/

The Comparator described in my library is of type Comparator<String> to 
remain compatible with the google external sorting project.  
===========================================================================
DEPENDENCIES:

- schema.xsd                         this schema, situated in package 
                                     com.foundations.comparator.structure,
                                     is used to validate the XML files that
                                     are provided by client programs

- externalsortinginjava-0.1.8.jar    if you want to use my comparator 
                                     with external sorting, this jar 
                                     provides such functionality
===========================================================================
XML FILE

Before sorting delimited String records, the following information is 
required:

(1) The String sequence representing the delimiter. 
    Use &#009; for TAB. See XML example below.

(2) The datatype of each individual column within the record. 
    Boolean, String, Integer, Decimal and DateTime are supported.
    Datatype is required, even when the column is not to be
    sorted.

(3) The names of each column.

(4) The sort order values for the columns. This is similar to the 
    ORDER BY clause in SQL. Omit this tag from columns that are not
    to be sorted. Must be an integer value greater than zero.
    Internally, omitted tags are assigned a value of zero.

(5) The sort attributes to apply to each sortable column. Only 
    applies when a SortOrder number is specified, otherwise these
    attributes are ignored. The majority of tags are applicable 
    to all column datatypes. Base attributes are defined in 
    schema.xsd as so: 

    - ascending        boolean      optional    default true
    - nullLowSortOrder boolean      optional    default true
    - trim             boolean      optional    default false

    In addition to these base types, the following type-specific 
    attributes are also supported:

     String
         - caseSensitive    boolean   optional  default true
         - stripAccents     boolean   optional  default false

     Decimal   
         - scale         positiveInteger  optional   default 2
         - roundingMode  RoundingMode     optional   default HALF_EVEN 

     DateTime
         - pattern       string   optional  default "yyyy-MM-dd HH:mm:ss"

    NOTE: Integer & Boolean only uses base attributes

Below is an XML example of a tab delimited record structure with
four columns. Only two of the four fields in this example can be
sorted; the others still require the minimal name tag and datatype
attribute to be provided, however.


<?xml version="1.0" encoding="ISO-8859-1"?>
<row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <delimiter>&#009;</delimiter>

    <column xsi:type="Decimal">
        <name>Column One</name>
    </column>

    <column xsi:type="Integer">
        <name>Column Two</name>
    </column>

    <column xsi:type="String">
        <name>Column Three</name>
        <sortOrder>2</sortOrder>
        <trim>true</trim>
        <caseSensitive>false</caseSensitive>
        <stripAccents>false</stripAccents>
    </column>

    <column xsi:type="DateTime">
        <name>Column Four</name>
        <sortOrder>1</sortOrder>
        <ascending>true</ascending>
        <nullLowSortOrder>true</nullLowSortOrder>
        <trim>true</trim>
        <pattern>yyyy-MM-dd</pattern>
    </column>

</row>
===========================================================================
USAGE: A small test program is provided with the project (see source code).

       Download the full project ExternalSorting.zip to see how this
       Comparator is used for external sorting. The following jar is
       required:

       - externalsortinginjava-0.1.8.jar

       This jar is included in the lib folder (see source code section). 
       For the latest version, go to:

       https://code.google.com/p/externalsortinginjava/
===========================================================================
Source: README.txt, updated 2014-03-02