public String encodeCompressionAlgorithm(CompressionAlgorithm compressionAlgorithm) { StringBuffer s = new StringBuffer(""); String[] names = compressionAlgorithm.getCompressionAlgorithmNames(); boolean first = true; for (int i = 0; i < names.length; i++) { if (first) { first = false; } else { s.append(";"); } s.append(names[i]); } return s.toString(); }
public static int encode(byte[] destination,int offset,CompressionAlgorithm compressionAlgorithm) { String[] names = compressionAlgorithm.getCompressionAlgorithmNames(); if(names.length==0) return 0; int usedLength=0; byte[] currBytes; int i=0; for(;i<names.length-1;i++) { currBytes=names[i].getBytes(); System.arraycopy(currBytes, 0, destination, offset+usedLength, currBytes.length); usedLength+=currBytes.length; destination[offset+usedLength]=StringFunctions.SEMICOLON_BYTE; usedLength++; } currBytes=names[i].getBytes(); System.arraycopy(currBytes, 0, destination, offset+usedLength, currBytes.length); usedLength+=currBytes.length; return usedLength; } }
public static int encode(byte[] destination,int offset,CompressionAlgorithm compressionAlgorithm) { String[] names = compressionAlgorithm.getCompressionAlgorithmNames(); if(names.length==0) return 0; int usedLength=0; byte[] currBytes; int i=0; for(;i<names.length-1;i++) { currBytes=names[i].getBytes(); System.arraycopy(currBytes, 0, destination, offset+usedLength, currBytes.length); usedLength+=currBytes.length; destination[offset+usedLength]=StringFunctions.SEMICOLON_BYTE; usedLength++; } currBytes=names[i].getBytes(); System.arraycopy(currBytes, 0, destination, offset+usedLength, currBytes.length); usedLength+=currBytes.length; return usedLength; } }