package com.perforce.p4java_ext; import java.util.ArrayList; import java.util.List; /** * Represents a single line in the permissions table. */ public class Permission { private String accessLevel; private String userGroup; private String name; private String host; private String files; public Permission() { } /** * Parse the standard line definition being returned by p4java into 5 fields. * * There isn't clear documentation that these lines are anything but * whitespace delimited at the moment. * * @param line Looks something like this: "write user * * //..." */ public Permission(String line){ List<String> parts = SpecUtils.splitLine(line); if (parts == null || parts.size() != 5) { throw new IllegalStateException("Not 5 whitespace deliminted strings in " + line); } this.accessLevel = parts.get(0); this.userGroup = parts.get(1); this.name = parts.get(2); this.host = parts.get(3); this.files = parts.get(4); } public String getAccessLevel() { return accessLevel; } public void setAccessLevel(String accessLevel) { this.accessLevel = accessLevel; } public String getUserGroup() { return userGroup; } public void setUserGroup(String userGroup) { this.userGroup = userGroup; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getHost() { return host; } public void setHost(String host) { this.host = host; } public String getFiles() { return files; } public void setFiles(String files) { this.files = files; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Permission that = (Permission) o; if (accessLevel != null ? !accessLevel.equals(that.accessLevel) : that.accessLevel != null) return false; if (files != null ? !files.equals(that.files) : that.files != null) return false; if (host != null ? !host.equals(that.host) : that.host != null) return false; if (name != null ? !name.equals(that.name) : that.name != null) return false; if (userGroup != null ? !userGroup.equals(that.userGroup) : that.userGroup != null) return false; return true; } @Override public int hashCode() { int result = accessLevel != null ? accessLevel.hashCode() : 0; result = 31 * result + (userGroup != null ? userGroup.hashCode() : 0); result = 31 * result + (name != null ? name.hashCode() : 0); result = 31 * result + (host != null ? host.hashCode() : 0); result = 31 * result + (files != null ? files.hashCode() : 0); return result; } public String asProtectionLine() { List<String> parts = new ArrayList<String>(); parts.add(accessLevel); parts.add(userGroup); parts.add(name); parts.add(host); parts.add(files); return SpecUtils.joinAndEnquote(parts); } @Override public String toString() { return "Permission{" + "accessLevel='" + accessLevel + '\'' + ", userGroup='" + userGroup + '\'' + ", name='" + name + '\'' + ", host='" + host + '\'' + ", files='" + files + '\'' + '}'; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 9086 | tjuricek |
0.1.0 Initial release of p4java_ext Mostly just contains enough of the P4 API to build the test data initializer. About 4 commands have minimal testing, so it works. Kind of. |
||
#1 | 9085 | tjuricek | First import of the project, before package refactoring. |