diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/caps/EntityCapsManager.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/caps/EntityCapsManager.java index 75ed85d1f..a0b61f40d 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/caps/EntityCapsManager.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/caps/EntityCapsManager.java @@ -281,7 +281,8 @@ private void fireCapsVerChanged() /** * Computes and returns the SHA-1 hash of the specified capsString. * - * @param capsString + * @param capsString the capabilities string that we'd like to compute a + * hash for. * * @return the SHA-1 hash of capsString or null if * generating the hash has failed. @@ -300,30 +301,54 @@ private static String capsToHash(String capsString) } } - private static String formFieldValuesToCaps(Iterator i) + /** + * Converts the form field values in the ffValuesIter into a + * caps string. + * + * @param ffValuesIter the {@link Iterator} containing the form field + * values. + * + * @return a String containing all the form field values. + */ + private static String formFieldValuesToCaps(Iterator ffValuesIter) { - String s = ""; + StringBuilder bldr = new StringBuilder(); SortedSet fvs = new TreeSet(); - for (; i.hasNext();) + + while( ffValuesIter.hasNext()) { - fvs.add(i.next()); + fvs.add(ffValuesIter.next()); } + for (String fv : fvs) { - s += fv + "<"; + bldr.append( fv + "<"); } - return s; + + return bldr.toString(); } + /** + * Calculates the ver string for the specified discoverInfo, + * identity type, name features, and extendedInfo. + * + * @param discoverInfo the {@link DiscoverInfo} we'd be creating a ver + * String for. + * @param identityType identity type (e.g. pc). + * @param identityName our identity name (the name of the application) + * @param features the list of features we'd like to encode. + * @param extendedInfo any extended information we'd like to add to the ver + * String + */ void calculateEntityCapsVersion(DiscoverInfo discoverInfo, String identityType, String identityName, List features, DataForm extendedInfo) { - String s = ""; + StringBuilder bldr = new StringBuilder(); // Add identity // FIXME language - s += "client/" + identityType + "//" + identityName + "<"; + bldr.append( "client/" + identityType + "//" + identityName + "<"); // Add features synchronized (features) @@ -336,7 +361,7 @@ void calculateEntityCapsVersion(DiscoverInfo discoverInfo, for (String f : fs) { - s += f + "<"; + bldr.append( f + "<" ); } } @@ -355,32 +380,32 @@ public int compare(FormField f1, } }); - FormField ft = null; + FormField formType = null; - for (Iterator i = extendedInfo.getFields(); i - .hasNext();) + for (Iterator fieldsIter = extendedInfo.getFields(); + fieldsIter.hasNext();) { - FormField f = i.next(); + FormField f = fieldsIter.next(); if (!f.getVariable().equals("FORM_TYPE")) { fs.add(f); } else { - ft = f; + formType = f; } } // Add FORM_TYPE values - if (ft != null) + if (formType != null) { - s += formFieldValuesToCaps(ft.getValues()); + bldr.append( formFieldValuesToCaps(formType.getValues()) ); } // Add the other values for (FormField f : fs) { - s += f.getVariable() + "<"; - s += formFieldValuesToCaps(f.getValues()); + bldr.append( f.getVariable() + "<" ); + bldr.append( formFieldValuesToCaps(f.getValues()) ); } } }