source: fedd/abac-src/ttg/trust/ProcessingState.java @ fd556d1

axis_examplecompt_changesinfo-opsversion-2.00version-3.01version-3.02
Last change on this file since fd556d1 was 8780cbec, checked in by Jay Jacobs <Jay.Jacobs@…>, 15 years ago

ABAC sources from Cobham

  • Property mode set to 100644
File size: 4.1 KB
Line 
1package com.nailabs.abac.trust;
2
3import java.util.*;
4import java.io.*;
5import com.nailabs.abac.test.XMLizable;
6
7/**
8 * A class to represent the processing state of a TTGNode instance. A node is
9 * considered fully processed when the state is both verifier and opponent
10 * processed. This class is serializable for use in node operations.
11 */
12public class ProcessingState extends Observable
13    implements Serializable, XMLizable {
14    /** internal state variable, set if the verifier has processed a node */
15    private boolean verifierProcessed = false;
16
17    /** internal state variable, set if the opponent has processed a node */
18    private boolean opponentProcessed = false;
19
20    /**
21     * Default constructor for a state where <EMP>NO</EMP> processing has
22     * occured.
23     */
24    public ProcessingState() { }
25   
26    /** Explicit constructor method for setting state */
27    public ProcessingState(boolean v, boolean o) {
28        verifierProcessed = v;
29        opponentProcessed = o;
30    }
31   
32    /** Jared: Added this method to make XML processing easier */
33    public void setVerifierProcessed() {
34        verifierProcessed = true;
35    }
36   
37    /** Jared: Added this method to make XML processing easier */
38    public void setOpponentProcessed() {
39        opponentProcessed = true;
40    }
41   
42    /** Jared: Added this method to make XML processing easier */
43    public void setFullyProcessed() {
44        setVerifierProcessed();
45        setOpponentProcessed();
46    }
47   
48    /** Jared: Added this method to make XML processing easier */
49    public void setUnprocessed() {
50        verifierProcessed = false;
51        opponentProcessed = false;
52    }
53   
54    /** Jared: Added this method to make XML processing easier */
55    public void setProcessingState(String state) {
56        if(state.equals("Fully Processed")) setFullyProcessed();
57        else if(state.equals("Verifier Processed")) setVerifierProcessed();
58        else if(state.equals("Opponent Processed")) setOpponentProcessed();
59        else if(state.equals("Unprocessed")) setUnprocessed();
60    }
61
62    /** method used to indicate that this node has been verifier processed */
63    public void verifierProcess() { 
64        verifierProcessed = true; 
65        setChanged();
66        notifyObservers();
67    }
68
69    /** method used to indicate that this node has been opponent processed */
70    public void opponentProcess() { 
71        opponentProcessed = true; 
72        setChanged();
73        notifyObservers();
74    }
75
76    /** boolean query to find out if the node has been verifier processed */
77    public boolean isVerifierProcessed() { return verifierProcessed; }
78
79    /** boolean query to find out if the node has been opponent processed */
80    public boolean isOpponentProcessed() { return opponentProcessed; }
81
82    /**
83     * boolean query to find out if the node was processed by opponent and
84     * and verifier.
85     */
86    public boolean isFullyProcessed() { 
87        return (verifierProcessed && opponentProcessed);
88    }
89
90    /** Update the processing state by duplicating the the specified state */
91    public void update(ProcessingState state) {
92        //if(state == null)return;
93        verifierProcessed |= state.isVerifierProcessed();
94        opponentProcessed |= state.isOpponentProcessed();
95        setChanged();
96        notifyObservers();
97    }
98
99   
100    /** convert this instance into XML formatted text */
101    public String toXML() {
102        StringBuffer buff = new StringBuffer("<ProcessingState>");
103        String value;
104        if(isFullyProcessed()) {
105            value =  "Fully Processed";
106        }
107        else if(isVerifierProcessed()) {
108            value = "Verifier Processed";
109        }
110        else if(isOpponentProcessed()) {
111            value = "Opponent Processed";
112        }
113        else {
114            value = "Unprocessed";
115        }
116        buff.append(value).append("</ProcessingState>");
117        return buff.append("\n").toString();
118    }
119
120    /** Convert this instance into human readable format */
121    public String toString() {
122        if(isFullyProcessed()) {
123            //return "[Fully Processed]";
124        return "fully";
125        }
126        else if(isVerifierProcessed()) {
127            //return "[Verifier Processed]";
128        return "verifier";
129        }
130        else if(isOpponentProcessed()) {
131            //return "[OpponentProcessed]";
132        return "opponent";
133        }
134        else {
135            //return "[Unprocessed]";
136        return "unprocessed";
137        }
138    }
139
140}
141
142
143
Note: See TracBrowser for help on using the repository browser.