Using java czml-writer


I'm trying to figure out the java version of czml-writer. Is there a
short tutorial or piece of code that uses this package? I've read
through a few of the unit tests and the code seems to be doing explicit
memory management!?! What is the point of this construct:

PositionCesiumWriter interval = position.openInterval();
try {
    // use it
} finallay {

It would help if I could read the source of DisposeHelper, but I
couldn't find it.


Hi Evan,

That code was generated by our C# -> Java translator, and it is correct but not especially clear. It’s not doing explicit memory management, but rather closing the interval that was opened on the first line. Here’s some equivalent (but clearer) code:

PositionCesiumWriter interval = position.openInterval();

// use it


More background, if you’re curious… In C#, we wrote this:

using (PositionCesiumWriter interval = position.OpenInterval())


// use it


This “using” construct guarantees that the interval is closed (by calling a method called Dispose) when execution leaves the block, even if it does so as a result of an exception. The try/finally you see in the Java version is the closest equivalent to that C# code. C# will call that Dispose method even if the static type it is used with does not implement IDisposable, but the runtime type does. DisposeHelper.dispose implements the same thing in Java.