001: //** Copyright Statement ***************************************************
002: //The Salmon Open Framework for Internet Applications (SOFIA)
003: // Copyright (C) 1999 - 2002, Salmon LLC
004: //
005: // This program is free software; you can redistribute it and/or
006: // modify it under the terms of the GNU General Public License version 2
007: // as published by the Free Software Foundation;
008: //
009: // This program is distributed in the hope that it will be useful,
010: // but WITHOUT ANY WARRANTY; without even the implied warranty of
011: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: // GNU General Public License for more details.
013: //
014: // You should have received a copy of the GNU General Public License
015: // along with this program; if not, write to the Free Software
016: // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
017: //
018: // For more information please visit http://www.salmonllc.com
019: //** End Copyright Statement ***************************************************
020: package com.salmonllc.sql;
021:
022: /////////////////////////
023: //$Archive: /SOFIA/SourceCode/com/salmonllc/sql/DSJoinDescriptor.java $
024: //$Author: Fred $
025: //$Revision: 12 $
026: //$Modtime: 6/11/04 8:16p $
027: /////////////////////////
028:
029: import java.util.*;
030:
031: /**
032: * This class is public as an implementation detail. It should not be used outside the framework.
033: */
034:
035: public class DSJoinDescriptor implements java.io.Serializable {
036: private Vector _left = new Vector(1, 1);
037: private Vector _right = new Vector(1, 1);
038: private boolean _outer;
039: //fc 06/11/04: Added to specify join relationship type.
040: private int _reltype;
041:
042: public DSJoinDescriptor(String left, String right, boolean outer) {
043: super ();
044: setColumns(left, right);
045: setOuter(outer);
046: setRelationType(DataStoreBuffer.RELATION_ONE_TO_ONE);
047: }
048:
049: //fc 06/11/04: Added new constructor.
050: public DSJoinDescriptor(String left, String right, boolean outer,
051: int reltype) {
052: super ();
053: setColumns(left, right);
054: setOuter(outer);
055: setRelationType(reltype);
056: }
057:
058: public String getLeftColumn(int no) {
059: if (no < 0 || no >= _left.size())
060: return null;
061: return (String) _left.elementAt(no);
062: }
063:
064: public int getLeftCount() {
065: return _left.size();
066: }
067:
068: public String getRightColumn(int no) {
069: if (no < 0 || no >= _right.size())
070: return null;
071: return (String) _right.elementAt(no);
072: }
073:
074: public int getRightCount() {
075: return _right.size();
076: }
077:
078: public boolean isOuter() {
079: return _outer;
080: }
081:
082: public void setColumns(String leftSide, String rightSide) {
083: StringTokenizer t1 = new StringTokenizer(leftSide, ",", false);
084: StringTokenizer t2 = new StringTokenizer(rightSide, ",", false);
085:
086: _left.removeAllElements();
087: _right.removeAllElements();
088:
089: try {
090: while (t1.hasMoreTokens())
091: _left.addElement(t1.nextToken());
092:
093: while (t2.hasMoreTokens())
094: _right.addElement(t2.nextToken());
095: } catch (Exception e) {
096: }
097:
098: }
099:
100: public void setOuter(boolean outer) {
101: _outer = outer;
102: }
103:
104: //fc 06/11/04: new method to get relationship type.
105: public int getRelationType() {
106: return _reltype;
107: }
108:
109: //fc 06/11/04: new method to set relationship type.
110: public void setRelationType(int reltype) {
111: _reltype = reltype;
112: }
113: }
|