001: /*
002: ** Java cvs client library package.
003: ** Copyright (c) 1997-2002 by Timothy Gerard Endres
004: **
005: ** This program is free software.
006: **
007: ** You may redistribute it and/or modify it under the terms of the GNU
008: ** Library General Public License (LGPL) as published by the Free Software
009: ** Foundation.
010: **
011: ** Version 2 of the license should be included with this distribution in
012: ** the file LICENSE.txt, as well as License.html. If the license is not
013: ** included with this distribution, you may find a copy at the FSF web
014: ** site at 'www.gnu.org' or 'www.fsf.org', or you may write to the Free
015: ** Software Foundation at 59 Temple Place - Suite 330, Boston, MA 02111 USA.
016: **
017: ** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,
018: ** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR
019: ** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY
020: ** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR
021: ** REDISTRIBUTION OF THIS SOFTWARE.
022: **
023: */
024:
025: package com.ice.cvsc;
026:
027: import java.io.*;
028: import java.lang.*;
029: import java.text.*;
030: import java.util.*;
031:
032: /**
033: * Encapsulates a single CVS server response item.
034: * A response item has an ID indicating what the response was.
035: * Some responses include parameters, and in some cases, files,
036: * and the CVSReponseItem encapsulates these 'additional' data.
037: *
038: * @version $Revision: 2.5 $
039: * @author Timothy Gerard Endres, <a href="mailto:time@ice.com">time@ice.com</a>.
040: * @see CVSClient
041: * @see CVSRequest
042: */
043:
044: public class CVSResponseItem extends Object {
045: static public final String RCS_ID = "$Id: CVSResponseItem.java,v 2.5 2003/07/27 01:08:32 time Exp $";
046: static public final String RCS_REV = "$Revision: 2.5 $";
047:
048: static public final int CHECKED_IN = 1;
049: static public final int CHECKSUM = 2;
050: static public final int CLEAR_STATIC_DIR = 3;
051: static public final int CLEAR_STICKY = 4;
052: static public final int COPY_FILE = 5;
053: static public final int CREATED = 6;
054: static public final int MERGED = 7;
055: static public final int MODULE_EXPANSION = 8;
056: static public final int NEW_ENTRY = 9;
057: static public final int NOTIFIED = 10;
058: static public final int PATCHED = 11;
059: static public final int REMOVED = 12;
060: static public final int REMOVE_ENTRY = 13;
061: static public final int UPDATED = 14;
062: static public final int UPDATE_EXISTING = 15;
063: static public final int VALID_REQUESTS = 16;
064: static public final int SET_CHECKIN_PROG = 17;
065: static public final int SET_STATIC_DIR = 18;
066: static public final int SET_STICKY = 19;
067: static public final int SET_UPDATE_PROG = 20;
068:
069: // These are temporaries use in the
070: static public final int GET_FULL_PATH = 1;
071: static public final int GET_ENTRIES_LINE = 2;
072: static public final int GET_MODE_LINE = 3;
073: static public final int GET_NEW_NAME = 4;
074: static public final int GET_TAG_SPEC = 5;
075: static public final int GET_PROGRAM = 6;
076: static public final int GET_FILE = 7;
077:
078: private boolean valid;
079:
080: private int type;
081: private int addState;
082: private boolean isGZIPed;
083:
084: private File file;
085: private String text;
086: private String pathName;
087: private String reposName;
088: private String modeLine;
089: private String entriesLine;
090:
091: private String newName;
092: private String tagSpec;
093: private String useProgram;
094:
095: public CVSResponseItem(int type) {
096: super ();
097:
098: this .type = type;
099: this .valid = false;
100: this .isGZIPed = false;
101:
102: this .file = null;
103: this .text = null;
104: this .pathName = null;
105: this .reposName = null;
106: this .modeLine = null;
107: this .entriesLine = null;
108:
109: this .newName = null;
110: this .tagSpec = null;
111: this .useProgram = null;
112: }
113:
114: public int getType() {
115: return type;
116: }
117:
118: public int getAddState() {
119: return this .addState;
120: }
121:
122: public void setAddState(int state) {
123: this .addState = state;
124: }
125:
126: public boolean isGZIPed() {
127: return this .isGZIPed;
128: }
129:
130: public void setGZIPed(boolean isGZIPed) {
131: this .isGZIPed = isGZIPed;
132: }
133:
134: public boolean isValid() {
135: return this .valid;
136: }
137:
138: public void setValid(boolean valid) {
139: this .valid = valid;
140: }
141:
142: public String getEntriesLine() {
143: return this .entriesLine;
144: }
145:
146: public void setEntriesLine(String line) {
147: this .entriesLine = line;
148: }
149:
150: public String getModeLine() {
151: return this .modeLine;
152: }
153:
154: public void setModeLine(String line) {
155: this .modeLine = line;
156: }
157:
158: public File getFile() {
159: return this .file;
160: }
161:
162: public void setFile(File file) {
163: this .file = file;
164: }
165:
166: public boolean deleteFile() {
167: boolean result = true;
168:
169: if (this .file != null) {
170: if (this .file.exists()) {
171: try {
172: this .file.delete();
173: } catch (SecurityException ex) {
174: result = false;
175: CVSLog.logMsg("ERROR deleting temp file '"
176: + this .file.getPath() + "'");
177: }
178: }
179: }
180:
181: return result;
182: }
183:
184: public String getPathName() {
185: return this .pathName;
186: }
187:
188: public void setPathName(String pathName) {
189: this .pathName = pathName;
190: }
191:
192: public String getRepositoryPath() {
193: int index = this .reposName.lastIndexOf('/');
194:
195: if (index < 0)
196: return "."; // REVIEW
197: else
198: return this .reposName.substring(0, index);
199: }
200:
201: public String getRepositoryName() {
202: return this .reposName;
203: }
204:
205: public void setRepositoryName(String reposName) {
206: this .reposName = reposName;
207: }
208:
209: public String getNewName() {
210: return this .newName;
211: }
212:
213: public void setNewName(String name) {
214: this .newName = name;
215: }
216:
217: public String getProgram() {
218: return this .newName;
219: }
220:
221: public void setProgram(String program) {
222: this .useProgram = program;
223: }
224:
225: public String getTagSpec() {
226: return this .tagSpec;
227: }
228:
229: public void setTagSpec(String tagspec) {
230: this .tagSpec = tagspec;
231: }
232:
233: public String getChecksum() {
234: if (this .type != CVSResponseItem.CHECKSUM)
235: return null;
236: else
237: return this .text;
238: }
239:
240: public void setChecksum(String sumStr) {
241: if (this .type == CVSResponseItem.CHECKSUM) {
242: this .text = sumStr;
243: }
244: }
245:
246: public String getValidRequests() {
247: if (this .type != CVSResponseItem.VALID_REQUESTS)
248: return null;
249: else
250: return this .text;
251: }
252:
253: public void setValidRequests(String requests) {
254: if (this .type == CVSResponseItem.VALID_REQUESTS) {
255: this .text = requests;
256: }
257: }
258:
259: public String toString() {
260: return "[ " + "type=" + this .type + "," + "pathName="
261: + this .pathName + "," + "reposName=" + this .reposName
262: + "," + "modeLine=" + this .modeLine + ","
263: + "entriesLine=" + this .entriesLine + "," + "newName="
264: + this .newName + "," + "tagSpec=" + this .tagSpec + ","
265: + "useProgram=" + this .useProgram + "," + "file="
266: + this .file + " ]";
267: }
268: }
|