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

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

      
    
Rootfs path

      
    
Size
4475 (4.4 KB)
MD5
d0be999727193dd3dffc1f86bad45fbb
SHA1
7e2c0209eb41360240043a35e79462e2bc055c49
SHA256
ef7bd7208e3757f15f3f83ecd5aa08321ac95a2f0fe43f9c5c4a86d8974a762a
SHA512

      
    
SHA1_git
0bd0786b7c3ce249cff9ebb8439d5313a92f0a1a
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
ValueTinyint.java | 4.4 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 TINYINT data type. */ public final class ValueTinyint extends Value { /** * The precision in bits. */ static final int PRECISION = 8; /** * The approximate precision in decimal digits. */ public static final int DECIMAL_PRECISION = 3; /** * The display size for a TINYINT. * Example: -127 */ static final int DISPLAY_SIZE = 4; private static final ValueTinyint[] STATIC_CACHE; private final byte value; static { ValueTinyint[] cache = new ValueTinyint[256]; for (int i = 0; i < 256; i++) { cache[i] = new ValueTinyint((byte) (i - 128)); } STATIC_CACHE = cache; } private ValueTinyint(byte value) { this.value = value; } @Override public Value add(Value v) { ValueTinyint other = (ValueTinyint) v; return checkRange(value + other.value); } private static ValueTinyint checkRange(int x) { if ((byte) x != x) { throw DbException.get(ErrorCode.NUMERIC_VALUE_OUT_OF_RANGE_1, Integer.toString(x)); } return ValueTinyint.get((byte) x); } @Override public int getSignum() { return Integer.signum(value); } @Override public Value negate() { return checkRange(-(int) value); } @Override public Value subtract(Value v) { ValueTinyint other = (ValueTinyint) v; return checkRange(value - other.value); } @Override public Value multiply(Value v) { ValueTinyint other = (ValueTinyint) v; return checkRange(value * other.value); } @Override public Value divide(Value v, TypeInfo quotientType) { ValueTinyint other = (ValueTinyint) 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) { ValueTinyint other = (ValueTinyint) v; if (other.value == 0) { throw DbException.get(ErrorCode.DIVISION_BY_ZERO_1, getTraceSQL()); } return ValueTinyint.get((byte) (value % other.value)); } @Override public StringBuilder getSQL(StringBuilder builder, int sqlFlags) { if ((sqlFlags & NO_CASTS) == 0) { return builder.append("CAST(").append(value).append(" AS TINYINT)"); } return builder.append(value); } @Override public TypeInfo getType() { return TypeInfo.TYPE_TINYINT; } @Override public int getValueType() { return TINYINT; } @Override public int getMemory() { // All possible values are statically initialized return 0; } @Override public byte[] getBytes() { return new byte[] { value }; } @Override public byte getByte() { return 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, ((ValueTinyint) o).value); } @Override public String getString() { return Integer.toString(value); } @Override public int hashCode() { return value; } /** * Get a TINYINT value for the given byte. * * @param i the byte * @return the value */ public static ValueTinyint get(byte i) { return STATIC_CACHE[i + 128]; } @Override public boolean equals(Object other) { return other instanceof ValueTinyint && value == ((ValueTinyint) other).value; } }
Detected license expression

      
    
Detected license expression (SPDX)

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