All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Modules Pages
Image.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
3import java.util.concurrent.atomic.AtomicBoolean;
4
18public abstract class Image {
22 public abstract byte[] getData();
23
27 public abstract int getWidth();
28
32 public abstract int getHeight();
33
37 public abstract ImageType getType();
38
39 private static final class CppProxy extends Image
40 {
41 private final long nativeRef;
42 private final AtomicBoolean destroyed = new AtomicBoolean(false);
43
44 private CppProxy(long nativeRef)
45 {
46 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
47 this.nativeRef = nativeRef;
48 }
49
50 private native void nativeDestroy(long nativeRef);
51 public void _djinni_private_destroy()
52 {
53 boolean destroyed = this.destroyed.getAndSet(true);
54 if (!destroyed) nativeDestroy(this.nativeRef);
55 }
56 protected void finalize() throws java.lang.Throwable
57 {
58 _djinni_private_destroy();
59 super.finalize();
60 }
61
62 // Image methods
63
64 @Override
65 public byte[] getData()
66 {
67 assert !this.destroyed.get() : "trying to use a destroyed object";
68 return native_getData(this.nativeRef);
69 }
70 private native byte[] native_getData(long _nativeRef);
71
72 @Override
73 public int getWidth()
74 {
75 assert !this.destroyed.get() : "trying to use a destroyed object";
76 return native_getWidth(this.nativeRef);
77 }
78 private native int native_getWidth(long _nativeRef);
79
80 @Override
81 public int getHeight()
82 {
83 assert !this.destroyed.get() : "trying to use a destroyed object";
84 return native_getHeight(this.nativeRef);
85 }
86 private native int native_getHeight(long _nativeRef);
87
88 @Override
89 public ImageType getType()
90 {
91 assert !this.destroyed.get() : "trying to use a destroyed object";
92 return native_getType(this.nativeRef);
93 }
94 private native ImageType native_getType(long _nativeRef);
95 }
96}