/* (non-Javadoc)
@see ca.mjdsystems.jmatio.io.DataOutputStream#write(java.nio.ByteBuffer)
4172
public void write( ByteBuffer byteBuffer ) throws IOException
    {
        byte[] tmp = new byte[BUFFER_SIZE]; 
        
        while ( byteBuffer.hasRemaining() )
        {
            int length = Math.min( byteBuffer.remaining(), tmp.length );
            byteBuffer.get( tmp, 0, length);
            write(tmp, 0, length);
        }
    }
505928
@Override
  public void write(byte[] b, int off, int len) {
    write(new String(b, off, len));
  }
1058937
public final void writeToBuffer(T t, byte[] buffer) {
        if (t == null) {
            throw new InvalidArgument("cannot write a null");
        } else if (buffer == null) {
            throw new InvalidArgument("cannot write to a null buffer");
        } else if (buffer.length != recordSize) {
            final String fmt = "invalid buffer (%d bytes, expected %d)";
            final String msg = format(fmt, buffer.length, recordSize);
            throw new InvalidArgument(msg);
        }
        writeTo(t, buffer);
    }
34507
@Override
  public void write(byte[] b, int off, int len) throws IOException {
    inner.write(b, off, len);
  }
824039
@Override
  public void write(byte []buf, int offset, int length, boolean isEnd)
    throws IOException
  {
    OutputStream stream = getStream();

    if (stream == null) {
      return;
    }

    synchronized (stream) {
      stream.write(buf, offset, length);
      
      if (isEnd) {
        stream.flush();
      }
    }
  }
587131
@Override
    public void write(byte[] b, int offset, int length) throws IOException {
        if (length == 0) {
            return;
        }
        int newcount = count + length;
        if (newcount > buf.length) {
            buf = Arrays.copyOf(buf, oversize(newcount));
        }
        System.arraycopy(b, offset, buf, count, length);
        count = newcount;
    }
740743
public void write(byte[] b, int off, int len) throws IOException
	{
		if (b == null)
			throw new NullPointerException();
		if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length)
			|| ((off + len) < 0))
			throw new IndexOutOfBoundsException();
		p.writeBytes(b, off, len);
	}
340550
public void write(byte []buf, int offset, int length, boolean isEnd)
    throws IOException
  {
    if (_stream != null)
      _stream.write(buf, offset, length, isEnd);
  }
600468
public void write(DataOutput out) throws IOException {
        WritableUtils.writeVInt(out, length);
        out.write(bytes, 0, length);
    }
303858
@Override
	public void writeTo(ByteBuffer buffer) {
	//field->id
	int id=0;
	id=getId();
	buffer.writeInt(id);
	//field->name
	String name=null;
	name=getName();
	if (name!=null){
	buffer.writeBoolean(true);
	buffer.writeUTF(name);
	}else{	buffer.writeBoolean(false);}
	//field->time
	Date time=null;
	time=getTime();
	if (time!=null){
	buffer.writeBoolean(true);
	buffer.writeLong(time.getTime());
	}else{	buffer.writeBoolean(false);}
	//field->age
	Integer age=null;
	age=getAge();
	if (age!=null){
	buffer.writeBoolean(true);
	buffer.writeInt(age);
	}else{	buffer.writeBoolean(false);}
	//field->array
	int[] array=null;
	array=getArray();
	if (array!=null){
	buffer.writeBoolean(true);
	int array_l=array.length;
	buffer.writeInt(array_l);
	for(int array_i=0;array_i<array_l;array_i++){
	int array_d=array[array_i];
	buffer.writeInt(array_d);
	}
	}else{	buffer.writeBoolean(false);}
	//field->listArray
	List<int[]> listArray=null;
	listArray=getListArray();
	if (listArray!=null){
	buffer.writeBoolean(true);
	int listArray_ls=listArray.size();
	buffer.writeInt(listArray_ls);
	for(int[] listArray_lv:listArray){
	int listArray_lv_l=listArray_lv.length;
	buffer.writeInt(listArray_lv_l);
	for(int listArray_lv_i=0;listArray_lv_i<listArray_lv_l;listArray_lv_i++){
	int listArray_lv_d=listArray_lv[listArray_lv_i];
	buffer.writeInt(listArray_lv_d);
	}
	}
	}else{	buffer.writeBoolean(false);}
	//field->setArray
	Set<java.lang.Integer[]> setArray=null;
	setArray=getSetArray();
	if (setArray!=null){
	buffer.writeBoolean(true);
	int setArray_ls=setArray.size();
	buffer.writeInt(setArray_ls);
	for(Integer[] setArray_lv:setArray){
	int setArray_lv_l=setArray_lv.length;
	buffer.writeInt(setArray_lv_l);
	for(int setArray_lv_i=0;setArray_lv_i<setArray_lv_l;setArray_lv_i++){
	Integer setArray_lv_d=setArray_lv[setArray_lv_i];
	buffer.writeInt(setArray_lv_d);
	}
	}
	}else{	buffer.writeBoolean(false);}
	//field->queues
	Queue<java.lang.Byte[]> queues=null;
	queues=getQueues();
	if (queues!=null){
	buffer.writeBoolean(true);
	int queues_ls=queues.size();
	buffer.writeInt(queues_ls);
	for(Byte[] queues_lv:queues){
	int queues_lv_l=queues_lv.length;
	buffer.writeInt(queues_lv_l);
	for(int queues_lv_i=0;queues_lv_i<queues_lv_l;queues_lv_i++){
	Byte queues_lv_d=queues_lv[queues_lv_i];
	buffer.writeByte(queues_lv_d);
	}
	}
	}else{	buffer.writeBoolean(false);}
	//field->map
	Map<java.util.List<int[]>,java.util.Set<java.lang.Integer>> map=null;
	map=getMap();
	if (map!=null){
	buffer.writeBoolean(true);
	int map_ms=map.size();
	buffer.writeInt(map_ms);
	for(List<int[]> map_mk:map.keySet()){
	Set<java.lang.Integer> map_mv=map.get(map_mk);
	int map_mk_ls=map_mk.size();
	buffer.writeInt(map_mk_ls);
	for(int[] map_mk_lv:map_mk){
	int map_mk_lv_l=map_mk_lv.length;
	buffer.writeInt(map_mk_lv_l);
	for(int map_mk_lv_i=0;map_mk_lv_i<map_mk_lv_l;map_mk_lv_i++){
	int map_mk_lv_d=map_mk_lv[map_mk_lv_i];
	buffer.writeInt(map_mk_lv_d);
	}
	}
	int map_mv_ls=map_mv.size();
	buffer.writeInt(map_mv_ls);
	for(Integer map_mv_lv:map_mv){
	buffer.writeInt(map_mv_lv);
	}
	}
	}else{	buffer.writeBoolean(false);}
	}
683498
@Override
    public void write(DataOutput out)
            throws IOException {
        ensureTextSet();
        // Write a variable int with the length
        WritableUtils.writeVInt(out, _text.limit());
        // Write the bytes.  For efficiency directly access the buffer's array.
        out.write(_text.array(), 0, _text.limit());
    }
441030
@Override
  public void write(byte []buffer, int offset, int length)
    throws IOException
  {
    _stream.write(buffer, offset, length, false);
  }
207718
public void write(byte[] buf, int offset, int length) throws IOException
    {
        if (length>_buffer.capacity())
            _flush=ByteBuffer.wrap(buf,offset,length);
        else
         {
             _buffer.clear();
             _buffer.put(buf,offset,length);
             _buffer.flip();
             _flush=_buffer;
         }
         flushBuffer();
    }
904849
public void write(byte []buffer, int offset, int length, boolean isEnd)
    throws IOException
  {
    _crc = Crc64.generate(_crc, buffer, offset, length);
    
    _next.write(buffer, offset, length, isEnd);
  }
402929
@Override
	public void write(byte[] b, int off, int len) {
		this.checkIncreaseArray(len);
		System.arraycopy(b, off, this.buffer, this.pos, len);
		this.pos += len;
	}
500630
public void write(ByteArrayBuffer buf) {
        data.copy(buf.data, 0, pointer, buf.length());
        pointer += buf.length();
    }
644258
private void writeBufferedData() throws IOException {
        if (buffer.length() > 0) {
            out.write(formatMessage(buffer.toString()).getBytes());
            out.write('\n');
            buffer = new StringBuffer();
        }
    }