java.lang.Object
org.klomp.snark.web.BridgeVersion
Version helpers for the I2PSnark Bridge extension: reads the version from the manifest.json inside the bundled XPI, and compares dotted extension versions numerically so the router can tell whether the installed extension is current.
Field Summary
Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionstatic intCompares two dotted version strings numerically by segment; missing or non-numeric segments count as 0.(package private) static StringextractVersion(String json) Extracts the "version" string from extension manifest JSON without a JSON parser, by locating the version key and reading the quoted value after it.static booleanisUpdateAvailable(String installed, String bundled) Whether an update to the bundled version is available for the installed one.static StringReads the "version" field from the manifest.json inside a zipped XPI.private static intThe leading digits of one part, 0 if there are none.private static String[]Splits a version string on dots, empty if it is null.
Field Details
HEADER
The HTTP header the extension adds to router requests to self-report.- See Also:
Constructor Details
BridgeVersion
private BridgeVersion()Utility class, not intended for instantiation.
Method Details
readXpiVersion
Reads the "version" field from the manifest.json inside a zipped XPI.- Parameters:
xpi- the open XPI stream; closed by this method. May be null.- Returns:
- the version string, or null if it cannot be determined
extractVersion
compare
Compares two dotted version strings numerically by segment; missing or non-numeric segments count as 0. "0.1.1" > "0.1.0", "0.1.10" > "0.1.9", "1.0" > "0.9.99".- Parameters:
a- first version, may be nullb- second version, may be null- Returns:
- negative if a is older, zero if equal, positive if a is newer
isUpdateAvailable
Whether an update to the bundled version is available for the installed one.- Parameters:
installed- the version reported by the extension, may be nullbundled- the version bundled in this war, may be null- Returns:
- true if installed is older than bundled
split
segment
The leading digits of one part, 0 if there are none.- Parameters:
parts- the version partsi- which part to read- Returns:
- the value of those digits