~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/Status.java

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:26:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205012614-qom4xfypgtsqc2xq
Tags: 1.2.3dfsg1-3ubuntu1
Merge with the final Debian release of 1.2.3dfsg1-3, bringing in
fixes to the clean target, better documentation of the libdb4.3
upgrade and build fixes to work with swig1.3_1.3.27.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * @copyright
 
3
 * ====================================================================
 
4
 * Copyright (c) 2003-2005 CollabNet.  All rights reserved.
 
5
 *
 
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.
 
11
 *
 
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
 * ====================================================================
 
16
 * @endcopyright
 
17
 */
 
18
package org.tigris.subversion.javahl;
 
19
 
 
20
import java.util.Date;
 
21
/**
 
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>
 
29
 */
 
30
public class Status
 
31
{
 
32
    /**
 
33
     * the url for accessing the item
 
34
     */
 
35
    private String url;
 
36
    /**
 
37
     * the path in the working copy
 
38
     */
 
39
    private String path;
 
40
    /**
 
41
     * kind of the item (file, directory or unknonw)
 
42
     */
 
43
    private int nodeKind;
 
44
    /**
 
45
     * the base revision of the working copy
 
46
     */
 
47
    private long revision;
 
48
    /**
 
49
     * the last revision the item was changed before base
 
50
     */
 
51
    private long lastChangedRevision;
 
52
    /**
 
53
     * the last date the item was changed before base
 
54
     */
 
55
    private long lastChangedDate;
 
56
    /**
 
57
     * the last author of the last change before base
 
58
     */
 
59
    private String lastCommitAuthor;
 
60
    /**
 
61
     * the file or directory status (See StatusKind)
 
62
     */
 
63
    private int textStatus;
 
64
    /**
 
65
     * the status of the properties (See StatusKind)
 
66
     */
 
67
    private int propStatus;
 
68
    /**
 
69
     * flag is this item is locked locally by subversion
 
70
     * (running or aborted operation)
 
71
     */
 
72
    private boolean locked;
 
73
    /**
 
74
     * has this item be copied from another item
 
75
     */
 
76
    private boolean copied;
 
77
    /**
 
78
     * has the url of the item be switch
 
79
     */
 
80
    private boolean switched;
 
81
    /**
 
82
     * the file or directory status of base (See StatusKind)
 
83
     */
 
84
    private int repositoryTextStatus;
 
85
    /**
 
86
     * the status of the properties base (See StatusKind)
 
87
     */
 
88
    private int repositoryPropStatus;
 
89
    /**
 
90
     * if there is a conflict, the filename of the new version
 
91
     * from the repository
 
92
     */
 
93
    private String conflictNew;
 
94
    /**
 
95
     * if there is a conflict, the filename of the common base version
 
96
     * from the repository
 
97
     */
 
98
    private String conflictOld;
 
99
    /**
 
100
     * if there is a conflict, the filename of the former working copy
 
101
     * version
 
102
     */
 
103
    private String conflictWorking;
 
104
    /**
 
105
     * if copied, the url of the copy source
 
106
     */
 
107
    private String urlCopiedFrom;
 
108
    /**
 
109
     * if copied, the revision number of the copy source
 
110
     */
 
111
    private long revisionCopiedFrom;
 
112
    /**
 
113
     * @since 1.2
 
114
     * token specified for the lock (null if not locked)
 
115
     */
 
116
    private String lockToken;
 
117
    /**
 
118
     * @since 1.2
 
119
     * owner of the lock (null if not locked)
 
120
     */
 
121
    private String lockOwner;
 
122
    /**
 
123
     * @since 1.2
 
124
     * comment specified for the lock (null if not locked)
 
125
     */
 
126
    private String lockComment;
 
127
    /**
 
128
     * @since 1.2
 
129
     * date of the creation of the lock (null if not locked)
 
130
     */
 
131
    private long lockCreationDate;
 
132
    /**
 
133
     * @since 1.2
 
134
     * the lock in the repository
 
135
     */
 
136
    private Lock reposLock;
 
137
 
 
138
    /**
 
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
 
148
     *                              StatusKind)
 
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
 
153
     *                              operation)
 
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
 
158
     *                              repository version
 
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
 
163
     *                              source
 
164
     * @param switched              flag if the node has been switched in the 
 
165
     *                              path
 
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
 
171
     *                              any
 
172
     */
 
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)
 
