OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 142 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 142 Rev 182
Line 1... Line 1...
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
9
 * language governing permissions and limitations under the License.
Line 267... Line 267...
267
    @Override
267
    @Override
268
    public boolean equals(Object obj) {
268
    public boolean equals(Object obj) {
269
        return equals(obj, null);
269
        return equals(obj, null);
270
    }
270
    }
271
 
271
 
272
    public boolean equals(Object obj, SQLSystem otherSystem) {
272
    public boolean equals(Object obj, SQLSyntax otherSyntax) {
273
        if (obj instanceof SQLType) {
273
        if (obj instanceof SQLType) {
274
            final SQLType o = (SQLType) obj;
274
            final SQLType o = (SQLType) obj;
275
            final boolean javaTypeOK = this.getJavaType().equals(o.getJavaType());
275
            final boolean javaTypeOK = this.getJavaType().equals(o.getJavaType());
276
            if (!javaTypeOK) {
276
            if (!javaTypeOK) {
277
                return false;
277
                return false;
Line 290... Line 290...
290
            // Floating-Point Types have no precision (apart from single or double precision, but
290
            // Floating-Point Types have no precision (apart from single or double precision, but
291
            // this is handled by typeOK)
291
            // this is handled by typeOK)
292
            if (this.getType() == Types.DATE || this.getJavaType() == Float.class || this.getJavaType() == Double.class) {
292
            if (this.getType() == Types.DATE || this.getJavaType() == Float.class || this.getJavaType() == Double.class) {
293
                sizeOK = true;
293
                sizeOK = true;
294
            } else {
294
            } else {
295
                if (otherSystem == null && o.getSyntax() != null)
295
                if (otherSyntax == null)
296
                    otherSystem = o.getSyntax().getSystem();
296
                    otherSyntax = o.getSyntax();
297
                final SQLSystem thisSystem = this.getSyntax() == null ? null : this.getSyntax().getSystem();
297
                final SQLSystem thisSystem = this.getSyntax() == null ? null : this.getSyntax().getSystem();
298
                final boolean isTime = this.getType() == Types.TIME || this.getType() == Types.TIMESTAMP;
298
                final boolean isTime = this.getType() == Types.TIME || this.getType() == Types.TIMESTAMP;
299
                final boolean decDigitsOK;
299
                final boolean decDigitsOK;
300
                // only TIME and NUMERIC use DECIMAL_DIGITS, others like integer use only size
300
                // only TIME and NUMERIC use DECIMAL_DIGITS, others like integer use only size
301
                if (!this.isNumeric() && !isTime) {
301
                if (!this.isNumeric() && !isTime) {
302
                    decDigitsOK = true;
302
                    decDigitsOK = true;
303
                } else if (this.isNumeric() ||
303
                } else if (this.isNumeric() ||
304
                // isTime() : if we don't know the system, play it safe and compare
304
                // isTime() : if we don't know the system, play it safe and compare
305
                        thisSystem == null || otherSystem == null || thisSystem.isFractionalSecondsSupported() && otherSystem.isFractionalSecondsSupported()) {
305
                        thisSystem == null || otherSyntax == null || thisSystem.isFractionalSecondsSupported() && otherSyntax.getSystem().isFractionalSecondsSupported()) {
306
                    decDigitsOK = CompareUtils.equals(this.getDecimalDigits(), o.getDecimalDigits());
306
                    decDigitsOK = CompareUtils.equals(this.getDecimalDigits(), o.getDecimalDigits());
307
                } else {
307
                } else {
308
                    decDigitsOK = true;
308
                    decDigitsOK = true;
309
                }
309
                }
310
                // not all systems return the same size for TIME but only DECIMAL DIGITS matters
310
                // not all systems return the same size for TIME but only DECIMAL DIGITS matters