|
| 1 | +/* |
| 2 | + * #%L |
| 3 | + * JSQLParser library |
| 4 | + * %% |
| 5 | + * Copyright (C) 2004 - 2013 JSQLParser |
| 6 | + * %% |
| 7 | + * This program is free software: you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU Lesser General Public License as |
| 9 | + * published by the Free Software Foundation, either version 2.1 of the |
| 10 | + * License, or (at your option) any later version. |
| 11 | + * |
| 12 | + * This program is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU General Lesser Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Lesser Public |
| 18 | + * License along with this program. If not, see |
| 19 | + * <http://www.gnu.org/licenses/lgpl-2.1.html>. |
| 20 | + * #L% |
| 21 | + */ |
| 22 | +package net.sf.jsqlparser.expression.operators.relational; |
| 23 | + |
| 24 | +import net.sf.jsqlparser.expression.BinaryExpression; |
| 25 | +import net.sf.jsqlparser.expression.ExpressionVisitor; |
| 26 | + |
| 27 | +public class RegExpMatchOperator extends BinaryExpression { |
| 28 | + |
| 29 | + private RegExpMatchOperatorType operatorType; |
| 30 | + |
| 31 | + public RegExpMatchOperator(RegExpMatchOperatorType operatorType) { |
| 32 | + if (operatorType == null) { |
| 33 | + throw new NullPointerException(); |
| 34 | + } |
| 35 | + this.operatorType = operatorType; |
| 36 | + } |
| 37 | + |
| 38 | + public RegExpMatchOperatorType getOperatorType() { |
| 39 | + return operatorType; |
| 40 | + } |
| 41 | + |
| 42 | + @Override |
| 43 | + public void accept(ExpressionVisitor expressionVisitor) { |
| 44 | + expressionVisitor.visit(this); |
| 45 | + } |
| 46 | + |
| 47 | + @Override |
| 48 | + public String getStringExpression() { |
| 49 | + switch (operatorType) { |
| 50 | + case MATCH_CASESENSITIVE: |
| 51 | + return "~"; |
| 52 | + case MATCH_CASEINSENSITIVE: |
| 53 | + return "~*"; |
| 54 | + case NOT_MATCH_CASESENSITIVE: |
| 55 | + return "!~"; |
| 56 | + case NOT_MATCH_CASEINSENSITIVE: |
| 57 | + return "!~*"; |
| 58 | + } |
| 59 | + return null; |
| 60 | + } |
| 61 | +} |
0 commit comments