182
    {
 
183
        this.path = path;
 
184
        this.url = url;
 
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;
 
207
    }
 
208
 
 
209
    /**
 
210
     * Returns the file system path of the item
 
211
     * @return path of status entry
 
212
     */
 
213
    public String getPath()
 
214
    {
 
215
        return path;
 
216
    }
 
217
 
 
218
    /**
 
219
     * Returns the revision as a Revision object
 
220
     * @return revision if versioned, otherwise SVN_INVALID_REVNUM
 
221
     */
 
222
    public Revision.Number getRevision()
 
223
    {
 
224
        return Revision.createNumber(revision);
 
225
    }
 
226
 
 
227
    /**
 
228
     * Returns the revision as a long integer
 
229
     * @return revision if versioned, otherwise SVN_INVALID_REVNUM
 
230
     */
 
231
    public long getRevisionNumber()
 
232
    {
 
233
        return revision;
 
234
    }
 
235
 
 
236
    /**
 
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
 
240
     */
 
241
    public Date getLastChangedDate()
 
242
    {
 
243
        if (lastChangedDate == 0)
 
244
            return null;
 
245
        else
 
246
            return new Date(lastChangedDate / 1000);
 
247
    }
 
248
 
 
249
    /**
 
250
     * Returns the author of the last changed or null
 
251
     * @return name of author if versioned, null otherwise
 
252
     */
 
253
    public String getLastCommitAuthor()
 
254
    {
 
255
        return lastCommitAuthor;
 
256
    }
 
257
 
 
258
    /**
 
259
     * Returns the status of the item (See StatusKind)
 
260
     * @return file status property enum of the "textual" component.
 
261
     */
 
262
    public int getTextStatus()
 
263
    {
 
264
        return textStatus;
 
265
    }
 
266
 
 
267
    /**
 
268
     * Returns the status of the item as text.
 
269
     * @return english text
 
270
     */
 
271
    public String getTextStatusDescription()
 
272
    {
 
273
        return Kind.getDescription(textStatus);
 
274
    }
 
275
 
 
276
    /**
 
277
     * Returns the status of the properties (See Status Kind)
 
278
     * @return file status property enum of the "property" component.
 
279
     */
 
280
    public int getPropStatus()
 
281
    {
 
282
        return propStatus;
 
283
    }
 
284
 
 
285
    /**
 
286
     * Returns the status of the properties as text
 
287
     * @return english text
 
288
     */
 
289
    public String getPropStatusDescription()
 
290
    {
 
291
        return Kind.getDescription(propStatus);
 
292
    }
 
293
 
 
294
    /**
 
295
     * Returns the status of the item in the repository (See StatusKind)
 
296
     * @return file status property enum of the "textual" component in the
 
297
     * repository.
 
298
     */
 
299
    public int getRepositoryTextStatus()
 
300
    {
 
301
        return repositoryTextStatus;
 
302
    }
 
303
 
 
304
    /**
 
305
     * Returns test status of the properties in the repository (See StatusKind)
 
306
     * @return file status property enum of the "property" component im the
 
307
     * repository.
 
308
     */
 
309
    public int getRepositoryPropStatus()
 
310
    {
 
311
        return repositoryPropStatus;
 
312
    }
 
313
 
 
314
    /**
 
315
     * Returns if the item is locked (running or aborted subversion operation)
 
316
     * @return true if locked
 
317
     */
 
318
    public boolean isLocked()
 
319
    {
 
320
        return locked;
 
321
    }
 
322
 
 
323
    /**
 
324
     * Returns if the item has been copied
 
325
     * @return true if copied
 
326
     */
 
327
    public boolean isCopied()
 
328
    {
 
329
        return copied;
 
330
    }
 
