Java Reference
In-Depth Information
&& rank < previousRank ){
newRank
#
rank;
newValue
#
value;
}
}
if
(newValue
##
null
)
System.err.println("Error: no admissible value");
attribute.value
#
newValue;
}
// substitute the value of an attribute of a proposal with
// a value with the immediately lower rank
public
Proposal decrease(Attribute attribute,
Proposal proposal){
AttributeMap map
#
(AttributeMap)
attributes.get(attribute.name);
if
(map
##
null
)
return
proposal;
double rank
#
map.rank(attribute);
double newRank
#
0;
Value newValue
#
null
;
Iterator it
#
map.ranks.values().iterator();
while
(it.hasNext()){
RankedAttribute attr
#
(RankedAttribute)it.next();
if
(attr.rank > newRank && attr.rank < rank){
newRank
#
attr.rank;
newValue
#
attr.value;
}
}
if
(newRank!
#
0){
attribute.value
#
newValue;
}
return
proposal;
}
public
String toString(){
StringBuffer buffer
#
new
StringBuffer();
Iterator it
#
attributes.values().iterator();
while
(it.hasNext()){
AttributeMap attribute
#
(AttributeMap)it.next();
buffer.append(attribute.toString()).append("\n");
}
return
buffer.toString();
}
}
Interface
Negotiator
defines the possible interactions between the
mediator and the negotiators. Method
intersect()
takes a proposal by the
negotiator and a proposal from the counterpart and creates a proposal that
contains only the attributes that are present in both proposals and, for each
attribute, sets as admissible values those that are admissible for both.