001: /*
002: * Copyright Aduna (http://www.aduna-software.com/) (c) 2008.
003: *
004: * Licensed under the Aduna BSD-style license.
005: */
006: package org.openrdf.sail.rdbms.algebra;
007:
008: import org.openrdf.query.algebra.QueryModelVisitor;
009: import org.openrdf.sail.rdbms.algebra.base.BinarySqlOperator;
010: import org.openrdf.sail.rdbms.algebra.base.RdbmsQueryModelVisitorBase;
011: import org.openrdf.sail.rdbms.algebra.base.SqlExpr;
012:
013: /**
014: * The regular SQL expression - notation varies between databases.
015: *
016: * @author James Leigh
017: *
018: */
019: public class SqlRegex extends BinarySqlOperator {
020:
021: /*-----------*
022: * Variables *
023: *-----------*/
024:
025: private SqlExpr flagsArg;
026:
027: /*--------------*
028: * Constructors *
029: *--------------*/
030:
031: public SqlRegex() {
032: }
033:
034: public SqlRegex(SqlExpr expr, SqlExpr pattern) {
035: super (expr, pattern);
036: }
037:
038: public SqlRegex(SqlExpr expr, SqlExpr pattern, SqlExpr flags) {
039: super (expr, pattern);
040: setFlagsArg(flags);
041: }
042:
043: /*---------*
044: * Methods *
045: *---------*/
046:
047: public SqlExpr getArg() {
048: return super .getLeftArg();
049: }
050:
051: public void setArg(SqlExpr leftArg) {
052: super .setLeftArg(leftArg);
053: }
054:
055: public SqlExpr getPatternArg() {
056: return super .getRightArg();
057: }
058:
059: public void setPatternArg(SqlExpr rightArg) {
060: super .setRightArg(rightArg);
061: }
062:
063: public void setFlagsArg(SqlExpr flags) {
064: this .flagsArg = flags;
065: }
066:
067: public SqlExpr getFlagsArg() {
068: return flagsArg;
069: }
070:
071: @Override
072: public <X extends Exception> void visitChildren(
073: QueryModelVisitor<X> visitor) throws X {
074: super .visitChildren(visitor);
075: if (flagsArg != null) {
076: flagsArg.visit(visitor);
077: }
078: }
079:
080: @Override
081: public SqlRegex clone() {
082: SqlRegex clone = (SqlRegex) super .clone();
083: if (flagsArg != null) {
084: clone.setFlagsArg(flagsArg.clone());
085: }
086: return clone;
087: }
088:
089: @Override
090: public <X extends Exception> void visit(
091: RdbmsQueryModelVisitorBase<X> visitor) throws X {
092: visitor.meet(this );
093: }
094:
095: @Override
096: public int hashCode() {
097: final int prime = 31;
098: int result = super .hashCode();
099: result = prime * result
100: + ((flagsArg == null) ? 0 : flagsArg.hashCode());
101: return result;
102: }
103:
104: @Override
105: public boolean equals(Object obj) {
106: if (this == obj)
107: return true;
108: if (!super .equals(obj))
109: return false;
110: if (getClass() != obj.getClass())
111: return false;
112: final SqlRegex other = (SqlRegex) obj;
113: if (flagsArg == null) {
114: if (other.flagsArg != null)
115: return false;
116: } else if (!flagsArg.equals(other.flagsArg))
117: return false;
118: return true;
119: }
120: }
|