Add Record.{get,render}
[yaz4j-moved-to-github.git] / src / main / java / org / yaz4j / Record.java
1 package org.yaz4j;
2
3 import java.io.UnsupportedEncodingException;
4
5 import org.yaz4j.jni.SWIGTYPE_p_ZOOM_record_p;
6 import org.yaz4j.jni.SWIGTYPE_p_int;
7 import org.yaz4j.jni.yaz4jlib;
8
9 public class Record
10 {
11         private SWIGTYPE_p_ZOOM_record_p record = null ;
12         private ResultSet resultSet = null ;
13         private boolean disposed = false;       
14
15         Record(SWIGTYPE_p_ZOOM_record_p record, ResultSet resultSet)
16         {
17                 this.resultSet = resultSet;
18                 this.record = record;
19         }
20
21         public void finalize()
22         {
23                 Dispose();
24         }
25
26         public byte[] get(String type)
27         {
28                 SWIGTYPE_p_int length = null ;
29                 return yaz4jlib.ZOOM_record_get_bytes(record, type, length) ;
30         }
31
32         public String render()
33         {
34                 return new String(get("render"));
35         }
36
37         public byte[] getContent()
38         {
39                 return get("raw");
40         }
41
42         public String getSyntax()
43         {
44                 return new String(get("syntax"));
45         }
46         
47         public String getDatabase()
48         {
49                 return new String(get("database"));
50         }
51
52         public void Dispose()
53         {
54                 if (!disposed)
55                 {
56                         resultSet = null;
57                         record = null;
58                         disposed = true;
59                 }
60         }
61 }