r642 - in trunk/lutinvcs/core/src/main/java/org/codelutin/vcs: . type util
Author: tchemit Date: 2008-04-27 12:55:51 +0000 (Sun, 27 Apr 2008) New Revision: 642 Added: trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSRootConfig.java trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/type/VCSRootConfigProperty.java trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/SimpleVCSRootConfig.java Log: introduce VCSRootConfig to represent a remote vcs host with a repository, no authentication is deal here. Added: trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSRootConfig.java =================================================================== --- trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSRootConfig.java (rev 0) +++ trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSRootConfig.java 2008-04-27 12:55:51 UTC (rev 642) @@ -0,0 +1,48 @@ +/** + * # #% Copyright (C) 2008 Code Lutin, Tony Chemit + * This program is free software; you + * can redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place + * - Suite 330, Boston, MA 02111-1307, USA. + * # #% + */ +package org.codelutin.vcs; + +import org.codelutin.util.config.Config; +import org.codelutin.vcs.type.VCSRootConfigProperty; + +/** + * Definition of a vcs root config comparable on his name. + * + * @author chemit + * @see VCSRootConfigProperty + * @see Config + */ +public interface VCSRootConfig extends Comparable<VCSRootConfig>, Config<VCSRootConfigProperty> { + + String getName(); + + String getType(); + + String getHost(); + + String getRepository(); + + Integer getPort(); + + void setName(String name); + + void setType(String type); + + void setHost(String host); + + void setPort(Integer port); + + void setRepository(String repository); +} Copied: trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/type/VCSRootConfigProperty.java (from rev 640, trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/type/VCSConnexionMode.java) =================================================================== --- trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/type/VCSRootConfigProperty.java (rev 0) +++ trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/type/VCSRootConfigProperty.java 2008-04-27 12:55:51 UTC (rev 642) @@ -0,0 +1,42 @@ +/** + * ##% Copyright (C) 2008 Code Lutin, Tony Chemit + * This program is free software; you + * can redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place + * - Suite 330, Boston, MA 02111-1307, USA. + * ##% + */ +package org.codelutin.vcs.type; + +import org.codelutin.vcs.VCSRootConfig; + +/** + * Enumaration of properties to be used in a {@link VCSRootConfig} + * + * @author chemit + * @see VCSRootConfig + */ +public enum VCSRootConfigProperty { + + /** property <code>name</code>, unique name of the root definition */ + name, + + /** property <code>type</code>, type of the root (eg, CVS,...), should match the name of a {@link org.codelutin.vcs.VCSProvider} */ + type, + + /** property <code>host</code>, host of the root (eg labs.libreentreprise.org), with no protocol information */ + host, + + /** property <code>repository</code>, relative path of vcs root on host (eg cvsroot/myModule) */ + repository, + + /** property <code>port</code>, the port used (if null, will use default vcs type port) */ + port + +} \ No newline at end of file Added: trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/SimpleVCSRootConfig.java =================================================================== --- trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/SimpleVCSRootConfig.java (rev 0) +++ trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/SimpleVCSRootConfig.java 2008-04-27 12:55:51 UTC (rev 642) @@ -0,0 +1,111 @@ +/** + * # #% Copyright (C) 2008 Code Lutin, Tony Chemit + * This program is free software; you + * can redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place + * - Suite 330, Boston, MA 02111-1307, USA. + * # #% + */ +package org.codelutin.vcs.util; + +import org.codelutin.util.config.SimpleConfig; +import org.codelutin.vcs.VCSRootConfig; +import org.codelutin.vcs.type.VCSRootConfigProperty; +import static org.codelutin.vcs.type.VCSRootConfigProperty.host; +import static org.codelutin.vcs.type.VCSRootConfigProperty.name; +import static org.codelutin.vcs.type.VCSRootConfigProperty.port; +import static org.codelutin.vcs.type.VCSRootConfigProperty.repository; +import static org.codelutin.vcs.type.VCSRootConfigProperty.type; + +import java.util.EnumMap; + +/** @author chemit */ +public class SimpleVCSRootConfig extends SimpleConfig<VCSRootConfigProperty> implements VCSRootConfig { + + public SimpleVCSRootConfig() { + super(VCSRootConfigProperty.class); + } + + public SimpleVCSRootConfig(EnumMap<VCSRootConfigProperty, Object> properties) { + super(VCSRootConfigProperty.class, properties); + } + + public SimpleVCSRootConfig(String name, String type, String host, String repository, Integer port) { + this(); + setName(name); + setType(type); + setHost(host); + setRepository(repository); + setPort(port); + } + + public String getName() { + return (String) properties.get(name); + } + + public String getType() { + return (String) properties.get(type); + } + + public String getHost() { + return (String) properties.get(host); + } + + public Integer getPort() { + return (Integer) properties.get(port); + } + + public String getRepository() { + return (String) properties.get(repository); + } + + public void setName(String newName) { + setProperty(name, newName); + } + + public void setType(String newType) { + setProperty(type, newType); + } + + public void setHost(String newHost) { + setProperty(host, newHost); + } + + public void setPort(Integer newPort) { + setProperty(port, newPort); + } + + public void setRepository(String newRepository) { + setProperty(repository, newRepository); + } + + public int compareTo(VCSRootConfig o) { + String name = getName(); + String oName = o.getName(); + return name == null ? -1 : oName == null ? 1 : name.compareTo(oName); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof SimpleConfig)) return false; + + SimpleVCSRootConfig that = (SimpleVCSRootConfig) o; + String name = getName(); + String oName = that.getName(); + return !(name != null ? !name.equals(oName) : oName != null); + } + + @Override + public int hashCode() { + String name = getName(); + return (name != null ? name.hashCode() : 0); + } + +} \ No newline at end of file
participants (1)
-
tchemit@users.labs.libre-entreprise.org