org.eclipse.birt.data.engine.impl.document.viewing.RowIndexUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.eclipse.birt.runtime Show documentation
Show all versions of org.eclipse.birt.runtime Show documentation
A component of the BIRT runtime
/*******************************************************************************
* Copyright (c) 2004 Actuate Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Actuate Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.birt.data.engine.impl.document.viewing;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.eclipse.birt.core.util.IOUtil;
/**
* Wrap simple I/O for row index information.
*/
public class RowIndexUtil
{
private DataOutputStream rowDos;
private DataInputStream rowDis;
private static Logger logger = Logger.getLogger( RowIndexUtil.class.getName( ) );
/**
* @param rowOs
*/
public RowIndexUtil( OutputStream rowOs )
{
rowDos = new DataOutputStream( rowOs );
}
/**
* @param rowIs
*/
public RowIndexUtil( InputStream rowIs )
{
rowDis = new DataInputStream( rowIs );
}
/**
* @param rowId
* @param filterHint
*/
public void write( int rowId )
{
try
{
IOUtil.writeInt( rowDos, rowId );
}
catch ( IOException e )
{
logger.log( Level.FINE, e.getMessage( ), e );
}
}
/**
* @return
*/
public int read( )
{
try
{
return IOUtil.readInt( rowDis );
}
catch ( IOException e )
{
return -1;
}
}
/**
*
*/
public void close( )
{
try
{
if ( rowDos != null )
{
rowDos.close( );
}
if ( rowDis != null )
{
rowDis.close( );
}
}
catch ( IOException e )
{
// ignore
}
}
}