331
 
 
332
    /**
 
333
     * Returns in case of conflict, the filename of the most recent repository
 
334
     * version
 
335
     * @return the filename of the most recent repository version
 
336
     */
 
337
    public String getConflictNew()
 
338
    {
 
339
        return conflictNew;
 
340
    }
 
341
 
 
342
    /**
 
343
     * Returns in case of conflict, the filename of the common base version
 
344
     * @return the filename of the common base version
 
345
     */
 
346
    public String getConflictOld()
 
347
    {
 
348
        return conflictOld;
 
349
    }
 
350
 
 
351
    /**
 
352
     * Returns in case of conflict, the filename of the former working copy
 
353
     * version
 
354
     * @return the filename of the former working copy version
 
355
     */
 
356
    public String getConflictWorking()
 
357
    {
 
358
        return conflictWorking;
 
359
    }
 
360
 
 
361
    /**
 
362
     * Returns the repository url if any
 
363
     * @return url in repository or null if not known
 
364
     */
 
365
    public String getUrl()
 
366
    {
 
367
        return url;
 
368
    }
 
369
 
 
370
 
 
371
    /**
 
372
     * Returns the last revision the file was changed as a Revision object
 
373
     * @return last changed revision
 
374
     */
 
375
    public Revision.Number getLastChangedRevision()
 
376
    {
 
377
        return Revision.createNumber(lastChangedRevision);
 
378
    }
 
379
 
 
380
    /**
 
381
     * Returns the last revision the file was changed as a long integer
 
382
     * @return last changed revision
 
383
     */
 
384
    public long getLastChangedRevisionNumber()
 
385
    {
 
386
        return lastChangedRevision;
 
387
    }
 
388
 
 
389
    /**
 
390
     * Returns the kind of the node (file, directory or unknown, see NodeKind)
 
391
     * @return the node kind
 
392
     */
 
393
    public int getNodeKind()
 
394
    {
 
395
        return nodeKind;
 
396
    }
 
397
 
 
398
    /**
 
399
     * Returns if copied the copy source url or null
 
400
     * @return the source url
 
401
     */
 
402
    public String getUrlCopiedFrom()
 
403
    {
 
404
        return urlCopiedFrom;
 
405
    }
 
406
 
 
407
    /**
 
408
     * Returns if copied the source revision as a Revision object
 
409
     * @return the source revision
 
410
     */
 
411
    public Revision.Number getRevisionCopiedFrom()
 
412
    {
 
413
        return Revision.createNumber(revisionCopiedFrom);
 
414
    }
 
415
 
 
416
    /**
 
417
     * Returns if copied the source revision as s long integer
 
418
     * @return the source revision
 
419
     */
 
420
    public long getRevisionCopiedFromNumber()
 
421
    {
 
422
        return revisionCopiedFrom;
 
423
    }
 
424
 
 
425
    /**
 
426
     * Returns if the repository url has been switched
 
427
     * @return is the item has been switched
 
428
     */
 
429
    public boolean isSwitched()
 
430
    {
 
431
        return switched;
 
432
    }
 
433
 
 
434
    /**
 
435
     * Returns if is managed by svn (added, normal, modified ...)
 
436
     * @return if managed by svn
 
437
     */
 
438
    public boolean isManaged()
 
439
    {
 
440
        int status = getTextStatus();
 
441
        return (status != Status.Kind.unversioned &&
 
442
                status != Status.Kind.none &&
 
443
                status != Status.Kind.ignored);
 
444
    }
 
445
 
 
446
    /**
 
447
     * Returns if the resource has a remote counter-part
 
448
     * @return has version in repository
 
449
     */
 
450
    public boolean hasRemote()
 
451
    {
 
452
        return (isManaged() && getTextStatus() != Status.Kind.added);
 
453
    }
 
454
 
 
455
    /**
 
456
     * Returns if the resource just has been added
 
457
     * @return if added
 
458
     */
 
459
    public boolean isAdded()
 
460
    {
 
461
        return getTextStatus() == Status.Kind.added;
 
462
    }
 
