source: ether_core/trunk/kit/interactifKit/zipContent/src/RemoteFileServerEvent.java @ 784

Last change on this file since 784 was 6, checked in by cbipsl, 18 years ago

ajout rep ether

  • Property svn:executable set to *
File size: 2.3 KB
Line 
1/*
2 *      <p>$Id: RemoteFileServerEvent.java,v 1.1 2001/01/15 15:38:47 pn Exp $</p><br>
3 *
4 *      <p>The class RemoteFileServerEvent describes events posted to a QueuedFileServer.</p>
5 *
6 *      @author Phillip Link
7 *      @since 1.2
8 *     
9 */
10package fr.alcatel.ether.app.common;
11
12// JDK - utils
13import java.util.ArrayList;
14
15
16
17public class RemoteFileServerEvent {
18       
19        public static final int OPEN            = 0;
20        public static final int CLOSE           = 1;
21        public static final int READ            = 2;
22        public static final int WRITE           = 3;
23        public static final int COPY            = 4;
24        public static final int MOVE            = 5;
25        public static final int DELETE  = 6;
26        public static final int LIST            = 7;
27        public static final int EXISTS  = 8;
28        public static final int SIZE            = 9;
29        public static final int RETRIEVE                = 10;
30       
31        private boolean completed = false;
32       
33        private int type;
34       
35        private Object result;
36       
37        private boolean hasResult = false;
38       
39        ArrayList args = new ArrayList( );
40       
41       
42        public RemoteFileServerEvent( int type ) {
43                init( type );
44        }
45       
46        public RemoteFileServerEvent( int type, ArrayList args ) {
47                init( type );
48                setArgs( args );
49        }
50       
51        private void init( int type ) {
52                this.type = type;
53                switch ( type ) {
54                        case COPY:
55                        case MOVE:
56                        case DELETE:
57                        case LIST:
58                        case EXISTS:
59                        case SIZE:
60                        case RETRIEVE:
61                                setHasResult( true );
62                                break;
63                        default:
64                                break;
65                }
66        }
67       
68        public int getType( ) {
69                return type;
70        }
71       
72       
73        public Object getArg( int argc ) {
74                return args.get( argc );
75        }
76       
77        public void setArgs( ArrayList params ) {
78                this.args.clear( );
79                for ( int i = 0; i < params.size(); i++ ) {
80                        this.args.add( i, params.get(i) );
81                }
82        }
83       
84       
85        public void setResult( Object result )
86        {
87                this.result = result;
88                completed = true;
89        }
90       
91        public synchronized Object getResult()
92        {
93                while ( !completed ) {
94                        try {
95                                wait( );
96                        }
97                        catch ( InterruptedException ignored ) {
98                        }
99                }
100                notify( );
101                return result;
102        }
103       
104        public void setHasResult( boolean hasResult )
105        {
106                this.hasResult = hasResult;
107        }
108
109        public boolean getHasResult( )
110        {
111                return hasResult;
112        }
113    }
Note: See TracBrowser for help on using the repository browser.