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:
013: package org.tmatesoft.svn.core.io;
014:
015: import java.util.Map;
016:
017: /**
018: * The <b>SVNFileRevision</b> class represents information on what path a file
019: * is located at (in a repository) in a particular revision, contains file properties
020: * and revision properties for that revision.
021: *
022: * <p>
023: * When getting a range of file revisions (in particular, annotating),
024: * calling an <b>SVNRepository</b>'s
025: * {@link SVNRepository#getFileRevisions(String, long, long, ISVNFileRevisionHandler) getFileRevision()}
026: * <b>SVNFileRevision</b> objects are passed to an <b>ISVNFileRevisionHandler</b>'s {@link ISVNFileRevisionHandler#openRevision(SVNFileRevision) openRevision()}
027: * method.
028: *
029: * @version 1.1.1
030: * @author TMate Software Ltd.
031: * @see SVNRepository
032: * @see ISVNFileRevisionHandler
033: */
034: public class SVNFileRevision implements Comparable {
035:
036: private String myPath;
037: private long myRevision;
038:
039: /**
040: * Constructs an instance of <b>SVNFileRevision</b>.
041: *
042: * @param path a file path relative to a repository location
043: * (a URL used to create an
044: * <b>SVNRepository</b> to access a repository)
045: * @param revision a revision of the file
046: * @param properties revision properties
047: * @param propertiesDelta file properties for the <code>revision</code>
048: */
049: public SVNFileRevision(String path, long revision, Map properties,
050: Map propertiesDelta) {
051: myPath = path;
052: myRevision = revision;
053: myProperties = properties;
054: myPropertiesDelta = propertiesDelta;
055: }
056:
057: /**
058: * Gets the file path (relative to a repository root URL).
059: *
060: * @return the path of the file
061: * @see SVNRepository
062: */
063: public String getPath() {
064: return myPath;
065: }
066:
067: /**
068: * Returns revision properties. Use {@link org.tmatesoft.svn.core.SVNRevisionProperty}
069: * constants (they are revision property names) to retrieve values of the
070: * corresponding properties.
071: *
072: * @deprecated use {@link #getRevisionProperties() } instead
073: * @return a map which keys are revision property names and values
074: * are their values (both are strings)
075: */
076: public Map getProperties() {
077: return myProperties;
078: }
079:
080: /**
081: * Returns revision properties. Use {@link org.tmatesoft.svn.core.SVNRevisionProperty}
082: * constants (they are revision property names) to retrieve values of the
083: * corresponding properties.
084: *
085: * @return a map which keys are revision property names and values
086: * are their values (both are strings)
087: */
088: public Map getRevisionProperties() {
089: return myProperties;
090: }
091:
092: /**
093: * Returns file properties for this file (for this revision).
094: * Properties delta for a revision is the same as full properties for
095: * that revision.
096: *
097: * @return a map where keys are file property names and values are the
098: * property values
099: */
100: public Map getPropertiesDelta() {
101: return myPropertiesDelta;
102: }
103:
104: /**
105: * Gets the revision of the file.
106: *
107: * @return the revision number of the file
108: */
109: public long getRevision() {
110: return myRevision;
111: }
112:
113: /**
114: * Compares this object with another one.
115: *
116: * @param o an object to compare with
117: * @return <ul>
118: * <li>1 - if <code>o</code> is either <span class="javakeyword">null</span>,
119: * or is not an instance of <b>SVNFileRevision</b>, or the revision value of
120: * this object is bigger than the one of <code>o</code>;
121: * </li>
122: * <li>-1 - if the revision value of this object is smaller than the one of
123: * <code>o</code>;
124: * </li>
125: * <li>0 - if and only if the revision values of this object and <code>o</code>
126: * are the same (equal)
127: * </li>
128: * </ul>
129: */
130: public int compareTo(Object o) {
131: if (o == null || o.getClass() != SVNFileRevision.class) {
132: return 1;
133: }
134: SVNFileRevision rev = (SVNFileRevision) o;
135: long number = rev.getRevision();
136: return myRevision == number ? 0 : myRevision > number ? 1 : -1;
137: }
138:
139: private Map myProperties;
140: private Map myPropertiesDelta;
141:
142: }
|