private int comparePart()

in archiva-jarinfo/archiva-jarinfo-cli/src/main/java/org/apache/archiva/common/utils/VersionComparator.java [150:192]


    private int comparePart( String s1, String s2 )
    {
        boolean is1Num = NumberUtils.isNumber( s1 );
        boolean is2Num = NumberUtils.isNumber( s2 );

        // (Special Case) Test for numbers both first.
        if ( is1Num && is2Num )
        {
            int i1 = NumberUtils.toInt( s1 );
            int i2 = NumberUtils.toInt( s2 );

            return i1 - i2;
        }

        // Test for text both next.
        if ( !is1Num && !is2Num )
        {
            int idx1 = specialWords.indexOf( s1.toLowerCase() );
            int idx2 = specialWords.indexOf( s2.toLowerCase() );

            // Only operate perform index based operation, if both strings
            // are found in the specialWords index.
            if ( idx1 >= 0 && idx2 >= 0 )
            {
                return idx1 - idx2;
            }
        }

        // Comparing text to num
        if ( !is1Num && is2Num )
        {
            return -1;
        }

        // Comparing num to text
        if ( is1Num && !is2Num )
        {
            return 1;
        }

        // Return comparison of strings themselves.
        return s1.compareToIgnoreCase( s2 );
    }