001: /*
002: * ====================================================================
003: * Copyright (c) 2004-2008 TMate Software Ltd. All rights reserved.
004: *
005: * This software is licensed as described in the file COPYING, which
006: * you should have received as part of this distribution. The terms
007: * are also available at http://svnkit.com/license.html
008: * If newer versions of this license are posted there, you may use a
009: * newer version instead, at your option.
010: * ====================================================================
011: */
012: package org.tmatesoft.svn.core.wc;
013:
014: import java.io.File;
015:
016: import org.tmatesoft.svn.core.SVNNodeKind;
017: import org.tmatesoft.svn.core.SVNURL;
018: import org.tmatesoft.svn.core.internal.wc.admin.SVNWCAccess;
019:
020: /**
021: * The <b>SVNCommitItem</b> represents a versioned item that is
022: * to be committed to a repository.
023: *
024: * <p>
025: * Used to wrap information about a versioned item into a single
026: * object. A commit item can represent either a Working Copy item
027: * (speaking of committing local changes in WC files and directories)
028: * or one that is located in a repository (for example, when deleting
029: * a file/directory right from a repository).
030: *
031: * <p>
032: * When you call <b>SVNCommitClient</b>'s {@link SVNCommitClient#doCollectCommitItems(File[], boolean, boolean, boolean) doCollectCommitItems()}
033: * this methods processes the specified paths and collects information
034: * on items to be committed in <b>SVNCommitItem</b> objects which are
035: * packed into a single <b>SVNCommitPacket</b> object. This object is
036: * returned by the method to the caller.
037: *
038: * @version 1.1.1
039: * @author TMate Software Ltd.
040: * @see SVNCommitPacket
041: *
042: */
043: public class SVNCommitItem {
044:
045: private SVNRevision myRevision;
046: private File myFile;
047: private SVNURL myURL;
048: private SVNURL myCopyFromURL;
049: private SVNNodeKind myKind;
050: private boolean myIsAdded;
051: private boolean myIsDeleted;
052: private boolean myIsPropertiesModified;
053: private boolean myIsContentsModified;
054: private boolean myIsCopied;
055: private boolean myIsLocked;
056: private String myPath;
057: private SVNWCAccess myWCAccess;
058: private SVNRevision myCopyFromRevision;
059:
060: /**
061: * Constructs and initializes an <b>SVNCommitItem</b> object.
062: *
063: * @param file a WC item's location
064: * @param URL the item's repository location
065: * @param copyFromURL the repository location of the item's ancestor
066: * (if the item was or to be copied)
067: * @param kind the item's node kind
068: * @param revision the item's revision
069: * @param copyFromRevision the revision of the item's ancestor
070: * it's copied from
071: * @param isAdded <span class="javakeyword">true</span> if the
072: * item is to be added to version control, otherwise
073: * <span class="javakeyword">false</span>
074: * @param isDeleted <span class="javakeyword">true</span> if the
075: * item is to be deleted from version control, otherwise
076: * <span class="javakeyword">false</span>
077: * @param isPropertiesModified <span class="javakeyword">true</span> if the
078: * item's properties have local changes, otherwise
079: * <span class="javakeyword">false</span>
080: * @param isContentsModified <span class="javakeyword">true</span> if the
081: * item's contents (file contents or directory entries)
082: * have local changes, otherwise
083: * <span class="javakeyword">false</span>
084: * @param isCopied <span class="javakeyword">true</span> if the
085: * item is to be added to version control with history,
086: * otherwise <span class="javakeyword">false</span>
087: * @param locked <span class="javakeyword">true</span> if the
088: * item is to be locked, otherwise
089: * <span class="javakeyword">false</span>
090: */
091: public SVNCommitItem(File file, SVNURL URL, SVNURL copyFromURL,
092: SVNNodeKind kind, SVNRevision revision,
093: SVNRevision copyFromRevision, boolean isAdded,
094: boolean isDeleted, boolean isPropertiesModified,
095: boolean isContentsModified, boolean isCopied, boolean locked) {
096: myRevision = revision == null ? SVNRevision.UNDEFINED
097: : revision;
098: myCopyFromRevision = copyFromRevision == null ? SVNRevision.UNDEFINED
099: : copyFromRevision;
100: myFile = file;
101: myURL = URL;
102: myCopyFromURL = copyFromURL;
103: myKind = kind;
104: myIsAdded = isAdded;
105: myIsDeleted = isDeleted;
106: myIsPropertiesModified = isPropertiesModified;
107: myIsContentsModified = isContentsModified;
108: myIsCopied = isCopied;
109: myIsLocked = locked;
110: }
111:
112: /**
113: * Gets the revision of the versioned item . For a WC item it is
114: * the current working revision.
115: *
116: * @return the revision of the item to be committed
117: */
118: public SVNRevision getRevision() {
119: return myRevision;
120: }
121:
122: /**
123: * Gets the revision of the versioned item's ancestor
124: * from which the item was copied.
125: *
126: * @return the revision the item was copied from
127: */
128: public SVNRevision getCopyFromRevision() {
129: return myCopyFromRevision;
130: }
131:
132: /**
133: * Gets the location of the Working Copy item.
134: *
135: * @return the item's local path
136: */
137: public File getFile() {
138: return myFile;
139: }
140:
141: /**
142: * Gets the versioned item's repository location.
143: *
144: * @return the item's URL pointing to its repository location
145: */
146: public SVNURL getURL() {
147: return myURL;
148: }
149:
150: /**
151: * Gets the repository location of the versioned item's ancestor
152: * from which the item was copied.
153: *
154: * @return the URL of the copy source in an {@link org.tmatesoft.svn.core.SVNURL}
155: * representation
156: */
157: public SVNURL getCopyFromURL() {
158: return myCopyFromURL;
159: }
160:
161: /**
162: * Gets the node kind of the versioned item.
163: *
164: * @return the item's node kind
165: */
166: public SVNNodeKind getKind() {
167: return myKind;
168: }
169:
170: /**
171: * Determines if the item is to be added to version control.
172: *
173: * @return <span class="javakeyword">true</span> if added,
174: * otherwise <span class="javakeyword">false</span>
175: */
176: public boolean isAdded() {
177: return myIsAdded;
178: }
179:
180: /**
181: * Determines if the item is to be deleted from version control.
182: *
183: * @return <span class="javakeyword">true</span> if deleted,
184: * otherwise <span class="javakeyword">false</span>
185: */
186: public boolean isDeleted() {
187: return myIsDeleted;
188: }
189:
190: /**
191: * Determines if the Working Copy item has local edits
192: * to properties.
193: *
194: * @return <span class="javakeyword">true</span> if the properties
195: * have local changes, otherwise <span class="javakeyword">false</span>
196: */
197: public boolean isPropertiesModified() {
198: return myIsPropertiesModified;
199: }
200:
201: /**
202: * Determines if the Working Copy item has local edits
203: * to its contents. If the item is a file - that is the file contents,
204: * a directory - the directory contents (meaning entries).
205: *
206: * @return <span class="javakeyword">true</span> if the contents
207: * have local changes, otherwise <span class="javakeyword">false</span>
208: */
209: public boolean isContentsModified() {
210: return myIsContentsModified;
211: }
212:
213: /**
214: * Determines if the item is to be added to version control with
215: * history.
216: *
217: * @return <span class="javakeyword">true</span> if added with
218: * history (copied in other words), otherwise
219: * <span class="javakeyword">false</span>
220: */
221: public boolean isCopied() {
222: return myIsCopied;
223: }
224:
225: /**
226: * Determines whether the item needs to be locked.
227: *
228: * @return <span class="javakeyword">true</span> if locked,
229: * otherwise <span class="javakeyword">false</span>
230: */
231: public boolean isLocked() {
232: return myIsLocked;
233: }
234:
235: /**
236: * Gets the item's relevant path. The path is relevant to
237: * the Working Copy root.
238: *
239: * @return the item's relevant path
240: */
241: public String getPath() {
242: return myPath;
243: }
244:
245: /**
246: * Sets the item's relevant path.
247: *
248: * @param path the item's path relevant to the Working Copy root
249: */
250: public void setPath(String path) {
251: myPath = path;
252: }
253:
254: /**
255: * This method is not intended for users (from an API point of view).
256: *
257: * @return wc access object
258: */
259: public SVNWCAccess getWCAccess() {
260: return myWCAccess;
261: }
262:
263: void setWCAccess(SVNWCAccess wcAccess) {
264: myWCAccess = wcAccess;
265: }
266: }
|