Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2009 eXo Platform SAS.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   *
   * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.exoplatform.services.jcr.ext.replication;
 
 
 import java.io.File;
Created by The eXo Platform SAS.

Author(s):
Alex Reshetnyak
Version:
$Id: FileDescriptor.java 111 2008-11-11 11:11:11Z rainf0x $
 
 
 public class ChangesFile implements Comparable<ChangesFile>
 {
   
file. The File object to file.
 
    private File file;

   
randomAccessFile. The RandomAccessFile object to file.
 
    private RandomAccessFile randomAccessFile;

   
systemId. The system identification String.
 
    private final String systemId;

   
totalPacketCount. The total packets.
 
    private final long totalPacketCount;

   
Current count.
 
    private long count = 0;

   
FileDescriptor constructor.

Parameters:
f the File object
systemId The system identification String
totalPacketCount the packet count.
 
    public ChangesFile(File fString systemIdlong totalPacketCount)
    {
       this. = f;
       this. = systemId;
       this. = totalPacketCount;
    }

   
getFile.

Returns:
File return the File object
 
    public File getFile()
    {
       return ;
    }

   
getSystemId.

Returns:
String return the system identification String
 
    public String getSystemId()
    {
       return ;
    }

   
   public int compareTo(ChangesFile o)
   {
      return .getName().compareTo(o.getFile().getName());
   }

   
Write data to file by offset.

Parameters:
offset - offset in file to store data.
data - byte[].
Throws:
java.io.IOException if IO exception occurs.
   public synchronized void write(long offsetbyte[] datathrows IOException
   {
      if ( == null)
      {
          = PrivilegedFileHelper.randomAccessFile("rw");
      }
      .seek(offset);
      .write(data);
      ++;
      if (isStored())
      {
         .close();
      }
   }

   
Is file complete.

Returns:
True if file completely written.
   public boolean isStored()
   {
      return ( == );
   }
New to GrepCode? Check out our FAQ X