-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathStorageParameters.java
More file actions
115 lines (99 loc) · 2.85 KB
/
StorageParameters.java
File metadata and controls
115 lines (99 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package PamController;
import java.io.Serializable;
import java.util.ArrayList;
import PamguardMVC.PamDataBlock;
public class StorageParameters implements Cloneable, Serializable {
public static final long serialVersionUID = 1L;
private ArrayList<StoreChoice> storeChoices = new ArrayList<StoreChoice>();
@Override
public StorageParameters clone() {
try {
return (StorageParameters) super.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
return null;
}
}
public void setStorageOptions(PamDataBlock pamDataBlock, boolean storeDatabase, boolean storeBinary) {
setStorageOptions(pamDataBlock.getLongDataName(), storeDatabase, storeBinary);
}
private void setStorageOptions(String dataName, boolean storeDatabase, boolean storeBinary) {
StoreChoice storeChoice = findStoreChoice(dataName);
if (storeChoice == null) {
storeChoice = new StoreChoice(dataName);
storeChoices.add(storeChoice);
}
storeChoice.binaryStore = storeBinary;
storeChoice.database = storeDatabase;
}
public boolean isStoreDatabase(PamDataBlock pamDataBlock, boolean def) {
return isStoreDatabase(pamDataBlock.getLongDataName(), def);
}
private boolean isStoreDatabase(String dataName, boolean def) {
StoreChoice storeChoice = findStoreChoice(dataName);
if (storeChoice == null) {
return def;
}
return storeChoice.database;
}
public boolean isStoreBinary(PamDataBlock pamDataBlock, boolean def) {
return isStoreBinary(pamDataBlock.getLongDataName(), def);
}
private boolean isStoreBinary(String dataName, boolean def) {
StoreChoice storeChoice = findStoreChoice(dataName);
if (storeChoice == null) {
return def;
}
return storeChoice.binaryStore;
}
public StoreChoice findStoreChoice(PamDataBlock pamDataBlock) {
return findStoreChoice(pamDataBlock.getLongDataName());
}
private StoreChoice findStoreChoice(String dataName) {
for (int i = 0; i < storeChoices.size(); i++) {
if (storeChoices.get(i).dataName.equals(dataName)) {
return storeChoices.get(i);
}
}
return null;
}
public class StoreChoice implements Cloneable, Serializable {
private static final long serialVersionUID = 1L;
public StoreChoice(String dataName) {
this.dataName = dataName;
}
private String dataName;
private boolean database;
private boolean binaryStore;
/**
* @return the dataName
*/
public String getDataName() {
return dataName;
}
/**
* @param dataName the dataName to set
*/
public void setDataName(String dataName) {
this.dataName = dataName;
}
/**
* @return the database
*/
public boolean isDatabase() {
return database;
}
/**
* @param database the database to set
*/
public void setDatabase(boolean database) {
this.database = database;
}
/**
* @return the binaryStore
*/
public boolean isBinaryStore() {
return binaryStore;
}
}
}