package org.yaz4j;

import java.io.UnsupportedEncodingException;

import org.yaz4j.jni.SWIGTYPE_p_ZOOM_record_p;
import org.yaz4j.jni.SWIGTYPE_p_int;
import org.yaz4j.jni.yaz4jlib;

public class Record
{
	private SWIGTYPE_p_ZOOM_record_p record = null ;
	private ResultSet resultSet = null ;
	private boolean disposed = false;	

	Record(SWIGTYPE_p_ZOOM_record_p record, ResultSet resultSet)
	{
		this.resultSet = resultSet;
		this.record = record;
	}

	public void finalize()
	{
		Dispose();
	}
	
	public byte[] getContent()
	{
		String type = "raw";
		SWIGTYPE_p_int length = null ;	
		return yaz4jlib.ZOOM_record_get_bytes(record, type, length) ;
//		String contentString = yaz4jlib.ZOOM_record_get(record, type, length) ;
//		System.err.println("!!!!!");
//		System.err.println(contentString);
//		System.err.println(contentString.length());
//		System.err.println("!!!!!");
//		try {
//			byte[] bytes = contentString.getBytes("UTF8");
//			System.err.println(bytes.length);
//			return bytes ;
//		} catch (UnsupportedEncodingException e) {
//			throw new RuntimeException(e);
//		}
	}

	public String getSyntax()
	{
		String type = "syntax";
		SWIGTYPE_p_int length = null ;		
		String syntax = yaz4jlib.ZOOM_record_get(record, type, length);
		return syntax ;
	}
	
	public String getDatabase()
	{
		String type = "database";
		SWIGTYPE_p_int length = null ;		
		String database = yaz4jlib.ZOOM_record_get(record, type, length);
	
		return database ;
	}

	public void Dispose()
	{
		if (!disposed)
		{
			resultSet = null;
			record = null;
			disposed = true;
		}
	}
}

@@ -484,27 +484,33 @@
 spose();%0A%09%7D%0A
-%09%0A%09
+%0A        
 public byte%5B
@@ -518,43 +518,31 @@
  get
-Content()%0A%09%7B%0A%09%09String type = %22raw%22;
+(String type)%0A        %7B
 %0A%09%09S
@@ -570,17 +570,16 @@
 = null ;
-%09
 %0A%09%09retur
@@ -639,624 +639,269 @@
 ) ;%0A
-//%09%09String contentString = yaz4jlib.ZOOM_record_get(record, type, length) ;%0A//%09%09System.err.println(%22!!!!!%22);%0A//%09%09System.err.println(contentString);%0A//%09%09System.err.println(contentString.length());%0A//%09%09System.err.println(%22!!!!!%22);%0A//%09%09try %7B%0A//%09%09%09byte%5B%5D bytes = contentString.getBytes(%22UTF8%22);%0A//%09%09%09System.err.println(bytes.length);%0A//%09%09%09return bytes ;%0A//%09%09%7D catch (UnsupportedEncodingException e) %7B%0A//%09%09%09throw new RuntimeException(e);%0A//%09%09%7D%0A%09%7D%0A%0A%09public String getSyntax()%0A%09%7B%0A%09%09String type = %22syntax%22;%0A%09%09SWIGTYPE_p_int length = null ;%09%09%0A%09%09String syntax = yaz4jlib.ZOOM_record_get(record, type, length);%0A%09%09return 
+        %7D%0A%0A       %09public String render()%0A        %7B%0A                return new String(get(%22render%22));%0A        %7D%0A%0A%09public byte%5B%5D getContent()%0A%09%7B%0A                return get(%22raw%22);%0A%09%7D%0A%0A%09public String getSyntax()%0A%09%7B%0A                return new String(get(%22
 syntax
- 
+%22))
 ;%0A%09%7D
@@ -939,158 +939,55 @@
 %0A%09%7B%0A
-%09%09String type = %22database%22;%0A%09%09SWIGTYPE_p_int length = null ;%09%09%0A%09%09String database = yaz4jlib.ZOOM_record_get(record, type, length);%0A%09%0A%09%09return 
+                return new String(get(%22
 database
  ;%0A%09
@@ -982,17 +982,19 @@
 database
- 
+%22))
 ;%0A%09%7D%0A%0A%09p

Add Record.{get,render}