View Javadoc

1   package fr.in2p3.jsaga.impl.file.stream;
2   
3   import fr.in2p3.jsaga.adaptor.data.DataAdaptor;
4   import fr.in2p3.jsaga.adaptor.data.read.FileReaderGetter;
5   import fr.in2p3.jsaga.adaptor.data.read.FileReaderStreamFactory;
6   import fr.in2p3.jsaga.adaptor.data.write.FileWriterPutter;
7   import fr.in2p3.jsaga.adaptor.data.write.FileWriterStreamFactory;
8   import org.ogf.saga.error.*;
9   import org.ogf.saga.file.FileInputStream;
10  import org.ogf.saga.file.FileOutputStream;
11  import org.ogf.saga.session.Session;
12  import org.ogf.saga.url.URL;
13  
14  /* ***************************************************
15  * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
16  * ***             http://cc.in2p3.fr/             ***
17  * ***************************************************
18  * File:   FileStreamFactoryImpl
19  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
20  * Date:   21 mars 2008
21  * ***************************************************
22  * Description:                                      */
23  /**
24   *
25   */
26  public class FileStreamFactoryImpl {
27      public static FileInputStream newFileInputStream(Session session, URL name, DataAdaptor adaptor, boolean disconnectable) throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, DoesNotExistException, TimeoutException, NoSuccessException {
28          if (adaptor instanceof FileReaderStreamFactory) {
29              return new FileInputStreamImpl(session, name, (FileReaderStreamFactory) adaptor, disconnectable);
30          } else if (adaptor instanceof FileReaderGetter) {
31              return new FileInputStreamPipedImpl(session, name, (FileReaderGetter) adaptor, disconnectable);
32          } else {
33              throw new NotImplementedException("Not supported for this protocol: "+ name.getScheme());
34          }
35      }
36  
37      public static FileOutputStream newFileOutputStream(Session session, URL name, DataAdaptor adaptor, boolean disconnectable, boolean append, boolean exclusive) throws NotImplementedException, IncorrectURLException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, AlreadyExistsException, DoesNotExistException, TimeoutException, NoSuccessException {
38          if (adaptor instanceof FileWriterStreamFactory) {
39              return new FileOutputStreamImpl(session, name, (FileWriterStreamFactory) adaptor, disconnectable, append, exclusive);
40          } else if (adaptor instanceof FileWriterPutter) {
41              return new FileOutputStreamPipedImpl(session, name, (FileWriterPutter) adaptor, disconnectable, append, exclusive);
42          } else {
43              throw new NotImplementedException("Not supported for this protocol: "+ name.getScheme());
44          }
45      }
46  }