/** * 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); }
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(); }
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; } }
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); 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);