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

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

      
    
Rootfs path

      
    
Size
4153 (4.1 KB)
MD5
0b37d65c0ae6343e5f3a36cecc983f30
SHA1
ccde4405ba0f362685021552a5a2aa229708b8b3
SHA256
c312382f66a714ba6858b5db681b15d991c3c97dab7b6363df962b44b2024812
SHA512

      
    
SHA1_git
17c3bac10c8c70dcbaa220841e354cc490857abd
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
ValueSmallint.java | 4.1 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; /** * Implementation of the SMALLINT data type. */ public final class ValueSmallint extends Value { /** * The precision in bits. */ static final int PRECISION = 16; /** * The approximate precision in decimal digits. */ public static final int DECIMAL_PRECISION = 5; /** * The maximum display size of a SMALLINT. * Example: -32768 */ static final int DISPLAY_SIZE = 6; private final short value; private ValueSmallint(short value) { this.value = value; } @Override public Value add(Value v) { ValueSmallint other = (ValueSmallint) v; return checkRange(value + other.value); } private static ValueSmallint checkRange(int x) { if ((short) x != x) { throw DbException.get(ErrorCode.NUMERIC_VALUE_OUT_OF_RANGE_1, Integer.toString(x)); } return ValueSmallint.get((short) x); } @Override public int getSignum() { return Integer.signum(value); } @Override public Value negate() { return checkRange(-(int) value); } @Override public Value subtract(Value v) { ValueSmallint other = (ValueSmallint) v; return checkRange(value - other.value); } @Override public Value multiply(Value v) { ValueSmallint other = (ValueSmallint) v; return checkRange(value * other.value); } @Override public Value divide(Value v, TypeInfo quotientType) { ValueSmallint other = (ValueSmallint) v; if (other.value == 0) { throw DbException.get(ErrorCode.DIVISION_BY_ZERO_1, getTraceSQL()); } return checkRange(value / other.value); } @Override public Value modulus(Value v) { ValueSmallint other = (ValueSmallint) v; if (other.value == 0) { throw DbException.get(ErrorCode.DIVISION_BY_ZERO_1, getTraceSQL()); } return ValueSmallint.get((short) (value % other.value)); } @Override public StringBuilder getSQL(StringBuilder builder, int sqlFlags) { if ((sqlFlags & NO_CASTS) == 0) { return builder.append("CAST(").append(value).append(" AS SMALLINT)"); } return builder.append(value); } @Override public TypeInfo getType() { return TypeInfo.TYPE_SMALLINT; } @Override public int getValueType() { return SMALLINT; } @Override public byte[] getBytes() { short value = this.value; return new byte[] { (byte) (value >> 8), (byte) value }; } @Override public short getShort() { return value; } @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, ((ValueSmallint) o).value); } @Override public String getString() { return Integer.toString(value); } @Override public int hashCode() { return value; } /** * Get or create a SMALLINT value for the given short. * * @param i the short * @return the value */ public static ValueSmallint get(short i) { return (ValueSmallint) Value.cache(new ValueSmallint(i)); } @Override public boolean equals(Object other) { return other instanceof ValueSmallint && value == ((ValueSmallint) other).value; } }
Detected license expression

      
    
Detected license expression (SPDX)

      
    
Percentage of license text
2.63
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