NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: ScalarType name already used ?

>I'm developing an application that needs to display several times the
>same data model, based on different imput files. This application
>creates a new instance of a class, let's call it VisADViewer, for each
>file. When the second instance of the class is created, the following
>exception is thrown:
>
>Visad.TypeException : ScalarType: name already used
>
>This happens in this section of my code:
>...
>RealType xRT = new RealType("latitude", null, null);
>RealType yRT = new RealType("longitude", null, null);
>RealType zRT = new RealType("temperature", null, null);
>...
>
>I have nothing declared static... in my code. Did anybody ever
>experience something like that ? Any idea to solve the problem ?
>(My first thought is that something may be declared static in the visad
>package...)

Alex,

VisAD does maintain a static Vector of ScalarTypes.  To reuse the same
ScalarType again, use the following code:

RealType xRT = (RealType) ScalarType.getScalarTypeByName("latitude");
if (xRT == null) xRT = new RealType("latitude", null, null);

This code searches the static Vector for an already existing RealType
called latitude.  If it can't find it, it creates it.

-Curtis


  • 2000 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: