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.lang.*;
028:
029: /**
030: * CVSMode implements the concept of file permissions. In other words,
031: * CVSMode objects are used to represent, parse, and otherwise handle
032: * CVS 'mode' lines such as 'u=rw,g=r,o=r'.
033: *
034: * @version $Revision: 2.2 $
035: * @author Timothy Gerard Endres, <a href="mailto:time@ice.com">time@ice.com</a>.
036: * @see CVSClient
037: * @see CVSEntry
038: */
039:
040: public class CVSMode extends Object implements Cloneable {
041: static public final String RCS_ID = "$Id: CVSMode.java,v 2.2 2003/07/27 01:08:32 time Exp $";
042: static public final String RCS_REV = "$Revision: 2.2 $";
043:
044: public boolean userRead;
045: public boolean userWrite;
046: public boolean userExecute;
047:
048: public boolean groupRead;
049: public boolean groupWrite;
050: public boolean groupExecute;
051:
052: public boolean otherRead;
053: public boolean otherWrite;
054: public boolean otherExecute;
055:
056: public CVSMode() {
057: super ();
058:
059: this .userRead = true;
060: this .userWrite = true;
061: this .userExecute = false;
062:
063: this .groupRead = true;
064: this .groupWrite = false;
065: this .groupExecute = false;
066:
067: this .otherRead = true;
068: this .otherWrite = false;
069: this .otherExecute = false;
070: }
071:
072: public String getModeLine() {
073: StringBuffer result = new StringBuffer("");
074:
075: result.append("u=");
076: if (this .userRead)
077: result.append("r");
078: if (this .userWrite)
079: result.append("w");
080: if (this .userExecute)
081: result.append("x");
082:
083: result.append(",");
084:
085: result.append("g=");
086: if (this .groupRead)
087: result.append("r");
088: if (this .groupWrite)
089: result.append("w");
090: if (this .groupExecute)
091: result.append("x");
092:
093: result.append(",");
094:
095: result.append("o=");
096: if (this .otherRead)
097: result.append("r");
098: if (this .otherWrite)
099: result.append("w");
100: if (this .otherExecute)
101: result.append("x");
102:
103: return result.toString();
104: }
105:
106: public String toString() {
107: return this.getModeLine();
108: }
109: }
|