Debian Codegraph @

javactn/DICOM/DICOMWrapper.java

raw
1 /*
2 * DICOMWrapper
3 */
4
5 package DICOM;
6
7 import java.util.Vector;
8
9 public class DICOMWrapper {
10 public native long newObjectJNI();
11 public native long openFileJNI(String fileName);
12 public native void closeFileJNI(long dcmObj);
13 public native int writeFileJNI(long dcmObj, String fileName);
14 public native long getLongJNI(long dcmObj, short group, short element);
15 public native int getIntJNI(long dcmObj, short group, short element);
16 public native float getFloatJNI(long dcmObj, short group, short element);
17 public native String getStringJNI(long dcmObj, short group, short element);
18 public native String getStringJNI(long dcmObj, int tag);
19 public native String getStringJNI(long dcmObj, int seqTag, int tag, int item);
20 public native int getSequenceLengthJNI(long dcmObj, short group, short element);
21 public native long getSequenceObjJNI(long dcmObj, short group, short element,
22 int index);
23 public native int attributePresentJNI(long dcmObj, int tag);
24 public native int countTagsJNI(long dcmObj);
25 public native int fillTagsJNI(long dcmObj, int tags[]);
26
27 public native int setStringJNI(long dcmObj, int tag, String s);
28 public native int setStringSeqJNI(long dcmObj, int seqTag, int tag, String s,
29 int index);
30 public native int addSequenceJNI(long dcmObj, int seqTag);
31 public native int addToSequenceJNI(long dcmObj, int seqTag, int index,
32 long newObj);
33 public native String getVRJNI(long dcmObj, int tag);
34 public native String getDescrJNI(long dcmObj, int tag);
35 public native int getLengthJNI(long dcmObj, int tag);
36
37 static {
38 System.loadLibrary("javactn");
39 }
40
41 protected long fDCMObject;
42 private int fOwnObject;
43
44 public DICOMWrapper( ) {
45 fDCMObject = newObjectJNI( );
46 fOwnObject = 1;
47 }
48
49 public DICOMWrapper(String fileName) {
50 fDCMObject = openFileJNI(fileName);
51 fOwnObject = 1;
52 }
53
54 public DICOMWrapper(long objReference) {
55 fDCMObject = objReference;
56 fOwnObject = 0;
57 }
58
59 public void close() {
60 if (fOwnObject == 1) {
61 closeFileJNI(fDCMObject);
62 fDCMObject = 0;
63 }
64 fOwnObject = 0;
65 }
66
67 public int writeFile(String fileName) {
68 return writeFileJNI(fDCMObject, fileName);
69 }
70
71 public String getString(short group, short element) {
72 return getStringJNI(fDCMObject, group, element);
73 }
74 public String getString(int tag) {
75 return getStringJNI(fDCMObject, tag);
76 }
77 public String getString(int seqTag, int tag, int item) {
78 return getStringJNI(fDCMObject, seqTag, tag, item);
79 }
80 public int getInt(short group, short element) {
81 return getIntJNI(fDCMObject, group, element);
82 }
83 public Vector getSequenceVector(short group, short element) {
84 Vector v = new Vector(3, 1);
85 return v;
86 }
87 public int attributePresent(int tag) {
88 return attributePresentJNI(fDCMObject, tag);
89 }
90
91 public int [] linearizeAttributes( ) {
92 int tagCount = countTagsJNI(fDCMObject);
93 //System.out.println("Tag count = " + tagCount);
94 int tags[] = new int[tagCount];
95 fillTagsJNI(fDCMObject, tags);
96 int i;
97 //for (i = 0; i < tagCount; i++) {
98 // Integer ix = new Integer(tags[i]);
99 // String s = ix.toString(tags[i], 16);
100 // System.out.println(" " + s);
101 //}
102 return tags;
103 }
104 public int setString(int tag, String s) {
105 return setStringJNI(fDCMObject, tag, s);
106 }
107 public int setString(int seqTag, int tag, String s, int index) {
108 return setStringSeqJNI(fDCMObject, seqTag, tag, s, index);
109 }
110 public int addSequence(int seqTag) {
111 return addSequenceJNI(fDCMObject, seqTag);
112 }
113 public int addToSequence(int seqTag, int index, DICOMWrapper w) {
114 return addToSequenceJNI(fDCMObject, seqTag, index, w.fDCMObject);
115 }
116
117 public long getObjectReference( ) {
118 return fDCMObject;
119 }
120
121 public String getVR(int tag) {
122 return getVRJNI(fDCMObject, tag);
123 }
124
125 public String getDescription(int tag) {
126 return getDescrJNI(fDCMObject, tag);
127 }
128
129 public int getLength(int tag) {
130 return getLengthJNI(fDCMObject, tag);
131 }
132
133 }