public final class PropertySetMixin
extends java.lang.Object
A client will mix in this class by keeping a reference to an instance of
this class, and forwarding all methods of (a subset of the interfaces)
com.sun.star.beans.XPropertySet
,
com.sun.star.beans.XFastPropertySet
, and
com.sun.star.beans.XPropertyAccess
to it.
Client code should not use the monitors associated with instances of this class, as they are used for internal purposes.
Modifier and Type | Class and Description |
---|---|
static class |
PropertySetMixin.BoundListeners
A class used by clients of
PropertySetMixin when implementing UNO
interface type attribute setter functions. |
Constructor and Description |
---|
PropertySetMixin(XComponentContext context,
XInterface object,
Type type,
java.lang.String[] absentOptional)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(java.lang.String propertyName,
XPropertyChangeListener listener)
Implements
com.sun.star.beans.XPropertySet.addPropertyChangeListener . |
void |
addVetoableChangeListener(java.lang.String propertyName,
XVetoableChangeListener listener)
Implements
com.sun.star.beans.XPropertySet.addVetoableChangeListener . |
void |
dispose()
Marks this instance as being disposed.
|
java.lang.Object |
getFastPropertyValue(int handle)
Implements
com.sun.star.beans.XFastPropertySet.getFastPropertyValue . |
XPropertySetInfo |
getPropertySetInfo()
Implements
com.sun.star.beans.XPropertySet.getPropertySetInfo . |
java.lang.Object |
getPropertyValue(java.lang.String propertyName)
Implements
com.sun.star.beans.XPropertySet.getPropertyValue . |
PropertyValue[] |
getPropertyValues()
Implements
com.sun.star.beans.XPropertyAccess.getPropertyValues . |
void |
prepareSet(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue,
PropertySetMixin.BoundListeners bound)
A method used by clients when implementing UNO interface type attribute
setter functions.
|
void |
prepareSet(java.lang.String propertyName,
PropertySetMixin.BoundListeners bound)
A simplified version of
prepareSet(String, Object, Object,
PropertySetMixin.BoundListeners) . |
void |
removePropertyChangeListener(java.lang.String propertyName,
XPropertyChangeListener listener)
Implements
com.sun.star.beans.XPropertySet.removePropertyChangeListener . |
void |
removeVetoableChangeListener(java.lang.String propertyName,
XVetoableChangeListener listener)
Implements
com.sun.star.beans.XPropertySet.removeVetoableChangeListener . |
void |
setFastPropertyValue(int handle,
java.lang.Object value)
Implements
com.sun.star.beans.XFastPropertySet.setFastPropertyValue . |
void |
setPropertyValue(java.lang.String propertyName,
java.lang.Object value)
Implements
com.sun.star.beans.XPropertySet.setPropertyValue . |
void |
setPropertyValues(PropertyValue[] props)
Implements
com.sun.star.beans.XPropertyAccess.setPropertyValues . |
public PropertySetMixin(XComponentContext context, XInterface object, Type type, java.lang.String[] absentOptional)
context
- the component context used by this instance; must not be
null, and must supply the service
com.sun.star.reflection.CoreReflection
and the singleton
com.sun.star.reflection.theTypeDescriptionManager
object
- the client UNO object into which this instance is mixed in;
must not be null, and must support the given type
type
- the UNO interface type whose attributes are mapped to
properties; must not be null, and must represent a UNO interface typeabsentOptional
- a list of optional properties that are not present,
and should thus not be visible via
com.sun.star.beans.XPropertySet.getPropertySetInfo
,
com.sun.star.beans.XPropertySet.addPropertyChangeListener
,
com.sun.star.beans.XPropertySet.removePropertyChangeListener
,
com.sun.star.beans.XPropertySet.addVetoableChangeListener
,
and com.sun.star.beans.XPropertySet.removeVetoableChangeListener
; null is treated the same as an
empty list; if non-null, the given array must not be modified after it is
passed to this constructor. For consistency reasons, the given
absentOptional
should only contain the names of attributes
that represent optional properties that are not present (that is, the
attribute getters and setters always throw a
com.sun.star.beans.UnknownPropertyException
), and should
contain each such name only once. If an optional property is not present
(that is, the corresponding attribute getter and setter always throw a
com.sun.star.beans.UnknownPropertyException
) but is not
contained in the given absentOptional
, then it will be
visible via
com.sun.star.beans.XPropertySet.getPropertySetInfo
as a
com.sun.star.beans.Property
with a set
com.sun.star.beans.PropertyAttribute.OPTIONAL
. If the given
object
does not implement
com.sun.star.beans.XPropertySet
, then the given
absentOptional
is effectively ignored and can be null or
empty.public void prepareSet(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue, PropertySetMixin.BoundListeners bound) throws PropertyVetoException
First, this method checks whether this instance has already been
disposed (see dispose()
), and throws a
com.sun.star.beans.DisposedException
if applicable. For a
constrained attribute (whose setter can explicitly raise
com.sun.star.beans.PropertyVetoException
), this method
notifies any com.sun.star.beans.XVetoableChangeListener
s.
For a bound attribute, this method modifies the passed-in
bound
so that it can afterwards be used to notify any
com.sun.star.beans.XPropertyChangeListener
s. This method
should be called before storing the new attribute value, and
bound.notifyListeners()
should be called exactly once after
storing the new attribute value (in case the attribute is bound;
otherwise, calling bound.notifyListeners()
is ignored).
Furthermore, bound.notifyListeners()
and this method have to
be called from the same thread.
propertyName
- the name of the property (which is the same as the
name of the attribute that is going to be set)oldValue
- the property value corresponding to the old attribute
value. This is only used as
com.sun.star.beans.PropertyChangeEvent.OldValue
, which is
rather useless, anyway (see “Using the Observer Pattern” in
OpenOffice.org Coding Guidelines). If the attribute
that is going to be set is neither bound nor constrained, or if
com.sun.star.beans.PropertyChangeEvent.OldValue
should not
be set, Any.VOID
can be used instead.newValue
- the property value corresponding to the new
attribute value. This is only used as
com.sun.star.beans.PropertyChangeEvent.NewValue
, which is
rather useless, anyway (see “Using the Observer Pattern” in
OpenOffice.org Coding Guidelines), unless the
attribute that is going to be set is constrained. If the attribute
that is going to be set is neither bound nor constrained, or if it is
only bound but
com.sun.star.beans.PropertyChangeEvent.NewValue
should not
be set, Any.VOID
can be used instead.bound
- a reference to a fresh PropertySetMixin.BoundListeners
instance
(which has not been passed to this method before, and on which
PropertySetMixin.BoundListeners.notifyListeners()
has not yet been called); may only
be null if the attribute that is going to be set is not boundPropertyVetoException
public void prepareSet(java.lang.String propertyName, PropertySetMixin.BoundListeners bound)
prepareSet(String, Object, Object,
PropertySetMixin.BoundListeners)
.
This method is useful for attributes that are not constrained.
propertyName
- the name of the property (which is the same as the
name of the attribute that is going to be set)bound
- a reference to a fresh PropertySetMixin.BoundListeners
instance
(which has not been passed to this method before, and on which
PropertySetMixin.BoundListeners.notifyListeners()
has not yet been called); may only
be null if the attribute that is going to be set is not boundpublic void dispose()
See com.sun.star.lang.XComponent
for the general concept
of disposing UNO objects. On the first call to this method, all
registered listeners
(com.sun.star.beans.XPropertyChangeListener
s and
com.sun.star.beans.XVetoableChangeListener
s) are notified of
the disposing source. Any subsequent calls to this method are
ignored.
public XPropertySetInfo getPropertySetInfo()
com.sun.star.beans.XPropertySet.getPropertySetInfo
.public void setPropertyValue(java.lang.String propertyName, java.lang.Object value) throws UnknownPropertyException, PropertyVetoException, com.sun.star.lang.IllegalArgumentException, WrappedTargetException
com.sun.star.beans.XPropertySet.setPropertyValue
.UnknownPropertyException
PropertyVetoException
com.sun.star.lang.IllegalArgumentException
WrappedTargetException
public java.lang.Object getPropertyValue(java.lang.String propertyName) throws UnknownPropertyException, WrappedTargetException
com.sun.star.beans.XPropertySet.getPropertyValue
.UnknownPropertyException
WrappedTargetException
public void addPropertyChangeListener(java.lang.String propertyName, XPropertyChangeListener listener) throws UnknownPropertyException, WrappedTargetException
com.sun.star.beans.XPropertySet.addPropertyChangeListener
.
If a listener is added more than once, it will receive all relevant notifications multiple times.
UnknownPropertyException
WrappedTargetException
public void removePropertyChangeListener(java.lang.String propertyName, XPropertyChangeListener listener) throws UnknownPropertyException, WrappedTargetException
com.sun.star.beans.XPropertySet.removePropertyChangeListener
.UnknownPropertyException
WrappedTargetException
public void addVetoableChangeListener(java.lang.String propertyName, XVetoableChangeListener listener) throws UnknownPropertyException, WrappedTargetException
com.sun.star.beans.XPropertySet.addVetoableChangeListener
.
If a listener is added more than once, it will receive all relevant notifications multiple times.
UnknownPropertyException
WrappedTargetException
public void removeVetoableChangeListener(java.lang.String propertyName, XVetoableChangeListener listener) throws UnknownPropertyException, WrappedTargetException
com.sun.star.beans.XPropertySet.removeVetoableChangeListener
.UnknownPropertyException
WrappedTargetException
public void setFastPropertyValue(int handle, java.lang.Object value) throws UnknownPropertyException, PropertyVetoException, com.sun.star.lang.IllegalArgumentException, WrappedTargetException
com.sun.star.beans.XFastPropertySet.setFastPropertyValue
.UnknownPropertyException
PropertyVetoException
com.sun.star.lang.IllegalArgumentException
WrappedTargetException
public java.lang.Object getFastPropertyValue(int handle) throws UnknownPropertyException, WrappedTargetException
com.sun.star.beans.XFastPropertySet.getFastPropertyValue
.UnknownPropertyException
WrappedTargetException
public PropertyValue[] getPropertyValues()
com.sun.star.beans.XPropertyAccess.getPropertyValues
.public void setPropertyValues(PropertyValue[] props) throws UnknownPropertyException, PropertyVetoException, com.sun.star.lang.IllegalArgumentException, WrappedTargetException
com.sun.star.beans.XPropertyAccess.setPropertyValues
.UnknownPropertyException
PropertyVetoException
com.sun.star.lang.IllegalArgumentException
WrappedTargetException