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: /**
015: * <b>SVNStatusType</b> provides information about versioned items'
016: * status type. This class contains a set of predefined constants each of that
017: * should be compared with a refrence to an <b>SVNStatusType</b> to find
018: * out the item's status type. That is done either in event handlers
019: * (implementing <b>ISVNEventHandler</b>) registered for <b>SVN</b>*<b>Client</b>
020: * objects like this:
021: * <pre class="javacode">
022: * <span class="javakeyword">import</span> org.tmatesoft.svn.core.wc.ISVNEventHandler;
023: * <span class="javakeyword">import</span> org.tmatesoft.svn.core.wc.SVNStatusType;
024: * <span class="javakeyword">import</span> org.tmatesoft.svn.core.wc.SVNEventAction;
025: * ...
026: *
027: * <span class="javakeyword">public class</span> MyCustomEventHandler <span class="javakeyword">implements</span> ISVNEventHandler {
028: * <span class="javakeyword">public void</span> handleEvent(SVNEvent event, <span class="javakeyword">double</span> progress){
029: * ...
030: *
031: * <span class="javakeyword">if</span>(event.getAction() == SVNEventAction.UPDATE_UPDATE){
032: * <span class="javacomment">//get contents status type</span>
033: * SVNStatusType contentsStatus = event.getContentsStatus();
034: * <span class="javacomment">//parse it</span>
035: * <span class="javakeyword">if</span>(contentsStatus != SVNStatusType.INAPPLICABLE){
036: * <span class="javakeyword">if</span>(contentsStatus == SVNStatusType.CONFLICTED){
037: * ...
038: * }
039: * }
040: *
041: * <span class="javacomment">//get properties status type</span>
042: * SVNStatusType propertiesStatus = event.getPropertiesStatus();
043: * <span class="javacomment">//parse it</span>
044: * <span class="javakeyword">if</span>(propertiesStatus != SVNStatusType.INAPPLICABLE){
045: * <span class="javakeyword">if</span>(contentsStatus == SVNStatusType.CONFLICTED){
046: * ...
047: * }
048: * }
049: * }
050: * ...
051: * }
052: * ...
053: * }</pre>
054: * <br>
055: * or in a status handler (implementing <b>ISVNStatusHandler</b>) registered
056: * for an <b>SVNStatusClient</b> like this:
057: * <pre class="javacode">
058: * <span class="javakeyword">import</span> org.tmatesoft.svn.core.wc.ISVNStatusHandler;
059: * <span class="javakeyword">import</span> org.tmatesoft.svn.core.wc.SVNStatus;
060: * <span class="javakeyword">import</span> org.tmatesoft.svn.core.wc.SVNStatusType;
061: * ...
062: *
063: * <span class="javakeyword">public class</span> MyCustomStatusHandler <span class="javakeyword">implements</span> ISVNStatusHandler {
064: * <span class="javakeyword">public void</span> handleStatus(SVNStatus status){
065: * ...
066: *
067: * <span class="javacomment">//get contents status type</span>
068: * SVNStatusType contentsStatus = status.getContentsStatus();
069: * <span class="javacomment">//parse it</span>
070: * <span class="javakeyword">if</span>(contentsStatus == SVNStatusType.STATUS_MODIFIED){
071: * ...
072: * }<span class="javakeyword">else if</span>(contentsStatus == SVNStatusType.STATUS_CONFLICTED){
073: * ...
074: * }
075: * ...
076: * <span class="javacomment">//get properties status type</span>
077: * SVNStatusType propertiesStatus = status.getPropertiesStatus();
078: * <span class="javacomment">//parse it</span>
079: * <span class="javakeyword">if</span>(contentsStatus == SVNStatusType.STATUS_MODIFIED){
080: * ...
081: * }<span class="javakeyword">else if</span>(contentsStatus == SVNStatusType.STATUS_CONFLICTED){
082: * ...
083: * }
084: * ...
085: * }
086: * ...
087: * }</pre>
088: *
089: * @version 1.1.1
090: * @author TMate Software Ltd.
091: * @see SVNEvent
092: * @see SVNStatus
093: */
094: public class SVNStatusType {
095:
096: private int myID;
097: private String myName;
098: private char myCode;
099:
100: private SVNStatusType(int id, String name) {
101: this (id, name, ' ');
102: }
103:
104: private SVNStatusType(int id, String name, char code) {
105: myID = id;
106: myName = name;
107: myCode = code;
108: }
109:
110: /**
111: * Returns this object's identifier as an integer nbumber.
112: * Each constant field of the <b>SVNStatusType</b> class is also an
113: * <b>SVNStatusType</b> object with its own id.
114: *
115: * @return id of this object
116: */
117: public int getID() {
118: return myID;
119: }
120:
121: /**
122: * Returns id of this object.
123: *
124: * @return id code
125: */
126: public char getCode() {
127: return myCode;
128: }
129:
130: /**
131: * Returns a string representation of this object. As a matter of fact
132: * this is a string representation of this object's id.
133: *
134: * @return a string representing this object
135: */
136: public String toString() {
137: return myName == null ? Integer.toString(myID) : myName;
138: }
139:
140: /**
141: * During some operations denotes that status info of item contents or
142: * properties is inapplicable. For example, this takes place during a
143: * commit operation - if there is any {@link ISVNEventHandler} registered
144: * for an {@link SVNCommitClient} then events that are dispatched to that event
145: * handler will have contents and properties status types set to <i>INAPPLICABLE</i>:
146: * <pre class="javacode">
147: * <span class="javakeyword">public class</span> MyCommitEventHandler <span class="javakeyword">implements</span> ISVNEventHandler{
148: * ...
149: *
150: * <span class="javakeyword">public void</span> handleEvent(SVNEvent event, <span class="javakeyword">double</span> progress){
151: * <span class="javacomment">//both are SVNStatusType.INAPPLICABLE</span>
152: * SVNStatusType contentsStatus = event.getContentsStatus();
153: * SVNStatusType propsStatus = event.getPropertiesStatus();
154: * }
155: * ...
156: * }</pre>
157: *
158: */
159: public static final SVNStatusType INAPPLICABLE = new SVNStatusType(
160: 0, "inapplicable");
161:
162: /**
163: * Denotes that the resultant status of the operation is for some
164: * reason unknown.
165: */
166: public static final SVNStatusType UNKNOWN = new SVNStatusType(1,
167: "unknown");
168:
169: /**
170: * During an operation denotes that file item contents or file/directory
171: * item properties are not changed. For example, in a Working Copy-to-URL copying.
172: */
173: public static final SVNStatusType UNCHANGED = new SVNStatusType(2,
174: "unchanged");
175:
176: /**
177: * Denotes that the item is versioned but missing (deleted from the
178: * fylesystem).
179: */
180: public static final SVNStatusType MISSING = new SVNStatusType(3,
181: "missing");
182:
183: /**
184: * Denotes that the item has an unexpected kind or somehow damaged or
185: * can not be managed by an operation.
186: */
187: public static final SVNStatusType OBSTRUCTED = new SVNStatusType(4,
188: "obstructed");
189:
190: /**
191: * During an operation (like an update) denotes that the item contents
192: * or item properties were changed.
193: */
194: public static final SVNStatusType CHANGED = new SVNStatusType(5,
195: "changed");
196:
197: /**
198: * During an operation (like an update or merge) denotes that the file
199: * item contents or file/directory item properties were merged
200: * with changes that came from the repository, so that local modifications
201: * and arrived ones do not overlap.
202: */
203: public static final SVNStatusType MERGED = new SVNStatusType(6,
204: "merged");
205:
206: /**
207: * During an operation (like an update) denotes that the file item contents
208: * or file/directory item properties are in conflict with those changes that
209: * came from the repository.
210: */
211: public static final SVNStatusType CONFLICTED = new SVNStatusType(7,
212: "conflicted");
213:
214: /**
215: * Denotes that the conflict state on the item is still unresolved.
216: * For example, it can be set when trying to merge into a file that is
217: * in conflict with the repository.
218: */
219: public static final SVNStatusType CONFLICTED_UNRESOLVED = new SVNStatusType(
220: 8, "conflicted_unresolved");
221:
222: /**
223: * During some operations denotes that lock status is inapplicable.
224: * For example, this takes place during a commit operation - if there
225: * is any {@link ISVNEventHandler} registered for {@link SVNCommitClient}
226: * then events that are dispatched to that event handler will have the
227: * lock status type set to <i>LOCK_INAPPLICABLE</i>:
228: * <pre class="javacode">
229: * <span class="javakeyword">public class</span> MyCommitEventHandler <span class="javakeyword">implements</span> ISVNEventHandler{
230: * ...
231: *
232: * <span class="javakeyword">public void</span> handleEvent(SVNEvent event, <span class="javakeyword">double</span> progress){
233: * <span class="javacomment">//is SVNStatusType.LOCK_INAPPLICABLE</span>
234: * SVNStatusType lockStatus = event.getLockStatus();
235: * }
236: * ...
237: * }</pre>
238: */
239: public static final SVNStatusType LOCK_INAPPLICABLE = new SVNStatusType(
240: 0, "lock_inapplicable");
241:
242: /**
243: * No lock information is known.
244: */
245: public static final SVNStatusType LOCK_UNKNOWN = new SVNStatusType(
246: 1, "lock_unknown");
247:
248: /**
249: * During an operation denotes that the lock status wasn't changed. For example, in a
250: * Working Copy-to-URL copying.
251: */
252: public static final SVNStatusType LOCK_UNCHANGED = new SVNStatusType(
253: 2, "lock_unchanged");
254:
255: /**
256: * During an operation denotes that the file item's locked.
257: */
258: public static final SVNStatusType LOCK_LOCKED = new SVNStatusType(
259: 3, "lock_locked");
260:
261: /**
262: * During an operation (like an update) denotes that the file item's lock
263: * was broken in the repositry by some other user.
264: */
265: public static final SVNStatusType LOCK_UNLOCKED = new SVNStatusType(
266: 4, "lock_unlocked");
267:
268: /**
269: * In a status operation denotes that no status type information is
270: * available.
271: */
272: public static final SVNStatusType STATUS_NONE = new SVNStatusType(
273: 0, "none");
274:
275: /**
276: * In a status operation (if it's being running with an option to report
277: * of all items set to <span class="javakeyword">true</span>) denotes that the
278: * item in the Working Copy being currently processed has no local changes
279: * (in a normal state).
280: */
281: public static final SVNStatusType STATUS_NORMAL = new SVNStatusType(
282: 1, "normal", ' ');
283:
284: /**
285: * In a status operation denotes that the item in the Working Copy being
286: * currently processed has local modifications.
287: */
288: public static final SVNStatusType STATUS_MODIFIED = new SVNStatusType(
289: 2, "modified", 'M');
290:
291: /**
292: * In a status operation denotes that the item in the Working Copy being
293: * currently processed is scheduled for addition to the repository.
294: */
295: public static final SVNStatusType STATUS_ADDED = new SVNStatusType(
296: 3, "added", 'A');
297:
298: /**
299: * In a status operation denotes that the item in the Working Copy being
300: * currently processed is scheduled for deletion from the repository.
301: */
302: public static final SVNStatusType STATUS_DELETED = new SVNStatusType(
303: 4, "deleted", 'D');
304:
305: /**
306: * In a status operation denotes that the item in the Working Copy being
307: * currently processed is not under version control.
308: */
309: public static final SVNStatusType STATUS_UNVERSIONED = new SVNStatusType(
310: 5, "unversioned", '?');
311:
312: /**
313: * In a status operation denotes that the item in the Working Copy being
314: * currently processed is under version control but is missing - for example,
315: * removed from the filesystem with a non-SVN, non-SVNKit or
316: * any other SVN non-compatible delete command).
317: */
318: public static final SVNStatusType STATUS_MISSING = new SVNStatusType(
319: 6, "missing", '!');
320:
321: /**
322: * In a status operation denotes that the item in the Working Copy being
323: * currently processed was replaced by another item with the same name (within
324: * a single revision the item was scheduled for deletion and then a new one with
325: * the same name was scheduled for addition). Though they may have the same name
326: * the items have their own distinct histories.
327: */
328: public static final SVNStatusType STATUS_REPLACED = new SVNStatusType(
329: 7, "replaced", 'R');
330:
331: /**
332: * In a status operation denotes that the item in the Working Copy being
333: * currently processed is in a conflict state (local changes overlap those
334: * that came from the repository). The conflicting overlaps need to be manually
335: * resolved.
336: */
337: public static final SVNStatusType STATUS_CONFLICTED = new SVNStatusType(
338: 9, "conflicted", 'C');
339:
340: /**
341: * In a status operation denotes that the item in the Working Copy being
342: * currently processed has a non-expected kind. For example, a file is
343: * considered to be obstructed if it was deleted (with an SVN client non-compatible
344: * delete operation) and a directory with the same name as the file had had was added
345: * (but again with an SVN client non-compatible operation).
346: */
347: public static final SVNStatusType STATUS_OBSTRUCTED = new SVNStatusType(
348: 10, "obstructed", '~');
349:
350: /**
351: * In a status operation denotes that the file item in the Working Copy being
352: * currently processed was set to be ignored (was added to svn:ignore property).
353: */
354: public static final SVNStatusType STATUS_IGNORED = new SVNStatusType(
355: 11, "ignored", 'I');
356:
357: /**
358: * In a status operation denotes that the item in the Working Copy being
359: * currently processed is under version control but is somehow incomplete -
360: * for example, it may happen when the previous update was interrupted.
361: */
362: public static final SVNStatusType STATUS_INCOMPLETE = new SVNStatusType(
363: 12, "incomplete", '!');
364:
365: /**
366: * In a status operation denotes that the item in the Working Copy being
367: * currently processed is not under version control but is related to
368: * externals definitions.
369: */
370: public static final SVNStatusType STATUS_EXTERNAL = new SVNStatusType(
371: 13, "external", 'X');
372:
373: /**
374: * In a status operation denotes that the item in the Working Copy being
375: * currently processed was merged - that is it was applied the differences
376: * (delta) between two sources in a merge operation.
377: *
378: * @deprecated this status is never reported by 'status' operation
379: * in this version, 'update' and 'merge' uses {@link SVNStatusType#MERGED} instead.
380: *
381: */
382: public static final SVNStatusType STATUS_MERGED = new SVNStatusType(
383: 8, "merged", 'G');
384:
385: }
|