ttomcat-1778514358873.zip-extract/_dependencies/maven/com.h2database_h2-2.2.220/org/h2/schema/Domain.java

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

      
    
Rootfs path

      
    
Size
6408 (6.3 KB)
MD5
077539f460abc63a31c3fc19d703e69b
SHA1
2eeeb40030797d839d3fce74fb429ea5dbe079b8
SHA256
ce3ce3884e370729824fca19d7d9af8d5b185cf303c026664a82d1aadb728aef
SHA512

      
    
SHA1_git
4b7d6c555d7b3d5004c7d5c8f3fc41c913f8733e
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
Domain.java | 6.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.schema; import java.util.ArrayList; import org.h2.constraint.Constraint; import org.h2.constraint.ConstraintDomain; import org.h2.engine.DbObject; import org.h2.engine.SessionLocal; import org.h2.expression.Expression; import org.h2.expression.ValueExpression; import org.h2.message.Trace; import org.h2.table.ColumnTemplate; import org.h2.util.Utils; import org.h2.value.TypeInfo; import org.h2.value.Value; /** * Represents a domain. */ public final class Domain extends SchemaObject implements ColumnTemplate { private TypeInfo type; /** * Parent domain. */ private Domain domain; private Expression defaultExpression; private Expression onUpdateExpression; private ArrayList<ConstraintDomain> constraints; public Domain(Schema schema, int id, String name) { super(schema, id, name, Trace.SCHEMA); } @Override public String getDropSQL() { StringBuilder builder = new StringBuilder("DROP DOMAIN IF EXISTS "); return getSQL(builder, DEFAULT_SQL_FLAGS).toString(); } @Override public String getCreateSQL() { StringBuilder builder = getSQL(new StringBuilder("CREATE DOMAIN "), DEFAULT_SQL_FLAGS).append(" AS "); if (domain != null) { domain.getSQL(builder, DEFAULT_SQL_FLAGS); } else { type.getSQL(builder, DEFAULT_SQL_FLAGS); } if (defaultExpression != null) { defaultExpression.getUnenclosedSQL(builder.append(" DEFAULT "), DEFAULT_SQL_FLAGS); } if (onUpdateExpression != null) { onUpdateExpression.getUnenclosedSQL(builder.append(" ON UPDATE "), DEFAULT_SQL_FLAGS); } return builder.toString(); } public void setDataType(TypeInfo type) { this.type = type; } public TypeInfo getDataType() { return type; } @Override public void setDomain(Domain domain) { this.domain = domain; } @Override public Domain getDomain() { return domain; } @Override public void setDefaultExpression(SessionLocal session, Expression defaultExpression) { // also to test that no column names are used if (defaultExpression != null) { defaultExpression = defaultExpression.optimize(session); if (defaultExpression.isConstant()) { defaultExpression = ValueExpression.get(defaultExpression.getValue(session)); } } this.defaultExpression = defaultExpression; } @Override public Expression getDefaultExpression() { return defaultExpression; } @Override public Expression getEffectiveDefaultExpression() { return defaultExpression != null ? defaultExpression : domain != null ? domain.getEffectiveDefaultExpression() : null; } @Override public String getDefaultSQL() { return defaultExpression == null ? null : defaultExpression.getUnenclosedSQL(new StringBuilder(), DEFAULT_SQL_FLAGS).toString(); } @Override public void setOnUpdateExpression(SessionLocal session, Expression onUpdateExpression) { // also to test that no column names are used if (onUpdateExpression != null) { onUpdateExpression = onUpdateExpression.optimize(session); if (onUpdateExpression.isConstant()) { onUpdateExpression = ValueExpression.get(onUpdateExpression.getValue(session)); } } this.onUpdateExpression = onUpdateExpression; } @Override public Expression getOnUpdateExpression() { return onUpdateExpression; } @Override public Expression getEffectiveOnUpdateExpression() { return onUpdateExpression != null ? onUpdateExpression : domain != null ? domain.getEffectiveOnUpdateExpression() : null; } @Override public String getOnUpdateSQL() { return onUpdateExpression == null ? null : onUpdateExpression.getUnenclosedSQL(new StringBuilder(), DEFAULT_SQL_FLAGS).toString(); } @Override public void prepareExpressions(SessionLocal session) { if (defaultExpression != null) { defaultExpression = defaultExpression.optimize(session); } if (onUpdateExpression != null) { onUpdateExpression = onUpdateExpression.optimize(session); } if (domain != null) { domain.prepareExpressions(session); } } /** * Add a constraint to the domain. * * @param constraint the constraint to add */ public void addConstraint(ConstraintDomain constraint) { if (constraints == null) { constraints = Utils.newSmallArrayList(); } if (!constraints.contains(constraint)) { constraints.add(constraint); } } public ArrayList<ConstraintDomain> getConstraints() { return constraints; } /** * Remove the given constraint from the list. * * @param constraint the constraint to remove */ public void removeConstraint(Constraint constraint) { if (constraints != null) { constraints.remove(constraint); } } @Override public int getType() { return DbObject.DOMAIN; } @Override public void removeChildrenAndResources(SessionLocal session) { if (constraints != null && !constraints.isEmpty()) { for (ConstraintDomain constraint : constraints.toArray(new ConstraintDomain[0])) { database.removeSchemaObject(session, constraint); } constraints = null; } database.removeMeta(session, getId()); } /** * Check the specified value. * * @param session the session * @param value the value */ public void checkConstraints(SessionLocal session, Value value) { if (constraints != null) { for (ConstraintDomain constraint : constraints) { constraint.check(session, value); } } if (domain != null) { domain.checkConstraints(session, value); } } }
Detected license expression

      
    
Detected license expression (SPDX)

      
    
Percentage of license text
2.87
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'}
public-domain {'score': 70.0, 'matcher': '2-aho', 'end_line': 39, 'rule_url': 'https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/public-domain_bare_words.RULE', 'from_file': None, 'start_line': 39, 'matched_text': ' public Domain(Schema schema, int id, String name) {', 'match_coverage': 100.0, 'matched_length': 2, 'rule_relevance': 70, 'rule_identifier': 'public-domain_bare_words.RULE', 'license_expression': 'public-domain', 'license_expression_spdx': 'LicenseRef-scancode-public-domain'}
public-domain {'score': 70.0, 'matcher': '2-aho', 'end_line': 80, 'rule_url': 'https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/public-domain_bare_words.RULE', 'from_file': None, 'start_line': 80, 'matched_text': ' public Domain getDomain() {', 'match_coverage': 100.0, 'matched_length': 2, 'rule_relevance': 70, 'rule_identifier': 'public-domain_bare_words.RULE', 'license_expression': 'public-domain', 'license_expression_spdx': 'LicenseRef-scancode-public-domain'}
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