1 /***
2 * Copyright (C) 2008 Jeremy Thomerson (jthomerson@users.sourceforge.net)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package net.sf.vcaperture.model;
18
19 import java.util.List;
20
21 import org.apache.commons.lang.builder.EqualsBuilder;
22 import org.apache.commons.lang.builder.HashCodeBuilder;
23
24 /***
25 * Represents a file within any repository.
26 *
27 * @author Jeremy Thomerson (jthomerson@users.sourceforge.net)
28 */
29 public class RepoFile {
30
31 private boolean mDirectory = false;
32 private String mRelativePath;
33 private String[] mRevisions;
34
35 public RepoFile() {
36
37 }
38
39 public RepoFile(RepoFile from) {
40 setDirectory(from.isDirectory());
41 setRelativePath(from.getRelativePath());
42 setRevisions(from.getRevisions());
43 }
44
45 public String getRelativePath() {
46 return mRelativePath;
47 }
48
49 public void setRelativePath(String relativePath) {
50 mRelativePath = relativePath;
51 }
52
53 public String[] getRevisions() {
54 return mRevisions;
55 }
56
57 public void setRevisions(String[] revisions) {
58 mRevisions = revisions;
59 }
60
61 public void setDirectory(boolean directory) {
62 mDirectory = directory;
63 }
64
65 public boolean isDirectory() {
66 return mDirectory;
67 }
68
69 /***
70 * @see java.lang.Object#equals(Object)
71 */
72 public boolean equals(Object object) {
73 if (!(object instanceof RepoFile)) {
74 return false;
75 }
76 RepoFile rhs = (RepoFile) object;
77 return new EqualsBuilder().appendSuper(super.equals(object)).append(this.mRevisions, rhs.mRevisions).append(this.mRelativePath,
78 rhs.mRelativePath).isEquals();
79 }
80
81 /***
82 * @see java.lang.Object#hashCode()
83 */
84 public int hashCode() {
85 return new HashCodeBuilder(613621661, -753951183).appendSuper(super.hashCode()).append(this.mRevisions).append(this.mRelativePath)
86 .toHashCode();
87 }
88
89 public List<RepoFile> getChildren(boolean showAll) {
90 throw new UnsupportedOperationException("You should probably have a subclass of this that implements this method.");
91 }
92
93 }