Turns out that ArrayString was added a few years back but it was not
integrated throughout the netCDF-Java library. In particular, it is not
used in any of the code that actually writes netCDF files.
For an Array of Strings, it is best to use the ArrayObject that is returned
when you call Array.factory(DataType.String, ...). The
Array.getElementType() function will return the correct DataType from any
Sorry for the confusion and the documentation that may not be clear. We
will double check the documentation and try to clarify. In the longer term,
we will be reviewing the design of ucar.ma2.Array and subclasses  and
work to make things a bit more consistent.
On Mon, Dec 15, 2014 at 5:20 PM, Ethan Davis <edavis@xxxxxxxx> wrote:
> Hi Rodrigo,
> I think the problem is that when ArrayString was added a few years back
> the Array.factory() method was not modified to handle it. I have added an
> issue for this  to our issue tracking system. You can "watch" this issue
> if you wish to follow our progress. I don't think a fix for this issue will
> make it into netCDF-Java/CDM 4.5.4 which is already in the process of being
> The ArrayString.factory() method is what should get called when
> Array.factory(DataType.STRING, ...) is called. So, the only risk in calling
> it directly is that it isn't a public method which means you'll have to
> kludge things a bit to call it. And, as a non-public method we don't really
> guarantee its existence like we do public methods.
>  https://bugtracking.unidata.ucar.edu/browse/TDS-614
> On Fri, Dec 12, 2014 at 8:38 AM, Rodrigo Botafogo <
> rodrigo@xxxxxxxxxxxxxxxxxxx> wrote:
>> I´m using netcdfAll version 4.5 (I think that it is actually 4.5.0) .
>> This is not the latest version. I cannot use the newer version as I´m also
>> using Renjin and it has an old version of Guava. It seems that this is not
>> the problem, but just in case.
>> My problem: I´m trying to create an ArrayString by calling Array.factory
>> giving it a dtype, a shape and a java string array. I´m getting back an
>> ArrayObject and not an ArrayString. Looking at netcdf code on github I see
>> that factory calls:
>> return ArrayObject.factory(classType, indexCalc, (Object) storage);
>> So, it seems that it is actually building an ArrayObject and not an
>> ArrayString. In my case, I think I really need an ArrayString. I was able
>> to create an ArrayString with a given storage by using what seems to be a
>> non public interface:
>> index = Index.factory(int)
>> ArrayString.factory(index, <shape>, <storage>)
>> Can you tell me the risk of doing this? Did I do something wrong?
>> Rodrigo Botafogo
>> netcdf-java mailing list
>> For list information or to unsubscribe, visit: