View | Details | Raw Unified | Return to bug 38886
Collapse All | Expand All

(-)Old/MemValueIndexer.java (-18 / +38 lines)
Lines 87-93 Link Here
87
    private static final String CHAR_VAL = "char";
87
    private static final String CHAR_VAL = "char";
88
    private static final String BOOLEAN_VAL = "boolean";
88
    private static final String BOOLEAN_VAL = "boolean";
89
89
90
    private static final IndexMatch[] EMPTY_INDEX_MATCH_ARRAY = new IndexMatch[0];
90
    private final static IndexMatch[] EMPTY_INDEX_MATCH_ARRAY = new IndexMatch[0];
91
91
92
    //
92
    //
93
    // Instance variables
93
    // Instance variables
Lines 410-426 Link Here
410
                // always compare against the String form of the comparator
410
                // always compare against the String form of the comparator
411
                // to ensure that comparisons happen as Strings as specified by XPath
411
                // to ensure that comparisons happen as Strings as specified by XPath
412
                // for starts-with
412
                // for starts-with
413
                aLowEndpoint = aQueryValueList[0];
413
                if(! (aLowEndpoint instanceof String) )
414
                if (itsValueType == TRIMMED) {
414
                {
415
                    aLowEndpoint = QueryEngine.normalizeString((String) aLowEndpoint);
415
                    aLowEndpoint = aLowEndpoint.toString();
416
                } else {
417
                    if (itsValueType != STRING) {
418
                        aLowEndpoint = ((String) aLowEndpoint).trim();
419
                    }
420
                }
416
                }
421
417
422
                // get the matching submap forcing String comparisons to be used regardless of stored type
418
                // get the matching submap forcing String comparisons to be used regardless of stored type
423
                aResult = getIndexMatchArray(getBWSubmap(aLowEndpoint, aLowEndpoint));
419
                aResult = getIndexMatchArray(getSWSubmap((String)aLowEndpoint));
424
                break;
420
                break;
425
421
426
            case IndexQuery.IN: // In the (presumed sorted) set of specified query values
422
            case IndexQuery.IN: // In the (presumed sorted) set of specified query values
Lines 447-459 Link Here
447
                // implement as LT or GT forcing String comparisons
443
                // implement as LT or GT forcing String comparisons
448
                // we get the raw String match value and use that instead of the typed value
444
                // we get the raw String match value and use that instead of the typed value
449
                // to force String comparisons (as required for starts-with)
445
                // to force String comparisons (as required for starts-with)
450
                aLowEndpoint = aQueryValueList[0];
446
                if(! (aLowEndpoint instanceof String) )
451
                if (itsValueType == TRIMMED) {
447
                {
452
                    aLowEndpoint = QueryEngine.normalizeString((String) aLowEndpoint);
448
                    aLowEndpoint = aLowEndpoint.toString();
453
                } else {
454
                    if (itsValueType != STRING) {
455
                        aLowEndpoint = ((String) aLowEndpoint).trim();
456
                    }
457
                }
449
                }
458
450
459
                // get all matches below starts-with range and above starts-with range
451
                // get all matches below starts-with range and above starts-with range
Lines 495-500 Link Here
495
    }
487
    }
496
488
497
    /**
489
    /**
490
     * Provides the submap containing the half-open range (inclusive of Low Endpoint but not High Endpoint)
491
     * between the theLowEndpoint and getNextValueOf(theLowEndpoint, STRING).
492
     *
493
     * @param theLowEndpoint low endpoint to use
494
     * @return a SortedMap containing the matches or null if no matches
495
     */
496
    private SortedMap getSWSubmap(String theLowEndpoint) {
497
        SortedMap aSubmap = null;
498
        TreeSet aLocatorSet;
499
500
        // force computation of next value as STRING if key is String
501
        // otherwise, next value will be of same type as stored values
502
        String aHighEndpoint = (String)getNextValueOf(theLowEndpoint, STRING);
503
504
        if (aHighEndpoint == null) {
505
            // return locators in tail map from low endpoint
506
            aSubmap = itsValues.tailMap(theLowEndpoint);
507
        } else {
508
            // return locators in sub map inclusive of endpoints
509
            aSubmap = itsValues.subMap(theLowEndpoint, aHighEndpoint);
510
        }
511
512
        return aSubmap == null || aSubmap.size() == 0 ? null : aSubmap;
513
    }
514
515
    /**
498
     * Provides the submap containing the closed range (inclusive of both endpoints)
516
     * Provides the submap containing the closed range (inclusive of both endpoints)
499
     * between the specified endpoints.
517
     * between the specified endpoints.
500
     *
518
     *
Lines 1036-1042 Link Here
1036
                    return theValue + "\0";
1054
                    return theValue + "\0";
1037
                }
1055
                }
1038
                // return a string of the same length with the final character incremented by 1
1056
                // return a string of the same length with the final character incremented by 1
1039
                aReturn = ((String) theValue).substring(0, aLength - 1) + String.valueOf(aLastChar + 1);
1057
                // be sure to avoid upcasting to int which would happen if you do "a" + (aLastChar + 1) 
1058
                aLastChar += 1; 
1059
                aReturn = ((String) theValue).substring(0, aLength - 1) + aLastChar;
1040
                break;
1060
                break;
1041
            case SHORT:
1061
            case SHORT:
1042
                {
1062
                {
Lines 1477-1480 Link Here
1477
         */
1497
         */
1478
        private final short itsAttributeID;
1498
        private final short itsAttributeID;
1479
    }
1499
    }
1480
}
1500
}

Return to bug 38886