forked from mbtaylor/jcdf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumericEncoding.java
More file actions
89 lines (80 loc) · 2.6 KB
/
NumericEncoding.java
File metadata and controls
89 lines (80 loc) · 2.6 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
package uk.ac.bristol.star.cdf.record;
import uk.ac.bristol.star.cdf.CdfFormatException;
/**
* Enumeration of numeric encoding values supported by CDF.
*
* @author Mark Taylor
* @since 20 Jun 2013
*/
public enum NumericEncoding {
NETWORK( Boolean.TRUE ),
SUN( Boolean.TRUE ),
NeXT( Boolean.TRUE ),
MAC( Boolean.TRUE ),
HP( Boolean.TRUE ),
SGi( Boolean.TRUE ),
IBMRS( Boolean.TRUE ),
DECSTATION( Boolean.FALSE ),
IBMPC( Boolean.FALSE ),
ALPHAOSF1( Boolean.FALSE ),
ALPHAVMSi( Boolean.FALSE ),
VAX( null ),
ALPHAVMSd( null ),
ALPHAVMSg( null );
private final Boolean isBigendian_;
/**
* Constructor.
*
* @param isBigendian TRUE for simple big-endian,
* FALSE for simple little-endian,
* null for something else
*/
NumericEncoding( Boolean isBigendian ) {
isBigendian_ = isBigendian;
}
/**
* Gives the big/little-endianness of this encoding, if that's all
* the work that has to be done.
* If the return value is non-null, then numeric values are
* encoded the same way that java does it (two's complement for
* integers and IEEE754 for floating point) with big- or little-endian
* byte ordering, according to the return value.
* Otherwise, some unspecified encoding is in operation.
*
* @return TRUE for simple big-endian, FALSE for simple little-endian,
* null for something weird
*/
public Boolean isBigendian() {
return isBigendian_;
}
/**
* Returns the encoding corresponding to the value of the
* <code>encoding</code> field of the CDF Descriptor Record.
*
* @param code encoding code
* @return encoding object
* @throws CdfFormatException if code is unknown
*/
public static NumericEncoding getEncoding( int code )
throws CdfFormatException {
switch ( code ) {
case 1: return NETWORK;
case 2: return SUN;
case 3: return VAX;
case 4: return DECSTATION;
case 5: return SGi;
case 6: return IBMPC;
case 7: return IBMRS;
case 9: return MAC;
case 11: return HP;
case 12: return NeXT;
case 13: return ALPHAOSF1;
case 14: return ALPHAVMSd;
case 15: return ALPHAVMSg;
case 16: return ALPHAVMSi;
default:
throw new CdfFormatException( "Unknown numeric encoding "
+ code );
}
}
}