ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/expression/CompatibilityDatePlusTimeOperation.java

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

      
    
Rootfs path

      
    
Size
4443 (4.3 KB)
MD5
65e6b5d66873780dcbeeda8950d096ce
SHA1
bcb0d35be88ac789e19b66ad7db70d82c224c7bf
SHA256
5fa094ad5bee1e8a2a00d26a6e5f540f82988dbee8e9987ac4bba155d01db1cf
SHA512

      
    
SHA1_git
f7becdee38fdcad68b23dd4cdc0bd6e2634c27a0
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
CompatibilityDatePlusTimeOperation.java | 4.3 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.expression; import static org.h2.util.DateTimeUtils.NANOS_PER_DAY; import org.h2.engine.SessionLocal; import org.h2.message.DbException; import org.h2.util.DateTimeUtils; import org.h2.value.TypeInfo; import org.h2.value.Value; import org.h2.value.ValueDate; import org.h2.value.ValueNull; import org.h2.value.ValueTime; import org.h2.value.ValueTimeTimeZone; import org.h2.value.ValueTimestamp; import org.h2.value.ValueTimestampTimeZone; /** * A compatibility mathematical operation with datetime values. */ public class CompatibilityDatePlusTimeOperation extends Operation2 { public CompatibilityDatePlusTimeOperation(Expression left, Expression right) { super(left, right); TypeInfo l = left.getType(), r = right.getType(); int t; switch (l.getValueType()) { case Value.TIMESTAMP_TZ: if (r.getValueType() == Value.TIME_TZ) { throw DbException.getUnsupportedException("TIMESTAMP WITH TIME ZONE + TIME WITH TIME ZONE"); } //$FALL-THROUGH$ case Value.TIME: t = r.getValueType() == Value.DATE ? Value.TIMESTAMP : l.getValueType(); break; case Value.TIME_TZ: if (r.getValueType() == Value.TIME_TZ) { throw DbException.getUnsupportedException("TIME WITH TIME ZONE + TIME WITH TIME ZONE"); } t = r.getValueType() == Value.DATE ? Value.TIMESTAMP_TZ : l.getValueType(); break; case Value.TIMESTAMP: t = r.getValueType() == Value.TIME_TZ ? Value.TIMESTAMP_TZ : Value.TIMESTAMP; break; default: throw DbException.getUnsupportedException( Value.getTypeName(l.getValueType()) + " + " + Value.getTypeName(r.getValueType())); } type = TypeInfo.getTypeInfo(t, 0L, Math.max(l.getScale(), r.getScale()), null); } @Override public boolean needParentheses() { return true; } @Override public StringBuilder getUnenclosedSQL(StringBuilder builder, int sqlFlags) { left.getSQL(builder, sqlFlags, AUTO_PARENTHESES).append(" + "); return right.getSQL(builder, sqlFlags, AUTO_PARENTHESES); } @Override public Value getValue(SessionLocal session) { Value l = left.getValue(session); Value r = right.getValue(session); if (l == ValueNull.INSTANCE || r == ValueNull.INSTANCE) { return ValueNull.INSTANCE; } switch (l.getValueType()) { case Value.TIME: if (r.getValueType() == Value.DATE) { return ValueTimestamp.fromDateValueAndNanos(((ValueDate) r).getDateValue(), // ((ValueTime) l).getNanos()); } break; case Value.TIME_TZ: if (r.getValueType() == Value.DATE) { ValueTimeTimeZone t = (ValueTimeTimeZone) l; return ValueTimestampTimeZone.fromDateValueAndNanos(((ValueDate) r).getDateValue(), t.getNanos(), t.getTimeZoneOffsetSeconds()); } break; case Value.TIMESTAMP: { if (r.getValueType() == Value.TIME_TZ) { ValueTimestamp ts = (ValueTimestamp) l; l = ValueTimestampTimeZone.fromDateValueAndNanos(ts.getDateValue(), ts.getTimeNanos(), ((ValueTimeTimeZone) r).getTimeZoneOffsetSeconds()); } break; } } long[] a = DateTimeUtils.dateAndTimeFromValue(l, session); long dateValue = a[0], timeNanos = a[1] + (r instanceof ValueTime ? ((ValueTime) r).getNanos() : ((ValueTimeTimeZone) r).getNanos()); if (timeNanos >= NANOS_PER_DAY) { timeNanos -= NANOS_PER_DAY; dateValue = DateTimeUtils.incrementDateValue(dateValue); } return DateTimeUtils.dateTimeToValue(l, dateValue, timeNanos); } @Override public Expression optimize(SessionLocal session) { left = left.optimize(session); right = right.optimize(session); if (left.isConstant() && right.isConstant()) { return ValueExpression.get(getValue(session)); } return this; } }
Detected license expression

      
    
Detected license expression (SPDX)

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