-
Notifications
You must be signed in to change notification settings - Fork 28
/
IType.java
executable file
·101 lines (91 loc) · 2.62 KB
/
IType.java
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
// Copyright (C) 2011 jOVAL.org. All rights reserved.
// This software is licensed under the AGPL 3.0 license available at http://www.joval.org/agpl_v3.txt
package org.joval.intf.oval;
import oval.schemas.common.ComplexDatatypeEnumeration;
import oval.schemas.common.SimpleDatatypeEnumeration;
import org.joval.oval.types.TypeConversionException;
/**
* Generic type interface, for both simple and complex OVAL types.
*
* @author David A. Solin
* @version %I% %G%
*/
public interface IType extends Comparable<IType> {
/**
* An enumeration mixing both simple and complex OVAL types.
*/
enum Type {
BINARY,
BOOLEAN,
EVR_STRING,
FILESET_REVISION,
FLOAT,
IOS_VERSION,
INT,
IPV_4_ADDRESS,
IPV_6_ADDRESS,
RECORD,
STRING,
VERSION;
/**
* Return the corresponding SimpleDatatypeEnumeration.
*/
public SimpleDatatypeEnumeration getSimple() throws UnsupportedOperationException {
if (this == RECORD) {
throw new UnsupportedOperationException("getSimple()");
} else {
switch(this) {
case BINARY:
return SimpleDatatypeEnumeration.BINARY;
case BOOLEAN:
return SimpleDatatypeEnumeration.BOOLEAN;
case EVR_STRING:
return SimpleDatatypeEnumeration.EVR_STRING;
case FILESET_REVISION:
return SimpleDatatypeEnumeration.FILESET_REVISION;
case FLOAT:
return SimpleDatatypeEnumeration.FLOAT;
case IOS_VERSION:
return SimpleDatatypeEnumeration.IOS_VERSION;
case INT:
return SimpleDatatypeEnumeration.INT;
case IPV_4_ADDRESS:
return SimpleDatatypeEnumeration.IPV_4_ADDRESS;
case IPV_6_ADDRESS:
return SimpleDatatypeEnumeration.IPV_6_ADDRESS;
case VERSION:
return SimpleDatatypeEnumeration.VERSION;
case STRING:
default:
return SimpleDatatypeEnumeration.STRING;
}
}
}
/**
* Return the corresponding ComplexDatatypeEnumeration.
*/
public ComplexDatatypeEnumeration getComplex() throws UnsupportedOperationException {
if (this == RECORD) {
return ComplexDatatypeEnumeration.RECORD;
} else {
throw new UnsupportedOperationException("getComplex()");
}
}
}
/**
* Get the datatype.
*/
Type getType();
/**
* Cast to another Type.
*/
IType cast(Type type) throws TypeConversionException;
/**
* Cast to another Type.
*/
IType cast(SimpleDatatypeEnumeration type) throws TypeConversionException;
/**
* @throws UnsupportedOperationException if the Type is RECORD.
*/
String getString() throws UnsupportedOperationException;
}