canonicalization

my ideal cache using guava

送分小仙女□ 提交于 2019-11-28 17:35:15
Off and on for the past few weeks I've been trying to find my ideal cache implementation using guava's MapMaker . See my previous two questions here and here to follow my thought process. Taking what I've learned, my next attempt is going to ditch soft values in favor of maximumSize and expireAfterAccess: ConcurrentMap<String, MyObject> cache = new MapMaker() .maximumSize(MAXIMUM_SIZE) .expireAfterAccess(MINUTES_TO_EXPIRY, TimeUnit.MINUTES) .makeComputingMap(loadFunction); where Function<String, MyObject> loadFunction = new Function<String, MyObject>() { @Override public MyObject apply(String

Java: XML canonicalization

倾然丶 夕夏残阳落幕 提交于 2019-11-27 12:26:31
问题 What's the easiest way to make a canonical form of a XML file in Java? Do you have some done code for that? I've found several links on the net, like this, this, and this, but I can't make it to work :/ Thanks, Ivan EDIT: I used the canonicalizer that was proposed down there, but I get strange results. To be more precize, this method doesn't delete white spaces between elements... This is what I get: <Metric xmlns="http://www.ibm.com/wsla" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

How to cryptographically hash a JSON object?

这一生的挚爱 提交于 2019-11-26 12:10:39
问题 The following question is more complex than it may first seem. Assume that I\'ve got an arbitrary JSON object, one that may contain any amount of data including other nested JSON objects. What I want is a cryptographic hash/digest of the JSON data, without regard to the actual JSON formatting itself (eg: ignoring newlines and spacing differences between the JSON tokens). The last part is a requirement, as the JSON will be generated/read by a variety of (de)serializers on a number of different