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

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

      
    
Rootfs path

      
    
Size
2946 (2.9 KB)
MD5
4a01284247d676374694c4fe06d1ceec
SHA1
b71f323f2d74091cb254eef187491803758a080f
SHA256
98a97a96a6e304d1eafdf78c2a94f7c4425e7638c35a2168fbeb82cab5e612c2
SHA512

      
    
SHA1_git
33db1d6548f8019c9104a408175606570f5de400
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
Parameter.java | 2.9 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 org.h2.api.ErrorCode; import org.h2.engine.SessionLocal; import org.h2.expression.condition.Comparison; import org.h2.message.DbException; import org.h2.table.Column; import org.h2.value.TypeInfo; import org.h2.value.Value; import org.h2.value.ValueNull; import org.h2.value.ValueVarchar; /** * A parameter of a prepared statement. */ public final class Parameter extends Operation0 implements ParameterInterface { private Value value; private Column column; private final int index; public Parameter(int index) { this.index = index; } @Override public StringBuilder getUnenclosedSQL(StringBuilder builder, int sqlFlags) { return builder.append('?').append(index + 1); } @Override public void setValue(Value v, boolean closeOld) { // don't need to close the old value as temporary files are anyway // removed this.value = v; } public void setValue(Value v) { this.value = v; } @Override public Value getParamValue() { if (value == null) { // to allow parameters in function tables return ValueNull.INSTANCE; } return value; } @Override public Value getValue(SessionLocal session) { return getParamValue(); } @Override public TypeInfo getType() { if (value != null) { return value.getType(); } if (column != null) { return column.getType(); } return TypeInfo.TYPE_UNKNOWN; } @Override public void checkSet() { if (value == null) { throw DbException.get(ErrorCode.PARAMETER_NOT_SET_1, "#" + (index + 1)); } } @Override public Expression optimize(SessionLocal session) { if (session.getDatabase().getMode().treatEmptyStringsAsNull) { if (value instanceof ValueVarchar && value.getString().isEmpty()) { value = ValueNull.INSTANCE; } } return this; } @Override public boolean isValueSet() { return value != null; } @Override public boolean isEverything(ExpressionVisitor visitor) { switch (visitor.getType()) { case ExpressionVisitor.INDEPENDENT: return value != null; default: return true; } } @Override public int getCost() { return 0; } @Override public Expression getNotIfPossible(SessionLocal session) { return new Comparison(Comparison.EQUAL, this, ValueExpression.FALSE, false); } public void setColumn(Column column) { this.column = column; } public int getIndex() { return index; } }
Detected license expression
mpl-2.0 AND epl-1.0
Detected license expression (SPDX)
MPL-2.0 AND EPL-1.0
Percentage of license text
3.16
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 detections License expression License expression SPDX
mpl_2_0_and_epl_1_0-796bf8d7-f485-3520-923d-e6a4b1ecd2f3 mpl-2.0 AND epl-1.0 MPL-2.0 AND EPL-1.0
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