/** * Given the map of manifest file asserted file paths and checksums, along with the checksum algorithm, * this method returns a List of Pair objects, whose keys are the file path with file system's specific File Separators, * and values are ChecksumImpl objects. * * @param fileChecksumMap * @param alg * @return */ protected List<Pair<String, Checksum>> parseData(Map<String, String> fileChecksumMap, String alg) { List<Pair<String, Checksum>> checksumPairList = new ArrayList<Pair<String, Checksum>>(); for (String key : fileChecksumMap.keySet()) { String checksumValue = fileChecksumMap.get(key); key = key.replace("/", File.separator); checksumPairList.add(new Pair<String, Checksum>(key, new ChecksumImpl(alg, checksumValue))); } return checksumPairList; }
/** * Given the map of manifest file asserted file paths and checksums, along with the checksum algorithm, * this method returns a List of Pair objects, whose keys are the file path with file system's specific File Separators, * and values are ChecksumImpl objects. * * @param fileChecksumMap * @param alg * @return */ protected List<Pair<String, Checksum>> parseData(Map<String, String> fileChecksumMap, String alg) { List<Pair<String, Checksum>> checksumPairList = new ArrayList<Pair<String, Checksum>>(); for (String key : fileChecksumMap.keySet()) { String checksumValue = fileChecksumMap.get(key); key = key.replace("/", File.separator); checksumPairList.add(new Pair<String, Checksum>(key, new ChecksumImpl(alg, checksumValue))); } return checksumPairList; }
public Pair<T,U> deserialize(String serializedString) throws IllegalArgumentException{ String keyString = null; String valueString = null; boolean escaped = false; boolean delimiterFound = false; for(int i = 0, n = serializedString.length() ; i < n ; i++) { char c = serializedString.charAt(i); if (!escaped && c == delimiter) { keyString = unescapeString(serializedString.substring(0, i)); valueString = serializedString.substring(i + 1); delimiterFound = true; break; } if (!escaped && c == escapeChar) { escaped = true; } else { escaped = false; } } if(!delimiterFound){ throw new IllegalArgumentException("Could not deserialize the string " + serializedString); } return new Pair(stringSerializerT.deserialize(keyString),stringSerializerU.deserialize(valueString)); }
Pair<String, Checksum> pair = new Pair<String, Checksum>(file.getPath(), fileChecksum); attributes.add(new AttributeImpl("Calculated-Checksum", AttributeValueType.PAIR, fileChecksumPairSerializer.serialize(pair))); Pair<String, Checksum> shaEntry = new Pair<String, Checksum>(file.getPath(), shaChecksum); attributes.add(new AttributeImpl("Calculated-Checksum", AttributeValueType.PAIR, fileChecksumPairSerializer.serialize(shaEntry))); } catch (Exception e) {