"this collection as an Array");
JSourceCode sourceCode = method.getSourceCode();
// create Javadoc
JDocComment comment = method.getJDocComment();
comment.appendComment("Returns the contents of the collection in an Array. ");
if (!(baseType.isPrimitive())) {
// For non-primitive types, we use the API method made for this purpose
comment.appendComment("<p>");
comment.appendComment("Note: Just in case the collection contents are changing in ");
comment.appendComment("another thread, we pass a 0-length Array of the correct type ");
comment.appendComment("into the API call. This way we <i>know</i> that the Array ");
comment.appendComment("returned is of exactly the correct length.");
String baseTypeName = baseType.toString();
if (baseType.isArray()) {
sourceCode.add(arrayType.toString() + " array = new ");
sourceCode.append(baseTypeName.substring(0, baseTypeName.length() - 2) + "[0][];");