View Javadoc

1   package org.apache.maven.scm;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.Serializable;
23  
24  /**
25   * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
26   *
27   */
28  public class ScmFile
29      implements Comparable<ScmFile>, Serializable
30  {
31      private static final long serialVersionUID = -9133015730693522690L;
32  
33      private String path;
34  
35      private ScmFileStatus status;
36  
37      /**
38       * @param path   The relative path of the file, should <b>never</b> start with any {@link java.io.File#separator}.
39       * @param status The file status
40       */
41      public ScmFile( String path, ScmFileStatus status )
42      {
43          this.path = path;
44  
45          this.status = status;
46      }
47  
48      /**
49       * Returns the relative path of the file.
50       * 
51       * @return the file path
52       */
53      public String getPath()
54      {
55          return path;
56      }
57  
58      /**
59       * @return The file status
60       */
61      public ScmFileStatus getStatus()
62      {
63          return status;
64      }
65  
66      // ----------------------------------------------------------------------
67      // Comparable Implementation
68      // ----------------------------------------------------------------------
69  
70      /** {@inheritDoc} */
71      public int compareTo( ScmFile other )
72      {
73          return other.getPath().compareTo( path );
74      }
75  
76      // ----------------------------------------------------------------------
77      // Object overrides
78      // ----------------------------------------------------------------------
79  
80      /** {@inheritDoc} */
81      public boolean equals( Object other )
82      {
83          if ( !( other instanceof ScmFile ) )
84          {
85              return false;
86          }
87  
88          return ( (ScmFile) other ).getPath().equals( path );
89      }
90  
91      /** {@inheritDoc} */
92      public int hashCode()
93      {
94          return path.hashCode();
95      }
96  
97      /** {@inheritDoc} */
98      public String toString()
99      {
100         return "[" + path + ":" + status + "]";
101     }
102 }