ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/result/SimpleResult.java

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

      
    
Rootfs path

      
    
Size
6932 (6.8 KB)
MD5
1eef979c871ecc13069690db5e512b15
SHA1
d5f20aa7c40342ff830a1c6a141c12aad50631a2
SHA256
b7a3daddcf34ff276c93741ee38e029408c6edeb36973c91ae36d620100c1f0a
SHA512

      
    
SHA1_git
912b29f930876f7bfa8766a827c3b1506a7d15e1
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
SimpleResult.java | 6.8 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.result; import java.sql.ResultSetMetaData; import java.util.ArrayList; import java.util.Comparator; import org.h2.engine.Session; import org.h2.util.Utils; import org.h2.value.TypeInfo; import org.h2.value.Value; /** * Simple in-memory result. */ public class SimpleResult implements ResultInterface, ResultTarget { /** * Column info for the simple result. */ static final class Column { /** Column alias. */ final String alias; /** Column name. */ final String columnName; /** Column type. */ final TypeInfo columnType; Column(String alias, String columnName, TypeInfo columnType) { if (alias == null || columnName == null) { throw new NullPointerException(); } this.alias = alias; this.columnName = columnName; this.columnType = columnType; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + alias.hashCode(); result = prime * result + columnName.hashCode(); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || getClass() != obj.getClass()) return false; Column other = (Column) obj; return alias.equals(other.alias) && columnName.equals(other.columnName); } @Override public String toString() { if (alias.equals(columnName)) { return columnName; } return columnName + ' ' + alias; } } private final ArrayList<Column> columns; private final ArrayList<Value[]> rows; private final String schemaName, tableName; private int rowId; /** * Creates new instance of simple result. */ public SimpleResult() { this("", ""); } /** * Creates new instance of simple result. * * @param schemaName * the name of the schema * @param tableName * the name of the table */ public SimpleResult(String schemaName, String tableName) { this.columns = Utils.newSmallArrayList(); this.rows = new ArrayList<>(); this.schemaName = schemaName; this.tableName = tableName; this.rowId = -1; } private SimpleResult(ArrayList<Column> columns, ArrayList<Value[]> rows, String schemaName, String tableName) { this.columns = columns; this.rows = rows; this.schemaName = schemaName; this.tableName = tableName; this.rowId = -1; } /** * Add column to the result. * * @param alias * Column's alias. * @param columnName * Column's name. * @param columnType * Column's value type. * @param columnPrecision * Column's precision. * @param columnScale * Column's scale. */ public void addColumn(String alias, String columnName, int columnType, long columnPrecision, int columnScale) { addColumn(alias, columnName, TypeInfo.getTypeInfo(columnType, columnPrecision, columnScale, null)); } /** * Add column to the result. * * @param columnName * Column's name. * @param columnType * Column's type. */ public void addColumn(String columnName, TypeInfo columnType) { addColumn(new Column(columnName, columnName, columnType)); } /** * Add column to the result. * * @param alias * Column's alias. * @param columnName * Column's name. * @param columnType * Column's type. */ public void addColumn(String alias, String columnName, TypeInfo columnType) { addColumn(new Column(alias, columnName, columnType)); } /** * Add column to the result. * * @param column * Column info. */ void addColumn(Column column) { assert rows.isEmpty(); columns.add(column); } @Override public void addRow(Value... values) { assert values.length == columns.size(); rows.add(values); } @Override public void reset() { rowId = -1; } @Override public Value[] currentRow() { return rows.get(rowId); } @Override public boolean next() { int count = rows.size(); if (rowId < count) { return ++rowId < count; } return false; } @Override public long getRowId() { return rowId; } @Override public boolean isAfterLast() { return rowId >= rows.size(); } @Override public int getVisibleColumnCount() { return columns.size(); } @Override public long getRowCount() { return rows.size(); } @Override public boolean hasNext() { return rowId < rows.size() - 1; } @Override public boolean needToClose() { return false; } @Override public void close() { // Do nothing for now } @Override public String getAlias(int i) { return columns.get(i).alias; } @Override public String getSchemaName(int i) { return schemaName; } @Override public String getTableName(int i) { return tableName; } @Override public String getColumnName(int i) { return columns.get(i).columnName; } @Override public TypeInfo getColumnType(int i) { return columns.get(i).columnType; } @Override public boolean isIdentity(int i) { return false; } @Override public int getNullable(int i) { return ResultSetMetaData.columnNullableUnknown; } @Override public void setFetchSize(int fetchSize) { // Ignored } @Override public int getFetchSize() { return 1; } @Override public boolean isLazy() { return false; } @Override public boolean isClosed() { return false; } @Override public SimpleResult createShallowCopy(Session targetSession) { return new SimpleResult(columns, rows, schemaName, tableName); } @Override public void limitsWereApplied() { // Nothing to do } /** * Sort rows in the list. * * @param comparator * the comparator */ public void sortRows(Comparator<? super Value[]> comparator) { rows.sort(comparator); } }
Detected license expression

      
    
Detected license expression (SPDX)

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