package com.perforce.p4java_ext; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * */ public class ProtectSpec { private Map<String, Object> protectionsMap; public ProtectSpec(Map<String, Object> protectionsMap) { this.protectionsMap = protectionsMap; } public Map<String, Object> getProtectionsMap() { return protectionsMap; } public void setProtectionsMap(Map<String, Object> protectionsMap) { this.protectionsMap = protectionsMap; } /** * Returns the registered protections table keys in the protections map. * You very likely do not need to use this method, but probably want * getProtections(). */ public List<String> getProtectionsLines() { ArrayList<String> protections = new ArrayList<String>(); for (String key : getProtectionsKeys()) { protections.add((String)protectionsMap.get(key)); } return protections; } public List<Permission> getProtections() { ArrayList<Permission> protections = new ArrayList<Permission>(); for (String line : getProtectionsLines()) { protections.add(new Permission(line)); } return protections; } /** * The keys of the protections map are simply prefixed with "Protections" * and then labeled with a number. This returns all keys. * @return */ public List<String> getProtectionsKeys() { return SpecUtils.keys("Protections", protectionsMap); } public void clearProtections() { for (String key : getProtectionsKeys()){ protectionsMap.remove(key); } } public void addProtectionLine(String line) { int nextNum = getProtectionsKeys().size(); String nextKey = "Protections" + Integer.toString(nextNum, 10); protectionsMap.put(nextKey, line); } public void addPermission(Permission permission) { addProtectionLine(permission.asProtectionLine()); } }
# | 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. |