content: /**
   * DBSyncer Copyright 2020-2023 All Rights Reserved.
   */
  package org.dbsyncer.connector.oracle;
  
  import org.dbsyncer.connector.oracle.cdc.DqlOracleListener;
  import org.dbsyncer.connector.oracle.validator.DqlOracleConfigValidator;
  import org.dbsyncer.sdk.connector.ConfigValidator;
  import org.dbsyncer.sdk.connector.database.AbstractDQLConnector;
  import org.dbsyncer.sdk.constant.DatabaseConstant;
  import org.dbsyncer.sdk.enums.ListenerTypeEnum;
  import org.dbsyncer.sdk.listener.DatabaseQuartzListener;
  import org.dbsyncer.sdk.listener.Listener;
  import org.dbsyncer.sdk.model.PageSql;
  import org.dbsyncer.sdk.plugin.ReaderContext;
  
  /**
   * DQLOracle连接器实现
   *
   * @Author AE86
   * @Version 1.0.0
   * @Date 2022-05-12 21:14
   */
  public final class DQLOracleConnector extends AbstractDQLConnector {
  
      private final DqlOracleConfigValidator configValidator = new DqlOracleConfigValidator();
  
      @Override
      public String getConnectorType() {
          return "DqlOracle";
      }
  
      @Override
      public ConfigValidator getConfigValidator() {
          return configValidator;
      }
  
      @Override
      public Listener getListener(String listenerType) {
          if (ListenerTypeEnum.isTiming(listenerType)) {
              return new DatabaseQuartzListener();
          }
  
          if (ListenerTypeEnum.isLog(listenerType)) {
              return new DqlOracleListener();
          }
          return null;
      }
  
      @Override
      public String getPageSql(PageSql config) {
          return DatabaseConstant.ORACLE_PAGE_SQL_START + config.getQuerySql() + DatabaseConstant.ORACLE_PAGE_SQL_END;
      }
  
      @Override
      public Object[] getPageArgs(ReaderContext context) {
          int pageSize = context.getPageSize();
          int pageIndex = context.getPageIndex();
          return new Object[]{pageIndex * pageSize, (pageIndex - 1) * pageSize};
      }
  
      @Override
      public String buildSqlWithQuotation() {
          return "\"";
      }
  
      @Override
      public String getValidationQuery() {
          return "select 1 from dual";
      }
  
  }