19 package org.sleuthkit.autopsy.modules.stix;
21 import java.util.List;
22 import java.util.ArrayList;
24 import org.mitre.cybox.cybox_2.OperatorTypeEnum;
29 class ObservableResult {
49 private ObservableState state = null;
50 private String description =
"";
51 private List<StixArtifactData> artifacts;
53 public ObservableResult(String a_id, String a_desc, String a_spacing,
54 ObservableState a_state, List<StixArtifactData> a_artifacts) {
56 description = a_spacing + a_id +
"\t" + a_state +
"\t" + a_desc +
"\r\n";
57 artifacts = a_artifacts;
60 public ObservableResult(OperatorTypeEnum a_operator, String a_spacing) {
61 state = ObservableState.INDETERMINATE;
62 description = a_spacing + a_operator +
"\r\n";
63 artifacts =
new ArrayList<StixArtifactData>();
66 public ObservableState getState() {
78 public boolean isTrue() {
79 return (state == ObservableState.TRUE);
90 public boolean isFalse() {
91 return (state == ObservableState.FALSE);
94 public String getDescription() {
98 public List<StixArtifactData> getArtifacts() {
108 public void addResult(ObservableResult a_result, OperatorTypeEnum a_operator) {
109 addResult(a_result.getDescription(), a_result.getState(),
110 a_result.getArtifacts(), a_operator);
120 private void addResult(String a_description, ObservableState a_state,
121 List<StixArtifactData> a_artifacts, OperatorTypeEnum a_operator) {
123 addToDesc(a_description);
125 if (a_operator == OperatorTypeEnum.AND) {
127 if (a_state == ObservableState.FALSE) {
130 state = ObservableState.FALSE;
132 }
else if (a_state == ObservableState.INDETERMINATE) {
136 if (state == ObservableState.FALSE) {
138 }
else if (state == ObservableState.TRUE) {
140 if ((artifacts == null) && (a_artifacts != null)) {
141 artifacts =
new ArrayList<StixArtifactData>();
143 if (a_artifacts != null) {
144 artifacts.addAll(a_artifacts);
148 state = ObservableState.TRUE;
149 if ((artifacts == null) && (a_artifacts != null)) {
150 artifacts =
new ArrayList<StixArtifactData>();
152 if (a_artifacts != null) {
153 artifacts.addAll(a_artifacts);
158 if (a_state == ObservableState.TRUE) {
161 state = ObservableState.TRUE;
162 if ((artifacts == null) && (a_artifacts != null)) {
163 artifacts =
new ArrayList<StixArtifactData>();
165 if (a_artifacts != null) {
166 artifacts.addAll(a_artifacts);
168 }
else if (a_state == ObservableState.INDETERMINATE) {
172 if (state == ObservableState.FALSE) {
174 }
else if (state == ObservableState.TRUE) {
178 state = ObservableState.FALSE;
191 private void addToDesc(String a_desc) {
192 if (description == null) {
193 description = a_desc;
195 description += a_desc;
ObservableState(String s)