Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://github.com/mpoquet/simgrid
[simgrid.git] / src / bindings / java / org / simgrid / msg / Storage.java
1 /* Bindings to the MSG storage */
2
3 /* Copyright (c) 2006-2014. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 package org.simgrid.msg;
10
11 public class Storage {
12
13         /**
14          * This attribute represents a bind between a java storage object and
15          * a native storage. Even if this attribute is public you must never
16          * access to it.
17          */ 
18         private long bind;
19
20         /** Storage name */
21         protected String name;
22
23         /** User data. */ 
24         private Object data;
25         protected Storage() {
26                 this.bind = 0;
27                 this.data = null;
28         }
29
30         @Override
31         public String toString (){
32                 return this.name; 
33
34         }
35
36         /**
37          * This static method gets a storage instance associated with a native
38          * storage of your platform. This is the best way to get a java storage object.
39          *
40          * @param name          The name of the storage to get.
41          *
42          * @return              The storage object with the given name.
43          * @exception           StorageNotFoundException if the name of the storage is not valid.
44          * @exception           NativeException if the native version of this method failed.
45          */ 
46         public static native Storage getByName(String name) 
47                         throws HostNotFoundException, NullPointerException, NativeException, StorageNotFoundException;
48
49         /**
50          * This method returns the name of a storage.
51          * @return                      The name of the storage.
52          *
53          */ 
54         public String getName() {
55                 return name;
56         }
57
58         /**
59          * This method returns the size (in bytes) of a storage element.
60          *
61          * @return      The size (in bytes) of the storage element.
62          *
63          */ 
64         public native long getSize();
65
66         /**
67          * This method returns the free size (in bytes) of a storage element.
68          *
69          * @return      The free size (in bytes) of the storage element.
70          *
71          */ 
72         public native long getFreeSize();
73
74         /**
75          * This method returns the used size (in bytes) of a storage element.
76          *
77          * @return      The used size (in bytes) of the storage element.
78          *
79          */ 
80         public native long getUsedSize();
81
82         /**
83          * Returns the value of a given storage property. 
84          */
85         public native String getProperty(String name);
86
87         /**
88          * Change the value of a given storage property. 
89          */
90         public native void setProperty(String name, String value);
91
92
93         /** 
94          *
95          * Returns the host name the storage is attached to
96          *
97          * @return      the host name the storage is attached to
98          */
99         public native String getHost();
100
101         /**
102          * This static method returns all of the storages of the installed platform.
103          *
104          * @return                      An array containing all the storages installed.
105          *
106          */ 
107         public static native Storage[] all();
108
109         /**
110          * Class initializer, to initialize various JNI stuff
111          */
112         public static native void nativeInit();
113         static {
114                 nativeInit();
115         }               
116
117 }