001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/syllabus/tags/sakai_2-4-1/syllabus-hbm/src/java/org/sakaiproject/component/app/syllabus/SyllabusItemImpl.java $
003: * $Id: SyllabusItemImpl.java 8802 2006-05-03 15:06:26Z cwen@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.component.app.syllabus;
021:
022: import java.util.Set;
023:
024: import java.util.TreeSet;
025:
026: import org.sakaiproject.api.app.syllabus.SyllabusItem;
027:
028: /**
029: * A syllabus item contains information relating to a syllabus and an order
030: * within a particular context (site).
031: *
032: * @author Jarrod Lannan
033: * @version $Id:
034: *
035: */
036:
037: public class SyllabusItemImpl implements SyllabusItem {
038: private Long surrogateKey;
039: private String userId;
040: private String contextId;
041: private String redirectURL;
042: private Integer lockId; // optimistic lock
043:
044: private Set syllabi = new TreeSet();
045:
046: /**
047: * Public no-arg Constructor.
048: */
049: public SyllabusItemImpl() {
050:
051: ;
052: }
053:
054: /**
055: * @param userId
056: * @param contextId
057: * @param redirectURL
058: * SyllabusEntry Constructor. Package protected.
059: */
060: public SyllabusItemImpl(String userId, String contextId,
061: String redirectURL) {
062:
063: if (userId == null || contextId == null) {
064: throw new IllegalArgumentException();
065: }
066:
067: this .userId = userId;
068: this .contextId = contextId;
069: this .redirectURL = redirectURL;
070: }
071:
072: /**
073: * @return Returns the syllabi.
074: */
075: public Set getSyllabi() {
076: return syllabi;
077: }
078:
079: /**
080: * @param syllabi The syllabi to set.
081: */
082: public void setSyllabi(Set syllabi) {
083: this .syllabi = syllabi;
084: }
085:
086: /**
087: * @return Returns the contextId.
088: */
089: public String getContextId() {
090: return contextId;
091: }
092:
093: /**
094: * @param contextId The contextId to set.
095: */
096: public void setContextId(String contextId) {
097: this .contextId = contextId;
098: }
099:
100: /**
101: * @return Returns the lockId.
102: */
103: public Integer getLockId() {
104: return lockId;
105: }
106:
107: /**
108: * @param lockId The lockId to set.
109: */
110: public void setLockId(Integer lockId) {
111: this .lockId = lockId;
112: }
113:
114: /**
115: * @return Returns the surrogateKey.
116: */
117: public Long getSurrogateKey() {
118: return surrogateKey;
119: }
120:
121: /**
122: * @param surrogateKey The surrogateKey to set.
123: */
124: private void setSurrogateKey(Long surrogateKey) {
125: this .surrogateKey = surrogateKey;
126: }
127:
128: /**
129: * @return Returns the userId.
130: */
131: public String getUserId() {
132: return userId;
133: }
134:
135: /**
136: * @param userId The userId to set.
137: */
138: public void setUserId(String userId) {
139: this .userId = userId;
140: }
141:
142: /**
143: * @return Returns the redirectURL.
144: */
145: public String getRedirectURL() {
146: if (redirectURL != null && redirectURL.length() > 1) {
147: redirectURL = redirectURL.trim();
148: }
149: return redirectURL;
150: }
151:
152: /**
153: * @param redirectURL The redirectURL to set.
154: */
155: public void setRedirectURL(String redirectURL) {
156: if (redirectURL != null && redirectURL.length() > 1) {
157: redirectURL = redirectURL.trim();
158: }
159: this .redirectURL = redirectURL;
160: }
161:
162: /**
163: * @see java.lang.Object#equals(java.lang.Object)
164: */
165: public boolean equals(Object obj) {
166: if (this == obj)
167: return true;
168: if (!(obj instanceof SyllabusItemImpl))
169: return false;
170: SyllabusItemImpl other = (SyllabusItemImpl) obj;
171:
172: if ((userId == null ? other.userId == null : userId
173: .equals(other.userId))
174: && (contextId == null ? other.contextId == null
175: : contextId.equals(other.contextId))
176: && (redirectURL == null ? other.redirectURL == null
177: : redirectURL.equals(other.redirectURL))) {
178: return true;
179: }
180: return false;
181: }
182:
183: /**
184: * @see java.lang.Object#hashCode()
185: */
186: public int hashCode() {
187: return userId.hashCode() + contextId.hashCode()
188: + redirectURL.hashCode();
189: }
190:
191: /**
192: * @see java.lang.Object#toString()
193: */
194: public String toString() {
195: StringBuffer sb = new StringBuffer();
196: sb.append("{surrogateKey=");
197: sb.append(surrogateKey);
198: sb.append(", userId=");
199: sb.append(userId);
200: sb.append(", contextId=");
201: sb.append(contextId);
202: sb.append(", redirectURL=");
203: sb.append(redirectURL);
204: sb.append(", lockId=");
205: sb.append(lockId);
206: sb.append("}");
207: return sb.toString();
208: }
209: }
|