|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jini.core.constraint.InvocationConstraints
public final class InvocationConstraints
An immutable aggregation of constraints into a set of requirements and a set of preferences. A requirement is a mandatory constraint that must be satisfied for the invocation. A preference is a desired constraint, to be satisfied if possible, but it will not be satisfied if it conflicts with a requirement. If two preferences conflict, it is arbitrary as to which one will be satisfied. If a constraint is not understood, due to lack of knowledge of the type of the constraint or the contents of the constraint, then the constraint cannot be satisfied.
Note that it is possible for an instance of this class to contain both requirements that conflict with each other, and preferences that conflict with each other and with requirements.
Field Summary | |
---|---|
private static InvocationConstraint[] |
empty
An empty array |
static InvocationConstraints |
EMPTY
An empty instance, one that has no requirements and no preferences. |
private InvocationConstraint[] |
prefs
The preferences. |
private int |
rel
Flags indicating whether any requirements and/or preferences are based on relative time. |
private static int |
REL_PREFS
Bit set in the rel field if there are relative preferences. |
private static int |
REL_REQS
Bit set in the rel field if there are relative requirements. |
private InvocationConstraint[] |
reqs
The requirements. |
private static ObjectStreamField[] |
serialPersistentFields
|
private static long |
serialVersionUID
|
Constructor Summary | |
---|---|
|
InvocationConstraints(Collection reqs,
Collection prefs)
Creates an instance that has all of the constraints from the first collection, reqs , added as requirements if the collection
is a non-null value, and has all of the constraints from
the second collection, prefs , added as preferences if the
collection is a non-null value. |
private |
InvocationConstraints(InvocationConstraint[] reqs,
int reqidx,
InvocationConstraint[] prefs,
int prefidx,
int rel)
Creates an instance containing the specified requirements and preferences. |
|
InvocationConstraints(InvocationConstraint[] reqs,
InvocationConstraint[] prefs)
Creates an instance that has all of the constraints from the first array, reqs , added as requirements if the array is a
non-null value, and has all of the constraints from
the second array, prefs , added as preferences if the
array is a non-null value. |
|
InvocationConstraints(InvocationConstraint req,
InvocationConstraint pref)
Creates an instance that has the first constraint, req ,
added as a requirement if it is a non-null value, and has
the second constraint, pref , added as a preference if it
is a non-null value and is not a duplicate of the
requirement. |
Method Summary | |
---|---|
static InvocationConstraints |
combine(InvocationConstraints constraints1,
InvocationConstraints constraints2)
Returns an instance of this class that has all of the requirements from each non- null argument added as requirements and has all
of the preferences from each non-null argument added as
preferences. |
private static InvocationConstraint[] |
concat(InvocationConstraint[] arr1,
InvocationConstraint[] arr2)
Returns a new array containing the elements of both arguments. |
boolean |
equals(Object obj)
Two instances of this class are equal if they have the same requirements and the same preferences. |
int |
hashCode()
Returns a hash code value for this object. |
boolean |
isEmpty()
Returns true if the instance has no requirements and no
preferences; returns false otherwise. |
InvocationConstraints |
makeAbsolute()
Returns an instance of this class constructed from all of the same requirements and preferences as this instance, but with every constraint that is an instance of RelativeTimeConstraint
replaced by the result of invoking the constraint's
makeAbsolute method with the current time (as given by
System.currentTimeMillis ). |
private static InvocationConstraint[] |
makeAbsolute(InvocationConstraint[] arr,
long baseTime)
Converts any relative constraints to absolute time. |
InvocationConstraints |
makeAbsolute(long baseTime)
Returns an instance of this class equal to the result of taking the requirements and preferences in this instance, replacing each constraint that is an instance of RelativeTimeConstraint with
the result of invoking that constraint's makeAbsolute
method with the specified base time, and creating a new instance of
this class with duplicate requirements, duplicate preferences, and
preferences that are duplicates of requirements all removed. |
Set |
preferences()
Returns an immutable set of all of the preferences. |
private void |
readObject(ObjectInputStream s)
Verifies that there are no null elements and no duplicates. |
private void |
reduce()
Replaces null fields with empty arrays, eliminates duplicates, and sets flags indicating which constraints are relative. |
private void |
reduce(int reqidx,
int prefidx)
Checks for nulls and eliminates duplicates. |
private static boolean |
relative(InvocationConstraint c)
Returns true if the specified constraint either implements RelativeTimeConstraint or is an instance of ConstraintAlternatives with elements that implement RelativeTimeConstraint, and false otherwise. |
Set |
requirements()
Returns an immutable set of all of the requirements. |
private void |
setRelative(InvocationConstraint[] constraints,
int flag)
Sets the given flag in the rel field if any if the specified constraints are relative. |
String |
toString()
Returns a string representation of this object. |
private static void |
verify(InvocationConstraint[] constraints)
Verifies that the array is non-null, the elements are all non-null, and there are no duplicates. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
private static final ObjectStreamField[] serialPersistentFields
private static final InvocationConstraint[] empty
private static final int REL_REQS
private static final int REL_PREFS
public static final InvocationConstraints EMPTY
private InvocationConstraint[] reqs
private InvocationConstraint[] prefs
private transient int rel
Constructor Detail |
---|
public InvocationConstraints(InvocationConstraint req, InvocationConstraint pref)
req
,
added as a requirement if it is a non-null
value, and has
the second constraint, pref
, added as a preference if it
is a non-null
value and is not a duplicate of the
requirement.
req
- a requirement, or null
pref
- a preference, or null
public InvocationConstraints(InvocationConstraint[] reqs, InvocationConstraint[] prefs)
reqs
, added as requirements if the array is a
non-null
value, and has all of the constraints from
the second array, prefs
, added as preferences if the
array is a non-null
value. Duplicate requirements,
duplicate preferences, and preferences that are duplicates of
requirements are all removed. The arguments passed to the constructor
are neither modified nor retained; subsequent changes to those
arguments have no effect on the instance created.
reqs
- requirements, or null
prefs
- preferences, or null
NullPointerException
- if any element of an argument is
null
public InvocationConstraints(Collection reqs, Collection prefs)
reqs
, added as requirements if the collection
is a non-null
value, and has all of the constraints from
the second collection, prefs
, added as preferences if the
collection is a non-null
value. Duplicate requirements,
duplicate preferences, and preferences that are duplicates of
requirements are all removed. The arguments passed to the constructor
are neither modified nor retained; subsequent changes to those
arguments have no effect on the instance created.
reqs
- requirements, or null
prefs
- preferences, or null
NullPointerException
- if any element of an argument is
null
IllegalArgumentException
- if any element of an argument is not
an instance of InvocationConstraint
private InvocationConstraints(InvocationConstraint[] reqs, int reqidx, InvocationConstraint[] prefs, int prefidx, int rel)
Method Detail |
---|
private void reduce()
private void reduce(int reqidx, int prefidx)
private static boolean relative(InvocationConstraint c)
private void setRelative(InvocationConstraint[] constraints, int flag)
public static InvocationConstraints combine(InvocationConstraints constraints1, InvocationConstraints constraints2)
null
argument added as requirements and has all
of the preferences from each non-null
argument added as
preferences. Duplicate requirements, duplicate preferences, and
preferences that are duplicates of requirements are all removed.
constraints1
- constraints, or null
constraints2
- constraints, or null
null
argument added as requirements and has all
of the preferences from each non-null
argument added as
preferencesprivate static InvocationConstraint[] concat(InvocationConstraint[] arr1, InvocationConstraint[] arr2)
private static InvocationConstraint[] makeAbsolute(InvocationConstraint[] arr, long baseTime)
public InvocationConstraints makeAbsolute(long baseTime)
RelativeTimeConstraint
with
the result of invoking that constraint's makeAbsolute
method with the specified base time, and creating a new instance of
this class with duplicate requirements, duplicate preferences, and
preferences that are duplicates of requirements all removed.
baseTime
- an absolute time, specified in milliseconds from
midnight, January 1, 1970 UTC
RelativeTimeConstraint
with the result of invoking that constraint's makeAbsolute
method with the specified base time, and creating a new instance of
this class with duplicate requirements, duplicate preferences, and
preferences that are duplicates of requirements all removedpublic InvocationConstraints makeAbsolute()
RelativeTimeConstraint
replaced by the result of invoking the constraint's
makeAbsolute
method with the current time (as given by
System.currentTimeMillis
). Duplicate
requirements, duplicate preferences, and preferences that are
duplicates of requirements are all removed.
RelativeTimeConstraint
replaced by the result of invoking the constraint's
makeAbsolute
method with the current timepublic Set requirements()
UnsupportedOperationException
being thrown.
public Set preferences()
UnsupportedOperationException
being thrown.
public boolean isEmpty()
true
if the instance has no requirements and no
preferences; returns false
otherwise.
true
if the instance has no requirements and no
preferences; false
otherwisepublic int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
TrustEquivalence.checkTrustEquivalence
.
equals
in class Object
public String toString()
toString
in class Object
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException
null
elements and no duplicates.
InvalidObjectException
- if the requirements or preferences
arrays are null
, or any element is null
,
or if there are duplicate requirements, duplicate preferences, or
preferences that are duplicates of requirements
IOException
ClassNotFoundException
private static void verify(InvocationConstraint[] constraints) throws InvalidObjectException
InvalidObjectException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |