├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── doc ├── 版本发行历史记录v1.3.6.txt ├── 版本发行历史记录v1.3.7.txt ├── 版本发行历史记录v1.3.8.txt ├── 版本发行历史记录v1.4.0.txt ├── 版本发行历史记录v1.4.1.txt ├── 版本发行历史记录v1.4.2.txt ├── 版本发行历史记录v2.0.0.txt ├── 版本发行历史记录v2.0.1.txt └── 版本发行历史记录v2.0.2.txt ├── logo.jpg ├── pom.xml └── src ├── main └── java │ ├── com │ └── sharksharding │ │ ├── core │ │ └── shard │ │ │ ├── DataSource.java │ │ │ ├── DataSourceHolder.java │ │ │ ├── DbRule.java │ │ │ ├── GetJdbcTemplate.java │ │ │ ├── HorizontalFacade.java │ │ │ ├── ResolveDbName.java │ │ │ ├── ResolveIndex.java │ │ │ ├── ResolveRouteRule.java │ │ │ ├── ResolveRouteValue.java │ │ │ ├── ResolveShardkey.java │ │ │ ├── ResolveTbName.java │ │ │ ├── Route.java │ │ │ ├── RouteImpl.java │ │ │ ├── Rule.java │ │ │ ├── RuleImpl.java │ │ │ ├── SQLExecute.java │ │ │ ├── SQLExecuterInterceptor.java │ │ │ ├── SetDatasource.java │ │ │ ├── SetTbName.java │ │ │ ├── ShardConfigInfo.java │ │ │ ├── ShardRule.java │ │ │ ├── SharkDataSourceHolder.java │ │ │ ├── SharkDatasourceGroup.java │ │ │ ├── TbRule.java │ │ │ └── VerticalFacade.java │ │ ├── exception │ │ ├── ConnectionException.java │ │ ├── FileNotFoundException.java │ │ ├── MapperException.java │ │ ├── RegisterBeanException.java │ │ ├── RenderException.java │ │ ├── ResourceException.java │ │ ├── SequenceIdException.java │ │ ├── SharkException.java │ │ ├── SharkRuntimeException.java │ │ ├── SqlParserException.java │ │ ├── UtilsRuntimeException.java │ │ ├── ValidateException.java │ │ └── XmlResolveException.java │ │ ├── factory │ │ ├── AnnotationResolverFactory.java │ │ ├── ClassResolverFactory.java │ │ ├── CreateMysqlSequenceIdFactory.java │ │ ├── CreateSequenceIdServiceFactory.java │ │ ├── CreateZookeeperSequenceIdFactory.java │ │ ├── DbRuleFactory.java │ │ ├── FieldResolverFactory.java │ │ ├── HorizontalFacadeFactory.java │ │ ├── RouteFactory.java │ │ ├── RuleFactory.java │ │ ├── TbRuleFactory.java │ │ └── VerticalFacadeFactory.java │ │ ├── resources │ │ ├── conn │ │ │ ├── DataSourceBean.java │ │ │ ├── RedisConnectionManager.java │ │ │ └── ZookeeperConnectionManager.java │ │ ├── register │ │ │ ├── bean │ │ │ │ ├── RegisterBean.java │ │ │ │ └── RegisterDataSource.java │ │ │ └── zookeeper │ │ │ │ └── node │ │ │ │ ├── RegisterDataSourceNode.java │ │ │ │ └── RegisterNode.java │ │ └── watcher │ │ │ ├── RedisWatcher.java │ │ │ └── ZookeeperWatcher.java │ │ ├── sql │ │ ├── PropertyPlaceholderConfigurer.java │ │ ├── RenderSQLTemplate.java │ │ ├── SQLIsWhereColumn.java │ │ ├── SQLTemplate.java │ │ ├── SQLUtils.java │ │ ├── ast │ │ │ ├── SQLCommentHint.java │ │ │ ├── SQLDataType.java │ │ │ ├── SQLDataTypeImpl.java │ │ │ ├── SQLExpr.java │ │ │ ├── SQLExprImpl.java │ │ │ ├── SQLHint.java │ │ │ ├── SQLName.java │ │ │ ├── SQLObject.java │ │ │ ├── SQLObjectImpl.java │ │ │ ├── SQLOrderBy.java │ │ │ ├── SQLOrderingSpecification.java │ │ │ ├── SQLOver.java │ │ │ ├── SQLPartitioningClause.java │ │ │ ├── SQLSetQuantifier.java │ │ │ ├── SQLStatement.java │ │ │ ├── SQLStatementImpl.java │ │ │ ├── expr │ │ │ │ ├── SQLAggregateExpr.java │ │ │ │ ├── SQLAggregateOption.java │ │ │ │ ├── SQLAllColumnExpr.java │ │ │ │ ├── SQLAllExpr.java │ │ │ │ ├── SQLAnyExpr.java │ │ │ │ ├── SQLArrayExpr.java │ │ │ │ ├── SQLBetweenExpr.java │ │ │ │ ├── SQLBinaryExpr.java │ │ │ │ ├── SQLBinaryOpExpr.java │ │ │ │ ├── SQLBinaryOperator.java │ │ │ │ ├── SQLBooleanExpr.java │ │ │ │ ├── SQLCaseExpr.java │ │ │ │ ├── SQLCastExpr.java │ │ │ │ ├── SQLCharExpr.java │ │ │ │ ├── SQLCurrentOfCursorExpr.java │ │ │ │ ├── SQLDefaultExpr.java │ │ │ │ ├── SQLExistsExpr.java │ │ │ │ ├── SQLHexExpr.java │ │ │ │ ├── SQLIdentifierExpr.java │ │ │ │ ├── SQLInListExpr.java │ │ │ │ ├── SQLInSubQueryExpr.java │ │ │ │ ├── SQLIntegerExpr.java │ │ │ │ ├── SQLListExpr.java │ │ │ │ ├── SQLLiteralExpr.java │ │ │ │ ├── SQLMethodInvokeExpr.java │ │ │ │ ├── SQLNCharExpr.java │ │ │ │ ├── SQLNotExpr.java │ │ │ │ ├── SQLNullExpr.java │ │ │ │ ├── SQLNumberExpr.java │ │ │ │ ├── SQLNumericLiteralExpr.java │ │ │ │ ├── SQLPropertyExpr.java │ │ │ │ ├── SQLQueryExpr.java │ │ │ │ ├── SQLSomeExpr.java │ │ │ │ ├── SQLTextLiteralExpr.java │ │ │ │ ├── SQLTimestampExpr.java │ │ │ │ ├── SQLUnaryExpr.java │ │ │ │ ├── SQLUnaryOperator.java │ │ │ │ ├── SQLValuableExpr.java │ │ │ │ └── SQLVariantRefExpr.java │ │ │ └── statement │ │ │ │ ├── NotNullConstraint.java │ │ │ │ ├── SQLAlterTableAddColumn.java │ │ │ │ ├── SQLAlterTableAddConstraint.java │ │ │ │ ├── SQLAlterTableAddIndex.java │ │ │ │ ├── SQLAlterTableAddPartition.java │ │ │ │ ├── SQLAlterTableAlterColumn.java │ │ │ │ ├── SQLAlterTableDisableConstraint.java │ │ │ │ ├── SQLAlterTableDisableKeys.java │ │ │ │ ├── SQLAlterTableDisableLifecycle.java │ │ │ │ ├── SQLAlterTableDropColumnItem.java │ │ │ │ ├── SQLAlterTableDropConstraint.java │ │ │ │ ├── SQLAlterTableDropForeignKey.java │ │ │ │ ├── SQLAlterTableDropIndex.java │ │ │ │ ├── SQLAlterTableDropPartition.java │ │ │ │ ├── SQLAlterTableDropPrimaryKey.java │ │ │ │ ├── SQLAlterTableEnableConstraint.java │ │ │ │ ├── SQLAlterTableEnableKeys.java │ │ │ │ ├── SQLAlterTableEnableLifecycle.java │ │ │ │ ├── SQLAlterTableItem.java │ │ │ │ ├── SQLAlterTableRename.java │ │ │ │ ├── SQLAlterTableRenameColumn.java │ │ │ │ ├── SQLAlterTableRenamePartition.java │ │ │ │ ├── SQLAlterTableSetComment.java │ │ │ │ ├── SQLAlterTableSetLifecycle.java │ │ │ │ ├── SQLAlterTableStatement.java │ │ │ │ ├── SQLAlterTableTouch.java │ │ │ │ ├── SQLAlterViewRenameStatement.java │ │ │ │ ├── SQLAssignItem.java │ │ │ │ ├── SQLCallStatement.java │ │ │ │ ├── SQLCharacterDataType.java │ │ │ │ ├── SQLCheck.java │ │ │ │ ├── SQLCloseStatement.java │ │ │ │ ├── SQLColumnCheck.java │ │ │ │ ├── SQLColumnConstraint.java │ │ │ │ ├── SQLColumnDefinition.java │ │ │ │ ├── SQLColumnPrimaryKey.java │ │ │ │ ├── SQLColumnReference.java │ │ │ │ ├── SQLColumnUniqueKey.java │ │ │ │ ├── SQLCommentStatement.java │ │ │ │ ├── SQLConstraint.java │ │ │ │ ├── SQLConstraintImpl.java │ │ │ │ ├── SQLCreateDatabaseStatement.java │ │ │ │ ├── SQLCreateIndexStatement.java │ │ │ │ ├── SQLCreateTableStatement.java │ │ │ │ ├── SQLCreateTriggerStatement.java │ │ │ │ ├── SQLCreateViewStatement.java │ │ │ │ ├── SQLDDLStatement.java │ │ │ │ ├── SQLDeleteStatement.java │ │ │ │ ├── SQLDescribeStatement.java │ │ │ │ ├── SQLDropDatabaseStatement.java │ │ │ │ ├── SQLDropFunctionStatement.java │ │ │ │ ├── SQLDropIndexStatement.java │ │ │ │ ├── SQLDropProcedureStatement.java │ │ │ │ ├── SQLDropSequenceStatement.java │ │ │ │ ├── SQLDropTableSpaceStatement.java │ │ │ │ ├── SQLDropTableStatement.java │ │ │ │ ├── SQLDropTriggerStatement.java │ │ │ │ ├── SQLDropUserStatement.java │ │ │ │ ├── SQLDropViewStatement.java │ │ │ │ ├── SQLExplainStatement.java │ │ │ │ ├── SQLExprHint.java │ │ │ │ ├── SQLExprTableSource.java │ │ │ │ ├── SQLFetchStatement.java │ │ │ │ ├── SQLForeignKeyConstraint.java │ │ │ │ ├── SQLForeignKeyImpl.java │ │ │ │ ├── SQLGrantStatement.java │ │ │ │ ├── SQLInsertInto.java │ │ │ │ ├── SQLInsertStatement.java │ │ │ │ ├── SQLJoinTableSource.java │ │ │ │ ├── SQLObjectType.java │ │ │ │ ├── SQLOpenStatement.java │ │ │ │ ├── SQLPrimaryKey.java │ │ │ │ ├── SQLPrimaryKeyImpl.java │ │ │ │ ├── SQLReleaseSavePointStatement.java │ │ │ │ ├── SQLRevokeStatement.java │ │ │ │ ├── SQLRollbackStatement.java │ │ │ │ ├── SQLSavePointStatement.java │ │ │ │ ├── SQLSelect.java │ │ │ │ ├── SQLSelectGroupByClause.java │ │ │ │ ├── SQLSelectItem.java │ │ │ │ ├── SQLSelectOrderByItem.java │ │ │ │ ├── SQLSelectQuery.java │ │ │ │ ├── SQLSelectQueryBlock.java │ │ │ │ ├── SQLSelectStatement.java │ │ │ │ ├── SQLSetStatement.java │ │ │ │ ├── SQLShowTablesStatement.java │ │ │ │ ├── SQLSubqueryTableSource.java │ │ │ │ ├── SQLTableConstraint.java │ │ │ │ ├── SQLTableElement.java │ │ │ │ ├── SQLTableSource.java │ │ │ │ ├── SQLTableSourceImpl.java │ │ │ │ ├── SQLTruncateStatement.java │ │ │ │ ├── SQLUnionOperator.java │ │ │ │ ├── SQLUnionQuery.java │ │ │ │ ├── SQLUnionQueryTableSource.java │ │ │ │ ├── SQLUnique.java │ │ │ │ ├── SQLUniqueConstraint.java │ │ │ │ ├── SQLUpdateSetItem.java │ │ │ │ ├── SQLUpdateStatement.java │ │ │ │ ├── SQLUseStatement.java │ │ │ │ └── SQLWithSubqueryClause.java │ │ ├── dialect │ │ │ └── mysql │ │ │ │ ├── ast │ │ │ │ ├── MySqlForceIndexHint.java │ │ │ │ ├── MySqlHint.java │ │ │ │ ├── MySqlIgnoreIndexHint.java │ │ │ │ ├── MySqlIndexHint.java │ │ │ │ ├── MySqlIndexHintImpl.java │ │ │ │ ├── MySqlKey.java │ │ │ │ ├── MySqlObject.java │ │ │ │ ├── MySqlObjectImpl.java │ │ │ │ ├── MySqlPrimaryKey.java │ │ │ │ ├── MySqlUnique.java │ │ │ │ ├── MySqlUseIndexHint.java │ │ │ │ ├── MysqlForeignKey.java │ │ │ │ ├── clause │ │ │ │ │ ├── MySqlCaseStatement.java │ │ │ │ │ ├── MySqlCreateProcedureStatement.java │ │ │ │ │ ├── MySqlCursorDeclareStatement.java │ │ │ │ │ ├── MySqlDeclareStatement.java │ │ │ │ │ ├── MySqlElseStatement.java │ │ │ │ │ ├── MySqlIfStatement.java │ │ │ │ │ ├── MySqlIterateStatement.java │ │ │ │ │ ├── MySqlLeaveStatement.java │ │ │ │ │ ├── MySqlLoopStatement.java │ │ │ │ │ ├── MySqlParameter.java │ │ │ │ │ ├── MySqlRepeatStatement.java │ │ │ │ │ ├── MySqlSelectIntoStatement.java │ │ │ │ │ ├── MySqlStatementType.java │ │ │ │ │ └── MySqlWhileStatement.java │ │ │ │ ├── expr │ │ │ │ │ ├── MySqlCharExpr.java │ │ │ │ │ ├── MySqlExpr.java │ │ │ │ │ ├── MySqlExprImpl.java │ │ │ │ │ ├── MySqlExtractExpr.java │ │ │ │ │ ├── MySqlIntervalExpr.java │ │ │ │ │ ├── MySqlIntervalUnit.java │ │ │ │ │ ├── MySqlMatchAgainstExpr.java │ │ │ │ │ ├── MySqlOutFileExpr.java │ │ │ │ │ ├── MySqlSelectGroupByExpr.java │ │ │ │ │ └── MySqlUserName.java │ │ │ │ └── statement │ │ │ │ │ ├── CobarShowStatus.java │ │ │ │ │ ├── MySqlAlterTableAddColumn.java │ │ │ │ │ ├── MySqlAlterTableChangeColumn.java │ │ │ │ │ ├── MySqlAlterTableCharacter.java │ │ │ │ │ ├── MySqlAlterTableDiscardTablespace.java │ │ │ │ │ ├── MySqlAlterTableImportTablespace.java │ │ │ │ │ ├── MySqlAlterTableModifyColumn.java │ │ │ │ │ ├── MySqlAlterTableOption.java │ │ │ │ │ ├── MySqlAlterTableStatement.java │ │ │ │ │ ├── MySqlAlterUserStatement.java │ │ │ │ │ ├── MySqlAnalyzeStatement.java │ │ │ │ │ ├── MySqlBinlogStatement.java │ │ │ │ │ ├── MySqlBlockStatement.java │ │ │ │ │ ├── MySqlCommitStatement.java │ │ │ │ │ ├── MySqlCreateIndexStatement.java │ │ │ │ │ ├── MySqlCreateTableStatement.java │ │ │ │ │ ├── MySqlCreateUserStatement.java │ │ │ │ │ ├── MySqlDeleteStatement.java │ │ │ │ │ ├── MySqlDescribeStatement.java │ │ │ │ │ ├── MySqlExecuteStatement.java │ │ │ │ │ ├── MySqlHelpStatement.java │ │ │ │ │ ├── MySqlHintStatement.java │ │ │ │ │ ├── MySqlInsertStatement.java │ │ │ │ │ ├── MySqlKillStatement.java │ │ │ │ │ ├── MySqlLoadDataInFileStatement.java │ │ │ │ │ ├── MySqlLoadXmlStatement.java │ │ │ │ │ ├── MySqlLockTableStatement.java │ │ │ │ │ ├── MySqlOptimizeStatement.java │ │ │ │ │ ├── MySqlPartitionByHash.java │ │ │ │ │ ├── MySqlPartitionByKey.java │ │ │ │ │ ├── MySqlPartitionByList.java │ │ │ │ │ ├── MySqlPartitionByRange.java │ │ │ │ │ ├── MySqlPartitioningClause.java │ │ │ │ │ ├── MySqlPartitioningDef.java │ │ │ │ │ ├── MySqlPrepareStatement.java │ │ │ │ │ ├── MySqlRenameTableStatement.java │ │ │ │ │ ├── MySqlReplaceStatement.java │ │ │ │ │ ├── MySqlResetStatement.java │ │ │ │ │ ├── MySqlRollbackStatement.java │ │ │ │ │ ├── MySqlSQLColumnDefinition.java │ │ │ │ │ ├── MySqlSelectGroupBy.java │ │ │ │ │ ├── MySqlSelectQueryBlock.java │ │ │ │ │ ├── MySqlSetCharSetStatement.java │ │ │ │ │ ├── MySqlSetNamesStatement.java │ │ │ │ │ ├── MySqlSetPasswordStatement.java │ │ │ │ │ ├── MySqlSetTransactionStatement.java │ │ │ │ │ ├── MySqlShowAuthorsStatement.java │ │ │ │ │ ├── MySqlShowBinLogEventsStatement.java │ │ │ │ │ ├── MySqlShowBinaryLogsStatement.java │ │ │ │ │ ├── MySqlShowCharacterSetStatement.java │ │ │ │ │ ├── MySqlShowCollationStatement.java │ │ │ │ │ ├── MySqlShowColumnsStatement.java │ │ │ │ │ ├── MySqlShowContributorsStatement.java │ │ │ │ │ ├── MySqlShowCreateDatabaseStatement.java │ │ │ │ │ ├── MySqlShowCreateEventStatement.java │ │ │ │ │ ├── MySqlShowCreateFunctionStatement.java │ │ │ │ │ ├── MySqlShowCreateProcedureStatement.java │ │ │ │ │ ├── MySqlShowCreateTableStatement.java │ │ │ │ │ ├── MySqlShowCreateTriggerStatement.java │ │ │ │ │ ├── MySqlShowCreateViewStatement.java │ │ │ │ │ ├── MySqlShowDatabasesStatement.java │ │ │ │ │ ├── MySqlShowEngineStatement.java │ │ │ │ │ ├── MySqlShowEnginesStatement.java │ │ │ │ │ ├── MySqlShowErrorsStatement.java │ │ │ │ │ ├── MySqlShowEventsStatement.java │ │ │ │ │ ├── MySqlShowFunctionCodeStatement.java │ │ │ │ │ ├── MySqlShowFunctionStatusStatement.java │ │ │ │ │ ├── MySqlShowGrantsStatement.java │ │ │ │ │ ├── MySqlShowIndexesStatement.java │ │ │ │ │ ├── MySqlShowKeysStatement.java │ │ │ │ │ ├── MySqlShowMasterLogsStatement.java │ │ │ │ │ ├── MySqlShowMasterStatusStatement.java │ │ │ │ │ ├── MySqlShowOpenTablesStatement.java │ │ │ │ │ ├── MySqlShowPluginsStatement.java │ │ │ │ │ ├── MySqlShowPrivilegesStatement.java │ │ │ │ │ ├── MySqlShowProcedureCodeStatement.java │ │ │ │ │ ├── MySqlShowProcedureStatusStatement.java │ │ │ │ │ ├── MySqlShowProcessListStatement.java │ │ │ │ │ ├── MySqlShowProfileStatement.java │ │ │ │ │ ├── MySqlShowProfilesStatement.java │ │ │ │ │ ├── MySqlShowRelayLogEventsStatement.java │ │ │ │ │ ├── MySqlShowSlaveHostsStatement.java │ │ │ │ │ ├── MySqlShowSlaveStatusStatement.java │ │ │ │ │ ├── MySqlShowStatement.java │ │ │ │ │ ├── MySqlShowStatusStatement.java │ │ │ │ │ ├── MySqlShowTableStatusStatement.java │ │ │ │ │ ├── MySqlShowTablesStatement.java │ │ │ │ │ ├── MySqlShowTriggersStatement.java │ │ │ │ │ ├── MySqlShowVariantsStatement.java │ │ │ │ │ ├── MySqlShowWarningsStatement.java │ │ │ │ │ ├── MySqlStartTransactionStatement.java │ │ │ │ │ ├── MySqlStatement.java │ │ │ │ │ ├── MySqlStatementImpl.java │ │ │ │ │ ├── MySqlTableIndex.java │ │ │ │ │ ├── MySqlUnionQuery.java │ │ │ │ │ ├── MySqlUnlockTablesStatement.java │ │ │ │ │ ├── MySqlUpdateStatement.java │ │ │ │ │ └── MySqlUpdateTableSource.java │ │ │ │ ├── parser │ │ │ │ ├── MySqlCreateTableParser.java │ │ │ │ ├── MySqlExprParser.java │ │ │ │ ├── MySqlLexer.java │ │ │ │ ├── MySqlSelectIntoParser.java │ │ │ │ ├── MySqlSelectParser.java │ │ │ │ └── MySqlStatementParser.java │ │ │ │ └── visitor │ │ │ │ ├── MySql2OracleOutputVisitor.java │ │ │ │ ├── MySqlASTVisitor.java │ │ │ │ ├── MySqlASTVisitorAdapter.java │ │ │ │ ├── MySqlEvalVisitorImpl.java │ │ │ │ ├── MySqlExportParameterVisitor.java │ │ │ │ ├── MySqlOutputVisitor.java │ │ │ │ ├── MySqlParameterizedOutputVisitor.java │ │ │ │ └── MySqlSchemaStatVisitor.java │ │ ├── parser │ │ │ ├── CharTypes.java │ │ │ ├── EOFParserException.java │ │ │ ├── Keywords.java │ │ │ ├── LayoutCharacters.java │ │ │ ├── Lexer.java │ │ │ ├── NotAllowCommentException.java │ │ │ ├── ParserException.java │ │ │ ├── SQLCreateTableParser.java │ │ │ ├── SQLDDLParser.java │ │ │ ├── SQLExprParser.java │ │ │ ├── SQLParser.java │ │ │ ├── SQLParserUtils.java │ │ │ ├── SQLSelectParser.java │ │ │ ├── SQLStatementParser.java │ │ │ └── Token.java │ │ └── visitor │ │ │ ├── ExportParameterVisitor.java │ │ │ ├── ExportParameterVisitorUtils.java │ │ │ ├── ParameterizedOutputVisitor.java │ │ │ ├── ParameterizedOutputVisitorUtils.java │ │ │ ├── ParameterizedVisitor.java │ │ │ ├── PrintableVisitor.java │ │ │ ├── SQLASTOutputVisitor.java │ │ │ ├── SQLASTOutputVisitorUtils.java │ │ │ ├── SQLASTVisitor.java │ │ │ ├── SQLASTVisitorAdapter.java │ │ │ ├── SQLEvalVisitorImpl.java │ │ │ ├── SQLEvalVisitorUtils.java │ │ │ └── SchemaStatVisitor.java │ │ └── util │ │ ├── ConfigInfoValidate.java │ │ ├── FileExist.java │ │ ├── HexBin.java │ │ ├── JdbcConstants.java │ │ ├── LoadSharkLogo.java │ │ ├── LoadVersion.java │ │ ├── MD5Util.java │ │ ├── TmpManager.java │ │ ├── mail │ │ ├── GetUserInfo.java │ │ ├── MailBean.java │ │ └── SendMail.java │ │ ├── mapper │ │ ├── AutoColumn.java │ │ ├── BeanMapper.java │ │ ├── ClassResolver.java │ │ ├── Column.java │ │ ├── FieldResolver.java │ │ ├── Mapper.java │ │ ├── SetValue.java │ │ ├── SharkAnnotationResolver.java │ │ └── SharkAnnotationResolverImpl.java │ │ ├── sequence │ │ ├── CreateSequenceIdService.java │ │ ├── CreateSequenceIdServiceImpl.java │ │ ├── SequenceIDManger.java │ │ ├── mysql │ │ │ ├── CreateMysqlSequenceId.java │ │ │ ├── CreateSequenceIdDao.java │ │ │ ├── CreateSequenceIdDaoImpl.java │ │ │ ├── DBConnectionManager.java │ │ │ └── UserType.java │ │ └── zookeeper │ │ │ ├── CreateZookeeperSequenceId.java │ │ │ ├── ZnodeService.java │ │ │ └── ZookeeperConnectionManager.java │ │ ├── web │ │ └── http │ │ │ ├── ExecuteSql.java │ │ │ ├── GetIndexData.java │ │ │ └── QueryViewServlet.java │ │ └── xml │ │ ├── Bean.java │ │ ├── Beans.java │ │ ├── ConstructorArg.java │ │ ├── CreateC3p0Xml.java │ │ ├── CreateCoreXml.java │ │ ├── CreateDSXml.java │ │ ├── CreateDruidXml.java │ │ ├── Entry.java │ │ ├── Map.java │ │ └── Property.java │ ├── shark-logo.txt │ ├── version.properties │ └── web │ └── http │ └── resources │ ├── index.html │ └── query.html └── test ├── java └── com │ └── test │ └── sharksharding │ ├── core │ └── shard │ │ ├── PropertyPlaceholderConfigurerTest.java │ │ ├── ResolveDbnameTest.java │ │ ├── ResolveIndexTest.java │ │ ├── ResolveShardkeyTest.java │ │ ├── RuleTest.java │ │ └── SetTabNameTest.java │ ├── sql │ └── mysql │ │ └── parser │ │ ├── ResolveRouteTest.java │ │ ├── ResolveTableNameTest.java │ │ ├── SQLIsWhereColumnTest.java │ │ ├── SqlLexerTest.java │ │ └── SqlParserTest.java │ ├── use │ ├── EmailDao.java │ ├── EmailDaoImpl.java │ ├── EmailInfo.java │ ├── EmailInfoMapper.java │ ├── Main.java │ ├── Message.java │ ├── MessageDao.java │ ├── MessageDaoImpl.java │ ├── MessageMapper.java │ ├── OtherTest.java │ ├── UserDao.java │ ├── UserDaoImpl.java │ ├── UserInfo.java │ ├── UserInfoMapper.java │ └── resource │ │ ├── RedisResourceTest.java │ │ ├── RedisSetData.java │ │ ├── ZkResourceTest.java │ │ └── ZkSetData.java │ └── util │ ├── FileExistTest.java │ ├── GetNewTabNameTest.java │ ├── LoadVersionTest.java │ ├── MD5UtilTest.java │ ├── ResolveRuleTest.java │ ├── TmpManagerTest.java │ ├── sequence │ ├── GetMysqlSequenceId2Test.java │ ├── GetMysqlSequenceIdTest.java │ └── GetZookeeperSequenceIdTest.java │ └── xml │ └── CreateXmlTest.java └── resources ├── create.sql ├── datasource1-context.xml ├── datasource2-context.xml ├── datasource3-context.xml ├── log4j.xml ├── properties ├── druid-jdbc.properties ├── redis.properties ├── sql.properties ├── sql.xml └── zookeeper.properties ├── shark1-context.xml ├── shark2-context.xml ├── shark3-context.xml ├── shark4-context.xml └── shark5-context.xml /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | /target/ 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java -------------------------------------------------------------------------------- /doc/版本发行历史记录v1.3.6.txt: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | 【版本号】 3 | 1.3.6 4 | 【功能改动】 5 | a、前身为kratos,1.3.6为第一个开源版本; 6 | 【发布日期】 7 | 2016-01-07 8 | ################################################################################# -------------------------------------------------------------------------------- /doc/版本发行历史记录v1.3.7.txt: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | 【版本号】 3 | 1.3.7 4 | 【功能改动】 5 | a、支持基于zookeeper作为集中式资源配置中心; 6 | b、支持基于redis3.x cluster作为集中式资源配置中心; 7 | c、基于zookeeper实现全局id生成器(和目前基于db的id生成策略并存); 8 | d、修复从配置中心拉完配置信息后本地生成tmpdir的bug; 9 | e、复基于redis3.x cluster的配置中心的客户端bug; 10 | f、对redis cluster作为集中式资源配置中心的客户端检查配置变动新增md5码 11 | 验证方式; 12 | g、修改部分异常描述信息; 13 | h、调整全局id生成器的单元测试 14 | 【发布日期】 15 | 2016-03-03 16 | ################################################################################# -------------------------------------------------------------------------------- /doc/版本发行历史记录v1.3.8.txt: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | 【版本号】 3 | 1.3.8 4 | 【功能改动】 5 | a、调整目录结构; 6 | b、不再继续使用module结构; 7 | c、调整pom.xml文件,降低shark构件依赖; 8 | d、支持将shark1.3.8构件发布到maven中央仓库中提供下载; 9 | 【发布日期】 10 | 2016-03-20 11 | ################################################################################# 12 | -------------------------------------------------------------------------------- /doc/版本发行历史记录v1.4.0.txt: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | 【版本号】 3 | 1.4.0 4 | 【功能改动】 5 | a、shark整体项目重构; 6 | b、降低与spring的整体依赖; 7 | c、修复基于zookeeper、redis3cluster作为集中式配置中心的bug; 8 | d、调整目录结构,删除src/main/resources,将web.http.resources目录下的html 9 | 移至src/main/java,修复加载html文件失败bug; 10 | e、修复GetIndexData类中的输出页面的json值bug; 11 | f、将ResolveRoute类中包含的kratos替换为shark; 12 | g、新增LoadVersion.java加载shark版本号; 13 | h、新增部分测试用例; 14 | 【发布日期】 15 | 2016-03-27 16 | ################################################################################# 17 | -------------------------------------------------------------------------------- /doc/版本发行历史记录v1.4.1.txt: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | 【版本号】 3 | 1.4.1 4 | 【功能改动】 5 | a、基于velocity模板引擎渲染内容,支持动态拼接sql,类似mybatis的sql配置方式(与shark目前的properties方式 6 | 并存),支持表达式; 7 | b、自动对spring mapper进行赋值映射操作; 8 | c、调整基于zookeeper生成全局唯一的sequenceid算法; 9 | d、解析sql语句时,开始支持数据库别名; 10 | e、底层解析分库分表索引时将%运算替换为&运算; 11 | f、将切换数据源动作的日志记录调整到SharkDatasourceGroup. 12 | determineCurrentLookupKey()方法中; 13 | g、修复PropertyPlaceholderConfigurer类中update语句占位符“?”替换的bug; 14 | h、增加部分测试用例; 15 | i、降低shark的pom.xml文件中与其它构件的依赖; 16 | j、解析SQL语句WHERE条件后面是否带参数; 17 | k、调整自动生成shark核心配置文件代码; 18 | 【发布日期】 19 | 未发版 20 | ################################################################################# 21 | -------------------------------------------------------------------------------- /doc/版本发行历史记录v1.4.2.txt: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | 【版本号】 3 | 1.4.2 4 | 【功能改动】 5 | a、调整自动生成shark核心配置文件代码,以及测试用例; 6 | b、调整基于配置中心的客户端相关代码实现; 7 | c、为shark的动态数据源层代码实现添加关于线程安全的注释; 8 | d、修改控制台启动时shark logo信息; 9 | e、删除SharkJdbcTemplate中重写Spring JdbcTemplate的一些过时方法; 10 | 【发布日期】 11 | 2016-07-08 12 | ################################################################################# -------------------------------------------------------------------------------- /doc/版本发行历史记录v2.0.0.txt: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | 【版本号】 3 | 2.0.0 4 | 【功能改动】 5 | a、调整分库分表模式,目前分库分表模式由单库多表和多库多表构成; 6 | b、废弃SharkJdbcTemplate,直接支持Spring的JdbcTemplate,实现业务零侵入; 7 | c、调整com.sharksharding.core包下的目录结构; 8 | d、修改com.sharksharding.util.xml包下自动生成shark配置文件代码; 9 | 【发布日期】 10 | 2016-07-12 11 | ################################################################################# -------------------------------------------------------------------------------- /doc/版本发行历史记录v2.0.1.txt: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | 【版本号】 3 | 2.0.1 4 | 【功能改动】 5 | a、调整分库分表路由模式接口Route的派生继承关系; 6 | b、调整com.sharksharding.factory包下的所有工厂方法类; 7 | c、修复com.sharksharding.factory下缺少RuleFactory问题; 8 | d、修复Shark的ID生成器BUG; 9 | e、Shark基于Mysql的ID生成器支持连接池配置; 10 | 【发布日期】 11 | 2016-08-24 12 | ################################################################################# -------------------------------------------------------------------------------- /doc/版本发行历史记录v2.0.2.txt: -------------------------------------------------------------------------------- 1 | ################################################################################# 2 | 【版本号】 3 | 2.0.2.RELEASE 4 | 【功能改动】 5 | a、收集用户的常规数据信息,发送到gao_xianglong@sina.com,方便作者统计目前的shark活跃用户数量; 6 | b、如果JdbcTemplate持有的不是SharkDatasourceGroup动态数据源,则不进行数据路由操作; 7 | 【发布日期】 8 | 2016-12-13 9 | ################################################################################# -------------------------------------------------------------------------------- /logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gaoxianglong/shark/be535652a37a669f7d9c7b568b8668539118322f/logo.jpg -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/core/shard/DataSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.core.shard; 17 | 18 | /** 19 | * shark动态数据源标记接口 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.3.5 24 | */ 25 | public interface DataSource { 26 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/core/shard/DataSourceHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.core.shard; 17 | 18 | /** 19 | * 数据源路由选择器接口 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.3.5 24 | */ 25 | public interface DataSourceHolder { 26 | /** 27 | * 设置数据源路由索引 28 | * 29 | * @author gaoxianglong 30 | * 31 | * @param index 32 | * 数据源路由索引 33 | * 34 | * @return void 35 | */ 36 | public void setIndex(int index); 37 | 38 | /** 39 | * 获取数据源路由索引 40 | * 41 | * @author gaoxianglong 42 | * 43 | * @return int 数据源路由索引 44 | */ 45 | public int getIndex(); 46 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/core/shard/DbRule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.core.shard; 17 | 18 | /** 19 | * 解析分库规则后计算数据源索引 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.3.5 24 | */ 25 | public class DbRule extends RuleImpl { 26 | private ShardConfigInfo sharkConfigInfo; 27 | 28 | public DbRule() { 29 | sharkConfigInfo = ShardConfigInfo.getShardInfo(); 30 | } 31 | 32 | @Override 33 | public int getIndex(long routeValue, String ruleArray) { 34 | int dbIndex = -1; 35 | /* 只有多库多表模式下需要计算数据源索引 */ 36 | if (sharkConfigInfo.getShardMode()) 37 | dbIndex = super.getDbIndex(routeValue, ruleArray); 38 | return dbIndex; 39 | } 40 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/core/shard/ResolveDbName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.core.shard; 17 | 18 | import com.sharksharding.core.shard.ResolveTbName; 19 | 20 | /** 21 | * 解析数据库名称 22 | * 23 | * @author gaoxianglong 24 | * 25 | * @version 1.3.5 26 | */ 27 | public class ResolveDbName { 28 | public static String getNewDbName(int index, String dbName, String tbSuffix) { 29 | return ResolveTbName.getNewTbName(index, dbName, tbSuffix); 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/core/shard/Route.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.core.shard; 17 | 18 | /** 19 | * 分库分表路由模式接口 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.3.5 24 | */ 25 | public interface Route { 26 | /** 27 | * 数据路由 28 | * 29 | * @author gaoxianglong 30 | * 31 | * @param sql 32 | * 需要进行重写的sql语句 33 | * 34 | * @param params 35 | * 委托对象的方法入参 36 | * 37 | * @param indexType 38 | * true为master启始索引,false为slave启始索引 39 | * 40 | * @return Object[] 重写后的委托对象的上下文信息 41 | */ 42 | public Object[] route(String sql, Object[] params, boolean indexType); 43 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/core/shard/Rule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.core.shard; 17 | 18 | /** 19 | * 路由规则接口 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.3.5 24 | */ 25 | public interface Rule { 26 | /** 27 | * 获取数据源索引/表索引 28 | * 29 | * @author gaoxianglong 30 | * 31 | * @param shardMode 32 | * 分表模式 33 | * 34 | * @param routeValue 35 | * 路由条件 36 | * 37 | * @param ruleArray 38 | * 路由规则 39 | * 40 | * @throws ShardException 41 | * 42 | * @return int 库索引/表索引 43 | */ 44 | public int getIndex(long routeValue, String ruleArray); 45 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/core/shard/SetDatasource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.core.shard; 17 | 18 | /** 19 | * 设置数据源索引 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.3.5 24 | */ 25 | public class SetDatasource { 26 | protected static void setIndex(int index, DataSourceHolder dataSourceHolder) { 27 | dataSourceHolder.setIndex(index); 28 | } 29 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/core/shard/TbRule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.core.shard; 17 | 18 | /** 19 | * 解析分表规则后计算分表索引 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.3.5 24 | */ 25 | public class TbRule extends RuleImpl { 26 | private ShardConfigInfo sharkConfigInfo; 27 | 28 | public TbRule() { 29 | sharkConfigInfo = ShardConfigInfo.getShardInfo(); 30 | } 31 | 32 | @Override 33 | public int getIndex(long routeValue, String ruleArray) { 34 | return getTbIndex(routeValue, ruleArray, sharkConfigInfo.getShardMode()); 35 | } 36 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/exception/ConnectionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.exception; 17 | 18 | /** 19 | * 连接异常 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.3.5 24 | */ 25 | public class ConnectionException extends SharkRuntimeException { 26 | private static final long serialVersionUID = 467676658994285663L; 27 | 28 | public ConnectionException(String str) { 29 | super(str); 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/exception/FileNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.exception; 17 | 18 | /** 19 | * 无法加载本地文件异常类 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.4.0 24 | */ 25 | public class FileNotFoundException extends SharkRuntimeException { 26 | private static final long serialVersionUID = 4798844003031396048L; 27 | 28 | public FileNotFoundException(String str) { 29 | super(str); 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/exception/MapperException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.exception; 17 | 18 | /** 19 | * 自动映射失败异常 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.4.1 24 | */ 25 | public class MapperException extends SharkRuntimeException { 26 | private static final long serialVersionUID = -8301606060406419061L; 27 | 28 | public MapperException(String str) { 29 | super(str); 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/exception/RegisterBeanException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.exception; 17 | 18 | /** 19 | * 动态向ioc容器中注入bean异常类 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.4.0 24 | */ 25 | public class RegisterBeanException extends SharkRuntimeException { 26 | private static final long serialVersionUID = 2622853967209321962L; 27 | 28 | public RegisterBeanException(String str) { 29 | super(str); 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/exception/RenderException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.exception; 17 | 18 | /** 19 | * 渲染sql.xml模板异常 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.4.1 24 | */ 25 | public class RenderException extends SharkRuntimeException { 26 | private static final long serialVersionUID = -2422454821632859357L; 27 | 28 | public RenderException(String str) { 29 | super(str); 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/exception/ResourceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.exception; 17 | 18 | /** 19 | * 资源配置中心异常信息 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.3.7 24 | */ 25 | public class ResourceException extends SharkRuntimeException { 26 | private static final long serialVersionUID = -1280572478348303040L; 27 | 28 | public ResourceException(String str) { 29 | super(str); 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/exception/SequenceIdException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.exception; 17 | 18 | /** 19 | * sequenceid生成异常 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.3.5 24 | */ 25 | public class SequenceIdException extends SharkRuntimeException { 26 | private static final long serialVersionUID = 467676658994285663L; 27 | 28 | public SequenceIdException(String str) { 29 | super(str); 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/exception/SharkException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.exception; 17 | 18 | /** 19 | * shark顶层异常超类 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.3.5 24 | */ 25 | public class SharkException extends Exception { 26 | private static final long serialVersionUID = -3575632318894603437L; 27 | 28 | public SharkException(String str) { 29 | super(str); 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/exception/SharkRuntimeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.exception; 17 | 18 | /** 19 | * shark顶层运行时异常超类 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.3.5 24 | */ 25 | public class SharkRuntimeException extends RuntimeException { 26 | private static final long serialVersionUID = -3575632318894603437L; 27 | 28 | public SharkRuntimeException(String str) { 29 | super(str); 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/exception/SqlParserException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.exception; 17 | 18 | /** 19 | * sql解析异常 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.4.0 24 | */ 25 | public class SqlParserException extends SharkRuntimeException { 26 | private static final long serialVersionUID = -3671607184598679934L; 27 | 28 | public SqlParserException(String str) { 29 | super(str); 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/exception/UtilsRuntimeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.exception; 17 | 18 | /** 19 | * 工具类异常信息 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.3.8 24 | */ 25 | public class UtilsRuntimeException extends SharkRuntimeException { 26 | private static final long serialVersionUID = 6348430020433825158L; 27 | 28 | public UtilsRuntimeException(String str) { 29 | super(str); 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/exception/ValidateException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.exception; 17 | 18 | /** 19 | * 数据验证失败异常 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.4.0 24 | */ 25 | public class ValidateException extends SharkRuntimeException { 26 | private static final long serialVersionUID = 81730352793737893L; 27 | 28 | public ValidateException(String str) { 29 | super(str); 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/exception/XmlResolveException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.exception; 17 | 18 | /** 19 | * xml解析错误异常 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.4.1 24 | */ 25 | public class XmlResolveException extends SharkRuntimeException { 26 | private static final long serialVersionUID = -5422035522424061979L; 27 | 28 | public XmlResolveException(String str) { 29 | super(str); 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/factory/AnnotationResolverFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.factory; 17 | 18 | import com.sharksharding.util.mapper.SharkAnnotationResolver; 19 | 20 | /** 21 | * shark注解解析器工厂方法类 22 | * 23 | * @author gaoxianglong 24 | * 25 | * @version 1.4.1 26 | */ 27 | public interface AnnotationResolverFactory { 28 | public SharkAnnotationResolver getSharkAnnotationResolver(); 29 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/factory/ClassResolverFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.factory; 17 | 18 | import com.sharksharding.util.mapper.ClassResolver; 19 | import com.sharksharding.util.mapper.SharkAnnotationResolver; 20 | 21 | /** 22 | * 类型注解解析器工厂类 23 | * 24 | * @author gaoxianglong 25 | * 26 | * @version 1.4.1 27 | */ 28 | public class ClassResolverFactory implements AnnotationResolverFactory { 29 | @Override 30 | public SharkAnnotationResolver getSharkAnnotationResolver() { 31 | return new ClassResolver(); 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/factory/CreateMysqlSequenceIdFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.factory; 17 | 18 | import com.sharksharding.util.sequence.CreateSequenceIdService; 19 | import com.sharksharding.util.sequence.mysql.CreateMysqlSequenceId; 20 | 21 | /** 22 | * 生成基于Mysql的SequenceId工厂类 23 | * 24 | * @author JohnGao 25 | * 26 | * @version 1.4.1 27 | */ 28 | public class CreateMysqlSequenceIdFactory implements CreateSequenceIdServiceFactory { 29 | private static CreateSequenceIdService createSequenceIdService; 30 | 31 | static { 32 | createSequenceIdService = new CreateMysqlSequenceId(); 33 | } 34 | 35 | @Override 36 | public CreateSequenceIdService getCreateSequenceIdService() { 37 | return createSequenceIdService; 38 | } 39 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/factory/CreateSequenceIdServiceFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.factory; 17 | 18 | import com.sharksharding.util.sequence.CreateSequenceIdService; 19 | 20 | /** 21 | * 生成SequenceId服务工厂方法类 22 | * 23 | * @author gaoxianglong 24 | * 25 | * @version 1.4.1 26 | */ 27 | public interface CreateSequenceIdServiceFactory { 28 | public CreateSequenceIdService getCreateSequenceIdService(); 29 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/factory/CreateZookeeperSequenceIdFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.factory; 17 | 18 | import com.sharksharding.util.sequence.CreateSequenceIdService; 19 | import com.sharksharding.util.sequence.zookeeper.CreateZookeeperSequenceId; 20 | 21 | /** 22 | * 生成基于Zookeeper的SequenceId工厂类 23 | * 24 | * @author JohnGao 25 | * 26 | * @version 1.4.1 27 | */ 28 | public class CreateZookeeperSequenceIdFactory implements CreateSequenceIdServiceFactory { 29 | private static CreateSequenceIdService createSequenceIdService; 30 | 31 | static { 32 | createSequenceIdService = new CreateZookeeperSequenceId(); 33 | } 34 | 35 | @Override 36 | public CreateSequenceIdService getCreateSequenceIdService() { 37 | return createSequenceIdService; 38 | } 39 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/factory/DbRuleFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.factory; 17 | 18 | import com.sharksharding.core.shard.DbRule; 19 | import com.sharksharding.core.shard.Rule; 20 | 21 | /** 22 | * 分库路由规则工厂类 23 | * 24 | * @author gaoxianglong 25 | * 26 | * @version 1.4.0 27 | */ 28 | public class DbRuleFactory implements RuleFactory{ 29 | @Override 30 | public Rule getRule() { 31 | return new DbRule(); 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/factory/FieldResolverFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.factory; 17 | 18 | import com.sharksharding.util.mapper.FieldResolver; 19 | import com.sharksharding.util.mapper.SharkAnnotationResolver; 20 | 21 | /** 22 | * 字段注解解析器工厂类 23 | * 24 | * @author gaoxianglong 25 | * 26 | * @version 1.4.1 27 | */ 28 | public class FieldResolverFactory implements AnnotationResolverFactory { 29 | @Override 30 | public SharkAnnotationResolver getSharkAnnotationResolver() { 31 | return new FieldResolver(); 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/factory/HorizontalFacadeFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.factory; 17 | 18 | import com.sharksharding.core.shard.HorizontalFacade; 19 | import com.sharksharding.core.shard.Route; 20 | 21 | /** 22 | * 水平分库,水平分片模式的工厂类 23 | * 24 | * @author gaoxianglong 25 | * 26 | * @author 2.0.1 27 | */ 28 | public class HorizontalFacadeFactory implements RouteFactory { 29 | @Override 30 | public Route getRoute() { 31 | return new HorizontalFacade(); 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/factory/RouteFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.factory; 17 | 18 | import com.sharksharding.core.shard.Route; 19 | import com.sharksharding.core.shard.RouteImpl; 20 | import com.sharksharding.util.sequence.CreateSequenceIdService; 21 | 22 | /** 23 | * 路由模式工厂方法类 24 | * 25 | * @author gaoxianglong 26 | * 27 | * @version 1.4.0 28 | */ 29 | public interface RouteFactory { 30 | public Route getRoute(); 31 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/factory/RuleFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.factory; 17 | 18 | import com.sharksharding.core.shard.Rule; 19 | 20 | public interface RuleFactory { 21 | public Rule getRule(); 22 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/factory/TbRuleFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.factory; 17 | 18 | import com.sharksharding.core.shard.Rule; 19 | import com.sharksharding.core.shard.TbRule; 20 | 21 | /** 22 | * 分表路由规则工厂类 23 | * 24 | * @author gaoxianglong 25 | * 26 | * @version 1.4.0 27 | */ 28 | public class TbRuleFactory implements RuleFactory{ 29 | @Override 30 | public Rule getRule() { 31 | return new TbRule(); 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/factory/VerticalFacadeFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.factory; 17 | 18 | import com.sharksharding.core.shard.Route; 19 | import com.sharksharding.core.shard.VerticalFacade; 20 | 21 | /** 22 | * 垂直分库,水平分片模式的工厂类 23 | * 24 | * @author gaoxianglong 25 | * 26 | * @author 2.0.1 27 | */ 28 | public class VerticalFacadeFactory implements RouteFactory { 29 | @Override 30 | public Route getRoute() { 31 | return new VerticalFacade(); 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/resources/conn/DataSourceBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.resources.conn; 17 | 18 | /** 19 | * 数据源信息bean 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.3.7 24 | */ 25 | @Deprecated 26 | public class DataSourceBean { 27 | private String nodePath; 28 | private int dataSourceSize; 29 | private int connPoolType; 30 | 31 | public int getDataSourceSize() { 32 | return dataSourceSize; 33 | } 34 | 35 | public void setDataSourceSize(int dataSourceSize) { 36 | this.dataSourceSize = dataSourceSize; 37 | } 38 | 39 | public int getConnPoolType() { 40 | return connPoolType; 41 | } 42 | 43 | public void setConnPoolType(int connPoolType) { 44 | this.connPoolType = connPoolType; 45 | } 46 | 47 | public String getNodePath() { 48 | return nodePath; 49 | } 50 | 51 | public void setNodePath(String nodePath) { 52 | this.nodePath = nodePath; 53 | } 54 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/resources/register/bean/RegisterBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.resources.register.bean; 17 | 18 | import org.springframework.context.ApplicationContextAware; 19 | 20 | import com.sharksharding.resources.conn.DataSourceBean; 21 | 22 | /** 23 | * 动态向spring的ioc容器中注册bean实例 24 | * 25 | * @author gaoxianglong 26 | * 27 | * @version 1.3.7 28 | */ 29 | public interface RegisterBean extends ApplicationContextAware { 30 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/SQLUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql; 17 | 18 | import com.sharksharding.sql.ast.SQLObject; 19 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlOutputVisitor; 20 | 21 | /** 22 | * Sql工具类 23 | * 24 | * @author gaoxianglong 25 | * 26 | * @version 1.3.5 27 | */ 28 | public class SQLUtils { 29 | public static String toSQLString(SQLObject sqlObject, String dbType) { 30 | return toSQLString(sqlObject); 31 | } 32 | 33 | public static String toSQLString(SQLObject sqlObject) { 34 | StringBuilder out = new StringBuilder(); 35 | sqlObject.accept(new MySqlOutputVisitor(out)); 36 | String sql = out.toString(); 37 | return sql; 38 | } 39 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/SQLCommentHint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast; 17 | 18 | import com.sharksharding.sql.visitor.SQLASTVisitor; 19 | 20 | public class SQLCommentHint extends SQLObjectImpl implements SQLHint { 21 | 22 | private String text; 23 | 24 | public SQLCommentHint(){ 25 | 26 | } 27 | 28 | public SQLCommentHint(String text){ 29 | 30 | this.text = text; 31 | } 32 | 33 | public String getText() { 34 | return this.text; 35 | } 36 | 37 | public void setText(String text) { 38 | this.text = text; 39 | } 40 | 41 | protected void accept0(SQLASTVisitor visitor) { 42 | visitor.visit(this); 43 | visitor.endVisit(this); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/SQLDataType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast; 17 | 18 | import java.util.List; 19 | 20 | public interface SQLDataType extends SQLObject { 21 | 22 | String getName(); 23 | 24 | void setName(String name); 25 | 26 | List getArguments(); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/SQLExpr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast; 17 | 18 | public interface SQLExpr extends SQLObject { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/SQLExprImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast; 17 | 18 | public abstract class SQLExprImpl extends SQLObjectImpl implements SQLExpr { 19 | 20 | public SQLExprImpl(){ 21 | 22 | } 23 | 24 | public abstract boolean equals(Object o); 25 | 26 | public abstract int hashCode(); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/SQLHint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast; 17 | 18 | 19 | public interface SQLHint extends SQLObject { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/SQLName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast; 17 | 18 | public interface SQLName extends SQLExpr { 19 | String getSimpleName(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/SQLOrderingSpecification.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast; 17 | 18 | public enum SQLOrderingSpecification { 19 | ASC, DESC 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/SQLPartitioningClause.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast; 17 | 18 | 19 | 20 | public interface SQLPartitioningClause extends SQLObject { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/SQLSetQuantifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast; 17 | 18 | public interface SQLSetQuantifier { 19 | 20 | // SQL 92 21 | public final static int ALL = 1; 22 | public final static int DISTINCT = 2; 23 | 24 | public final static int UNIQUE = 3; 25 | public final static int DISTINCTROW = 4; 26 | 27 | // 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/SQLStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast; 17 | 18 | public interface SQLStatement extends SQLObject { 19 | String getDbType(); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/expr/SQLAggregateOption.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.expr; 17 | 18 | public enum SQLAggregateOption { 19 | 20 | DISTINCT, ALL, UNIQUE, // 21 | 22 | DEDUPLICATION // just for nut 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/expr/SQLAllColumnExpr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.expr; 17 | 18 | import com.sharksharding.sql.ast.SQLExprImpl; 19 | import com.sharksharding.sql.visitor.SQLASTVisitor; 20 | 21 | public class SQLAllColumnExpr extends SQLExprImpl { 22 | 23 | public SQLAllColumnExpr(){ 24 | 25 | } 26 | 27 | public void output(StringBuffer buf) { 28 | buf.append("*"); 29 | } 30 | 31 | protected void accept0(SQLASTVisitor visitor) { 32 | visitor.visit(this); 33 | visitor.endVisit(this); 34 | } 35 | 36 | public int hashCode() { 37 | return 0; 38 | } 39 | 40 | public boolean equals(Object o) { 41 | return o instanceof SQLAllColumnExpr; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/expr/SQLDefaultExpr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.expr; 17 | 18 | import com.sharksharding.sql.ast.SQLExprImpl; 19 | import com.sharksharding.sql.visitor.SQLASTVisitor; 20 | 21 | public class SQLDefaultExpr extends SQLExprImpl implements SQLLiteralExpr { 22 | 23 | @Override 24 | public boolean equals(Object o) { 25 | return o instanceof SQLDefaultExpr; 26 | } 27 | 28 | @Override 29 | public int hashCode() { 30 | return 0; 31 | } 32 | 33 | @Override 34 | protected void accept0(SQLASTVisitor visitor) { 35 | visitor.visit(this); 36 | visitor.endVisit(this); 37 | } 38 | 39 | public String toString() { 40 | return "DEFAULT"; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/expr/SQLLiteralExpr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.expr; 17 | 18 | import com.sharksharding.sql.ast.SQLExpr; 19 | 20 | public interface SQLLiteralExpr extends SQLExpr { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/expr/SQLNCharExpr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.expr; 17 | 18 | import com.sharksharding.sql.visitor.SQLASTVisitor; 19 | 20 | public class SQLNCharExpr extends SQLTextLiteralExpr { 21 | 22 | public SQLNCharExpr(){ 23 | 24 | } 25 | 26 | public SQLNCharExpr(String text){ 27 | super(text); 28 | } 29 | 30 | public void output(StringBuffer buf) { 31 | if ((this.text == null) || (this.text.length() == 0)) { 32 | buf.append("NULL"); 33 | return; 34 | } 35 | 36 | buf.append("N'"); 37 | buf.append(this.text.replaceAll("'", "''")); 38 | buf.append("'"); 39 | } 40 | 41 | protected void accept0(SQLASTVisitor visitor) { 42 | visitor.visit(this); 43 | visitor.endVisit(this); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/expr/SQLNullExpr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.expr; 17 | 18 | import com.sharksharding.sql.ast.SQLExprImpl; 19 | import com.sharksharding.sql.visitor.SQLASTVisitor; 20 | 21 | public class SQLNullExpr extends SQLExprImpl implements SQLLiteralExpr, SQLValuableExpr { 22 | 23 | public SQLNullExpr(){ 24 | 25 | } 26 | 27 | public void output(StringBuffer buf) { 28 | buf.append("NULL"); 29 | } 30 | 31 | protected void accept0(SQLASTVisitor visitor) { 32 | visitor.visit(this); 33 | 34 | visitor.endVisit(this); 35 | } 36 | 37 | public int hashCode() { 38 | return 0; 39 | } 40 | 41 | public boolean equals(Object o) { 42 | return o instanceof SQLNullExpr; 43 | } 44 | 45 | @Override 46 | public Object getValue() { 47 | return new Object(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/expr/SQLNumericLiteralExpr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.expr; 17 | 18 | import com.sharksharding.sql.ast.SQLExprImpl; 19 | 20 | public abstract class SQLNumericLiteralExpr extends SQLExprImpl implements SQLLiteralExpr { 21 | 22 | public SQLNumericLiteralExpr(){ 23 | 24 | } 25 | 26 | public abstract Number getNumber(); 27 | 28 | public abstract void setNumber(Number number); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/expr/SQLUnaryOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.expr; 17 | 18 | public enum SQLUnaryOperator { 19 | Plus("+"), // 20 | Negative("-"), // 21 | Not("!"), // 22 | Compl("~"), // 23 | Prior("PRIOR"), // 24 | ConnectByRoot("CONNECT BY"), // 25 | BINARY("BINARY"), // 26 | RAW("RAW"), // 27 | NOT("NOT"), 28 | Pound("#") // Number of points in path or polygon 29 | ; 30 | 31 | public final String name; 32 | 33 | SQLUnaryOperator(String name){ 34 | this.name = name; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/expr/SQLValuableExpr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.expr; 17 | 18 | import com.sharksharding.sql.ast.SQLExpr; 19 | 20 | public interface SQLValuableExpr extends SQLExpr { 21 | 22 | Object getValue(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/NotNullConstraint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.visitor.SQLASTVisitor; 19 | 20 | public class NotNullConstraint extends SQLConstraintImpl implements SQLColumnConstraint { 21 | 22 | public NotNullConstraint(){ 23 | 24 | } 25 | 26 | @Override 27 | protected void accept0(SQLASTVisitor visitor) { 28 | visitor.visit(this); 29 | visitor.endVisit(this); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLAlterTableAddColumn.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import com.sharksharding.sql.ast.SQLObjectImpl; 22 | import com.sharksharding.sql.visitor.SQLASTVisitor; 23 | 24 | public class SQLAlterTableAddColumn extends SQLObjectImpl implements SQLAlterTableItem { 25 | 26 | private final List columns = new ArrayList(); 27 | 28 | @Override 29 | protected void accept0(SQLASTVisitor visitor) { 30 | if (visitor.visit(this)) { 31 | acceptChild(visitor, columns); 32 | } 33 | visitor.endVisit(this); 34 | } 35 | 36 | public List getColumns() { 37 | return columns; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLAlterTableDisableKeys.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLObjectImpl; 19 | import com.sharksharding.sql.visitor.SQLASTVisitor; 20 | 21 | public class SQLAlterTableDisableKeys extends SQLObjectImpl implements SQLAlterTableItem { 22 | 23 | @Override 24 | protected void accept0(SQLASTVisitor visitor) { 25 | visitor.visit(this); 26 | visitor.endVisit(this); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLAlterTableDisableLifecycle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import com.sharksharding.sql.ast.SQLObjectImpl; 22 | import com.sharksharding.sql.visitor.SQLASTVisitor; 23 | 24 | public class SQLAlterTableDisableLifecycle extends SQLObjectImpl implements SQLAlterTableItem { 25 | 26 | private final List partition = new ArrayList(4); 27 | 28 | public List getPartition() { 29 | return partition; 30 | } 31 | 32 | @Override 33 | protected void accept0(SQLASTVisitor visitor) { 34 | if (visitor.visit(this)) { 35 | acceptChild(visitor, partition); 36 | } 37 | visitor.endVisit(this); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLAlterTableDropForeignKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLName; 19 | import com.sharksharding.sql.ast.SQLObjectImpl; 20 | import com.sharksharding.sql.visitor.SQLASTVisitor; 21 | 22 | public class SQLAlterTableDropForeignKey extends SQLObjectImpl implements SQLAlterTableItem { 23 | 24 | private SQLName indexName; 25 | 26 | public SQLName getIndexName() { 27 | return indexName; 28 | } 29 | 30 | public void setIndexName(SQLName indexName) { 31 | this.indexName = indexName; 32 | } 33 | 34 | @Override 35 | protected void accept0(SQLASTVisitor visitor) { 36 | if (visitor.visit(this)) { 37 | acceptChild(visitor, indexName); 38 | } 39 | visitor.endVisit(this); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLAlterTableDropIndex.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLName; 19 | import com.sharksharding.sql.ast.SQLObjectImpl; 20 | import com.sharksharding.sql.visitor.SQLASTVisitor; 21 | 22 | public class SQLAlterTableDropIndex extends SQLObjectImpl implements SQLAlterTableItem { 23 | 24 | private SQLName indexName; 25 | 26 | public SQLName getIndexName() { 27 | return indexName; 28 | } 29 | 30 | public void setIndexName(SQLName indexName) { 31 | this.indexName = indexName; 32 | } 33 | 34 | @Override 35 | protected void accept0(SQLASTVisitor visitor) { 36 | if (visitor.visit(this)) { 37 | acceptChild(visitor, indexName); 38 | } 39 | visitor.endVisit(this); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLAlterTableDropPrimaryKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLObjectImpl; 19 | import com.sharksharding.sql.visitor.SQLASTVisitor; 20 | 21 | public class SQLAlterTableDropPrimaryKey extends SQLObjectImpl implements SQLAlterTableItem { 22 | 23 | @Override 24 | protected void accept0(SQLASTVisitor visitor) { 25 | visitor.visit(this); 26 | visitor.endVisit(this); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLAlterTableEnableKeys.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLObjectImpl; 19 | import com.sharksharding.sql.visitor.SQLASTVisitor; 20 | 21 | public class SQLAlterTableEnableKeys extends SQLObjectImpl implements SQLAlterTableItem { 22 | 23 | @Override 24 | protected void accept0(SQLASTVisitor visitor) { 25 | visitor.visit(this); 26 | visitor.endVisit(this); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLAlterTableEnableLifecycle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import com.sharksharding.sql.ast.SQLObjectImpl; 22 | import com.sharksharding.sql.visitor.SQLASTVisitor; 23 | 24 | public class SQLAlterTableEnableLifecycle extends SQLObjectImpl implements SQLAlterTableItem { 25 | 26 | private final List partition = new ArrayList(4); 27 | 28 | public List getPartition() { 29 | return partition; 30 | } 31 | 32 | @Override 33 | protected void accept0(SQLASTVisitor visitor) { 34 | if (visitor.visit(this)) { 35 | acceptChild(visitor, partition); 36 | } 37 | visitor.endVisit(this); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLAlterTableItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLObject; 19 | 20 | public interface SQLAlterTableItem extends SQLObject { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLAlterTableRename.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLExpr; 19 | import com.sharksharding.sql.ast.SQLObjectImpl; 20 | import com.sharksharding.sql.visitor.SQLASTVisitor; 21 | 22 | public class SQLAlterTableRename extends SQLObjectImpl implements SQLAlterTableItem { 23 | 24 | protected SQLExpr to; 25 | 26 | public SQLExpr getTo() { 27 | return to; 28 | } 29 | 30 | public void setTo(SQLExpr to) { 31 | this.to = to; 32 | to.setParent(this); 33 | } 34 | 35 | @Override 36 | protected void accept0(SQLASTVisitor visitor) { 37 | if (visitor.visit(this)) { 38 | acceptChild(visitor, to); 39 | } 40 | visitor.endVisit(this); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLAlterTableTouch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import com.sharksharding.sql.ast.SQLObjectImpl; 22 | import com.sharksharding.sql.visitor.SQLASTVisitor; 23 | 24 | public class SQLAlterTableTouch extends SQLObjectImpl implements SQLAlterTableItem { 25 | 26 | private final List partition = new ArrayList(4); 27 | 28 | public List getPartition() { 29 | return partition; 30 | } 31 | 32 | @Override 33 | protected void accept0(SQLASTVisitor visitor) { 34 | if (visitor.visit(this)) { 35 | 36 | } 37 | visitor.endVisit(this); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLCloseStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLStatementImpl; 19 | import com.sharksharding.sql.visitor.SQLASTVisitor; 20 | /** 21 | * 22 | * @Description: MySql cursor close statement 23 | * @author zz email:455910092@qq.com 24 | * @date 2015-9-14 25 | * @version V1.0 26 | */ 27 | public class SQLCloseStatement extends SQLStatementImpl{ 28 | 29 | //cursor name 30 | private String cursorName; 31 | 32 | public String getCursorName() { 33 | return cursorName; 34 | } 35 | 36 | public void setCursorName(String cursorName) { 37 | this.cursorName = cursorName; 38 | } 39 | 40 | @Override 41 | protected void accept0(SQLASTVisitor visitor) { 42 | visitor.visit(this); 43 | visitor.endVisit(this); 44 | 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLColumnConstraint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | public interface SQLColumnConstraint extends SQLConstraint { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLColumnPrimaryKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.visitor.SQLASTVisitor; 19 | 20 | public class SQLColumnPrimaryKey extends SQLConstraintImpl implements SQLColumnConstraint { 21 | 22 | @Override 23 | protected void accept0(SQLASTVisitor visitor) { 24 | if (visitor.visit(this)) { 25 | acceptChild(visitor, this.getName()); 26 | } 27 | visitor.endVisit(this); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLColumnUniqueKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.visitor.SQLASTVisitor; 19 | 20 | public class SQLColumnUniqueKey extends SQLConstraintImpl implements SQLColumnConstraint { 21 | 22 | @Override 23 | protected void accept0(SQLASTVisitor visitor) { 24 | if (visitor.visit(this)) { 25 | acceptChild(visitor, this.getName()); 26 | } 27 | visitor.endVisit(this); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLConstraint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLName; 19 | import com.sharksharding.sql.ast.SQLObject; 20 | 21 | public interface SQLConstraint extends SQLObject { 22 | 23 | SQLName getName(); 24 | 25 | void setName(SQLName value); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLConstraintImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLName; 19 | import com.sharksharding.sql.ast.SQLObjectImpl; 20 | 21 | public abstract class SQLConstraintImpl extends SQLObjectImpl implements SQLConstraint { 22 | 23 | private SQLName name; 24 | private Boolean enable; 25 | 26 | public SQLConstraintImpl(){ 27 | 28 | } 29 | 30 | public SQLName getName() { 31 | return name; 32 | } 33 | 34 | public void setName(SQLName name) { 35 | this.name = name; 36 | } 37 | 38 | public Boolean getEnable() { 39 | return enable; 40 | } 41 | 42 | public void setEnable(Boolean enable) { 43 | this.enable = enable; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLDDLStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLStatement; 19 | 20 | 21 | public interface SQLDDLStatement extends SQLStatement { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLDescribeStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLName; 19 | import com.sharksharding.sql.ast.SQLStatementImpl; 20 | import com.sharksharding.sql.visitor.SQLASTVisitor; 21 | 22 | public class SQLDescribeStatement extends SQLStatementImpl { 23 | 24 | protected SQLName object; 25 | 26 | public SQLName getObject() { 27 | return object; 28 | } 29 | 30 | public void setObject(SQLName object) { 31 | this.object = object; 32 | } 33 | 34 | @Override 35 | protected void accept0(SQLASTVisitor visitor) { 36 | throw new UnsupportedOperationException(this.getClass().getName()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLDropTriggerStatement.java: -------------------------------------------------------------------------------- 1 | package com.sharksharding.sql.ast.statement; 2 | 3 | import com.sharksharding.sql.ast.SQLName; 4 | import com.sharksharding.sql.ast.SQLStatementImpl; 5 | import com.sharksharding.sql.visitor.SQLASTVisitor; 6 | 7 | public class SQLDropTriggerStatement extends SQLStatementImpl implements SQLDDLStatement { 8 | 9 | private SQLName name; 10 | 11 | public SQLDropTriggerStatement() { 12 | 13 | } 14 | 15 | public SQLDropTriggerStatement(String dbType) { 16 | super (dbType); 17 | } 18 | 19 | public SQLName getName() { 20 | return name; 21 | } 22 | 23 | public void setName(SQLName name) { 24 | this.name = name; 25 | } 26 | 27 | @Override 28 | protected void accept0(SQLASTVisitor visitor) { 29 | if (visitor.visit(this)) { 30 | acceptChild(visitor, name); 31 | } 32 | visitor.endVisit(this); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLForeignKeyConstraint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import java.util.List; 19 | 20 | import com.sharksharding.sql.ast.SQLName; 21 | 22 | public interface SQLForeignKeyConstraint extends SQLConstraint, SQLTableElement, SQLTableConstraint { 23 | 24 | List getReferencingColumns(); 25 | 26 | SQLName getReferencedTableName(); 27 | 28 | void setReferencedTableName(SQLName value); 29 | 30 | List getReferencedColumns(); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLObjectType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | public enum SQLObjectType { 19 | TABLE, FUNCTION, PROCEDURE, USER, DATABASE 20 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLOpenStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLStatementImpl; 19 | import com.sharksharding.sql.visitor.SQLASTVisitor; 20 | /** 21 | * 22 | * @Description: MySql cursor open statement 23 | * @author zz email:455910092@qq.com 24 | * @date 2015-9-14 25 | * @version V1.0 26 | */ 27 | public class SQLOpenStatement extends SQLStatementImpl{ 28 | 29 | //cursor name 30 | private String cursorName; 31 | 32 | public String getCursorName() { 33 | return cursorName; 34 | } 35 | 36 | public void setCursorName(String cursorName) { 37 | this.cursorName = cursorName; 38 | } 39 | 40 | @Override 41 | protected void accept0(SQLASTVisitor visitor) { 42 | // TODO Auto-generated method stub 43 | visitor.visit(this); 44 | visitor.endVisit(this); 45 | 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLPrimaryKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | public interface SQLPrimaryKey extends SQLUniqueConstraint, SQLTableElement { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLPrimaryKeyImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.visitor.SQLASTVisitor; 19 | 20 | public class SQLPrimaryKeyImpl extends SQLUnique implements SQLPrimaryKey { 21 | 22 | @Override 23 | protected void accept0(SQLASTVisitor visitor) { 24 | if (visitor.visit(this)) { 25 | acceptChild(visitor, this.getName()); 26 | acceptChild(visitor, this.getColumns()); 27 | } 28 | visitor.endVisit(this); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLSelectQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLObject; 19 | 20 | public interface SQLSelectQuery extends SQLObject { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLTableConstraint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | public interface SQLTableConstraint extends SQLConstraint, SQLTableElement { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLTableElement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLObject; 19 | 20 | public interface SQLTableElement extends SQLObject { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLTableSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import java.util.List; 19 | 20 | import com.sharksharding.sql.ast.SQLHint; 21 | import com.sharksharding.sql.ast.SQLObject; 22 | 23 | public interface SQLTableSource extends SQLObject { 24 | 25 | String getAlias(); 26 | 27 | void setAlias(String alias); 28 | 29 | List getHints(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLUnionOperator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | public enum SQLUnionOperator { 19 | UNION("UNION"), UNION_ALL("UNION ALL"), MINUS("MINUS"), EXCEPT("EXCEPT"), INTERSECT("INTERSECT"), 20 | DISTINCT("UNION DISTINCT"); 21 | 22 | public final String name; 23 | 24 | private SQLUnionOperator(String name){ 25 | this.name = name; 26 | } 27 | 28 | public String toString() { 29 | return name; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/ast/statement/SQLUniqueConstraint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.ast.statement; 17 | 18 | import java.util.List; 19 | 20 | import com.sharksharding.sql.ast.SQLExpr; 21 | 22 | public interface SQLUniqueConstraint extends SQLConstraint { 23 | 24 | List getColumns(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/MySqlForceIndexHint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast; 17 | 18 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 19 | 20 | public class MySqlForceIndexHint extends MySqlIndexHintImpl { 21 | 22 | @Override 23 | public void accept0(MySqlASTVisitor visitor) { 24 | if (visitor.visit(this)) { 25 | acceptChild(visitor, getIndexList()); 26 | } 27 | visitor.endVisit(this); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/MySqlHint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast; 17 | 18 | import com.sharksharding.sql.ast.SQLHint; 19 | 20 | 21 | public interface MySqlHint extends SQLHint, MySqlObject { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/MySqlIgnoreIndexHint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast; 17 | 18 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 19 | 20 | public class MySqlIgnoreIndexHint extends MySqlIndexHintImpl { 21 | 22 | @Override 23 | public void accept0(MySqlASTVisitor visitor) { 24 | if (visitor.visit(this)) { 25 | acceptChild(visitor, getIndexList()); 26 | } 27 | visitor.endVisit(this); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/MySqlIndexHint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast; 17 | 18 | public interface MySqlIndexHint extends MySqlHint { 19 | public static enum Option { 20 | JOIN("JOIN"), 21 | ORDER_BY("ORDER BY"), 22 | GROUP_BY("GROUP BY") 23 | ; 24 | 25 | public final String name; 26 | 27 | Option(String name) { 28 | this.name = name; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/MySqlObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast; 17 | 18 | import com.sharksharding.sql.ast.SQLObject; 19 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 20 | 21 | 22 | public interface MySqlObject extends SQLObject { 23 | void accept0(MySqlASTVisitor visitor); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/MySqlObjectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast; 17 | 18 | import com.sharksharding.sql.ast.SQLObjectImpl; 19 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 20 | import com.sharksharding.sql.visitor.SQLASTVisitor; 21 | 22 | public abstract class MySqlObjectImpl extends SQLObjectImpl implements MySqlObject { 23 | 24 | @Override 25 | protected void accept0(SQLASTVisitor visitor) { 26 | if (visitor instanceof MySqlASTVisitor) { 27 | accept0((MySqlASTVisitor) visitor); 28 | } else { 29 | throw new IllegalArgumentException("not support visitor type : " + visitor.getClass().getName()); 30 | } 31 | } 32 | 33 | public abstract void accept0(MySqlASTVisitor visitor); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/MySqlPrimaryKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast; 17 | 18 | import com.sharksharding.sql.ast.statement.SQLPrimaryKey; 19 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 20 | 21 | public class MySqlPrimaryKey extends MySqlKey implements SQLPrimaryKey { 22 | 23 | public MySqlPrimaryKey(){ 24 | 25 | } 26 | 27 | protected void accept0(MySqlASTVisitor visitor) { 28 | if (visitor.visit(this)) { 29 | acceptChild(visitor, this.getName()); 30 | acceptChild(visitor, this.getColumns()); 31 | } 32 | visitor.endVisit(this); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/MySqlUnique.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast; 17 | 18 | import com.sharksharding.sql.ast.statement.SQLPrimaryKey; 19 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 20 | 21 | public class MySqlUnique extends MySqlKey implements SQLPrimaryKey { 22 | 23 | public MySqlUnique(){ 24 | 25 | } 26 | 27 | protected void accept0(MySqlASTVisitor visitor) { 28 | if (visitor.visit(this)) { 29 | acceptChild(visitor, this.getName()); 30 | acceptChild(visitor, this.getColumns()); 31 | acceptChild(visitor, this.getIndexName()); 32 | } 33 | visitor.endVisit(this); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/MySqlUseIndexHint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast; 17 | 18 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 19 | 20 | public class MySqlUseIndexHint extends MySqlIndexHintImpl { 21 | 22 | @Override 23 | public void accept0(MySqlASTVisitor visitor) { 24 | if (visitor.visit(this)) { 25 | acceptChild(visitor, getIndexList()); 26 | } 27 | visitor.endVisit(this); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/expr/MySqlExpr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.expr; 17 | 18 | import com.sharksharding.sql.ast.SQLExpr; 19 | 20 | public interface MySqlExpr extends SQLExpr { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/expr/MySqlExprImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.expr; 17 | 18 | import com.sharksharding.sql.ast.SQLExpr; 19 | import com.sharksharding.sql.dialect.mysql.ast.MySqlObjectImpl; 20 | 21 | public abstract class MySqlExprImpl extends MySqlObjectImpl implements SQLExpr { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/expr/MySqlIntervalUnit.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.expr; 17 | 18 | public enum MySqlIntervalUnit { 19 | YEAR, YEAR_MONTH, 20 | 21 | QUARTER, 22 | 23 | MONTH, WEEK, DAY, DAY_HOUR, DAY_MINUTE, DAY_SECOND, DAY_MICROSECOND, 24 | 25 | HOUR, HOUR_MINUTE, HOUR_SECOND, HOUR_MICROSECOND, 26 | 27 | MINUTE, MINUTE_SECOND, MINUTE_MICROSECOND, 28 | 29 | SECOND, SECOND_MICROSECOND, 30 | 31 | MICROSECOND 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/CobarShowStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 19 | 20 | public class CobarShowStatus extends MySqlStatementImpl { 21 | 22 | public void accept0(MySqlASTVisitor visitor) { 23 | visitor.visit(this); 24 | 25 | visitor.endVisit(this); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlAlterUserStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import com.sharksharding.sql.ast.SQLExpr; 22 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 23 | 24 | public class MySqlAlterUserStatement extends MySqlStatementImpl { 25 | 26 | private final List users = new ArrayList(); 27 | 28 | public void accept0(MySqlASTVisitor visitor) { 29 | if (visitor.visit(this)) { 30 | acceptChild(visitor, users); 31 | } 32 | visitor.endVisit(this); 33 | } 34 | 35 | public List getUsers() { 36 | return users; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlBinlogStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLExpr; 19 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 20 | 21 | public class MySqlBinlogStatement extends MySqlStatementImpl { 22 | 23 | private SQLExpr expr; 24 | 25 | public SQLExpr getExpr() { 26 | return expr; 27 | } 28 | 29 | public void setExpr(SQLExpr expr) { 30 | this.expr = expr; 31 | } 32 | 33 | public void accept0(MySqlASTVisitor visitor) { 34 | if (visitor.visit(this)) { 35 | acceptChild(visitor, expr); 36 | } 37 | visitor.endVisit(this); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlHelpStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLExpr; 19 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 20 | 21 | public class MySqlHelpStatement extends MySqlStatementImpl { 22 | 23 | private SQLExpr content; 24 | 25 | public SQLExpr getContent() { 26 | return content; 27 | } 28 | 29 | public void setContent(SQLExpr content) { 30 | this.content = content; 31 | } 32 | 33 | public void accept0(MySqlASTVisitor visitor) { 34 | if (visitor.visit(this)) { 35 | acceptChild(visitor, content); 36 | } 37 | visitor.endVisit(this); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlHintStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import java.util.List; 19 | 20 | import com.sharksharding.sql.ast.SQLCommentHint; 21 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 22 | 23 | public class MySqlHintStatement extends MySqlStatementImpl { 24 | 25 | private List hints; 26 | 27 | public void accept0(MySqlASTVisitor visitor) { 28 | if (visitor.visit(this)) { 29 | acceptChild(visitor, this.hints); 30 | } 31 | visitor.endVisit(this); 32 | } 33 | 34 | public List getHints() { 35 | return hints; 36 | } 37 | 38 | public void setHints(List hints) { 39 | this.hints = hints; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlPartitioningClause.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import com.sharksharding.sql.ast.SQLPartitioningClause; 22 | import com.sharksharding.sql.dialect.mysql.ast.MySqlObjectImpl; 23 | 24 | public abstract class MySqlPartitioningClause extends MySqlObjectImpl implements SQLPartitioningClause { 25 | 26 | private List partitions = new ArrayList(); 27 | 28 | public List getPartitions() { 29 | return partitions; 30 | } 31 | 32 | public void setPartitions(List partitions) { 33 | this.partitions = partitions; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlResetStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 22 | 23 | public class MySqlResetStatement extends MySqlStatementImpl { 24 | 25 | private List options = new ArrayList(); 26 | 27 | public List getOptions() { 28 | return options; 29 | } 30 | 31 | public void setOptions(List options) { 32 | this.options = options; 33 | } 34 | 35 | public void accept0(MySqlASTVisitor visitor) { 36 | visitor.visit(this); 37 | visitor.endVisit(this); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowAuthorsStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 19 | 20 | public class MySqlShowAuthorsStatement extends MySqlStatementImpl implements MySqlShowStatement { 21 | 22 | public void accept0(MySqlASTVisitor visitor) { 23 | visitor.visit(this); 24 | visitor.endVisit(this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowBinaryLogsStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 19 | 20 | public class MySqlShowBinaryLogsStatement extends MySqlStatementImpl implements MySqlShowStatement { 21 | 22 | public void accept0(MySqlASTVisitor visitor) { 23 | visitor.visit(this); 24 | visitor.endVisit(this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowContributorsStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 19 | 20 | public class MySqlShowContributorsStatement extends MySqlStatementImpl implements MySqlShowStatement { 21 | 22 | public void accept0(MySqlASTVisitor visitor) { 23 | visitor.visit(this); 24 | visitor.endVisit(this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowCreateDatabaseStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLExpr; 19 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 20 | 21 | public class MySqlShowCreateDatabaseStatement extends MySqlStatementImpl implements MySqlShowStatement { 22 | 23 | private SQLExpr database; 24 | 25 | public void accept0(MySqlASTVisitor visitor) { 26 | if (visitor.visit(this)) { 27 | acceptChild(visitor, database); 28 | } 29 | visitor.endVisit(this); 30 | } 31 | 32 | public SQLExpr getDatabase() { 33 | return database; 34 | } 35 | 36 | public void setDatabase(SQLExpr database) { 37 | this.database = database; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowCreateEventStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLExpr; 19 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 20 | 21 | public class MySqlShowCreateEventStatement extends MySqlStatementImpl implements MySqlShowStatement { 22 | 23 | private SQLExpr eventName; 24 | 25 | public void accept0(MySqlASTVisitor visitor) { 26 | if (visitor.visit(this)) { 27 | acceptChild(visitor, eventName); 28 | } 29 | visitor.endVisit(this); 30 | } 31 | 32 | public SQLExpr getEventName() { 33 | return eventName; 34 | } 35 | 36 | public void setEventName(SQLExpr eventName) { 37 | this.eventName = eventName; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowCreateFunctionStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLExpr; 19 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 20 | 21 | public class MySqlShowCreateFunctionStatement extends MySqlStatementImpl implements MySqlShowStatement { 22 | 23 | private SQLExpr name; 24 | 25 | public void accept0(MySqlASTVisitor visitor) { 26 | if (visitor.visit(this)) { 27 | acceptChild(visitor, name); 28 | } 29 | visitor.endVisit(this); 30 | } 31 | 32 | public SQLExpr getName() { 33 | return name; 34 | } 35 | 36 | public void setName(SQLExpr functionName) { 37 | this.name = functionName; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowCreateProcedureStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLExpr; 19 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 20 | 21 | public class MySqlShowCreateProcedureStatement extends MySqlStatementImpl implements MySqlShowStatement { 22 | 23 | private SQLExpr name; 24 | 25 | public void accept0(MySqlASTVisitor visitor) { 26 | if (visitor.visit(this)) { 27 | acceptChild(visitor, name); 28 | } 29 | visitor.endVisit(this); 30 | } 31 | 32 | public SQLExpr getName() { 33 | return name; 34 | } 35 | 36 | public void setName(SQLExpr functionName) { 37 | this.name = functionName; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowCreateTableStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLExpr; 19 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 20 | 21 | public class MySqlShowCreateTableStatement extends MySqlStatementImpl implements MySqlShowStatement { 22 | 23 | private SQLExpr name; 24 | 25 | public void accept0(MySqlASTVisitor visitor) { 26 | if (visitor.visit(this)) { 27 | acceptChild(visitor, name); 28 | } 29 | visitor.endVisit(this); 30 | } 31 | 32 | public SQLExpr getName() { 33 | return name; 34 | } 35 | 36 | public void setName(SQLExpr name) { 37 | if (name != null) { 38 | name.setParent(this); 39 | } 40 | this.name = name; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowCreateTriggerStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLExpr; 19 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 20 | 21 | public class MySqlShowCreateTriggerStatement extends MySqlStatementImpl implements MySqlShowStatement { 22 | 23 | private SQLExpr name; 24 | 25 | public void accept0(MySqlASTVisitor visitor) { 26 | if (visitor.visit(this)) { 27 | acceptChild(visitor, name); 28 | } 29 | visitor.endVisit(this); 30 | } 31 | 32 | public SQLExpr getName() { 33 | return name; 34 | } 35 | 36 | public void setName(SQLExpr functionName) { 37 | this.name = functionName; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowCreateViewStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLExpr; 19 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 20 | 21 | public class MySqlShowCreateViewStatement extends MySqlStatementImpl implements MySqlShowStatement { 22 | 23 | private SQLExpr name; 24 | 25 | public void accept0(MySqlASTVisitor visitor) { 26 | if (visitor.visit(this)) { 27 | acceptChild(visitor, name); 28 | } 29 | visitor.endVisit(this); 30 | } 31 | 32 | public SQLExpr getName() { 33 | return name; 34 | } 35 | 36 | public void setName(SQLExpr functionName) { 37 | this.name = functionName; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowEnginesStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 19 | 20 | public class MySqlShowEnginesStatement extends MySqlStatementImpl implements MySqlShowStatement { 21 | 22 | private boolean storage = false; 23 | 24 | public void accept0(MySqlASTVisitor visitor) { 25 | visitor.visit(this); 26 | visitor.endVisit(this); 27 | } 28 | 29 | public boolean isStorage() { 30 | return storage; 31 | } 32 | 33 | public void setStorage(boolean storage) { 34 | this.storage = storage; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowFunctionCodeStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLExpr; 19 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 20 | 21 | public class MySqlShowFunctionCodeStatement extends MySqlStatementImpl implements MySqlShowStatement { 22 | 23 | private SQLExpr name; 24 | 25 | public void accept0(MySqlASTVisitor visitor) { 26 | if (visitor.visit(this)) { 27 | acceptChild(visitor, name); 28 | } 29 | visitor.endVisit(this); 30 | } 31 | 32 | public SQLExpr getName() { 33 | return name; 34 | } 35 | 36 | public void setName(SQLExpr functionName) { 37 | this.name = functionName; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowGrantsStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLExpr; 19 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 20 | 21 | public class MySqlShowGrantsStatement extends MySqlStatementImpl implements MySqlShowStatement { 22 | 23 | private SQLExpr user; 24 | 25 | public void accept0(MySqlASTVisitor visitor) { 26 | if (visitor.visit(this)) { 27 | acceptChild(visitor, user); 28 | } 29 | visitor.endVisit(this); 30 | } 31 | 32 | public SQLExpr getUser() { 33 | return user; 34 | } 35 | 36 | public void setUser(SQLExpr user) { 37 | if (user != null) { 38 | user.setParent(this); 39 | } 40 | this.user = user; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowMasterLogsStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 19 | 20 | public class MySqlShowMasterLogsStatement extends MySqlStatementImpl implements MySqlShowStatement { 21 | 22 | public void accept0(MySqlASTVisitor visitor) { 23 | visitor.visit(this); 24 | visitor.endVisit(this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowMasterStatusStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 19 | 20 | public class MySqlShowMasterStatusStatement extends MySqlStatementImpl implements MySqlShowStatement { 21 | 22 | public void accept0(MySqlASTVisitor visitor) { 23 | visitor.visit(this); 24 | visitor.endVisit(this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowPluginsStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 19 | 20 | public class MySqlShowPluginsStatement extends MySqlStatementImpl implements MySqlShowStatement { 21 | 22 | public void accept0(MySqlASTVisitor visitor) { 23 | visitor.visit(this); 24 | visitor.endVisit(this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowPrivilegesStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 19 | 20 | public class MySqlShowPrivilegesStatement extends MySqlStatementImpl implements MySqlShowStatement { 21 | 22 | public void accept0(MySqlASTVisitor visitor) { 23 | visitor.visit(this); 24 | visitor.endVisit(this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowProcedureCodeStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLExpr; 19 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 20 | 21 | public class MySqlShowProcedureCodeStatement extends MySqlStatementImpl implements MySqlShowStatement { 22 | 23 | private SQLExpr name; 24 | 25 | public void accept0(MySqlASTVisitor visitor) { 26 | if (visitor.visit(this)) { 27 | acceptChild(visitor, name); 28 | } 29 | visitor.endVisit(this); 30 | } 31 | 32 | public SQLExpr getName() { 33 | return name; 34 | } 35 | 36 | public void setName(SQLExpr functionName) { 37 | this.name = functionName; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowProcessListStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 19 | 20 | public class MySqlShowProcessListStatement extends MySqlStatementImpl implements MySqlShowStatement { 21 | 22 | private boolean full = false; 23 | 24 | public void accept0(MySqlASTVisitor visitor) { 25 | visitor.visit(this); 26 | visitor.endVisit(this); 27 | } 28 | 29 | public boolean isFull() { 30 | return full; 31 | } 32 | 33 | public void setFull(boolean full) { 34 | this.full = full; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowProfilesStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 19 | 20 | public class MySqlShowProfilesStatement extends MySqlStatementImpl implements MySqlShowStatement { 21 | 22 | public void accept0(MySqlASTVisitor visitor) { 23 | visitor.visit(this); 24 | visitor.endVisit(this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowSlaveHostsStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 19 | 20 | public class MySqlShowSlaveHostsStatement extends MySqlStatementImpl implements MySqlShowStatement { 21 | 22 | public void accept0(MySqlASTVisitor visitor) { 23 | visitor.visit(this); 24 | visitor.endVisit(this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowSlaveStatusStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 19 | 20 | public class MySqlShowSlaveStatusStatement extends MySqlStatementImpl implements MySqlShowStatement { 21 | 22 | public void accept0(MySqlASTVisitor visitor) { 23 | visitor.visit(this); 24 | visitor.endVisit(this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlShowStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | public interface MySqlShowStatement extends MySqlStatement { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.ast.SQLStatement; 19 | import com.sharksharding.sql.dialect.mysql.ast.MySqlObject; 20 | 21 | public interface MySqlStatement extends SQLStatement, MySqlObject { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/ast/statement/MySqlUnlockTablesStatement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.ast.statement; 17 | 18 | import com.sharksharding.sql.dialect.mysql.visitor.MySqlASTVisitor; 19 | 20 | public class MySqlUnlockTablesStatement extends MySqlStatementImpl { 21 | 22 | public void accept0(MySqlASTVisitor visitor) { 23 | visitor.visit(this); 24 | visitor.endVisit(this); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/dialect/mysql/visitor/MySql2OracleOutputVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.dialect.mysql.visitor; 17 | 18 | 19 | public class MySql2OracleOutputVisitor extends MySqlOutputVisitor { 20 | 21 | public MySql2OracleOutputVisitor(Appendable appender){ 22 | super(appender); 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/parser/EOFParserException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.parser; 17 | 18 | @SuppressWarnings("serial") 19 | public class EOFParserException extends ParserException { 20 | 21 | public EOFParserException(){ 22 | super("EOF"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/parser/NotAllowCommentException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.parser; 17 | 18 | public class NotAllowCommentException extends ParserException { 19 | 20 | private static final long serialVersionUID = 1L; 21 | 22 | public NotAllowCommentException(){ 23 | this("comment not allow"); 24 | } 25 | 26 | public NotAllowCommentException(String message, Throwable e){ 27 | super(message, e); 28 | } 29 | 30 | public NotAllowCommentException(String message){ 31 | super(message); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/parser/ParserException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.parser; 17 | 18 | import java.io.Serializable; 19 | 20 | public class ParserException extends RuntimeException implements Serializable { 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | public ParserException(){ 25 | } 26 | 27 | public ParserException(String message){ 28 | super(message); 29 | } 30 | 31 | public ParserException(String message, Throwable e){ 32 | super(message, e); 33 | } 34 | 35 | public ParserException(String message, int line, int col){ 36 | super(message); 37 | } 38 | 39 | public ParserException(Throwable ex, String ksql){ 40 | super("parse error. detail message is :\n" + ex.getMessage() + "\nsource sql is : \n" + ksql, ex); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/visitor/ExportParameterVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.visitor; 17 | 18 | import java.util.List; 19 | 20 | 21 | public interface ExportParameterVisitor extends SQLASTVisitor { 22 | List getParameters(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/visitor/ParameterizedVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.visitor; 17 | 18 | public interface ParameterizedVisitor extends PrintableVisitor { 19 | 20 | int getReplaceCount(); 21 | 22 | void incrementReplaceCunt(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/sql/visitor/PrintableVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.sql.visitor; 17 | 18 | public interface PrintableVisitor extends SQLASTVisitor { 19 | 20 | void print(char value); 21 | 22 | void print(String text); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/util/FileExist.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.util; 17 | 18 | import java.io.File; 19 | 20 | /** 21 | * 验证java.io.tmpdir临时目录下得文件是否存在 22 | * 23 | * @author gaoxianglong 24 | * 25 | * @version 1.3.7 26 | */ 27 | public class FileExist { 28 | public @Deprecated static boolean exist(String path) { 29 | boolean result = false; 30 | if (new File(path).exists()) { 31 | result = true; 32 | } 33 | return result; 34 | } 35 | 36 | public static boolean exists(String path) { 37 | return new File(path).exists(); 38 | } 39 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/util/LoadVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 gaoxianglong Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.util; 17 | 18 | import java.io.InputStreamReader; 19 | import java.util.Properties; 20 | import com.sharksharding.exception.FileNotFoundException; 21 | 22 | /** 23 | * 加载版本号 24 | * 25 | * @author gaoxianglong 26 | * 27 | * @version 1.4.0 28 | */ 29 | public class LoadVersion { 30 | public static String getVersion() { 31 | String version = null; 32 | final String PATH = "version.properties"; 33 | Properties properties = new Properties(); 34 | try { 35 | properties.load(new InputStreamReader(LoadSharkLogo.class.getClassLoader().getResourceAsStream(PATH))); 36 | version = properties.getProperty("version"); 37 | } catch (Exception e) { 38 | throw new FileNotFoundException("can not find config"); 39 | } 40 | return version; 41 | } 42 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/util/mapper/AutoColumn.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.util.mapper; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 自动映射bean中的所有标记字段 26 | * 27 | * @author gaoxianglong 28 | * 29 | * @version 1.4.1 30 | */ 31 | @Documented 32 | @Target(ElementType.TYPE) 33 | @Retention(RetentionPolicy.RUNTIME) 34 | public @interface AutoColumn { 35 | /* 为true时意味着自动赋值生效 */ 36 | public boolean value() default true; 37 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/util/mapper/ClassResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.util.mapper; 17 | 18 | /** 19 | * 类型注解解析器,用于解析标记了@Mapper的类型 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.4.1 24 | */ 25 | public class ClassResolver extends SharkAnnotationResolverImpl { 26 | public boolean classResolver(T goalObject) { 27 | /* 检测目标对象是否标记有@Mapper注解 */ 28 | return goalObject.getClass().isAnnotationPresent(Mapper.class); 29 | } 30 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/util/mapper/Column.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.util.mapper; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 自动映射标记字段 26 | * 27 | * @author gaoxianglong 28 | * 29 | * @version 1.4.1 30 | */ 31 | @Documented 32 | @Target(value = { ElementType.FIELD, ElementType.METHOD }) 33 | @Retention(RetentionPolicy.RUNTIME) 34 | public @interface Column { 35 | /* 如果name属性存在,则重写value属性的定义 */ 36 | public String name() default ""; 37 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/util/mapper/Mapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.util.mapper; 17 | 18 | import java.lang.annotation.Documented; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * 自动映射标记类,只有标记了该注解的类型才能实现自动映射 26 | * 27 | * @author gaoxianglong 28 | * 29 | * @version 1.4.1 30 | */ 31 | @Documented 32 | @Target(ElementType.TYPE) 33 | @Retention(RetentionPolicy.RUNTIME) 34 | public @interface Mapper { 35 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/util/mapper/SharkAnnotationResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.util.mapper; 17 | 18 | import java.lang.reflect.Field; 19 | import java.sql.ResultSet; 20 | 21 | /** 22 | * shark注解解析器接口 23 | * 24 | * @author gaoxianglong 25 | * 26 | * @version 1.4.1 27 | */ 28 | public interface SharkAnnotationResolver { 29 | /** 30 | * 字段注解解析 31 | * 32 | * @author JohnGao 33 | * 34 | * @param goalObject 35 | * 目标对象, 即需要被自动赋值的对象 36 | * 37 | * @param ResultSet 38 | * 39 | * @exception MapperException 40 | * 41 | * @return void 42 | */ 43 | public void fieldResolver(T goalObject, ResultSet rs); 44 | 45 | /** 46 | * 类型注解解析 47 | * 48 | * @author JohnGao 49 | * 50 | * @param goalObject 51 | * 目标对象, 即需要被自动赋值的对象 52 | * 53 | * @return boolean 解析结果 54 | */ 55 | public boolean classResolver(T goalObject); 56 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/util/mapper/SharkAnnotationResolverImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.util.mapper; 17 | 18 | import java.lang.reflect.Field; 19 | import java.sql.ResultSet; 20 | 21 | /** 22 | * shark注解解析器接口实现 23 | * 24 | * @author gaoxianglong 25 | * 26 | * @version 1.4.1 27 | */ 28 | public abstract class SharkAnnotationResolverImpl implements SharkAnnotationResolver { 29 | @Override 30 | public void fieldResolver(T goalObject, ResultSet rs) { 31 | } 32 | 33 | @Override 34 | public boolean classResolver(T goalObject) { 35 | return false; 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/util/sequence/CreateSequenceIdServiceImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.util.sequence; 17 | 18 | /** 19 | * 生成SequenceId服务实现 20 | * 21 | * @author gaoxianglong 22 | * 23 | * @version 1.4.1 24 | */ 25 | public abstract class CreateSequenceIdServiceImpl implements CreateSequenceIdService { 26 | @Override 27 | public long getSequenceId(int idcNum, int type, long memData) { 28 | return -1L; 29 | } 30 | 31 | @Override 32 | public long getSequenceId(String rootNodePath, int idcNum, int type, long memData) { 33 | return -1L; 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/util/xml/Beans.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.util.xml; 17 | 18 | import java.util.List; 19 | 20 | import javax.xml.bind.annotation.XmlAccessType; 21 | import javax.xml.bind.annotation.XmlAccessorType; 22 | import javax.xml.bind.annotation.XmlElement; 23 | import javax.xml.bind.annotation.XmlRootElement; 24 | 25 | /** 26 | * @author gaoxianglong 27 | * 28 | * @version 1.3.5 29 | */ 30 | @XmlRootElement(name = "beans") 31 | @XmlAccessorType(XmlAccessType.FIELD) 32 | public class Beans { 33 | @XmlElement(name = "bean", nillable = true) 34 | private List bean; 35 | 36 | public List getBean() { 37 | return bean; 38 | } 39 | 40 | public void setBean(List bean) { 41 | this.bean = bean; 42 | } 43 | } -------------------------------------------------------------------------------- /src/main/java/com/sharksharding/util/xml/CreateDSXml.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sharksharding.util.xml; 17 | 18 | import java.io.File; 19 | 20 | /** 21 | * 生成数据源配置文件 22 | * 23 | * @author gaoxianglong 24 | * 25 | * @version 1.3.5 26 | */ 27 | public interface CreateDSXml { 28 | /** 29 | * 生成kratos的数据源信息配置文件 30 | * 31 | * @author gaoxianglong 32 | * 33 | * @return boolean 生成结果 34 | */ 35 | public boolean createDatasourceXml(File savePath); 36 | } -------------------------------------------------------------------------------- /src/main/java/shark-logo.txt: -------------------------------------------------------------------------------- 1 | /' ) 2 | /' ( , 3 | __/' ) .' `; 4 | _.-~~~~' ``---..__ .' ; 5 | _.--' O) ``--...____.' .' version: [version] 6 | ( _. ))) `-._ < 7 | `\|\|\|\|)-.....___.- `-. __...--'-.'. https://github.com/gaoxianglong/shark 8 | `---......____...---`.___.'----... .' `.; 9 | `-` -------------------------------------------------------------------------------- /src/main/java/version.properties: -------------------------------------------------------------------------------- 1 | version=2.0.3.Alpha1 -------------------------------------------------------------------------------- /src/test/java/com/test/sharksharding/core/shard/ResolveDbnameTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.test.sharksharding.core.shard; 17 | 18 | import org.junit.Assert; 19 | import org.junit.Test; 20 | import com.sharksharding.core.shard.ResolveDbName; 21 | 22 | public class ResolveDbnameTest { 23 | public @Test void testGetNewDbName() { 24 | Assert.assertEquals("userinfo_test_0010", ResolveDbName.getNewDbName(10, "userinfo_test", "_0000")); 25 | Assert.assertEquals("userinfo_test_0100", ResolveDbName.getNewDbName(100, "userinfo_test", "_0000")); 26 | Assert.assertEquals("userinfo_test_1000", ResolveDbName.getNewDbName(1000, "userinfo_test", "_0000")); 27 | } 28 | } -------------------------------------------------------------------------------- /src/test/java/com/test/sharksharding/core/shard/ResolveIndexTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.test.sharksharding.core.shard; 17 | 18 | import org.junit.Test; 19 | import com.sharksharding.core.shard.ResolveIndex; 20 | import junit.framework.Assert; 21 | 22 | public class ResolveIndexTest { 23 | public @Test void testGetIndex() { 24 | Assert.assertEquals(0, ResolveIndex.getBeginIndex("r1024w0", true)); 25 | Assert.assertEquals(1024, ResolveIndex.getBeginIndex("r1024w0", false)); 26 | Assert.assertEquals(0, ResolveIndex.getBeginIndex("R1024W0", true)); 27 | Assert.assertEquals(1024, ResolveIndex.getBeginIndex("R0w1024", true)); 28 | } 29 | } -------------------------------------------------------------------------------- /src/test/java/com/test/sharksharding/sql/mysql/parser/SQLIsWhereColumnTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.test.sharksharding.sql.mysql.parser; 17 | 18 | import org.junit.Test; 19 | import com.sharksharding.sql.SQLIsWhereColumn; 20 | import junit.framework.Assert; 21 | 22 | /** 23 | * 验证SQL语句WHERE条件后面是否带参数 24 | * 25 | * @author gaoxianglong 26 | * 27 | * @version 1.4.1 28 | */ 29 | public class SQLIsWhereColumnTest { 30 | public @Test void testIsColumn() { 31 | String sql = "SELECT c2,c3 FROM tab WHERE c1=?"; 32 | Assert.assertTrue(SQLIsWhereColumn.isColumn(sql)); 33 | sql = "UPDATE tab SET c2=?,c3=? WHERE c1=?"; 34 | Assert.assertTrue(SQLIsWhereColumn.isColumn(sql)); 35 | sql = "DELETE FROM tab WHERE c1=?"; 36 | Assert.assertTrue(SQLIsWhereColumn.isColumn(sql)); 37 | } 38 | } -------------------------------------------------------------------------------- /src/test/java/com/test/sharksharding/use/EmailDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.test.sharksharding.use; 17 | 18 | import java.util.List; 19 | import java.util.Map; 20 | 21 | /** 22 | * email反向索引表Dao接口 23 | * 24 | * @author gaoxianglong 25 | */ 26 | public interface EmailDao { 27 | public void setEmail(EmailInfo email) throws Exception; 28 | 29 | /** 30 | * 不需要进行数据路由 31 | * 32 | * @author gaoxianglong 33 | */ 34 | public void setEmail2(EmailInfo email) throws Exception; 35 | 36 | public void setEmail(Map params) throws Exception; 37 | 38 | public List getEmail(EmailInfo email) throws Exception; 39 | 40 | /** 41 | * 不需要进行数据路由 42 | * 43 | * @author gaoxianglong 44 | */ 45 | public List getEmail2(EmailInfo email) throws Exception; 46 | 47 | public List getEmail(Map params) throws Exception; 48 | } -------------------------------------------------------------------------------- /src/test/java/com/test/sharksharding/use/EmailInfoMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.test.sharksharding.use; 17 | 18 | import java.sql.ResultSet; 19 | import java.sql.SQLException; 20 | import org.springframework.jdbc.core.RowMapper; 21 | import org.springframework.stereotype.Component; 22 | 23 | import com.sharksharding.util.mapper.BeanMapper; 24 | 25 | /** 26 | * Email实体映射类 27 | * 28 | * @author gaoxianglong 29 | */ 30 | @Component 31 | public class EmailInfoMapper implements RowMapper { 32 | @Override 33 | public EmailInfo mapRow(ResultSet rs, int rowNum) throws SQLException { 34 | EmailInfo email = new EmailInfo(); 35 | BeanMapper.mapper(email, rs); 36 | return email; 37 | } 38 | } -------------------------------------------------------------------------------- /src/test/java/com/test/sharksharding/use/Message.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.test.sharksharding.use; 17 | 18 | import org.springframework.stereotype.Component; 19 | 20 | /** 21 | * 对应数据库表[message_info] 22 | * 23 | * @author JohnGao 24 | */ 25 | @Component 26 | public class Message { 27 | private int message_id; 28 | private long userinfo_test_id; 29 | private String message; 30 | 31 | public int getMessage_id() { 32 | return message_id; 33 | } 34 | 35 | public void setMessage_id(int message_id) { 36 | this.message_id = message_id; 37 | } 38 | 39 | public long getUserinfo_test_id() { 40 | return userinfo_test_id; 41 | } 42 | 43 | public void setUserinfo_test_id(long userinfo_test_id) { 44 | this.userinfo_test_id = userinfo_test_id; 45 | } 46 | 47 | public String getMessage() { 48 | return message; 49 | } 50 | 51 | public void setMessage(String message) { 52 | this.message = message; 53 | } 54 | } -------------------------------------------------------------------------------- /src/test/java/com/test/sharksharding/use/MessageDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.test.sharksharding.use; 17 | 18 | import java.util.List; 19 | 20 | public interface MessageDao { 21 | public void insertMessage(Message message) throws Exception; 22 | 23 | public List queryMessagebyUid(long uid) throws Exception; 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/com/test/sharksharding/use/MessageMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.test.sharksharding.use; 17 | 18 | import java.sql.ResultSet; 19 | import java.sql.SQLException; 20 | import org.springframework.jdbc.core.RowMapper; 21 | import org.springframework.stereotype.Component; 22 | 23 | /** 24 | * Message实体映射类 25 | * 26 | * @author gaoxianglong 27 | */ 28 | @Component 29 | public class MessageMapper implements RowMapper { 30 | @Override 31 | public Message mapRow(ResultSet rs, int rowNum) throws SQLException { 32 | Message msg = new Message(); 33 | msg.setMessage(rs.getString("message")); 34 | return msg; 35 | } 36 | } -------------------------------------------------------------------------------- /src/test/java/com/test/sharksharding/use/UserDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.test.sharksharding.use; 17 | 18 | import java.util.List; 19 | import java.util.Map; 20 | 21 | /** 22 | * 用户信息Dao接口 23 | * 24 | * @author gaoxianglong 25 | */ 26 | public interface UserDao { 27 | public void setUserInfo(UserInfo user) throws Exception; 28 | 29 | public void setUserInfo(Map params) throws Exception; 30 | 31 | public List getUserInfo(long uid) throws Exception; 32 | 33 | public List getUserInfo(Map params) throws Exception; 34 | 35 | public void changeUserInfo(UserInfo user) throws Exception; 36 | 37 | public void changeUserInfo(Map params) throws Exception; 38 | } -------------------------------------------------------------------------------- /src/test/java/com/test/sharksharding/use/UserInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.test.sharksharding.use; 17 | 18 | import org.springframework.stereotype.Component; 19 | 20 | /** 21 | * 对应数据库表[userinfo_test] 22 | * 23 | * @author JohnGao 24 | */ 25 | @Component 26 | public class UserInfo { 27 | private long uid; 28 | private String userName; 29 | 30 | public String getUserName() { 31 | return userName; 32 | } 33 | 34 | public void setUserName(String userName) { 35 | this.userName = userName; 36 | } 37 | 38 | public long getUid() { 39 | return uid; 40 | } 41 | 42 | public void setUid(long uid) { 43 | this.uid = uid; 44 | } 45 | } -------------------------------------------------------------------------------- /src/test/java/com/test/sharksharding/use/UserInfoMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.test.sharksharding.use; 17 | 18 | import java.sql.ResultSet; 19 | import java.sql.SQLException; 20 | import org.springframework.jdbc.core.RowMapper; 21 | import org.springframework.stereotype.Component; 22 | 23 | /** 24 | * UserInfo实体映射类 25 | * 26 | * @author gaoxianglong 27 | */ 28 | @Component 29 | public class UserInfoMapper implements RowMapper { 30 | @Override 31 | public UserInfo mapRow(ResultSet rs, int rowNum) throws SQLException { 32 | UserInfo user = new UserInfo(); 33 | user.setUserName(rs.getString("userName")); 34 | return user; 35 | } 36 | } -------------------------------------------------------------------------------- /src/test/java/com/test/sharksharding/use/resource/ZkResourceTest.java: -------------------------------------------------------------------------------- 1 | package com.test.sharksharding.use.resource; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import java.util.Scanner; 6 | 7 | import javax.annotation.Resource; 8 | 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.springframework.jdbc.core.JdbcTemplate; 12 | import org.springframework.test.context.ContextConfiguration; 13 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 14 | 15 | import com.sharksharding.core.shard.GetJdbcTemplate; 16 | import com.sharksharding.sql.SQLTemplate; 17 | 18 | /** 19 | * 从配置中心动态获取加载配置信息测试 20 | * 21 | * @author gaoxianglong 22 | */ 23 | @RunWith(SpringJUnit4ClassRunner.class) 24 | /* 基于zookeeper的配置中心 */ 25 | @ContextConfiguration(locations = "classpath*:shark4-context.xml") 26 | public class ZkResourceTest { 27 | @Resource 28 | private SQLTemplate sqlTemplate; 29 | 30 | public @Test void testInsert() { 31 | while (true) { 32 | System.out.println("input-->"); 33 | Scanner scan = new Scanner(System.in); 34 | final String uid = scan.nextLine(); 35 | JdbcTemplate jdbcTemplate = GetJdbcTemplate.getJdbcTemplate("jdbcTemplate"); 36 | System.out.println("hash:" + jdbcTemplate.hashCode()); 37 | Map params = new HashMap(); 38 | params.put("uid", Long.valueOf(uid)); 39 | params.put("userName", "gaoxianglong"); 40 | final String sql = sqlTemplate.getSql("setUserInfo", params); 41 | jdbcTemplate.update(sql); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/test/java/com/test/sharksharding/util/FileExistTest.java: -------------------------------------------------------------------------------- 1 | package com.test.sharksharding.util; 2 | 3 | import java.io.File; 4 | import org.junit.Test; 5 | import com.sharksharding.util.FileExist; 6 | import junit.framework.Assert; 7 | 8 | public class FileExistTest { 9 | public @Test void testeExists() { 10 | String path = System.getProperty("java.io.tmpdir") + File.separator + "test.xml"; 11 | Assert.assertEquals(FileExist.exists(path), FileExist.exist(path)); 12 | System.out.println(FileExist.exists(path)); 13 | path = System.getProperty("java.io.tmpdir") + File.separator + "cavalier.xml"; 14 | Assert.assertEquals(FileExist.exists(path), FileExist.exist(path)); 15 | System.out.println(FileExist.exists(path)); 16 | } 17 | } -------------------------------------------------------------------------------- /src/test/java/com/test/sharksharding/util/GetNewTabNameTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.test.sharksharding.util; 17 | 18 | import org.junit.Test; 19 | 20 | import com.sharksharding.core.shard.ResolveTbName; 21 | 22 | public class GetNewTabNameTest { 23 | public @Test void getNewTabName() { 24 | System.out.println(ResolveTbName.getNewTbName(1, "userinfo_test", "_00000")); 25 | System.out.println(ResolveTbName.getNewTbName(1024, "userinfo_test", "_0000")); 26 | } 27 | } -------------------------------------------------------------------------------- /src/test/java/com/test/sharksharding/util/LoadVersionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.test.sharksharding.util; 17 | 18 | import org.junit.Test; 19 | import com.sharksharding.util.LoadVersion; 20 | import junit.framework.Assert; 21 | 22 | /** 23 | * 加载版本号测试 24 | * 25 | * @author gaoxianglong 26 | * 27 | * @version 1.4.0 28 | */ 29 | public class LoadVersionTest { 30 | public @Test void getVersion() { 31 | System.out.println(LoadVersion.getVersion()); 32 | } 33 | } -------------------------------------------------------------------------------- /src/test/java/com/test/sharksharding/util/MD5UtilTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2101 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.test.sharksharding.util; 17 | 18 | public class MD5UtilTest { 19 | // public @Test void testToMd5Code() { 20 | // final String value = UUID.randomUUID().toString(); 21 | // System.out.println(MD5Util.toMd5Code(value)); 22 | // } 23 | } -------------------------------------------------------------------------------- /src/test/java/com/test/sharksharding/util/TmpManagerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015-2101 gaoxianglong 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.test.sharksharding.util; 17 | 18 | import java.io.BufferedWriter; 19 | import java.io.FileWriter; 20 | import java.util.UUID; 21 | import org.junit.Test; 22 | 23 | import com.sharksharding.util.TmpManager; 24 | 25 | public class TmpManagerTest { 26 | public @Test void testTmp() { 27 | final String tmpdir = TmpManager.createTmp(); 28 | System.out.println("tmpdir-->" + tmpdir); 29 | try (BufferedWriter writ = new BufferedWriter(new FileWriter(tmpdir))) { 30 | writ.write(UUID.randomUUID().toString()); 31 | writ.flush(); 32 | } catch (Exception e) { 33 | e.printStackTrace(); 34 | } finally { 35 | try { 36 | /* 按任意键退出 */ 37 | // System.in.read(); 38 | TmpManager.deleteTmp(tmpdir); 39 | } catch (Exception e) { 40 | e.printStackTrace(); 41 | } 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/test/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/test/resources/properties/druid-jdbc.properties: -------------------------------------------------------------------------------- 1 | um.username=root 2 | #um.password=a1VMGhS+hpj+z5qy5s/6N8epQzXtB0LXYeTghMV3yq2vLwV3r2vIp2E8RgY2fWNq0E6c6Rk7W2nsU0ShY7lsnw== 3 | um.password=yunji 4 | um.initialSize=1 5 | um.minIdle=2 6 | um.maxActive=5 7 | um.maxWait=100000 8 | um.poolPreparedStatements=false 9 | um.maxOpenPreparedStatements=-1 10 | um.testOnBorrow=false 11 | um.testOnReturn=false 12 | um.testWhileIdle=true 13 | um.filters=mergeStat,log4j,config 14 | um.connectionProperties=config.decrypt=false 15 | um.useGlobalDataSourceStat=false 16 | um.timeBetweenLogStatsMillis=300000 -------------------------------------------------------------------------------- /src/test/resources/properties/redis.properties: -------------------------------------------------------------------------------- 1 | redis.key=shark-datasource 2 | redis.host=ip 3 | redis.port=7000 4 | redis.pool.maxTotal=10 5 | redis.pool.minIdle=1 6 | redis.pool.maxIdle=5 7 | redis.pool.maxWait=5000 8 | redis.pool.testOnBorrow=true 9 | redis.pool.testOnReturn=true -------------------------------------------------------------------------------- /src/test/resources/properties/sql.properties: -------------------------------------------------------------------------------- 1 | insertEmail=INSERT INTO email_test(email_hash,email,uid) VALUES(?,?,?) 2 | queryEmail=SELECT e.email_hash,e.email,e.uid FROM email_test e WHERE e.email_hash=? AND e.email=? 3 | insertMessage=INSERT INTO message_info(userinfo_test_id,message) VALUES(?,?) 4 | queryMessagebyUid=SELECT message FROM message_info WHERE userinfo_test_id = ? LIMIT 0,10 5 | changeUserInfo=UPDATE userinfo_test u SET u.username=? WHERE u.uid = ? 6 | ###################################################test sql############################################################ 7 | update=UPDATE tab SET c1=?,c2=? WHERE c3=? AND c4=? 8 | insert=INSERT INTO tab(c1,c2) VALUES(?,?) 9 | delete=DELETE FROM tab WHERE c1=? 10 | select=SELECT c1,c2 FROM tab WHERE c3=? -------------------------------------------------------------------------------- /src/test/resources/properties/sql.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 12 | 13 | 14 | 17 | 18 | 19 | 22 | 23 | 24 | 33 | 34 | -------------------------------------------------------------------------------- /src/test/resources/properties/zookeeper.properties: -------------------------------------------------------------------------------- 1 | address=ip:port 2 | session.timeout=30000 3 | nodepath=/info/shark --------------------------------------------------------------------------------