+
+class StateSet(object):
+ '''
+ Python proxy for the L{_StateSetImpl} class. Use this to safely instantiate
+ new StateSet objects in Python.
+
+ @param impl: State set implementation
+ @type impl: L{_StateSetImpl}
+ '''
+ def __init__(self, *states):
+ '''
+ Initializes the state set with the given states.
+
+ @param states: States to add immediately
+ @type states: list
+ '''
+ self.impl = _StateSetImpl()
+ map(self.impl._this().add, states)
+
+ def contains(self, state):
+ '''
+ Checks if this StateSet contains the given state.
+
+ @param state: State to check
+ @type state: Accessibility.StateType
+ @return: True if the set contains the given state
+ @rtype: boolean
+ '''
+ return self.impl._this().contains(state)
+
+ def add(self, *states):
+ '''
+ Adds states to this set.
+
+ @param states: State(s) to add
+ @type states: Accessibility.StateType
+ '''
+ map(self.impl._this().add, state)
+
+ def remove(self, state):
+ '''
+ Removes states from this set.
+
+ @param states: State(s) to remove
+ @type states: Accessibility.StateType
+ '''
+ map(self.impl._this().remove, state)
+
+ def equals(self, state_set):
+ '''
+ Checks if this StateSet contains exactly the same members as the given
+ StateSet.
+
+ @param state_set: Another set
+ @type state_set: Accessibility.StateSet
+ @return: Are the sets equivalent in terms of their contents?
+ @rtype: boolean
+ '''
+ if isinstance(state_set, self.__class__):
+ # convenience if we're given a proxy
+ state_set = state_set.raw()
+ return self.impl._this().equals(state_set)
+
+ def compare(self, state_set):
+ '''
+ Finds the symmetric difference between this state set andthe one provided,
+ and returns it as a new StateSet.
+
+ @note: This does not use L{_StateSetImpl.compare} which cannot be
+ implemented at this time
+ @param state_set: Set to compare against
+ @type state_set: Accessibility.StateSet
+ @return: Proxy for the new set
+ @rtype: L{StateSet}
+ '''
+ if isinstance(state_set, self.__class__):
+ # shortcut if it's another one of our proxies
+ state_set = state_set.raw()
+ a = set(self.impl._this().getStates())
+ b = set(state_set.getStates())
+ diff = a.symmetric_difference(b)
+ return StateSet(*diff)
+
+ def isEmpty(self):
+ '''
+ Checks if this StateSet is empty.
+
+ @return: Is it empty?
+ @rtype: boolean
+ '''
+ return self.impl._this().isEmpty()
+
+ def getStates(self):
+ '''
+ Gets the sequence of all states in this set.
+
+ @return: List of states
+ @rtype: list
+ '''
+ return self.impl._this().getStates()
+
+ def raw(self):
+ '''
+ Gets the Accessibility.StateSet object proxied for use in a remote
+ call.
+
+ @return: State set
+ @rtype: Accessibility.StateSet
+ '''
+ return self.impl._this()