forked from olap4j/olap4j
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored the selection objects so that everything is statically typ…
…ed rather than a conditional instanceof check. I used a pseudo visitor pattern approach. I also factored out the selection implementations into an abstract super class. I also simplified the selection objects and removed all unnecessary calls. git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@401 c6a108a4-781c-0410-a6c6-c2d559e19af0
- Loading branch information
1 parent
633ca0a
commit 828ad8f
Showing
8 changed files
with
138 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
// $Id:$ | ||
// This software is subject to the terms of the Eclipse Public License v1.0 | ||
// Agreement, available at the following URL: | ||
// http://www.eclipse.org/legal/epl-v10.html. | ||
// Copyright (C) 2007-2011 Julian Hyde | ||
// All Rights Reserved. | ||
// You must accept the terms of that agreement to use this software. | ||
*/ | ||
package org.olap4j.query; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.olap4j.metadata.Dimension; | ||
|
||
/** | ||
* Abstract implementation of a selection. | ||
* @author LBoudreau | ||
* @version $Id:$ | ||
*/ | ||
abstract class AbstractSelection extends QueryNodeImpl implements Selection { | ||
|
||
Operator operator; | ||
Dimension dimension; | ||
List<Selection> selectionContext; | ||
|
||
public AbstractSelection( | ||
Dimension dimension, | ||
Operator operator) | ||
{ | ||
this.dimension = dimension; | ||
this.operator = operator; | ||
} | ||
|
||
public Dimension getDimension() { | ||
return dimension; | ||
} | ||
|
||
public Operator getOperator() { | ||
return operator; | ||
} | ||
|
||
public void setOperator(Operator operator) { | ||
assert operator != null; | ||
this.operator = operator; | ||
notifyChange(this,-1); | ||
} | ||
|
||
void tearDown() { | ||
} | ||
|
||
public List<Selection> getSelectionContext() { | ||
return selectionContext; | ||
} | ||
|
||
public void addContext(Selection selection) { | ||
if (selectionContext == null) { | ||
selectionContext = new ArrayList<Selection>(); | ||
} | ||
selectionContext.add(selection); | ||
} | ||
|
||
public void removeContext(Selection selection) { | ||
selectionContext.remove(selection); | ||
} | ||
|
||
public String getUniqueName() { | ||
return getRootElement().getUniqueName(); | ||
} | ||
} | ||
|
||
// End AbstractSelection.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.