ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/value/ValueInteger.java

Path
ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/value/ValueInteger.java
Status
scanned
Type
file
Name
ValueInteger.java
Extension
.java
Programming language
Java
Mime type
text/x-java
File type
Java source, ASCII text
Tag

      
    
Rootfs path

      
    
Size
4776 (4.7 KB)
MD5
9dee702fc0caed33ecbd5a39e230cd62
SHA1
a05135746df3444d5874e7d2edb9e5961f04e8ae
SHA256
0ad832491aa5ab686474b3fbc142b0889c1a1cd3f6256803e5688bfc20d01ac3
SHA512

      
    
SHA1_git
32815369c6956edf6401cf7f7a70983e81768c81
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
ValueInteger.java | 4.7 KB |

/* * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0, * and the EPL 1.0 (https://h2database.com/html/license.html). * Initial Developer: H2 Group */ package org.h2.value; import java.math.BigDecimal; import org.h2.api.ErrorCode; import org.h2.engine.CastDataProvider; import org.h2.message.DbException; import org.h2.util.Bits; /** * Implementation of the INTEGER data type. */ public final class ValueInteger extends Value { /** * The precision in bits. */ public static final int PRECISION = 32; /** * The approximate precision in decimal digits. */ public static final int DECIMAL_PRECISION = 10; /** * The maximum display size of an INT. * Example: -2147483648 */ public static final int DISPLAY_SIZE = 11; private static final int STATIC_SIZE = 128; // must be a power of 2 private static final int DYNAMIC_SIZE = 256; private static final ValueInteger[] STATIC_CACHE = new ValueInteger[STATIC_SIZE]; private static final ValueInteger[] DYNAMIC_CACHE = new ValueInteger[DYNAMIC_SIZE]; private final int value; static { for (int i = 0; i < STATIC_SIZE; i++) { STATIC_CACHE[i] = new ValueInteger(i); } } private ValueInteger(int value) { this.value = value; } /** * Get or create an INTEGER value for the given int. * * @param i the int * @return the value */ public static ValueInteger get(int i) { if (i >= 0 && i < STATIC_SIZE) { return STATIC_CACHE[i]; } ValueInteger v = DYNAMIC_CACHE[i & (DYNAMIC_SIZE - 1)]; if (v == null || v.value != i) { v = new ValueInteger(i); DYNAMIC_CACHE[i & (DYNAMIC_SIZE - 1)] = v; } return v; } @Override public Value add(Value v) { ValueInteger other = (ValueInteger) v; return checkRange((long) value + (long) other.value); } private static ValueInteger checkRange(long x) { if ((int) x != x) { throw DbException.get(ErrorCode.NUMERIC_VALUE_OUT_OF_RANGE_1, Long.toString(x)); } return ValueInteger.get((int) x); } @Override public int getSignum() { return Integer.signum(value); } @Override public Value negate() { return checkRange(-(long) value); } @Override public Value subtract(Value v) { ValueInteger other = (ValueInteger) v; return checkRange((long) value - (long) other.value); } @Override public Value multiply(Value v) { ValueInteger other = (ValueInteger) v; return checkRange((long) value * (long) other.value); } @Override public Value divide(Value v, TypeInfo quotientType) { int y = ((ValueInteger) v).value; if (y == 0) { throw DbException.get(ErrorCode.DIVISION_BY_ZERO_1, getTraceSQL()); } int x = value; if (x == Integer.MIN_VALUE && y == -1) { throw DbException.get(ErrorCode.NUMERIC_VALUE_OUT_OF_RANGE_1, "2147483648"); } return ValueInteger.get(x / y); } @Override public Value modulus(Value v) { ValueInteger other = (ValueInteger) v; if (other.value == 0) { throw DbException.get(ErrorCode.DIVISION_BY_ZERO_1, getTraceSQL()); } return ValueInteger.get(value % other.value); } @Override public StringBuilder getSQL(StringBuilder builder, int sqlFlags) { return builder.append(value); } @Override public TypeInfo getType() { return TypeInfo.TYPE_INTEGER; } @Override public int getValueType() { return INTEGER; } @Override public byte[] getBytes() { byte[] b = new byte[4]; Bits.writeInt(b, 0, getInt()); return b; } @Override public int getInt() { return value; } @Override public long getLong() { return value; } @Override public BigDecimal getBigDecimal() { return BigDecimal.valueOf(value); } @Override public float getFloat() { return value; } @Override public double getDouble() { return value; } @Override public int compareTypeSafe(Value o, CompareMode mode, CastDataProvider provider) { return Integer.compare(value, ((ValueInteger) o).value); } @Override public String getString() { return Integer.toString(value); } @Override public int hashCode() { return value; } @Override public boolean equals(Object other) { return other instanceof ValueInteger && value == ((ValueInteger) other).value; } }
Detected license expression

      
    
Detected license expression (SPDX)

      
    
Percentage of license text
2.13
Copyrights
- end_line: 2
  copyright: Copyright 2004-2023 H2 Group. Multiple-Licensed
  start_line: 2
Holders
- holder: H2 Group. Multiple-Licensed
  end_line: 2
  start_line: 2
Authors

      
    
License expression License clue details
(mpl-2.0 OR epl-1.0) AND proprietary-license {'score': 20.37, 'matcher': '3-seq', 'end_line': 3, 'rule_url': 'https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/mpl-2.0_or_epl-1.0_and_proprietary-license_2.RULE', 'from_file': None, 'start_line': 2, 'matched_text': ' * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0,\n * and the EPL 1.0 (https://h2database.com/html/license.html).', 'match_coverage': 20.37, 'matched_length': 11, 'rule_relevance': 100, 'rule_identifier': 'mpl-2.0_or_epl-1.0_and_proprietary-license_2.RULE', 'license_expression': '(mpl-2.0 OR epl-1.0) AND proprietary-license', 'license_expression_spdx': '(MPL-2.0 OR EPL-1.0) AND LicenseRef-scancode-proprietary-license'}
URL Start line End line
https://h2database.com/html/license.html 3 3
Package URL License Primary language
pkg:osgi/com.h2database.source@2.2.220