Merge pull request #3 from rhauch/DBZ-4

DBZ-4 Changed copyright statement in source code headers and adjusted checkstyle rules
This commit is contained in:
Randall Hauch 2016-01-27 08:44:35 -06:00
commit 74f5b1ad4b
97 changed files with 168 additions and 2130 deletions

View File

@ -1,7 +1,7 @@
[![Build Status](https://travis-ci.org/debezium/debezium.svg?branch=master)](https://travis-ci.org/debezium/debezium)
[![License](http://img.shields.io/:license-apache-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
Copyright 2008-2016 Debezium Authors. Licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
Copyright Debezium Authors. Licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
# Debezium

6
copyright.txt Normal file
View File

@ -0,0 +1,6 @@
Barry LaFond
Daniel Kelleher
Horia Chiorean
Jure Kajzer
Randall Hauch
Sanne Grinovero

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
@ -12,18 +12,20 @@
/**
* An immutable representation of a data type
*
* @author Randall Hauch
*/
@Immutable
public final class DataType {
/**
* Obtain the data type for a user-defined or fully-qualified type name.
*
* @param qualifiedName the fully-qualified name; may not be null
* @return the data type; never null
*/
public static DataType userDefinedType( String qualifiedName ) {
return new DataType(qualifiedName,qualifiedName,Types.OTHER,-1,-1,null,0);
public static DataType userDefinedType(String qualifiedName) {
return new DataType(qualifiedName, qualifiedName, Types.OTHER, -1, -1, null, 0);
}
private final String expression;
@ -32,44 +34,44 @@ public static DataType userDefinedType( String qualifiedName ) {
private final long length;
private final int scale;
private final int[] arrayDimensions;
protected DataType( String expr, String name, int jdbcType, long length, int scale, int[] arrayDimensions, int arrayDimLength ) {
protected DataType(String expr, String name, int jdbcType, long length, int scale, int[] arrayDimensions, int arrayDimLength) {
this.expression = expr;
this.name= name;
this.name = name;
this.jdbcType = jdbcType;
this.length = length;
this.scale = scale;
if ( arrayDimensions == null || arrayDimLength == 0 ) {
if (arrayDimensions == null || arrayDimLength == 0) {
this.arrayDimensions = null;
} else {
this.arrayDimensions = Arrays.copyOf(arrayDimensions, arrayDimLength);
}
}
public String expression() {
return expression;
}
public String name() {
return name;
}
public int jdbcType() {
return jdbcType;
}
public long length() {
return length;
}
public int scale() {
return scale;
}
public int[] arrayDimensions() {
return arrayDimensions;
}
@Override
public String toString() {
return expression;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
@ -19,10 +19,14 @@
import io.debezium.text.TokenStream.Marker;
/**
* A parser of SQL data types. Callers set up a parser and register patterns that describe the possible lists of tokens, and then
* can repeatedly {@link #parse(TokenStream, Consumer) parse} {@link TokenStream streams of tokens} looking for matches.
* A parser of SQL data types. Callers set up a parser and register patterns that describe the possible lists of data type tokens,
* and then repeatedly {@link #parse(TokenStream, Consumer) parse} {@link TokenStream streams of tokens} looking for matches.
* <p>
* This is typically used within a {@link DdlParser} implementation to parse and identify data types appearing within a stream
* of DDL content.
*
* @author Randall Hauch
* @see DdlParser
*/
@ThreadSafe
public class DataTypeParser {

View File

@ -1,223 +0,0 @@
/*
* Copyright 2016 Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.debezium.relational.ddl;
import java.util.Arrays;
import java.util.List;
public interface DdlConstants {
public static final long KILO = 1024;
public static final long MEGA = KILO * 1024;
public static final long GIGA = MEGA * 1024;
public static final String DEFAULT_TERMINATOR = ";";
/*
* Character Strings
*/
public static final String SPACE = " ";
public static final String PERIOD = ".";
public static final String COMMA = ",";
public static final String SEMICOLON = ";";
public static final String L_PAREN = "(";
public static final String R_PAREN = ")";
public static final String L_SQUOTE = "";
public static final String LS_BRACE = "[";
public static final String RS_BRACE = "]";
/*
* Table Constraint ID's
*/
public static final int CONSTRAINT_UC = 0;
public static final int CONSTRAINT_FK = 1;
public static final int CONSTRAINT_PK = 2;
public static final int CONSTRAINT_C = 3;
public static final String PRIMARY_KEY = "PRIMARY KEY";
public static final String FOREIGN_KEY = "FOREIGN KEY";
/*
* Common DDL Keywords
*/
public static final String ALTER = "ALTER";
public static final String CHECK = "CHECK";
public static final String COLUMN = "COLUMN";
public static final String CONSTRAINT = "CONSTRAINT";
public static final String CREATE = "CREATE";
public static final String DECLARE = "DECLARE";
public static final String DROP = "DROP";
public static final String FOREIGN = "FOREIGN";
public static final String GRANT = "GRANT";
public static final String REVOKE = "REVOKE";
public static final String INDEX = "INDEX";
public static final String INSERT = "INSERT";
public static final String UPDATE = "UPDATE";
public static final String DELETE = "DELETE";
public static final String SELECT = "SELECT";
public static final String KEY = "KEY";
public static final String OFF = "OFF";
public static final String ON = "ON";
public static final String PRIMARY = "PRIMARY";
public static final String SCHEMA = "SCHEMA";
public static final String SET = "SET";
public static final String TABLE = "TABLE";
public static final String UNIQUE = "UNIQUE";
public static final String VIEW = "VIEW";
public static final String NOT = "NOT";
public static final String NULL = "NULL";
public static final String MISSING_TERMINATOR_NODE_LITERAL = "missingTerminator";
interface DropBehavior {
public static final String CASCADE = "CASCADE";
public static final String RESTRICT = "RESTRICT";
}
interface MatchType {
public static final String FULL = "FULL";
public static final String PARTIAL = "PARTIAL";
}
interface ReferencialAction {
public static final String CASCADE = "CASCADE";
public static final String SET_NULL = "SET NULL";
public static final String SET_DEFAULT = "SET DEFAULT";
public static final String NO_ACTION = "NO ACTION";
}
// Basic SQL 92 statement start phrases
interface StatementStartPhrases {
public static final String[] STMT_CREATE_SCHEMA = {CREATE, SCHEMA};
public static final String[] STMT_CREATE_TABLE = {CREATE, TABLE}; // { GLOBAL | LOCAL } TEMPORARY ] TABLE
public static final String[] STMT_CREATE_GLOBAL_TEMPORARY_TABLE = {CREATE, "GLOBAL", "TEMPORARY", TABLE};
public static final String[] STMT_CREATE_LOCAL_TEMPORARY_TABLE = {CREATE, "LOCAL", "TEMPORARY", TABLE};
public static final String[] STMT_CREATE_VIEW = {CREATE, VIEW};
public static final String[] STMT_CREATE_OR_REPLACE_VIEW = {CREATE, "OR", "REPLACE", VIEW};
public static final String[] STMT_CREATE_ASSERTION = {CREATE, "ASSERTION"};
public static final String[] STMT_CREATE_CHARACTER_SET = {CREATE, "CHARACTER", SET};
public static final String[] STMT_CREATE_COLLATION = {CREATE, "COLLATION"};
public static final String[] STMT_CREATE_DOMAIN = {CREATE, "DOMAIN"};
public static final String[] STMT_CREATE_TRANSLATION = {CREATE, "TRANSLATION"};
public static final String[] STMT_ALTER_TABLE = {ALTER, TABLE};
public static final String[] STMT_ALTER_DOMAIN = {ALTER, "DOMAIN"};
public static final String[] STMT_GRANT = {GRANT};
public static final String[] STMT_REVOKE = {REVOKE};
public static final String[] STMT_DROP_SCHEMA = {DROP, SCHEMA};
public static final String[] STMT_DROP_TABLE = {DROP, TABLE};
public static final String[] STMT_DROP_VIEW = {DROP, VIEW};
public static final String[] STMT_DROP_DOMAIN = {DROP, "DOMAIN"};
public static final String[] STMT_DROP_CHARACTER_SET = {DROP, "CHARACTER", SET};
public static final String[] STMT_DROP_COLLATION = {DROP, "COLLATION"};
public static final String[] STMT_DROP_TRANSLATION = {DROP, "TRANSLATION"};
public static final String[] STMT_DROP_ASSERTION = {DROP, "ASSERTION"};
public static final String[] STMT_INSERT_INTO = {"INSERT", "INTO"};
public static final String[] STMT_SET_DEFINE = {"SET", "DEFINE"};
public final static String[][] SQL_92_ALL_PHRASES = {STMT_CREATE_SCHEMA, STMT_CREATE_TABLE,
STMT_CREATE_GLOBAL_TEMPORARY_TABLE, STMT_CREATE_LOCAL_TEMPORARY_TABLE, STMT_CREATE_VIEW, STMT_CREATE_OR_REPLACE_VIEW,
STMT_CREATE_ASSERTION, STMT_CREATE_CHARACTER_SET, STMT_CREATE_COLLATION, STMT_CREATE_TRANSLATION, STMT_CREATE_DOMAIN,
STMT_ALTER_TABLE, STMT_ALTER_DOMAIN, STMT_GRANT, STMT_REVOKE, STMT_DROP_SCHEMA, STMT_DROP_TABLE, STMT_DROP_VIEW,
STMT_DROP_DOMAIN, STMT_DROP_CHARACTER_SET, STMT_DROP_COLLATION, STMT_DROP_TRANSLATION, STMT_DROP_ASSERTION,
STMT_INSERT_INTO, STMT_SET_DEFINE};
}
/**
* Constants related to Data Types
*/
interface DataTypes {
public static final int DTYPE_CODE_ANY = -1;
public static final int DTYPE_CODE_CHAR_STRING = 0;
public static final int DTYPE_CODE_NCHAR_STRING = 1;
public static final int DTYPE_CODE_BIT_STRING = 2;
public static final int DTYPE_CODE_EXACT_NUMERIC = 3;
public static final int DTYPE_CODE_APROX_NUMERIC = 4;
public static final int DTYPE_CODE_DATE_TIME = 5;
public static final int DTYPE_CODE_MISC = 6;
public static final int DTYPE_CODE_CUSTOM = 7;
// CHAR
public static final String[] DTYPE_CHARACTER = {"CHARACTER"};
public static final String[] DTYPE_CHAR = {"CHAR"};
public static final String[] DTYPE_CHARACTER_VARYING = {"CHARACTER", "VARYING"};
public static final String[] DTYPE_CHAR_VARYING = {"CHAR", "VARYING"};
public static final String[] DTYPE_VARCHAR = {"VARCHAR"};
// NATIONAL CHAR
public static final String[] DTYPE_NATIONAL_CHARACTER = {"NATIONAL", "CHARACTER"};
public static final String[] DTYPE_NATIONAL_CHAR = {"NATIONAL", "CHAR"};
public static final String[] DTYPE_NATIONAL_CHARACTER_VARYING = {"NATIONAL", "CHARACTER", "VARYING"};
public static final String[] DTYPE_NATIONAL_CHAR_VARYING = {"NATIONAL", "CHAR", "VARYING"};
public static final String[] DTYPE_NCHAR_VARYING = {"NCHAR", "VARYING"};
public static final String[] DTYPE_NCHAR = {"NCHAR"};
// BIT STRING
public static final String[] DTYPE_BIT = {"BIT"};
public static final String[] DTYPE_BIT_VARYING = {"BIT", "VARYING"};
// EXACT NUMERIC
public static final String[] DTYPE_NUMERIC = {"NUMERIC"};
public static final String[] DTYPE_DEC = {"DEC"};
public static final String[] DTYPE_DECIMAL = {"DECIMAL"};
public static final String[] DTYPE_INTEGER = {"INTEGER"};
public static final String[] DTYPE_INT = {"INT"};
public static final String[] DTYPE_SMALLINT = {"SMALLINT"};
// APPROXIMATE NUMERIC
public static final String[] DTYPE_FLOAT = {"FLOAT"};
public static final String[] DTYPE_REAL = {"REAL"};
public static final String[] DTYPE_DOUBLE_PRECISION = {"DOUBLE", "PRECISION"};
// DATE-TIME
public static final String[] DTYPE_DATE = {"DATE"};
public static final String[] DTYPE_TIME = {"TIME"};
public static final String[] DTYPE_TIMESTAMP = {"TIMESTAMP"};
// INTERVAL
public static final String[] DTYPE_INTERVAL = {"INTERVAL"};
public final static List<String> DATATYPE_START_WORDS = Arrays.asList(new String[] {"CHAR", "CHARACTER", "VARCHAR",
"NATIONAL", "NCHAR", "BIT", "NUMERIC", "DEC", "DECIMAL", "INT", "INTEGER", "SMALLINT", "FLOAT", "REAL", "DOUBLE",
"DATE", "TIME", "TIMESTAMP", "INTERVAL"});
}
@SuppressWarnings( "nls" )
public final static String[] SQL_92_RESERVED_WORDS = {"ABSOLUTE", "ACTION", "ADD", "ALL", "ALLOCATE", ALTER, "AND", "ANY",
"ARE", "AS", "ASC", "ASSERTION", "AT", "AUTHORIZATION", "AVG", "BEGIN", "BETWEEN", "BIT", "BIT_LENGTH", "BOTH", "BY",
"CASCADE", "CASCADED", "CASE", "CAST", "CATALOG", "CHAR", "CHARACTER", "CHAR_LENGTH", "CHARACTER_LENGTH", CHECK, "CLOSE",
"COALESCE", "COLLATE", "COLLATION", COLUMN, "COMMIT", "CONNECT", "CONNECTION", CONSTRAINT, "CONSTRAINTS", "CONTINUE",
"CONVERT", "CORRESPONDING", "COUNT", CREATE, "CROSS", "CURRENT", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP",
"CURRENT_USER", "CURSOR", "DATE", "DAY", "DEALLOCATE", "DEC", "DECIMAL", DECLARE, "DEFAULT", "DEFERRABLE", "DEFERRED",
"DELETE", "DESC", "DESCRIBE", "DESCRIPTOR", "DIAGNOSTICS", "DISCONNECT", "DISTINCT", "DOMAIN", "DOUBLE", DROP, "ELSE",
"END", "END_EXEC", "ESCAPE", "EXCEPT", "EXCEPTION", "EXEC", "EXECUTE", "EXISTS", "EXTERNAL", "EXTRACT", "FALSE", "FETCH",
"FIRST", "FLOAT", "FOR", FOREIGN, "FOUND", "FROM", "FULL", "GET", "GLOBAL", "GO", "GOTO", GRANT, "GROUP", "HAVING",
"HOUR", "IDENTITY", "IMMEDIATE", "IN", "INDICATOR", "INITIALLY", "INNER", "INPUT", "INSENSITIVE", INSERT, "INT",
"INTEGER", "INTERSECT", "INTERVAL", "INTO", "IS", "ISOLATION", "JOIN", KEY, "LANGUAGE", "LAST", "LEADING", "LEFT",
"LEVEL", "LIKE", "LOCAL", "LOWER", "MATCH", "MAX", "MIN", "MINUTE", "MODULE", "MONTH", "NAMES", "NATIONAL", "NATURAL",
"NCHAR", "NEXT", "NO", "NOT", "NULL", "NULLIF", "NUMERIC", "OCTET_LENGTH", "OF", ON, "ONLY", "OPEN", "OPTION", "OR",
"ORDER", "OUTER", "OUTPUT", "OVERLAPS", "PAD", "PARTIAL", "POSITION", "PRECISION", "PREPARE", "PRESERVE", PRIMARY,
"PRIOR", "PRIVILEGES", "PROCEDURE", "PUBLIC", "READ", "REAL", "REFERENCES", "RELATIVE", "RESTRICT", "REVOKE", "RIGHT",
"ROLLBACK", "ROWS", SCHEMA, "SCROLL", "SECOND", "SECTION", "SELECT", "SESSION", "SESSION_USER", SET, "SIZE", "SMALLINT",
"SOME", "SPACE", "SQL", "SQLCODE", "SQLERROR", "SQLSTATE", "SUBSTRING", "SUM", "SYSTEM_USER", TABLE, "TEMPORARY", "THEN",
"TIME", "TIMESTAMP", "TIMEZONE_HOUR", "TIMEZONE_MINUTE", "TO", "TRAILING", "TRANSACTION", "TRANSLATE", "TRANSLATION",
"TRIM", "TRUE", "UNION", UNIQUE, "UNKNOWN", "UPDATE", "UPPER", "USAGE", "USER", "USING", "VALUE", "VALUES", "VARCHAR",
"VARYING", VIEW, "WHEN", "WHENEVER", "WHERE", "WITH", "WORK", "WRITE", "YEAR", "ZONE"};
interface Problems {
public static final int OK = 0;
public static final int WARNING = 1;
public static final int ERROR = 2;
}
interface AstNodeNames {
public static final String TABLE_DEFINITION = "TABLE_DEFINITION";
public static final String ALTER_TABLE_DEFINITION = "ALTER_TABLE_DEFINITION";
public static final String COLUMN_DEFINITION = "COLUMN_DEFINITION";
public static final String COLUMN_REFERENCE = "COLUMN_REFERENCE";
public static final String TABLE_CONSTRAINT = "TABLE_CONSTRAINT";
// public static final String TABLE_OPTION = "TABLE_OPTION";
public static final String ADD_COLUMN_DEFINITION = "ADD_COLUMN_DEFINITION";
public static final String ADD_TABLE_CONSTRAINT = "ADD_TABLE_CONSTRAINT";
public static final String DROP_COLUMN_DEFINITION = "DROP_COLUMN_DEFINITION";
public static final String DROP_TABLE_CONSTRAINT = "DROP_TABLE_CONSTRAINT";
public static final String ALTER_COLUMN_DEFINITION = "ALTER_COLUMN_DEFINITION";
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
@ -33,6 +33,8 @@
* A parser for DDL statements.
*
* @author Randall Hauch
* @author Horia Chiorean
* @author Barry LaFond
*/
@NotThreadSafe
public class DdlParser {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
@ -13,8 +13,12 @@
import io.debezium.text.TokenStream.Tokens;
/**
* A {@link Tokenizer} that is specialized for tokenizing DDL streams.
*
* @author Randall Hauch
*
* @author Horia Chiorean
* @author Barry LaFond
* @author Jure Kajzer
*/
public class DdlTokenizer implements Tokenizer {
@ -56,7 +60,6 @@ public class DdlTokenizer implements Tokenizer {
* <p>
* Examples would be: "CREATE", "TABLE", "ALTER", "SCHEMA", "DROP", etc...
* </p>
* see {@link DdlConstants} for the default SQL 92 representations.
*/
public static final int KEYWORD = 64;
@ -66,7 +69,6 @@ public class DdlTokenizer implements Tokenizer {
* <p>
* Examples would be: {"CREATE", "TABLE"} {"CREATE", "OR", "REPLACE", "VIEW"}
* </p>
* see {@link DdlConstants} for the default SQL 92 representations.
*/
public static final int STATEMENT_KEY = 128;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2010 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
@ -7,6 +7,8 @@
/**
* An exception representing a problem during parsing of text.
*
* @author Randall Hauch
*/
public class ParsingException extends RuntimeException {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2010 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
@ -9,6 +9,8 @@
/**
* A class that represents the position of a particular character in terms of the lines and columns of a character sequence.
*
* @author Randall Hauch
*/
@Immutable
public final class Position {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2010 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
@ -337,6 +337,9 @@
* {@link Tokenizer}s with exactly this behavior can actually be created using the {@link #basicTokenizer(boolean)} method. So
* while this very basic implementation is not meant to be used in all situations, it may be useful in some situations.
* </p>
* @author Randall Hauch
* @author Horia Chiorean
* @author Daniel Kelleher
*/
@NotThreadSafe
public class TokenStream {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2010 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
@ -13,6 +13,8 @@
/**
* A utility class for determining the validity of various XML names, per the <a href="http://www.w3.org/TR/REC-xml/">XML 1.0
* Specification</a>.
*
* @author Randall Hauch
*/
@Immutable
public class XmlCharacters {

View File

@ -1,33 +0,0 @@
/*
* Copyright 2015 Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.debezium.util;
/**
* @author Randall Hauch
*
*/
public interface Clock {
public static final Clock SYSTEM = new Clock() {
@Override
public long currentTimeInMillis() {
return System.currentTimeMillis();
}
@Override
public long currentTimeInNanos() {
return System.nanoTime();
}
};
public static Clock system() {
return SYSTEM;
}
public long currentTimeInNanos();
public long currentTimeInMillis();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,319 +0,0 @@
/*
* Copyright 2015 Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.debezium.util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
import io.debezium.annotation.Immutable;
/**
* Utility for parsing and accessing the command line options and parameters.
*
* @author Randall Hauch
*/
@Immutable
public class CommandLineOptions {
/**
* Parse the array of arguments passed to a Java {@code main} method and create a {@link CommandLineOptions} instance.
*
* @param args the {@code main} method's parameters; may not be null
* @return the representation of the command line options and parameters; never null
*/
public static CommandLineOptions parse(String[] args) {
Map<String, String> options = new HashMap<>();
List<String> params = new ArrayList<>();
List<String> optionNames = new ArrayList<>();
String optionName = null;
for (String value : args) {
value = value.trim();
if (value.startsWith("-")) {
optionName = value;
options.put(optionName, "true");
optionNames.add(optionName);
} else {
if (optionName != null)
options.put(optionName, value);
else
params.add(value);
}
}
return new CommandLineOptions(options, params, optionNames);
}
private final Map<String, String> options;
private final List<String> params;
private final List<String> orderedOptionNames;
private CommandLineOptions(Map<String, String> options, List<String> params, List<String> orderedOptionNames) {
this.options = options;
this.params = params;
this.orderedOptionNames = orderedOptionNames;
}
/**
* Determine if the option with the given name was used on the command line.
* <p>
* The supplied option name is trimmed before matching against the command line arguments. Note that any special characters
* such as prefixes (e.g., '{@code -}' or '{@code --}') must be included in the name.
*
* @param name the name for the option (e.g., "-v" or "--verbose")
* @return true if the exact option was used, or false otherwise or if the supplied option name is null
* @see #hasOption(String, String)
*/
public boolean hasOption(String name) {
return hasOption(name, null);
}
/**
* Determine if the option with one of the given names was used on the command line.
* <p>
* The supplied option name and alternative names are trimmed before matching against the command line arguments. Note that
* any special characters such as prefixes (e.g., '{@code -}' or '{@code --}') must be included in the name.
*
* @param name the name for the option (e.g., "-v" or "--verbose")
* @param alternativeName an alternative name for the option; may be null
* @return true if the exact option was used, or false otherwise or if both the supplied option name and alternative name are
* null
* @see #hasOption(String)
*/
public boolean hasOption(String name, String alternativeName) {
return getOption(name, alternativeName, null) != null;
}
/**
* Obtain the value associated with the named option.
* <p>
* The supplied option name is trimmed before matching against the command line arguments. Note that any special characters
* such as prefixes (e.g., '{@code -}' or '{@code --}') must be included in the name.
*
* @param name the name for the option (e.g., "-v" or "--verbose")
* @return the value associated with the option, or null if no option was found or the name is null
* @see #getOption(String, String)
* @see #getOption(String, String, String)
*/
public String getOption(String name) {
return getOption(name, null);
}
/**
* Obtain the value associated with the named option, using the supplied default value if none is found.
* <p>
* The supplied option name is trimmed before matching against the command line arguments. Note that any special characters
* such as prefixes (e.g., '{@code -}' or '{@code --}') must be included in the name.
*
* @param name the name for the option (e.g., "-v" or "--verbose")
* @param defaultValue the value that should be returned no named option was found
* @return the value associated with the option, or the default value if none was found or the name is null
* @see #getOption(String)
* @see #getOption(String, String, String)
*/
public String getOption(String name, String defaultValue) {
return getOption(name, null, defaultValue);
}
/**
* Obtain the value associated with the option given the name and alternative name of the option, using the supplied default
* value if none is found.
* <p>
* The supplied option name and alternative names are trimmed before matching against the command line arguments. Note that
* any special characters such as prefixes (e.g., '{@code -}' or '{@code --}') must be included in the name.
*
* @param name the name for the option (e.g., "-v" or "--verbose")
* @param alternativeName an alternative name for the option; may be null
* @param defaultValue the value that should be returned no named option was found
* @return the value associated with the option, or the default value if none was found or if both the name and alternative
* name are null
* @see #getOption(String)
* @see #getOption(String, String)
*/
public String getOption(String name, String alternativeName, String defaultValue) {
recordOptionUsed(name, alternativeName);
String result = options.get(name.trim());
if (result == null && alternativeName != null) result = options.get(alternativeName.trim());
return result != null ? result : defaultValue;
}
protected void recordOptionUsed(String name, String alternativeName) {
orderedOptionNames.remove(name.trim());
if (alternativeName != null) orderedOptionNames.remove(alternativeName.trim());
}
/**
* Obtain the long value associated with the named option, using the supplied default value if none is found or if the value
* cannot be parsed as a long value.
* <p>
* The supplied option name is trimmed before matching against the command line arguments. Note that any special characters
* such as prefixes (e.g., '{@code -}' or '{@code --}') must be included in the name.
*
* @param name the name for the option (e.g., "-v" or "--verbose")
* @param defaultValue the value that should be returned no named option was found
* @return the value associated with the option, or the default value if none was found or the name is null
* @see #getOption(String, String, long)
*/
public long getOption(String name, long defaultValue) {
return getOption(name, null, defaultValue);
}
/**
* Obtain the long value associated with the option given the name and alternative name of the option, using the supplied
* default value if none is found or if the value cannot be parsed as a long value.
* <p>
* The supplied option name and alternative names are trimmed before matching against the command line arguments. Note that
* any special characters such as prefixes (e.g., '{@code -}' or '{@code --}') must be included in the name.
*
* @param name the name for the option (e.g., "-v" or "--verbose")
* @param alternativeName an alternative name for the option; may be null
* @param defaultValue the value that should be returned no named option was found
* @return the value associated with the option, or the default value if none was found or if both the name and alternative
* name are null
* @see #getOption(String, long)
*/
public long getOption(String name, String alternativeName, long defaultValue) {
return Strings.asLong(getOption(name, alternativeName, null), defaultValue);
}
/**
* Obtain the integer value associated with the named option, using the supplied default value if none is found or if the
* value
* cannot be parsed as an integer value.
* <p>
* The supplied option name is trimmed before matching against the command line arguments. Note that any special characters
* such as prefixes (e.g., '{@code -}' or '{@code --}') must be included in the name.
*
* @param name the name for the option (e.g., "-v" or "--verbose")
* @param defaultValue the value that should be returned no named option was found
* @return the value associated with the option, or the default value if none was found or the name is null
* @see #getOption(String, String, int)
*/
public int getOption(String name, int defaultValue) {
return getOption(name, null, defaultValue);
}
/**
* Obtain the integer value associated with the option given the name and alternative name of the option, using the supplied
* default value if none is found or if the value cannot be parsed as an integer value.
* <p>
* The supplied option name and alternative names are trimmed before matching against the command line arguments. Note that
* any special characters such as prefixes (e.g., '{@code -}' or '{@code --}') must be included in the name.
*
* @param name the name for the option (e.g., "-v" or "--verbose")
* @param alternativeName an alternative name for the option; may be null
* @param defaultValue the value that should be returned no named option was found
* @return the value associated with the option, or the default value if none was found or if both the name and alternative
* name are null
* @see #getOption(String, int)
*/
public int getOption(String name, String alternativeName, int defaultValue) {
return Strings.asInt(getOption(name, alternativeName, null), defaultValue);
}
/**
* Obtain the boolean value associated with the named option, using the supplied default value if none is found or if the
* value
* cannot be parsed as a boolean value.
* <p>
* The supplied option name is trimmed before matching against the command line arguments. Note that any special characters
* such as prefixes (e.g., '{@code -}' or '{@code --}') must be included in the name.
*
* @param name the name for the option (e.g., "-v" or "--verbose")
* @param defaultValue the value that should be returned no named option was found
* @return the value associated with the option, or the default value if none was found or the name is null
* @see #getOption(String, String, boolean)
*/
public boolean getOption(String name, boolean defaultValue) {
return getOption(name, null, defaultValue);
}
/**
* Obtain the boolean value associated with the option given the name and alternative name of the option, using the supplied
* default value if none is found or if the value cannot be parsed as a boolean value.
* <p>
* The supplied option name and alternative names are trimmed before matching against the command line arguments. Note that
* any special characters such as prefixes (e.g., '{@code -}' or '{@code --}') must be included in the name.
*
* @param name the name for the option (e.g., "-v" or "--verbose")
* @param alternativeName an alternative name for the option; may be null
* @param defaultValue the value that should be returned no named option was found
* @return the value associated with the option, or the default value if none was found or if both the name and alternative
* name are null
* @see #getOption(String, boolean)
*/
public boolean getOption(String name, String alternativeName, boolean defaultValue) {
return Strings.asBoolean(getOption(name, alternativeName, null), defaultValue);
}
/**
* Obtain the parameter at the given index. Parameters are those arguments that are not preceded by an option name.
*
* @param index the index of the parameter
* @return the parameter value, or null if there was no parameter at the given index
*/
public String getParameter(int index) {
return index < 0 || index >= params.size() ? null : params.get(index);
}
/**
* Determine whether the specified value matches one of the parameters.
*
* @param value the parameter value to match
* @return true if one of the parameter matches the value, or false otherwise
*/
public boolean hasParameter(String value) {
return value == null || params.isEmpty() ? false : params.contains(value);
}
/**
* Determine whether there were any unknown option names after all possible options have been checked via one of the
* {@code getOption(String,...)} methods.
*
* @return true if there was at least one option (e.g., beginning with '{@code -}') that was not checked, or false
* if there were no unknown options on the command line
* @see #getFirstUnknownOptionName()
* @see #hasUnknowns()
*/
public boolean hasUnknowns() {
return !orderedOptionNames.isEmpty();
}
/**
* Get the list of unknown option names after all possible options have been checked via one of the
* {@code getOption(String,...)} methods.
*
* @return the list of options (e.g., beginning with '{@code -}') that were not checked; never null but possible empty
* @see #getFirstUnknownOptionName()
* @see #hasUnknowns()
*/
public List<String> getUnknownOptionNames() {
return Collections.unmodifiableList(orderedOptionNames);
}
/**
* If there were {@link #hasUnknowns() unknown options}, return the first one that appeared on the command line.
* @return the first unknown option, or null if there were no {@link #hasUnknowns() unknown options}
* @see #getUnknownOptionNames()
* @see #getFirstUnknownOptionName()
*/
public String getFirstUnknownOptionName() {
return orderedOptionNames.isEmpty() ? null : orderedOptionNames.get(0);
}
@Override
public String toString() {
StringJoiner joiner = new StringJoiner(" ");
options.forEach((opt, val) -> {
joiner.add("-" + opt).add(val);
});
params.forEach(joiner::add);
return joiner.toString();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2008 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
@ -15,10 +15,10 @@
*/
@Immutable
public class HashCode {
// Prime number used in improving distribution
private static final int PRIME = 103;
/**
* Compute a combined hash code from the supplied objects. This method always returns 0 if no objects are supplied.
*
@ -26,9 +26,9 @@ public class HashCode {
* @return the hash code
*/
public static int compute(Object... objects) {
return _compute(0, objects);
return computeHashCode(0, objects);
}
/**
* Compute a combined hash code from the supplied objects using the supplied seed.
*
@ -36,8 +36,8 @@ public static int compute(Object... objects) {
* @param objects the objects that should be used to compute the hash code
* @return the hash code
*/
private static int _compute(int seed,
Object... objects) {
private static int computeHashCode(int seed,
Object... objects) {
if (objects == null || objects.length == 0) {
return seed * HashCode.PRIME;
}
@ -69,8 +69,8 @@ private static int _compute(int seed,
}
return hc;
}
private HashCode() {
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2008 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
@ -164,7 +164,7 @@ public static String read(InputStream stream) throws IOException {
* reading.
*
* @param stream the streamed contents; may be null
* @param charset charset of the stream data; may not be null
* @param charset character set of the stream data; may not be null
* @return the contents, or an empty string if the supplied stream is null
* @throws IOException if there is an error reading the content
*/

View File

@ -1,316 +0,0 @@
/*
* Copyright 2015 Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.debezium.util;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.function.BiFunction;
import java.util.function.Function;
import io.debezium.annotation.Immutable;
/**
* A utility for creating iterators.
*
* @author Randall Hauch
*/
@Immutable
public class Iterators {
public static <T> Iterator<T> empty() {
return new Iterator<T>() {
@Override
public boolean hasNext() {
return false;
}
@Override
public T next() {
throw new NoSuchElementException();
}
};
}
public static <T> Iterator<T> with(final T value) {
return new Iterator<T>() {
private boolean finished = false;
@Override
public boolean hasNext() {
return !finished;
}
@Override
public T next() {
if (finished) {
throw new NoSuchElementException();
}
finished = true;
return value;
}
};
}
public static <T> Iterator<T> with(T value1, T value2) {
return new Iterator<T>() {
private int remaining = 2;
@Override
public boolean hasNext() {
return remaining > 0;
}
@Override
public T next() {
if (remaining == 2) {
--remaining;
return value1;
}
if (remaining == 1) {
--remaining;
return value2;
}
throw new NoSuchElementException();
}
};
}
public static <T> Iterator<T> with(T value1, T value2, T value3) {
return new Iterator<T>() {
private int remaining = 3;
@Override
public boolean hasNext() {
return remaining > 0;
}
@Override
public T next() {
if (remaining == 3) {
--remaining;
return value1;
}
if (remaining == 2) {
--remaining;
return value2;
}
if (remaining == 1) {
--remaining;
return value3;
}
throw new NoSuchElementException();
}
};
}
@SafeVarargs
public static <T> Iterator<T> with(T value1, T value2, T value3, T... additional) {
return new Iterator<T>() {
private int index = 0;
@Override
public boolean hasNext() {
return index < additional.length + 3;
}
@Override
public T next() {
try {
if (index == 0) return value1;
if (index == 1) return value2;
if (index == 2) return value3;
if (index < additional.length + 3) return additional[index - 3];
--index;
throw new NoSuchElementException();
} finally {
++index;
}
}
};
}
public static <T> Iterator<T> with(T[] values) {
return new Iterator<T>() {
private int index = 0;
@Override
public boolean hasNext() {
return index < values.length;
}
@Override
public T next() {
try {
if (index < values.length) return values[index];
--index;
throw new NoSuchElementException();
} finally {
++index;
}
}
};
}
public static <T, U, V> Iterator<V> around(Iterable<? extends T> first,
Iterable<? extends U> second,
BiFunction<T, U, V> conversion) {
return around(first.iterator(), second.iterator(), conversion);
}
public static <T, U, V> Iterator<V> around(final Iterator<? extends T> first,
final Iterator<? extends U> second,
final BiFunction<T, U, V> combineFirstAndSecond) {
return new Iterator<V>() {
@Override
public boolean hasNext() {
return second.hasNext();
}
@Override
public V next() {
return combineFirstAndSecond.apply(first.next(), second.next());
}
};
}
public static <V, T> Iterator<T> around(final Iterable<? extends V> iterable, Function<V, T> conversion) {
return around(iterable.iterator(), conversion);
}
public static <V, T> Iterator<T> around(final Iterator<? extends V> iterator, Function<V, T> conversion) {
return new Iterator<T>() {
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public T next() {
return conversion.apply(iterator.next());
}
@Override
public void remove() {
iterator.remove();
}
};
}
public static <T> Iterable<T> around(final Iterator<T> iterator) {
return new Iterable<T>() {
@Override
public Iterator<T> iterator() {
return iterator;
}
};
}
public static <T> Iterator<T> readOnly(final Iterator<T> iterator) {
return new Iterator<T>() {
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public T next() {
return iterator.next();
}
};
}
public static <V, T> Iterator<T> readOnly(final Iterator<? extends V> iterator, Function<V, T> conversion) {
return new Iterator<T>() {
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public T next() {
return conversion.apply(iterator.next());
}
};
}
public static <T> Iterator<T> readOnly(final Iterable<T> iterable) {
return readOnly(iterable.iterator());
}
public static <V, T> Iterator<T> readOnly(final Iterable<V> iterable, Function<V, T> conversion) {
return readOnly(iterable.iterator(), conversion);
}
public static <T> Iterable<T> readOnlyIterable(final Iterable<T> iterable) {
return new Iterable<T>() {
@Override
public Iterator<T> iterator() {
return readOnly(iterable.iterator());
}
};
}
public static <V, T> Iterable<T> readOnlyIterable(final Iterable<? extends V> iterable, Function<V, T> conversion) {
return new Iterable<T>() {
@Override
public Iterator<T> iterator() {
return readOnly(iterable.iterator(), conversion);
}
};
}
public static <T> Iterator<T> join(Iterable<T> first, T last) {
return join(first.iterator(), with(last));
}
public static <T> Iterator<T> join(Iterable<T> first, T last1, T last2) {
return join(first.iterator(), with(last1, last2));
}
public static <T> Iterator<T> join(Iterable<T> first, T last1, T last2, T last3) {
return join(first.iterator(), with(last1, last2, last3));
}
public static <T> Iterator<T> join(Iterable<T> first, T last1, T last2, T last3, T last4) {
return join(first.iterator(), with(last1, last2, last3, last4));
}
public static <T> Iterator<T> join(Iterable<T> first, Iterable<T> second) {
return join(first.iterator(), second.iterator());
}
public static <T> Iterator<T> join(Iterator<T> first, Iterator<T> second) {
return new Iterator<T>() {
private boolean completedFirst = false;
@Override
public boolean hasNext() {
if (!completedFirst) {
if (first.hasNext()) return true;
completedFirst = true;
}
return second.hasNext();
}
@Override
public T next() {
if (!completedFirst) {
if (first.hasNext()) return first.next();
completedFirst = true;
}
return second.next();
}
@Override
public void remove() {
if (!completedFirst) {
first.remove();
}
second.remove();
}
};
}
}

View File

@ -1,80 +0,0 @@
/*
* Copyright 2015 Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.debezium.util;
import java.util.Iterator;
import java.util.StringJoiner;
import io.debezium.annotation.Immutable;
/**
* A utility for joining multiple {@link CharSequence character sequences} together.
*
* @author Randall Hauch
*/
@Immutable
public final class Joiner {
public static Joiner on(CharSequence delimiter) {
return new Joiner(new StringJoiner(delimiter));
}
public static Joiner on(CharSequence prefix, CharSequence delimiter) {
return new Joiner(new StringJoiner(delimiter, prefix, ""));
}
public static Joiner on(CharSequence prefix, CharSequence delimiter, CharSequence suffix) {
return new Joiner(new StringJoiner(delimiter, prefix, suffix));
}
private final StringJoiner joiner;
private Joiner(StringJoiner joiner) {
this.joiner = joiner;
}
public String join(Object[] values) {
for (Object value : values) {
if (value != null) joiner.add(value.toString());
}
return joiner.toString();
}
public String join(CharSequence firstValue, CharSequence... additionalValues) {
if (firstValue != null) joiner.add(firstValue);
for (CharSequence value : additionalValues) {
if (value != null) joiner.add(value);
}
return joiner.toString();
}
public String join(Iterable<?> values) {
for (Object value : values) {
if (value != null) joiner.add(value.toString());
}
return joiner.toString();
}
public String join(Iterable<?> values, CharSequence nextValue, CharSequence... additionalValues) {
for (Object value : values) {
if (value != null) joiner.add(value.toString());
}
if (nextValue != null) joiner.add(nextValue);
for (CharSequence value : additionalValues) {
if (value != null) joiner.add(value);
}
return joiner.toString();
}
public String join(Iterator<?> values) {
while (values.hasNext()) {
Object value = values.next();
if (value != null) joiner.add(value.toString());
}
return joiner.toString();
}
}

View File

@ -1,81 +0,0 @@
/*
* Copyright 2015 Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.debezium.util;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.function.Supplier;
import io.debezium.annotation.ThreadSafe;
/**
* An atomic reference that atomically uses a supplier to lazily accesses the referenced object the first time it is needed.
*
* @author Randall Hauch
* @param <T> the type of referenced object
*/
@ThreadSafe
public final class LazyReference<T> {
public static <T> LazyReference<T> create(Supplier<T> supplier) {
return new LazyReference<T>(supplier);
}
private final AtomicReference<T> ref = new AtomicReference<>();
private final Supplier<T> supplier;
private LazyReference(Supplier<T> supplier) {
this.supplier = supplier;
}
/**
* Determine if the referenced object has been created and accessed.
*
* @return {@code true} if the object has been created, or false otherwise
*/
public boolean isInitialized() {
return ref.get() != null;
}
/**
* If the referenced object has been {@link #isInitialized() initialized}, then release it.
* This method does nothing if the reference has not yet been accessed or {@link #isInitialized() initialized}.
*/
public void release() {
release(null);
}
/**
* If the referenced object has been {@link #isInitialized() initialized}, then release it and call the supplied function with
* the reference. This method does nothing if the reference has not yet been accessed or {@link #isInitialized() initialized}.
*
* @param finalizer the function that should be called when the previously-{@link #isInitialized() initialized} referenced
* object is released; may be null
*/
public void release(Consumer<T> finalizer) {
ref.updateAndGet(existing->{
if ( existing != null && finalizer != null ) finalizer.accept(existing);
return null;
});
}
/**
* Get the referenced value (creating it if required) and call the supplied function.
*
* @param consumer the function that operates on the value; may not be null
* @return true if the function was called on the referenced value, or false if there is no referenced value
*/
public boolean execute(Consumer<T> consumer) {
T value = get();
if (value == null) return false;
consumer.accept(value);
return true;
}
public T get() {
return ref.updateAndGet(existing->existing != null ? existing : supplier.get());
}
}

View File

@ -1,721 +0,0 @@
/*
* Copyright 2010 Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.debezium.util;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import io.debezium.annotation.Immutable;
/**
* Utilities for performing math operations with mixed native and advanced numeric types.
*
* @author Randall Hauch
*/
@Immutable
public final class MathOps {
public static Number add(Number first, Number second) {
if (second == null)
return first;
else if (first == null) return second;
if (first instanceof Short) return add((Short) first, second);
if (first instanceof Integer) return add((Integer) first, second);
if (first instanceof Long) return add((Long) first, second);
if (first instanceof Float) return add((Float) first, second);
if (first instanceof Double) return add((Double) first, second);
if (first instanceof BigInteger) return add((BigInteger) first, second);
if (first instanceof BigDecimal) return add((BigDecimal) first, second);
if (first instanceof AtomicLong) return add((AtomicLong) first, second);
if (first instanceof AtomicInteger) return add((AtomicInteger) first, second);
throw new IllegalArgumentException();
}
public static Number add(Short first, Number second) {
if (second instanceof Short) return add(first, (Short) second);
if (second instanceof Integer) return add(first, (Integer) second);
if (second instanceof Long) return add(first, (Long) second);
if (second instanceof Float) return add(first, (Float) second);
if (second instanceof Double) return add(first, (Double) second);
if (second instanceof BigInteger) return add(first, (BigInteger) second);
if (second instanceof BigDecimal) return add(first, (BigDecimal) second);
if (second instanceof AtomicInteger) return add(first, (AtomicInteger) second);
if (second instanceof AtomicLong) return add(first, (AtomicLong) second);
throw new IllegalArgumentException();
}
public static Number add(Short first, short second) {
int sum = first.shortValue() + second;
if (Short.MAX_VALUE >= sum && Short.MIN_VALUE <= sum) return new Short((short) sum);
return new Integer(sum);
}
public static Number add(Short first, int second) {
long sum = first.longValue() + second;
if (Short.MAX_VALUE >= sum && Short.MIN_VALUE <= sum) return new Short((short) sum);
if (Integer.MAX_VALUE >= sum && Integer.MIN_VALUE <= sum) return new Integer((int) sum);
return new Long(sum);
}
public static Number add(Short first, long second) {
long sum = first.longValue() + second;
if (Short.MAX_VALUE >= sum && Short.MIN_VALUE <= sum) return new Short((short) sum);
if (Integer.MAX_VALUE >= sum && Integer.MIN_VALUE <= sum) return new Integer((int) sum);
return new Long(sum);
}
public static Number add(Short first, float second) {
double sum = first.floatValue() + second;
if (Float.MAX_VALUE >= sum && Float.MIN_VALUE <= sum) return new Float((float) sum);
return new Double(sum);
}
public static Number add(Short first, double second) {
double sum = first.doubleValue() + second;
if (Float.MAX_VALUE >= sum && Float.MIN_VALUE <= sum) return new Float((float) sum);
return new Double(sum);
}
public static Number add(Short first, Short second) {
return add(first, second.shortValue());
}
public static Number add(Short first, Integer second) {
return add(first, second.intValue());
}
public static Number add(Short first, Long second) {
return add(first, second.longValue());
}
public static Number add(Short first, Float second) {
return add(first, second.floatValue());
}
public static Number add(Short first, Double second) {
return add(first, second.doubleValue());
}
public static Number add(Short first, BigDecimal second) {
return second.add(BigDecimal.valueOf(first.longValue()));
}
public static Number add(Short first, BigInteger second) {
return second.add(BigInteger.valueOf(first.longValue()));
}
public static Number add(Short first, AtomicInteger second) {
return add(first, second.intValue());
}
public static Number add(Short first, AtomicLong second) {
return add(first, second.longValue());
}
public static Number add(Integer first, Number second) {
if (second instanceof Short) return add(first, (Short) second);
if (second instanceof Integer) return add(first, (Integer) second);
if (second instanceof Long) return add(first, (Long) second);
if (second instanceof Float) return add(first, (Float) second);
if (second instanceof Double) return add(first, (Double) second);
if (second instanceof BigInteger) return add(first, (BigInteger) second);
if (second instanceof BigDecimal) return add(first, (BigDecimal) second);
if (second instanceof AtomicInteger) return add(first, (AtomicInteger) second);
if (second instanceof AtomicLong) return add(first, (AtomicLong) second);
throw new IllegalArgumentException();
}
public static Number add(Integer first, short second) {
long sum = first.longValue() + second;
if (Short.MAX_VALUE >= sum && Short.MIN_VALUE <= sum) return new Short((short) sum);
if (Integer.MAX_VALUE >= sum && Integer.MIN_VALUE <= sum) return new Integer((int) sum);
return new Long(sum);
}
public static Number add(Integer first, int second) {
long sum = first.longValue() + second;
if (Short.MAX_VALUE >= sum && Short.MIN_VALUE <= sum) return new Short((short) sum);
if (Integer.MAX_VALUE >= sum && Integer.MIN_VALUE <= sum) return new Integer((int) sum);
return new Long(sum);
}
public static Number add(Integer first, long second) {
long sum = first.longValue() + second;
if (Short.MAX_VALUE >= sum && Short.MIN_VALUE <= sum) return new Short((short) sum);
if (Integer.MAX_VALUE >= sum && Integer.MIN_VALUE <= sum) return new Integer((int) sum);
return new Long(sum);
}
public static Number add(Integer first, float second) {
double sum = first.floatValue() + second;
if (Float.MAX_VALUE >= sum && Float.MIN_VALUE <= sum) return new Float((float) sum);
return new Double(sum);
}
public static Number add(Integer first, double second) {
double sum = first.doubleValue() + second;
if (Float.MAX_VALUE >= sum && Float.MIN_VALUE <= sum) return new Float((float) sum);
return new Double(sum);
}
public static Number add(Integer first, Short second) {
return add(first, second.shortValue());
}
public static Number add(Integer first, Integer second) {
return add(first, second.intValue());
}
public static Number add(Integer first, Long second) {
return add(first, second.longValue());
}
public static Number add(Integer first, Float second) {
return add(first, second.floatValue());
}
public static Number add(Integer first, Double second) {
return add(first, second.doubleValue());
}
public static Number add(Integer first, BigDecimal second) {
return second.add(BigDecimal.valueOf(first.longValue()));
}
public static Number add(Integer first, BigInteger second) {
return second.add(BigInteger.valueOf(first.longValue()));
}
public static Number add(Integer first, AtomicInteger second) {
return add(first, second.intValue());
}
public static Number add(Integer first, AtomicLong second) {
return add(first, second.longValue());
}
public static Number add(Long first, Number second) {
if (second instanceof Short) return add(first, (Short) second);
if (second instanceof Integer) return add(first, (Integer) second);
if (second instanceof Long) return add(first, (Long) second);
if (second instanceof Float) return add(first, (Float) second);
if (second instanceof Double) return add(first, (Double) second);
if (second instanceof BigInteger) return add(first, (BigInteger) second);
if (second instanceof BigDecimal) return add(first, (BigDecimal) second);
if (second instanceof AtomicInteger) return add(first, (AtomicInteger) second);
if (second instanceof AtomicLong) return add(first, (AtomicLong) second);
throw new IllegalArgumentException();
}
public static Number add(Long first, short second) {
long sum = first.longValue() + second;
if (Short.MAX_VALUE >= sum && Short.MIN_VALUE <= sum) return new Short((short) sum);
if (Integer.MAX_VALUE >= sum && Integer.MIN_VALUE <= sum) return new Integer((int) sum);
return new Long(sum);
}
public static Number add(Long first, int second) {
long sum = first.longValue() + second;
if (Short.MAX_VALUE >= sum && Short.MIN_VALUE <= sum) return new Short((short) sum);
if (Integer.MAX_VALUE >= sum && Integer.MIN_VALUE <= sum) return new Integer((int) sum);
return new Long(sum);
}
public static Number add(Long first, long second) {
long sum = first.longValue() + second;
if (Short.MAX_VALUE >= sum && Short.MIN_VALUE <= sum) return new Short((short) sum);
if (Integer.MAX_VALUE >= sum && Integer.MIN_VALUE <= sum) return new Integer((int) sum);
return new Long(sum);
}
public static Number add(Long first, float second) {
double sum = first.doubleValue() + second;
if (Float.MAX_VALUE >= sum && Float.MIN_VALUE <= sum) return new Float((float) sum);
return new Double(sum);
}
public static Number add(Long first, double second) {
double sum = first.doubleValue() + second;
if (Float.MAX_VALUE >= sum && Float.MIN_VALUE <= sum) return new Float((float) sum);
return new Double(sum);
}
public static Number add(Long first, Short second) {
return add(first, second.shortValue());
}
public static Number add(Long first, Integer second) {
return add(first, second.intValue());
}
public static Number add(Long first, Long second) {
return add(first, second.longValue());
}
public static Number add(Long first, Float second) {
return add(first, second.floatValue());
}
public static Number add(Long first, Double second) {
return add(first, second.doubleValue());
}
public static Number add(Long first, BigDecimal second) {
return second.add(BigDecimal.valueOf(first.longValue()));
}
public static Number add(Long first, BigInteger second) {
return second.add(BigInteger.valueOf(first.longValue()));
}
public static Number add(Long first, AtomicInteger second) {
return add(first, second.intValue());
}
public static Number add(Long first, AtomicLong second) {
return add(first, second.longValue());
}
public static Number add(Float first, Number second) {
if (second instanceof Short) return add(first, (Short) second);
if (second instanceof Integer) return add(first, (Integer) second);
if (second instanceof Long) return add(first, (Long) second);
if (second instanceof Float) return add(first, (Float) second);
if (second instanceof Double) return add(first, (Double) second);
if (second instanceof BigInteger) return add(first, (BigInteger) second);
if (second instanceof BigDecimal) return add(first, (BigDecimal) second);
if (second instanceof AtomicInteger) return add(first, (AtomicInteger) second);
if (second instanceof AtomicLong) return add(first, (AtomicLong) second);
throw new IllegalArgumentException();
}
public static Number add(Float first, short second) {
double sum = first.floatValue() + second;
if (Float.MAX_VALUE >= sum && Float.MIN_VALUE <= sum) return new Float((float) sum);
return new Double(sum);
}
public static Number add(Float first, int second) {
double sum = first.floatValue() + second;
if (Float.MAX_VALUE >= sum && Float.MIN_VALUE <= sum) return new Float((float) sum);
return new Double(sum);
}
public static Number add(Float first, long second) {
double sum = first.floatValue() + second;
if (Float.MAX_VALUE >= sum && Float.MIN_VALUE <= sum) return new Float((float) sum);
return new Double(sum);
}
public static Number add(Float first, float second) {
double sum = first.floatValue() + second;
if (Float.MAX_VALUE >= sum && Float.MIN_VALUE <= sum) return new Float((float) sum);
return new Double(sum);
}
public static Number add(Float first, double second) {
double sum = first.floatValue() + second;
if (Float.MAX_VALUE >= sum && Float.MIN_VALUE <= sum) return new Float((float) sum);
return new Double(sum);
}
public static Number add(Float first, Short second) {
return add(first, second.shortValue());
}
public static Number add(Float first, Integer second) {
return add(first, second.intValue());
}
public static Number add(Float first, Long second) {
return add(first, second.longValue());
}
public static Number add(Float first, Float second) {
return add(first, second.floatValue());
}
public static Number add(Float first, Double second) {
return add(first, second.doubleValue());
}
public static Number add(Float first, BigDecimal second) {
return second.add(BigDecimal.valueOf(first.longValue()));
}
public static Number add(Float first, BigInteger second) {
return second.add(BigInteger.valueOf(first.longValue()));
}
public static Number add(Float first, AtomicInteger second) {
return add(first, second.intValue());
}
public static Number add(Float first, AtomicLong second) {
return add(first, second.longValue());
}
public static Number add(Double first, Number second) {
if (second instanceof Short) return add(first, (Short) second);
if (second instanceof Integer) return add(first, (Integer) second);
if (second instanceof Long) return add(first, (Long) second);
if (second instanceof Float) return add(first, (Float) second);
if (second instanceof Double) return add(first, (Double) second);
if (second instanceof BigInteger) return add(first, (BigInteger) second);
if (second instanceof BigDecimal) return add(first, (BigDecimal) second);
if (second instanceof AtomicInteger) return add(first, (AtomicInteger) second);
if (second instanceof AtomicLong) return add(first, (AtomicLong) second);
throw new IllegalArgumentException();
}
public static Number add(Double first, short second) {
double sum = first.floatValue() + second;
if (Float.MAX_VALUE >= sum && Float.MIN_VALUE <= sum) return new Float((float) sum);
return new Double(sum);
}
public static Number add(Double first, int second) {
double sum = first.floatValue() + second;
if (Float.MAX_VALUE >= sum && Float.MIN_VALUE <= sum) return new Float((float) sum);
return new Double(sum);
}
public static Number add(Double first, long second) {
double sum = first.floatValue() + second;
if (Float.MAX_VALUE >= sum && Float.MIN_VALUE <= sum) return new Float((float) sum);
return new Double(sum);
}
public static Number add(Double first, float second) {
double sum = first.floatValue() + second;
if (Float.MAX_VALUE >= sum && Float.MIN_VALUE <= sum) return new Float((float) sum);
return new Double(sum);
}
public static Number add(Double first, double second) {
double sum = first.floatValue() + second;
if (Float.MAX_VALUE >= sum && Float.MIN_VALUE <= sum) return new Float((float) sum);
return new Double(sum);
}
public static Number add(Double first, Short second) {
return add(first, second.shortValue());
}
public static Number add(Double first, Integer second) {
return add(first, second.intValue());
}
public static Number add(Double first, Long second) {
return add(first, second.longValue());
}
public static Number add(Double first, Float second) {
return add(first, second.floatValue());
}
public static Number add(Double first, Double second) {
return add(first, second.doubleValue());
}
public static Number add(Double first, BigDecimal second) {
return second.add(BigDecimal.valueOf(first.longValue()));
}
public static Number add(Double first, BigInteger second) {
return second.add(BigInteger.valueOf(first.longValue()));
}
public static Number add(Double first, AtomicInteger second) {
return add(first, second.intValue());
}
public static Number add(Double first, AtomicLong second) {
return add(first, second.longValue());
}
public static Number add(BigInteger first, Number second) {
if (second instanceof Short) return add(first, (Short) second);
if (second instanceof Integer) return add(first, (Integer) second);
if (second instanceof Long) return add(first, (Long) second);
if (second instanceof Float) return add(first, (Float) second);
if (second instanceof Double) return add(first, (Double) second);
if (second instanceof BigInteger) return add(first, (BigInteger) second);
if (second instanceof BigDecimal) return add(first, (BigDecimal) second);
if (second instanceof AtomicInteger) return add(first, (AtomicInteger) second);
if (second instanceof AtomicLong) return add(first, (AtomicLong) second);
throw new IllegalArgumentException();
}
public static Number add(BigInteger first, short second) {
return first.add(BigInteger.valueOf(second));
}
public static Number add(BigInteger first, int second) {
return first.add(BigInteger.valueOf(second));
}
public static Number add(BigInteger first, long second) {
return first.add(BigInteger.valueOf(second));
}
public static Number add(BigInteger first, float second) {
return new BigDecimal(first).add(BigDecimal.valueOf(second));
}
public static Number add(BigInteger first, double second) {
return new BigDecimal(first).add(BigDecimal.valueOf(second));
}
public static Number add(BigInteger first, Short second) {
return add(first, second.shortValue());
}
public static Number add(BigInteger first, Integer second) {
return add(first, second.intValue());
}
public static Number add(BigInteger first, Long second) {
return add(first, second.longValue());
}
public static Number add(BigInteger first, Float second) {
return add(first, second.floatValue());
}
public static Number add(BigInteger first, Double second) {
return add(first, second.doubleValue());
}
public static Number add(BigInteger first, BigDecimal second) {
return second.add(new BigDecimal(first));
}
public static Number add(BigInteger first, BigInteger second) {
return second.add(second);
}
public static Number add(BigInteger first, AtomicInteger second) {
return add(first, second.intValue());
}
public static Number add(BigInteger first, AtomicLong second) {
return add(first, second.longValue());
}
public static Number add(BigDecimal first, Number second) {
if (second instanceof Short) return add(first, (Short) second);
if (second instanceof Integer) return add(first, (Integer) second);
if (second instanceof Long) return add(first, (Long) second);
if (second instanceof Float) return add(first, (Float) second);
if (second instanceof Double) return add(first, (Double) second);
if (second instanceof BigInteger) return add(first, (BigInteger) second);
if (second instanceof BigDecimal) return add(first, (BigDecimal) second);
if (second instanceof AtomicInteger) return add(first, (AtomicInteger) second);
if (second instanceof AtomicLong) return add(first, (AtomicLong) second);
throw new IllegalArgumentException();
}
public static Number add(BigDecimal first, short second) {
return first.add(BigDecimal.valueOf(second));
}
public static Number add(BigDecimal first, int second) {
return first.add(BigDecimal.valueOf(second));
}
public static Number add(BigDecimal first, long second) {
return first.add(BigDecimal.valueOf(second));
}
public static Number add(BigDecimal first, float second) {
return first.add(BigDecimal.valueOf(second));
}
public static Number add(BigDecimal first, double second) {
return first.add(BigDecimal.valueOf(second));
}
public static Number add(BigDecimal first, Short second) {
return add(first, second.shortValue());
}
public static Number add(BigDecimal first, Integer second) {
return add(first, second.intValue());
}
public static Number add(BigDecimal first, Long second) {
return add(first, second.longValue());
}
public static Number add(BigDecimal first, Float second) {
return add(first, second.floatValue());
}
public static Number add(BigDecimal first, Double second) {
return add(first, second.doubleValue());
}
public static Number add(BigDecimal first, BigDecimal second) {
return second.add(first);
}
public static Number add(BigDecimal first, BigInteger second) {
return second.add(second);
}
public static Number add(BigDecimal first, AtomicInteger second) {
return add(first, second.intValue());
}
public static Number add(BigDecimal first, AtomicLong second) {
return add(first, second.longValue());
}
public static Number add(AtomicInteger first, Number second) {
if (second instanceof Short) return add(first, (Short) second);
if (second instanceof Integer) return add(first, (Integer) second);
if (second instanceof Long) return add(first, (Long) second);
if (second instanceof Float) return add(first, (Float) second);
if (second instanceof Double) return add(first, (Double) second);
if (second instanceof BigInteger) return add(first, (BigInteger) second);
if (second instanceof BigDecimal) return add(first, (BigDecimal) second);
if (second instanceof AtomicInteger) return add(first, (AtomicInteger) second);
if (second instanceof AtomicLong) return add(first, (AtomicLong) second);
throw new IllegalArgumentException();
}
public static Number add(AtomicInteger first, short second) {
return add(new Integer(first.intValue()), second);
}
public static Number add(AtomicInteger first, int second) {
return add(new Integer(first.intValue()), second);
}
public static Number add(AtomicInteger first, long second) {
return add(new Integer(first.intValue()), second);
}
public static Number add(AtomicInteger first, float second) {
return add(new Integer(first.intValue()), second);
}
public static Number add(AtomicInteger first, double second) {
return add(new Integer(first.intValue()), second);
}
public static Number add(AtomicInteger first, Short second) {
return add(first, second.shortValue());
}
public static Number add(AtomicInteger first, Integer second) {
return add(first, second.intValue());
}
public static Number add(AtomicInteger first, Long second) {
return add(first, second.longValue());
}
public static Number add(AtomicInteger first, Float second) {
return add(first, second.floatValue());
}
public static Number add(AtomicInteger first, Double second) {
return add(first, second.doubleValue());
}
public static Number add(AtomicInteger first, BigDecimal second) {
return add(second, first);
}
public static Number add(AtomicInteger first, BigInteger second) {
return add(second, first);
}
public static Number add(AtomicInteger first, AtomicInteger second) {
return add(first, second.intValue());
}
public static Number add(AtomicInteger first, AtomicLong second) {
return add(first, second.longValue());
}
public static Number add(AtomicLong first, Number second) {
if (second instanceof Short) return add(first, (Short) second);
if (second instanceof Integer) return add(first, (Integer) second);
if (second instanceof Long) return add(first, (Long) second);
if (second instanceof Float) return add(first, (Float) second);
if (second instanceof Double) return add(first, (Double) second);
if (second instanceof BigInteger) return add(first, (BigInteger) second);
if (second instanceof BigDecimal) return add(first, (BigDecimal) second);
if (second instanceof AtomicInteger) return add(first, (AtomicInteger) second);
if (second instanceof AtomicLong) return add(first, (AtomicLong) second);
throw new IllegalArgumentException();
}
public static Number add(AtomicLong first, short second) {
return add(new Long(first.longValue()), second);
}
public static Number add(AtomicLong first, int second) {
return add(new Long(first.longValue()), second);
}
public static Number add(AtomicLong first, long second) {
return add(new Long(first.longValue()), second);
}
public static Number add(AtomicLong first, float second) {
return add(new Long(first.longValue()), second);
}
public static Number add(AtomicLong first, double second) {
return add(new Long(first.longValue()), second);
}
public static Number add(AtomicLong first, Short second) {
return add(first, second.shortValue());
}
public static Number add(AtomicLong first, Integer second) {
return add(first, second.intValue());
}
public static Number add(AtomicLong first, Long second) {
return add(first, second.longValue());
}
public static Number add(AtomicLong first, Float second) {
return add(first, second.floatValue());
}
public static Number add(AtomicLong first, Double second) {
return add(first, second.doubleValue());
}
public static Number add(AtomicLong first, BigDecimal second) {
return add(second, first);
}
public static Number add(AtomicLong first, BigInteger second) {
return add(second, first);
}
public static Number add(AtomicLong first, AtomicInteger second) {
return add(first, second.intValue());
}
public static Number add(AtomicLong first, AtomicLong second) {
return add(first, second.longValue());
}
private MathOps() {
}
}

View File

@ -1,71 +0,0 @@
/*
* Copyright 2010 Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.debezium.util;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import io.debezium.annotation.ThreadSafe;
/**
* A simple named thread factory that creates threads named "{@code $PREFIX$-$NAME$-thread-$NUMBER$}".
*
* @author Randall Hauch
*/
@ThreadSafe
public final class NamedThreadFactory implements ThreadFactory {
private static final boolean DEFAULT_DAEMON_THREAD = true;
private static final int DEFAULT_STACK_SIZE = 0;
private final boolean daemonThreads;
private final ThreadGroup group;
private final AtomicInteger threadNumber = new AtomicInteger(1);
private final String namePrefix;
private final int stackSize;
private final Consumer<String> afterThreadCreation;
public NamedThreadFactory(String prefix) {
this(prefix, DEFAULT_DAEMON_THREAD, DEFAULT_STACK_SIZE);
}
public NamedThreadFactory(String prefix, boolean daemonThreads) {
this(prefix, daemonThreads, DEFAULT_STACK_SIZE);
}
public NamedThreadFactory(String prefix, boolean daemonThreads, int stackSize) {
this(prefix, daemonThreads, stackSize, null);
}
public NamedThreadFactory(String prefix, boolean daemonThreads, int stackSize, Consumer<String> afterThreadCreation) {
if ( prefix == null ) throw new IllegalArgumentException("The thread prefix may not be null");
final SecurityManager s = System.getSecurityManager();
this.group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
this.namePrefix = prefix;
this.daemonThreads = daemonThreads;
this.stackSize = stackSize;
this.afterThreadCreation = afterThreadCreation;
}
@Override
public Thread newThread(final Runnable runnable) {
String threadName = namePrefix + threadNumber.getAndIncrement();
final Thread t = new Thread(group, runnable, threadName, stackSize);
t.setDaemon(daemonThreads);
if (t.getPriority() != Thread.NORM_PRIORITY) {
t.setPriority(Thread.NORM_PRIORITY);
}
if (afterThreadCreation != null) {
try {
afterThreadCreation.accept(threadName);
} catch (Throwable e) {
// do nothing
}
}
return t;
}
}

View File

@ -1,99 +0,0 @@
/*
* Copyright 2015 Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.debezium.util;
import java.util.Iterator;
import java.util.Random;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import io.debezium.annotation.Immutable;
/**
* Utility methods for obtaining streams of integers.
*
* @author Randall Hauch
*/
@Immutable
public class Sequences {
/**
* Create a stream of <em>number</em> monotonically increasing numbers starting at 0, useful when performing an operation
* <em>number</em> times.
*
* @param number the number of values to include in the stream; must be positive
* @return the sequence; never null
*/
public static IntStream times(int number) {
return IntStream.range(0, number);
}
/**
* Create an iterator over an infinite number of monotonically increasing numbers starting at 0, useful when performing an
* operation an unknown number of times.
*
* @return the sequence; never null
*/
public static Iterable<Integer> infiniteIntegers() {
return infiniteIntegers(0);
}
/**
* Create an iterator over an infinite number monotonically increasing numbers starting at the given number, useful when
* performing an operation an unknown number of times.
*
* @param startingAt the first number to include in the resulting stream
* @return the sequence; never null
*/
public static Iterable<Integer> infiniteIntegers(int startingAt) {
return Iterators.around(new Iterator<Integer>() {
private int counter = startingAt;
@Override
public boolean hasNext() {
return true;
}
@Override
public Integer next() {
return Integer.valueOf(counter++);
}
});
}
/**
* Obtain a supplier function that randomly selects from the given values. If the supplied values contain nulls, then
* the resulting supplier function may return null values.
*
* @param first the first value that may be randomly picked
* @param additional the additional values to randomly pick from; may be null or empty
* @return the supplier function; never null
*/
@SafeVarargs
public static <T> Supplier<T> randomlySelect(T first, T... additional) {
if (additional == null || additional.length == 0) return () -> first;
Random rng = new Random(System.currentTimeMillis());
int max = additional.length + 1;
return () -> {
int index = rng.nextInt(max);
return index == 0 ? first : additional[index-1];
};
}
/**
* Obtain a supplier function that randomly selects from the given values. If the supplied values contain nulls, then
* the resulting supplier function may return null values.
*
* @param values the values to randomly pick from; may not be null, should not be empty
* @return the supplier function; never null
*/
@SafeVarargs
public static <T> Supplier<T> randomlySelect(T... values) {
if (values == null || values.length == 0) throw new IllegalArgumentException("The values array may not be null or empty");
Random rng = new Random(System.currentTimeMillis());
return () -> values[rng.nextInt(values.length)];
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
@ -65,9 +65,6 @@ public static interface Durations {
/**
* The timing statistics for a recorded set of samples.
*
* @author Randall Hauch
*
*/
public static interface Statistics {
/**
@ -255,8 +252,6 @@ public static Stopwatch accumulating() {
* This set is threadsafe, meaning that multiple threads can {@link #create()} new stopwatches concurrently, and each
* stopwatch's duration is measured separately. Additionally, all of the other methods of this interface are also threadsafe.
* </p>
*
* @author Randall Hauch
*/
@ThreadSafe
public static interface StopwatchSet extends Durations {
@ -464,8 +459,6 @@ protected static String asString(Duration duration) {
/**
* Abstract base class for {@link Durations} implementations.
*
* @author Randall Hauch
*/
@ThreadSafe
protected static abstract class BaseDurations implements Durations {
@ -479,8 +472,6 @@ public String toString() {
/**
* A {@link Durations} implementation that only remembers the most recently {@link #add(Duration) added} duration.
*
* @author Randall Hauch
*/
@ThreadSafe
private static final class SingleDuration extends BaseDurations {
@ -501,8 +492,6 @@ public void add(Duration duration) {
/**
* A {@link Durations} implementation that accumulates all {@link #add(Duration) added} durations.
*
* @author Randall Hauch
*/
@ThreadSafe
private static final class MultipleDurations extends BaseDurations {

View File

@ -1,27 +0,0 @@
/*
* Copyright 2015 Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.debezium.util;
import java.util.StringJoiner;
/**
* Interface that allows a class to more efficiently generate a string that is to be added to other strings via a
* {@link StringJoiner}.
*
* @author Randall Hauch
*/
@FunctionalInterface
public interface Stringifiable {
/**
* Used the supplied {@link StringJoiner} to record string representations of this object. The supplied joiner may concatenate
* these strings together using custom delimiter strings.
*
* @param joiner the string joiner instance that will accumulate the
*/
void asString(StringJoiner joiner);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2008 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
@ -18,6 +18,7 @@
* String-related utility methods.
*
* @author Randall Hauch
* @author Horia Chiorean
*/
@ThreadSafe
public final class Strings {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2010 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
@ -9,6 +9,9 @@
import static org.fest.assertions.Assertions.assertThat;
/**
* @author Randall Hauch
*/
public class PositionTest {
private int combinedIndex(int firstIndex,

View File

@ -1,5 +1,5 @@
/*
* Copyright 2010 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
@ -15,6 +15,10 @@
import io.debezium.text.TokenStream.BasicTokenizer;
import io.debezium.text.TokenStream.Tokenizer;
/**
* @author Randall Hauch
* @author Daniel Kelleher
*/
public class TokenStreamTest {
public static final int WORD = TokenStream.BasicTokenizer.WORD;
public static final int SYMBOL = TokenStream.BasicTokenizer.SYMBOL;
@ -44,25 +48,25 @@ public void makeCaseInsensitive() {
tokens.start();
}
@Test( expected = IllegalStateException.class )
@Test(expected = IllegalStateException.class)
public void shouldNotAllowConsumeBeforeStartIsCalled() {
tokens = new TokenStream(content, TokenStream.basicTokenizer(false), false);
tokens.consume("Select");
}
@Test( expected = IllegalStateException.class )
@Test(expected = IllegalStateException.class)
public void shouldNotAllowHasNextBeforeStartIsCalled() {
tokens = new TokenStream(content, TokenStream.basicTokenizer(false), false);
tokens.hasNext();
}
@Test( expected = IllegalStateException.class )
@Test(expected = IllegalStateException.class)
public void shouldNotAllowMatchesBeforeStartIsCalled() {
tokens = new TokenStream(content, TokenStream.basicTokenizer(false), false);
tokens.matches("Select");
}
@Test( expected = IllegalStateException.class )
@Test(expected = IllegalStateException.class)
public void shouldNotAllowCanConsumeBeforeStartIsCalled() {
tokens = new TokenStream(content, TokenStream.basicTokenizer(false), false);
tokens.canConsume("Select");
@ -88,7 +92,7 @@ public void shouldConsumeInCaseSensitiveMannerWithExpectedValuesWhenMatchingExac
assertThat(tokens.hasNext()).isFalse();
}
@Test( expected = ParsingException.class )
@Test(expected = ParsingException.class)
public void shouldFailToConsumeInCaseSensitiveMannerWithExpectedValuesWhenMatchingIncorrectCase() {
makeCaseSensitive();
tokens.consume("Select");
@ -108,7 +112,7 @@ public void shouldConsumeInCaseInsensitiveMannerWithExpectedValuesWhenMatchingNo
assertThat(tokens.hasNext()).isFalse();
}
@Test( expected = ParsingException.class )
@Test(expected = ParsingException.class)
public void shouldFailToConsumeInCaseInsensitiveMannerWithExpectedValuesWhenMatchingStringIsInLowerCase() {
makeCaseInsensitive();
tokens.consume("SELECT");
@ -311,7 +315,7 @@ public void shouldConsumeMultipleTokensIfTheyMatch() {
assertThat(tokens.hasNext()).isFalse();
}
@Test( expected = ParsingException.class )
@Test(expected = ParsingException.class)
public void shouldFailToConsumeMultipleTokensIfTheyDoNotMatch() {
makeCaseInsensitive();
tokens.consume("SELECT", "ALL", "COLUMNS", "FROM", "TABLE");
@ -327,8 +331,8 @@ public void shouldReturnTrueFromCanConsumeMultipleTokensIfTheyAllMatch() {
@Test
public void shouldReturnTrueFromCanConsumeArrayOfTokensIfTheyAllMatch() {
makeCaseInsensitive();
assertThat(tokens.matches(new String[] {"SELECT", "ALL", "COLUMNS", "FROM", "THIS", "TABLE"})).isTrue();
assertThat(tokens.canConsume(new String[] {"SELECT", "ALL", "COLUMNS", "FROM", "THIS", "TABLE"})).isTrue();
assertThat(tokens.matches(new String[] { "SELECT", "ALL", "COLUMNS", "FROM", "THIS", "TABLE" })).isTrue();
assertThat(tokens.canConsume(new String[] { "SELECT", "ALL", "COLUMNS", "FROM", "THIS", "TABLE" })).isTrue();
assertThat(tokens.hasNext()).isFalse();
}
@ -417,7 +421,7 @@ public void shouldCanConsumeSingleAfterTokensCompleteFromCanConsumeStringList()
public void shouldCanConsumeStringAfterTokensCompleteFromCanConsumeStringArray() {
makeCaseInsensitive();
// consume ALL the tokens using canConsume()
tokens.canConsume(new String[] {"SELECT", "ALL", "COLUMNS", "FROM", "THIS", "TABLE"});
tokens.canConsume(new String[] { "SELECT", "ALL", "COLUMNS", "FROM", "THIS", "TABLE" });
// try to canConsume() single word
assertThat(tokens.canConsume("SELECT")).isFalse();
assertThat(tokens.canConsume(TokenStream.ANY_VALUE)).isFalse();
@ -428,7 +432,7 @@ public void shouldCanConsumeStringAfterTokensCompleteFromCanConsumeStringArray()
public void shouldCanConsumeStringAfterTokensCompleteFromCanConsumeStringIterator() {
makeCaseInsensitive();
// consume ALL the tokens using canConsume()
tokens.canConsume(Arrays.asList(new String[] {"SELECT", "ALL", "COLUMNS", "FROM", "THIS", "TABLE"}));
tokens.canConsume(Arrays.asList(new String[] { "SELECT", "ALL", "COLUMNS", "FROM", "THIS", "TABLE" }));
// try to canConsume() single word
assertThat(tokens.canConsume("SELECT")).isFalse();
assertThat(tokens.canConsume(TokenStream.ANY_VALUE)).isFalse();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2010 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
@ -9,6 +9,9 @@
import static org.fest.assertions.Assertions.assertThat;
/**
* @author Randall Hauch
*/
public class XmlCharactersTest {
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
@ -11,6 +11,9 @@
import org.junit.Test;
/**
* @author Randall Hauch
*/
public class HashCodeTest {
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
@ -14,6 +14,10 @@
import org.junit.Test;
/**
* @author Randall Hauch
* @author Horia Chiorean
*/
public class StringsTest {
public void compareSeparatedLines( Object... lines ) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
@ -13,19 +13,15 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
import java.util.regex.Pattern;
public class Header extends com.puppycrawl.tools.checkstyle.checks.header.HeaderCheck {
private static final String YEAR_MATCHING_PATTERN = "${YYYY}";
private Set<String> excludedFileSet;
private String excludedFilesRegex;
private Pattern excludedFilesPattern;
private final String workingDirPath = new File(".").getAbsoluteFile().getParentFile().getAbsolutePath();
private final int workingDirPathLength = workingDirPath.length();
private Predicate<String> yearLineMatcher;
public Header() {
}
@ -63,11 +59,6 @@ public void setHeaderFile( String aFileName ) {
if (l == null) {
break;
}
if (l.contains(YEAR_MATCHING_PATTERN)) {
String prefix = l.substring(0, l.indexOf(YEAR_MATCHING_PATTERN));
String suffix = l.substring(l.indexOf(YEAR_MATCHING_PATTERN)+YEAR_MATCHING_PATTERN.length());
yearLineMatcher = (line)->line.startsWith(prefix) && line.endsWith(suffix);
}
sb.append(l).append("\\n");
}
super.setHeader(sb.toString());
@ -100,19 +91,4 @@ protected void processFiltered( File aFile,
if (isExcluded(aFile)) return;
super.processFiltered(aFile, aLines);
}
/**
* Checks if a code line matches the required header line.
* @param lineNumber the line number to check against the header
* @param line the line contents
* @return true if and only if the line matches the required header line
*/
@Override
protected boolean isMatch(int lineNumber, String line) {
if ( super.isMatch(lineNumber, line)) return true;
// Otherwise it does not match, so see if the line contain our "${year}" string
if ( yearLineMatcher != null && yearLineMatcher.test(line) ) return true;
return false;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright ${YYYY} Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/

View File

@ -7,7 +7,7 @@
id="org.eclipse.jdt.ui.text.codetemplates.filecomment"
name="filecomment">
/*
* Copyright 2016 Debezium Authors.
* Copyright Debezium Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/