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.internal.io.fs;
013:
014: import java.io.Serializable;
015: import java.util.HashMap;
016: import java.util.Map;
017:
018: import org.tmatesoft.svn.core.SVNLogEntryPath;
019:
020: /**
021: * The kind of change that occurred on the path.
022: *
023: * @version 1.1.1
024: * @author TMate Software Ltd.
025: */
026: public class FSPathChangeKind implements Serializable {
027:
028: public static final String ACTION_MODIFY = "modify";
029: public static final String ACTION_ADD = "add";
030: public static final String ACTION_DELETE = "delete";
031: public static final String ACTION_REPLACE = "replace";
032: public static final String ACTION_RESET = "reset";
033:
034: public static final FSPathChangeKind FS_PATH_CHANGE_MODIFY = new FSPathChangeKind(
035: ACTION_MODIFY);
036: public static final FSPathChangeKind FS_PATH_CHANGE_ADD = new FSPathChangeKind(
037: ACTION_ADD);
038: public static final FSPathChangeKind FS_PATH_CHANGE_DELETE = new FSPathChangeKind(
039: ACTION_DELETE);
040: public static final FSPathChangeKind FS_PATH_CHANGE_REPLACE = new FSPathChangeKind(
041: ACTION_REPLACE);
042: public static final FSPathChangeKind FS_PATH_CHANGE_RESET = new FSPathChangeKind(
043: ACTION_RESET);
044:
045: private String myName;
046:
047: private static final Map ACTIONS_TO_CHANGE_KINDS = new HashMap();
048:
049: static {
050: ACTIONS_TO_CHANGE_KINDS.put(ACTION_MODIFY,
051: FSPathChangeKind.FS_PATH_CHANGE_MODIFY);
052: ACTIONS_TO_CHANGE_KINDS.put(ACTION_ADD,
053: FSPathChangeKind.FS_PATH_CHANGE_ADD);
054: ACTIONS_TO_CHANGE_KINDS.put(ACTION_DELETE,
055: FSPathChangeKind.FS_PATH_CHANGE_DELETE);
056: ACTIONS_TO_CHANGE_KINDS.put(ACTION_REPLACE,
057: FSPathChangeKind.FS_PATH_CHANGE_REPLACE);
058: ACTIONS_TO_CHANGE_KINDS.put(ACTION_RESET,
059: FSPathChangeKind.FS_PATH_CHANGE_RESET);
060: }
061:
062: private FSPathChangeKind(String name) {
063: myName = name;
064: }
065:
066: public String toString() {
067: return myName;
068: }
069:
070: public int hashCode() {
071: return myName.hashCode();
072: }
073:
074: public boolean equals(Object o) {
075: if (o == this ) {
076: return true;
077: }
078: if (o == null || o.getClass() != FSPathChangeKind.class) {
079: return false;
080: }
081: return myName.equals(((FSPathChangeKind) o).myName);
082: }
083:
084: private Object readResolve() {
085: return ACTIONS_TO_CHANGE_KINDS.get(myName);
086: }
087:
088: public static FSPathChangeKind fromString(String changeKindStr) {
089: return (FSPathChangeKind) ACTIONS_TO_CHANGE_KINDS
090: .get(changeKindStr);
091: }
092:
093: public static char getType(FSPathChangeKind kind) {
094: if (kind == FSPathChangeKind.FS_PATH_CHANGE_ADD) {
095: return SVNLogEntryPath.TYPE_ADDED;
096: } else if (kind == FSPathChangeKind.FS_PATH_CHANGE_DELETE) {
097: return SVNLogEntryPath.TYPE_DELETED;
098: } else if (kind == FSPathChangeKind.FS_PATH_CHANGE_MODIFY) {
099: return SVNLogEntryPath.TYPE_MODIFIED;
100: }
101:
102: return SVNLogEntryPath.TYPE_REPLACED;
103: }
104:
105: }
|