View Javadoc

1   /*
2   Karma core - Core of the Karma application
3   Copyright (C) 2004  Toolforge <www.toolforge.nl>
4   
5   This library is free software; you can redistribute it and/or
6   modify it under the terms of the GNU Lesser General Public
7   License as published by the Free Software Foundation; either
8   version 2.1 of the License, or (at your option) any later version.
9   
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  Lesser General Public License for more details.
14  
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19  package nl.toolforge.karma.core.vc;
20  
21  import nl.toolforge.karma.core.location.BaseLocation;
22  import nl.toolforge.karma.core.location.LocationType;
23  
24  /***
25   * <p>A reference for a VCS (Version Control System). Everybody knows what a version
26   * control system is (otherwise you are not entitled to use this codebase anyway ...),
27   * so I'll stick to this message as a documentation snippet for this interface.
28   *
29   * <p>
30   *
31   * @author D.A. Smedes
32   * @version $Id: VersionControlSystem.java,v 1.11 2004/11/02 22:26:44 asmedes Exp $
33   */
34  public abstract class VersionControlSystem extends BaseLocation {
35  
36    private String host = null;
37    private String username = null;
38    private String protocol = null;
39    private int port = -1;
40    private String repository = null;
41  
42    private String offset;
43  
44    public VersionControlSystem(String id, LocationType type) {
45      super(id, type);
46    }
47  
48    public void setHost(String host) {
49      this.host = host;
50    }
51  
52  
53    public String getHost() {
54      return host;
55    }
56  
57    /***
58     * The protocol determines the way a client can communicate to a version control system.
59     *
60     * @param protocol The protocol for the version control system.
61     */
62    public void setProtocol(String protocol) {
63      this.protocol = protocol;
64    }
65  
66  
67    public String getProtocol() {
68      return protocol;
69    }
70  
71  
72    public void setPort(int port) {
73      this.port = port;
74    }
75  
76    /***
77     * Sets the server port. When <code>port</code> is not a number, <code>-1</code> is set.
78     *
79     * @param port
80     */
81    public void setPort(String port) {
82  
83      try {
84        setPort(Integer.parseInt(port));
85      } catch (NumberFormatException n) {
86        setPort(-1);
87      }
88    }
89  
90    public int getPort() {
91      return port;
92    }
93  
94  
95    public void setOffset(String offset) {
96      this.offset = offset;
97    }
98  
99    public String getModuleOffset() {
100     if ("".equals(offset)) {
101       return null;
102     }
103     return offset;
104   }
105 
106   public void setRepository(String repository) {
107 
108     if ((repository == null) || (repository.length() == 0)) {
109       throw new IllegalArgumentException("Repository cannot be null.");
110     }
111 
112     this.repository = repository;
113   }
114 
115 
116   public String getRepository() {
117     return repository;
118   }
119 
120 
121   public void setUsername(String username) {
122 
123     if ((username == null) || (username.length() == 0)) {
124       throw new IllegalArgumentException("Username cannot be null.");
125     }
126     this.username = username;
127   }
128 
129   public String getUsername() {
130     return username;
131   }
132 
133 
134 }