@Override protected int compareSecure(Value o, CompareMode mode) { // compatibility: the other object could be another type ValueString v = (ValueString) o; return mode.compareString(value, v.value, false); }
private boolean compare(char[] pattern, String s, int pi, int si) { return pattern[pi] == s.charAt(si) || (!fastCompare && compareMode.equalsChars(patternString, pi, s, si, ignoreCase)); }
/** * Create a new compare mode with the given collator and strength. If * required, a new CompareMode is created, or if possible the last one is * returned. A cache is used to speed up comparison when using a collator; * CollationKey objects are cached. * * @param name the collation name or null * @param strength the collation strength * @return the compare mode */ public static synchronized CompareMode getInstance(String name, int strength) { return getInstance(name, strength, SysProperties.SORT_BINARY_UNSIGNED); }
final boolean binaryUnsigned = database.getCompareMode().isBinaryUnsigned(); CompareMode compareMode; StringBuilder buff = new StringBuilder(stringValue); if (stringValue.equals(CompareMode.OFF)) { compareMode = CompareMode.getInstance(null, 0, binaryUnsigned); } else { int strength = getIntValue(); buff.append("TERTIARY"); compareMode = CompareMode.getInstance(stringValue, strength, binaryUnsigned); if (old.equals(compareMode)) { break; CompareMode newMode; if (stringValue.equals(CompareMode.SIGNED)) { newMode = CompareMode.getInstance(currentMode.getName(), currentMode.getStrength(), false); } else if (stringValue.equals(CompareMode.UNSIGNED)) { newMode = CompareMode.getInstance(currentMode.getName(), currentMode.getStrength(), true); } else { throw DbException.getInvalidValueException("BINARY_COLLATION", stringValue);
@Override public boolean equals(Object obj) { if (obj == this) { return true; } else if (!(obj instanceof CompareMode)) { return false; } CompareMode o = (CompareMode) obj; if (!getName().equals(o.getName())) { return false; } if (strength != o.strength) { return false; } return binaryUnsigned == o.binaryUnsigned; }
@Override protected int compareSecure(Value v, CompareMode mode) { byte[] v2 = ((ValueBytes) v).value; if (mode.isBinaryUnsigned()) { return Utils.compareNotNullUnsigned(value, v2); } return Utils.compareNotNullSigned(value, v2); }
if (compareLocaleNames(locale, name)) { result = Collator.getInstance(locale); String country = name.substring(idx + 1); Locale locale = new Locale(language, country); if (compareLocaleNames(locale, name)) { result = Collator.getInstance(locale); if (compareLocaleNames(locale, name)) { result = Collator.getInstance(locale); break;
lastUsed = new CompareMode(name, strength, binaryUnsigned); } else { boolean useICU4J;
private Set parseSetCollation() { Set command = new Set(session, SetTypes.COLLATION); String name = readAliasIdentifier(); command.setString(name); if (equalsToken(name, CompareMode.OFF)) { return command; } Collator coll = CompareMode.getCollator(name); if (coll == null) { throw DbException.getInvalidValueException("collation", name); } if (readIf("STRENGTH")) { if (readIf("PRIMARY")) { command.setInt(Collator.PRIMARY); } else if (readIf("SECONDARY")) { command.setInt(Collator.SECONDARY); } else if (readIf("TERTIARY")) { command.setInt(Collator.TERTIARY); } else if (readIf("IDENTICAL")) { command.setInt(Collator.IDENTICAL); } } else { command.setInt(coll.getStrength()); } return command; }
@Override public int hashCode() { return getName().hashCode() ^ strength ^ (binaryUnsigned ? -1 : 0); }
/** * Compare name name of the locale with the given name. The case of the name * is ignored. * * @param locale the locale * @param name the name * @return true if they match */ static boolean compareLocaleNames(Locale locale, String name) { return name.equalsIgnoreCase(locale.toString()) || name.equalsIgnoreCase(getName(locale)); }
@Override protected int compareSecure(Value o, CompareMode mode) { ValueStringIgnoreCase v = (ValueStringIgnoreCase) o; return mode.compareString(value, v.value, true); }
public Database(Configuration configuration) { this.configuration = configuration; this.compareMode = CompareMode.getInstance(null, 0); this.dbSettings = getDbSettings(configuration.settings); this.mode = Mode.getInstance(dbSettings.sqlMode); this.traceSystem = new TraceSystem(); this.trace = traceSystem.getTrace(Trace.DATABASE); this.queryExecutor = createQueryExecutor(); this.repository = bindRepository(); this.executorFactory = new ExecutorFactoryImpl(); openDatabase(); }
private void initPattern(String p, Character escapeChar) { if (compareMode.getName().equals(CompareMode.OFF) && !ignoreCase) { fastCompare = true;
if (compareMode.compareString(begin, end, ignoreCase) == -1) { filter.addIndexCondition(IndexCondition.get( Comparison.SMALLER, l,
protected List<Value> enumRange(Value firstV, Value lastV) { if (isNull(firstV) || isNull(lastV)) { return null; } if (firstV.getType() != lastV.getType()) { return null; } int type = firstV.getType(); switch (type) { case Value.BYTE: case Value.INT: case Value.LONG: case Value.SHORT: if (lastV.subtract(firstV).getLong() > 200) { return null; } List<Value> enumValues = New.arrayList(10); Value enumValue = firstV; CompareMode compareMode = CompareMode.getInstance(null, 0); while (enumValue.compareTo(lastV, compareMode) <= 0) { enumValues.add(enumValue); Value increase = ValueLong.get(1).convertTo(enumValue.getType()); enumValue = enumValue.add(increase); } return enumValues; default: return null; } }