463
 
 
464
    /**
 
465
     * Returns if the resource is schedules for delete
 
466
     * @return if deleted
 
467
     */
 
468
    public boolean isDeleted()
 
469
    {
 
470
        return getTextStatus() == Status.Kind.deleted;
 
471
    }
 
472
 
 
473
    /**
 
474
     * Returns if the resource has been merged
 
475
     * @return if merged
 
476
     */
 
477
    public boolean isMerged()
 
478
    {
 
479
        return getTextStatus() == Status.Kind.merged;
 
480
    }
 
481
 
 
482
    /**
 
483
     * Returns if the resource is ignored by svn (only returned if noIgnore
 
484
     * is set on SVNClient.list)
 
485
     * @return if ignore
 
486
     */
 
487
    public boolean isIgnored()
 
488
    {
 
489
        return getTextStatus() == Status.Kind.ignored;
 
490
    }
 
491
 
 
492
    /**
 
493
     * Returns if the resource itself is modified
 
494
     * @return if modified
 
495
     */
 
496
    public boolean isModified()
 
497
    {
 
498
        return getTextStatus() == Status.Kind.modified;
 
499
    }
 
500
 
 
501
    /**
 
502
     * Returns the lock token
 
503
     * @return the lock token
 
504
     * @since 1.2
 
505
     */
 
506
    public String getLockToken()
 
507
    {
 
508
        return lockToken;
 
509
    }
 
510
 
 
511
    /**
 
512
     * Returns the lock  owner
 
513
     * @return the lock owner
 
514
     * @since 1.2
 
515
     */
 
516
    public String getLockOwner()
 
517
    {
 
518
        return lockOwner;
 
519
    }
 
520
 
 
521
    /**
 
522
     * Returns the lock comment
 
523
     * @return the lock comment
 
524
     * @since 1.2
 
525
     */
 
526
    public String getLockComment()
 
527
    {
 
528
        return lockComment;
 
529
    }
 
530
 
 
531
    /**
 
532
     * Returns the lock creation date
 
533
     * @return the lock creation date
 
534
     * @since 1.2
 
535
     */
 
536
    public Date getLockCreationDate()
 
537
    {
 
538
        if (lockCreationDate == 0)
 
539
            return null;
 
540
        else
 
541
            return new Date(lockCreationDate / 1000);
 
542
    }
 
543
 
 
544
    /**
 
545
     * Returns the lock as in the repository
 
546
     * @return the lock as in the repository
 
547
     * @since 1.2
 
548
     */
 
549
    public Lock getReposLock()
 
550
    {
 
551
        return reposLock;
 
552
    }
 
553
    /**
 
554
     * class for kind status of the item or its properties
 
555
     * the constants are defined in the interface StatusKind for building
 
556
     * reasons
 
557
     */
 
558
    public static final class Kind implements StatusKind
 
559
    {
 
560
        /**
 
561
         * Returns the textual representation of the status
 
562
         * @param kind of status
 
563
         * @return english status
 
564
         */
 
565
        public static final String getDescription(int kind)
 
566
        {
 
567
            switch (kind)
 
568
            {
 
569
            case StatusKind.none:
 
570
                return "non-svn";
 
571
            case StatusKind.normal:
 
572
                return "normal";
 
573
            case StatusKind.added:
 
574
                return "added";
 
575
            case StatusKind.missing:
 
576
                return "missing";
 
577
            case StatusKind.deleted:
 
578
                return "deleted";
 
579
            case StatusKind.replaced:
 
580
                return "replaced";
 
581
            case StatusKind.modified:
 
582
                return "modified";
 
583
            case StatusKind.merged:
 
584
                return "merged";
 
585
            case StatusKind.conflicted:
 
586
                return "conflicted";
 
587
            case StatusKind.ignored:
 
588
                return "ignored";
 
589
            case StatusKind.incomplete:
 
590
                return "incomplete";
 
591
            case StatusKind.external:
 
592
                return "external";
 
593
            case StatusKind.unversioned:
 
594
            default:
 
595
                return "unversioned";
 
596
            }
 
597
        }
 
598
    }
 
599
}