3
* ====================================================================
4
* Copyright (c) 2003-2005 CollabNet. All rights reserved.
6
* This software is licensed as described in the file COPYING, which
7
* you should have received as part of this distribution. The terms
8
* are also available at http://subversion.tigris.org/license-1.html.
9
* If newer versions of this license are posted there, you may use a
10
* newer version instead, at your option.
12
* This software consists of voluntary contributions made by many
13
* individuals. For exact contribution history, see the revision
14
* history and logs, available at http://subversion.tigris.org/.
15
* ====================================================================
18
package org.tigris.subversion.javahl;
20
import java.util.Date;
22
* Subversion status API.
23
* This describes the status of one subversion item (file or directory) in
24
* the working copy. Will be returned by SVNClient.status or
25
* SVNClient.singleStatus
26
* @author Patrick Mayweg
27
* @author Cédric Chabanois
28
* <a href="mailto:cchabanois@ifrance.com">cchabanois@ifrance.com</a>
33
* the url for accessing the item
37
* the path in the working copy
41
* kind of the item (file, directory or unknonw)
45
* the base revision of the working copy
47
private long revision;
49
* the last revision the item was changed before base
51
private long lastChangedRevision;
53
* the last date the item was changed before base
55
private long lastChangedDate;
57
* the last author of the last change before base
59
private String lastCommitAuthor;
61
* the file or directory status (See StatusKind)
63
private int textStatus;
65
* the status of the properties (See StatusKind)
67
private int propStatus;
69
* flag is this item is locked locally by subversion
70
* (running or aborted operation)
72
private boolean locked;
74
* has this item be copied from another item
76
private boolean copied;
78
* has the url of the item be switch
80
private boolean switched;
82
* the file or directory status of base (See StatusKind)
84
private int repositoryTextStatus;
86
* the status of the properties base (See StatusKind)
88
private int repositoryPropStatus;
90
* if there is a conflict, the filename of the new version
93
private String conflictNew;
95
* if there is a conflict, the filename of the common base version
98
private String conflictOld;
100
* if there is a conflict, the filename of the former working copy
103
private String conflictWorking;
105
* if copied, the url of the copy source
107
private String urlCopiedFrom;
109
* if copied, the revision number of the copy source
111
private long revisionCopiedFrom;
114
* token specified for the lock (null if not locked)
116
private String lockToken;
119
* owner of the lock (null if not locked)
121
private String lockOwner;
124
* comment specified for the lock (null if not locked)
126
private String lockComment;
129
* date of the creation of the lock (null if not locked)
131
private long lockCreationDate;
134
* the lock in the repository
136
private Lock reposLock;
139
* this constructor should only called from JNI code
140
* @param path the file system path of item
141
* @param url the url of the item
142
* @param nodeKind kind of item (directory, file or unknown
143
* @param revision the revision number of the base
144
* @param lastChangedRevision the last revision this item was changed
145
* @param lastChangedDate the last date this item was changed
146
* @param lastCommitAuthor the author of the last change
147
* @param textStatus the file or directory status (See
149
* @param propStatus the property status (See StatusKind)
150
* @param repositoryTextStatus the file or directory status of the base
151
* @param repositoryPropStatus the property status of the base
152
* @param locked if the item is locked (running or aborted
154
* @param copied if the item is copy
155
* @param conflictOld in case of conflict, the file name of the
156
* the common base version
157
* @param conflictNew in case of conflict, the file name of new
159
* @param conflictWorking in case of conflict, the file name of the
160
* former working copy version
161
* @param urlCopiedFrom if copied, the url of the copy source
162
* @param revisionCopiedFrom if copied, the revision number of the copy
164
* @param switched flag if the node has been switched in the
166
* @param lockToken the token for the current lock if any
167
* @param lockOwner the owner of the current lock is any
168
* @param lockComment the comment of the current lock if any
169
* @param lockCreationDate the date, the lock was created if any
170
* @param reposLock the lock as stored in the repository if
173
public Status(String path, String url, int nodeKind, long revision,
174
long lastChangedRevision, long lastChangedDate,
175
String lastCommitAuthor, int textStatus, int propStatus,
176
int repositoryTextStatus, int repositoryPropStatus,
177
boolean locked, boolean copied, String conflictOld,
178
String conflictNew, String conflictWorking,
179
String urlCopiedFrom, long revisionCopiedFrom,
180
boolean switched, String lockToken, String lockOwner,
181
String lockComment, long lockCreationDate, Lock reposLock)
185
this.nodeKind = nodeKind;
186
this.revision = revision;
187
this.lastChangedRevision = lastChangedRevision;
188
this.lastChangedDate = lastChangedDate;
189
this.lastCommitAuthor = lastCommitAuthor;
190
this.textStatus = textStatus;
191
this.propStatus = propStatus;
192
this.locked = locked;
193
this.copied = copied;
194
this.repositoryTextStatus = repositoryTextStatus;
195
this.repositoryPropStatus = repositoryPropStatus;
196
this.conflictOld = conflictOld;
197
this.conflictNew = conflictNew;
198
this.conflictWorking = conflictWorking;
199
this.urlCopiedFrom = urlCopiedFrom;
200
this.revisionCopiedFrom = revisionCopiedFrom;
201
this.switched = switched;
202
this.lockToken = lockToken;
203
this.lockOwner = lockOwner;
204
this.lockComment = lockComment;
205
this.lockCreationDate = lockCreationDate;
206
this.reposLock = reposLock;
210
* Returns the file system path of the item
211
* @return path of status entry
213
public String getPath()
219
* Returns the revision as a Revision object
220
* @return revision if versioned, otherwise SVN_INVALID_REVNUM
222
public Revision.Number getRevision()
224
return Revision.createNumber(revision);
228
* Returns the revision as a long integer
229
* @return revision if versioned, otherwise SVN_INVALID_REVNUM
231
public long getRevisionNumber()
237
* Returns the last date the item was changed or null
238
* @return the last time the item was changed.
239
* or null if not available
241
public Date getLastChangedDate()
243
if (lastChangedDate == 0)
246
return new Date(lastChangedDate / 1000);
250
* Returns the author of the last changed or null
251
* @return name of author if versioned, null otherwise
253
public String getLastCommitAuthor()
255
return lastCommitAuthor;
259
* Returns the status of the item (See StatusKind)
260
* @return file status property enum of the "textual" component.
262
public int getTextStatus()
268
* Returns the status of the item as text.
269
* @return english text
271
public String getTextStatusDescription()
273
return Kind.getDescription(textStatus);
277
* Returns the status of the properties (See Status Kind)
278
* @return file status property enum of the "property" component.
280
public int getPropStatus()
286
* Returns the status of the properties as text
287
* @return english text
289
public String getPropStatusDescription()
291
return Kind.getDescription(propStatus);
295
* Returns the status of the item in the repository (See StatusKind)
296
* @return file status property enum of the "textual" component in the
299
public int getRepositoryTextStatus()
301
return repositoryTextStatus;
305
* Returns test status of the properties in the repository (See StatusKind)
306
* @return file status property enum of the "property" component im the
309
public int getRepositoryPropStatus()
311
return repositoryPropStatus;
315
* Returns if the item is locked (running or aborted subversion operation)
316
* @return true if locked
318
public boolean isLocked()
324
* Returns if the item has been copied
325
* @return true if copied
327
public boolean isCopied()
333
* Returns in case of conflict, the filename of the most recent repository
335
* @return the filename of the most recent repository version
337
public String getConflictNew()
343
* Returns in case of conflict, the filename of the common base version
344
* @return the filename of the common base version
346
public String getConflictOld()
352
* Returns in case of conflict, the filename of the former working copy
354
* @return the filename of the former working copy version
356
public String getConflictWorking()
358
return conflictWorking;
362
* Returns the repository url if any
363
* @return url in repository or null if not known
365
public String getUrl()
372
* Returns the last revision the file was changed as a Revision object
373
* @return last changed revision
375
public Revision.Number getLastChangedRevision()
377
return Revision.createNumber(lastChangedRevision);
381
* Returns the last revision the file was changed as a long integer
382
* @return last changed revision
384
public long getLastChangedRevisionNumber()
386
return lastChangedRevision;
390
* Returns the kind of the node (file, directory or unknown, see NodeKind)
391
* @return the node kind
393
public int getNodeKind()
399
* Returns if copied the copy source url or null
400
* @return the source url
402
public String getUrlCopiedFrom()
404
return urlCopiedFrom;
408
* Returns if copied the source revision as a Revision object
409
* @return the source revision
411
public Revision.Number getRevisionCopiedFrom()
413
return Revision.createNumber(revisionCopiedFrom);
417
* Returns if copied the source revision as s long integer
418
* @return the source revision
420
public long getRevisionCopiedFromNumber()
422
return revisionCopiedFrom;
426
* Returns if the repository url has been switched
427
* @return is the item has been switched
429
public boolean isSwitched()
435
* Returns if is managed by svn (added, normal, modified ...)
436
* @return if managed by svn
438
public boolean isManaged()
440
int status = getTextStatus();
441
return (status != Status.Kind.unversioned &&
442
status != Status.Kind.none &&
443
status != Status.Kind.ignored);
447
* Returns if the resource has a remote counter-part
448
* @return has version in repository
450
public boolean hasRemote()
452
return (isManaged() && getTextStatus() != Status.Kind.added);
456
* Returns if the resource just has been added
459
public boolean isAdded()
461
return getTextStatus() == Status.Kind.added;
465
* Returns if the resource is schedules for delete
468
public boolean isDeleted()
470
return getTextStatus() == Status.Kind.deleted;
474
* Returns if the resource has been merged
477
public boolean isMerged()
479
return getTextStatus() == Status.Kind.merged;
483
* Returns if the resource is ignored by svn (only returned if noIgnore
484
* is set on SVNClient.list)
487
public boolean isIgnored()
489
return getTextStatus() == Status.Kind.ignored;
493
* Returns if the resource itself is modified
494
* @return if modified
496
public boolean isModified()
498
return getTextStatus() == Status.Kind.modified;
502
* Returns the lock token
503
* @return the lock token
506
public String getLockToken()
512
* Returns the lock owner
513
* @return the lock owner
516
public String getLockOwner()
522
* Returns the lock comment
523
* @return the lock comment
526
public String getLockComment()
532
* Returns the lock creation date
533
* @return the lock creation date
536
public Date getLockCreationDate()
538
if (lockCreationDate == 0)
541
return new Date(lockCreationDate / 1000);
545
* Returns the lock as in the repository
546
* @return the lock as in the repository
549
public Lock getReposLock()
554
* class for kind status of the item or its properties
555
* the constants are defined in the interface StatusKind for building
558
public static final class Kind implements StatusKind
561
* Returns the textual representation of the status
562
* @param kind of status
563
* @return english status
565
public static final String getDescription(int kind)
569
case StatusKind.none:
571
case StatusKind.normal:
573
case StatusKind.added:
575
case StatusKind.missing:
577
case StatusKind.deleted:
579
case StatusKind.replaced:
581
case StatusKind.modified:
583
case StatusKind.merged:
585
case StatusKind.conflicted:
587
case StatusKind.ignored:
589
case StatusKind.incomplete:
591
case StatusKind.external:
593
case StatusKind.unversioned:
595
return "unversioned";