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);
121 private void addResult(String a_description, ObservableState a_state,
122 List<StixArtifactData> a_artifacts, OperatorTypeEnum a_operator) {
124 addToDesc(a_description);
126 if (a_operator == OperatorTypeEnum.AND) {
128 if (a_state == ObservableState.FALSE) {
131 state = ObservableState.FALSE;
133 }
else if (a_state == ObservableState.INDETERMINATE) {
137 if (state == ObservableState.FALSE) {
139 }
else if (state == ObservableState.TRUE) {
141 if ((artifacts == null) && (a_artifacts != null)) {
142 artifacts =
new ArrayList<StixArtifactData>();
144 if (a_artifacts != null) {
145 artifacts.addAll(a_artifacts);
149 state = ObservableState.TRUE;
150 if ((artifacts == null) && (a_artifacts != null)) {
151 artifacts =
new ArrayList<StixArtifactData>();
153 if (a_artifacts != null) {
154 artifacts.addAll(a_artifacts);
159 if (a_state == ObservableState.TRUE) {
162 state = ObservableState.TRUE;
163 if ((artifacts == null) && (a_artifacts != null)) {
164 artifacts =
new ArrayList<StixArtifactData>();
166 if (a_artifacts != null) {
167 artifacts.addAll(a_artifacts);
169 }
else if (a_state == ObservableState.INDETERMINATE) {
173 if (state == ObservableState.FALSE) {
175 }
else if (state == ObservableState.TRUE) {
179 state = ObservableState.FALSE;
192 private void addToDesc(String a_desc) {
193 if (description == null) {
194 description = a_desc;
196 description += a_desc;
ObservableState(String s)