Java Reference
In-Depth Information
JNLP server can keep in memory the sorted list of different versions of the same logical
resource to minimize handling operations.
Note also at lines 68-91 the compareToVersionId method that compares two VersionId
instances. The normalization step (lines 72,73) ensures that the array of strings composing the
VersionId element can be effectively compared, both in their length and in neutralizing possi-
ble problems with padding zeros (so “ 1.002 ” correctly matches “ 1.2 ”).
L ISTING 12.4
The VersionId Class
12
package com.marinilli.b2.c12;
import java.util.*;
/**
* Chapter 12 - VersionIds representations
*
* A VersionId as defined in the JNLP specs. from Sun.
* An example is represented by the string '1.2.2-ea'.
*
* @author Mauro Marinilli
* @version 1.0
*/
public class VersionId extends Versionable implements Comparable {
public final static char DOT_CHAR = '.';
public final static String SEPARATORS = DOT_CHAR+”-_”;//
see JNLP specs. Appendix A
private String[] singleValues;//see JNLP specs. Appendix A
/**
* Creates a new Version Id.
* @param String s the string representing the version
*/
protected VersionId(String s) {
if (s==null)
return;
ArrayList arraylist = new ArrayList();
int i = 0;
for(int j = 0; j < s.length(); j++)
if(SEPARATORS.indexOf(s.charAt(j)) !=-1) {
if(i < j) {
String s1 = s.substring(i, j);
arraylist.add(s1);
}
i = j + 1;
}
Search WWH ::




Custom Search