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

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

      
    
Rootfs path

      
    
Size
4777 (4.7 KB)
MD5
0247393657688c14e0b74995fd1cc8ba
SHA1
bbdd377eb6346f2f7dcc6937d979267d77d2fe3e
SHA256
68d940ef42722c50f200ddabb56700ba3c422a4bb2501d9997d4e6344d330818
SHA512

      
    
SHA1_git
5c0dfcd92e8f25183eb4d65c450e1e9adc222f45
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
ResultWithPaddedStrings.java | 4.7 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.util.Arrays; import org.h2.engine.Session; import org.h2.util.MathUtils; import org.h2.value.TypeInfo; import org.h2.value.Value; import org.h2.value.ValueVarchar; /** * Result with padded fixed length strings. */ public class ResultWithPaddedStrings implements ResultInterface { private final ResultInterface source; /** * Returns wrapped result if necessary, or original result if it does not * contain visible CHAR columns. * * @param source * source result * @return wrapped result or original result */ public static ResultInterface get(ResultInterface source) { int count = source.getVisibleColumnCount(); for (int i = 0; i < count; i++) { if (source.getColumnType(i).getValueType() == Value.CHAR) { return new ResultWithPaddedStrings(source); } } return source; } /** * Creates new instance of result. * * @param source * the source result */ private ResultWithPaddedStrings(ResultInterface source) { this.source = source; } @Override public void reset() { source.reset(); } @Override public Value[] currentRow() { int count = source.getVisibleColumnCount(); Value[] row = Arrays.copyOf(source.currentRow(), count); for (int i = 0; i < count; i++) { TypeInfo type = source.getColumnType(i); if (type.getValueType() == Value.CHAR) { long precision = type.getPrecision(); if (precision == Integer.MAX_VALUE) { // CHAR is CHAR(1) precision = 1; } String s = row[i].getString(); if (s != null && s.length() < precision) { /* * Use ValueString to avoid truncation of spaces. There is * no difference between ValueStringFixed and ValueString * for JDBC layer anyway. */ row[i] = ValueVarchar.get(rightPadWithSpaces(s, MathUtils.convertLongToInt(precision))); } } } return row; } private static String rightPadWithSpaces(String s, int length) { int used = s.length(); if (length <= used) { return s; } char[] res = new char[length]; s.getChars(0, used, res, 0); Arrays.fill(res, used, length, ' '); return new String(res); } @Override public boolean next() { return source.next(); } @Override public long getRowId() { return source.getRowId(); } @Override public boolean isAfterLast() { return source.isAfterLast(); } @Override public int getVisibleColumnCount() { return source.getVisibleColumnCount(); } @Override public long getRowCount() { return source.getRowCount(); } @Override public boolean hasNext() { return source.hasNext(); } @Override public boolean needToClose() { return source.needToClose(); } @Override public void close() { source.close(); } @Override public String getAlias(int i) { return source.getAlias(i); } @Override public String getSchemaName(int i) { return source.getSchemaName(i); } @Override public String getTableName(int i) { return source.getTableName(i); } @Override public String getColumnName(int i) { return source.getColumnName(i); } @Override public TypeInfo getColumnType(int i) { return source.getColumnType(i); } @Override public boolean isIdentity(int i) { return source.isIdentity(i); } @Override public int getNullable(int i) { return source.getNullable(i); } @Override public void setFetchSize(int fetchSize) { source.setFetchSize(fetchSize); } @Override public int getFetchSize() { return source.getFetchSize(); } @Override public boolean isLazy() { return source.isLazy(); } @Override public boolean isClosed() { return source.isClosed(); } @Override public ResultInterface createShallowCopy(Session targetSession) { ResultInterface copy = source.createShallowCopy(targetSession); return copy != null ? new ResultWithPaddedStrings(copy) : null; } }
Detected license expression

      
    
Detected license expression (SPDX)

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