/* */ else {
/* 468 */ negStatus = 3;
/* */ }
/* */ }
/* */
/* 472 */ ParameterListDescriptor pld = getParameterListDescriptor();
/* 473 */ ParameterListDescriptor otherPld = capability.getParameterListDescriptor();
/* */
/* 475 */ String[] thisNames = pld.getParamNames();
/* 476 */ if (thisNames == null)
/* 477 */ thisNames = new String[0];
/* 478 */ String[] otherNames = otherPld.getParamNames();
/* 479 */ if (otherNames == null)
/* 480 */ otherNames = new String[0];
/* 481 */ Hashtable thisHash = hashNames(thisNames);
/* 482 */ Hashtable otherHash = hashNames(otherNames);
/* */
/* 484 */ Class[] thisClasses = pld.getParamClasses();
/* 485 */ Class[] otherClasses = otherPld.getParamClasses();
/* 486 */ Object[] thisDefaults = pld.getParamDefaults();
/* 487 */ Object[] otherDefaults = otherPld.getParamDefaults();
/* */
/* 489 */ NegotiableCapability result = null;
/* */
/* 492 */ ArrayList resultGenerators = new ArrayList();
/* 493 */ if (this.generators != null)
/* 494 */ resultGenerators.addAll(this.generators);
/* 495 */ if (capability.getGenerators() != null)
/* 496 */ resultGenerators.addAll(capability.getGenerators());
/* */ Vector commonNames;
/* */ Hashtable commonHash;
/* */ Vector thisExtras;
/* */ Vector otherExtras;
/* */ Vector resultParams;
/* */ int resultLength;
/* */ String[] resultNames;
/* */ Class[] resultClasses;
/* */ Object[] resultDefaults;
/* */ Object[] resultValidValues;
/* */ int count;
/* */ ParameterListDescriptorImpl resultPLD;
/* 498 */ switch (negStatus)
/* */ {
/* */ case 0:
/* 502 */ commonNames = commonElements(thisHash, otherHash);
/* 503 */ commonHash = hashNames(commonNames);
/* 504 */ thisExtras = removeAll(thisHash, commonHash);
/* 505 */ otherExtras = removeAll(otherHash, commonHash);
/* */
/* 507 */ int thisExtraLength = thisExtras.size();
/* 508 */ int otherExtraLength = otherExtras.size();
/* */
/* 512 */ resultParams = new Vector(commonNames);
/* 513 */ resultParams.addAll(thisExtras);
/* 514 */ resultParams.addAll(otherExtras);
/* 515 */ resultLength = resultParams.size();
/* 516 */ resultNames = new String[resultLength];
/* 517 */ for (int i = 0; i < resultLength; i++) {
/* 518 */ resultNames[i] = ((String)resultParams.elementAt(i));
/* */ }
/* */
/* 521 */ resultClasses = new Class[resultLength];
/* 522 */ resultDefaults = new Object[resultLength];
/* 523 */ resultValidValues = new Object[resultLength];
/* */
/* 526 */ for (count = 0; count < commonNames.size(); count++) {
/* 527 */ String name = (String)commonNames.elementAt(count);
/* 528 */ resultClasses[count] = thisClasses[getIndex(thisHash, name)];
/* 529 */ resultDefaults[count] = thisDefaults[getIndex(thisHash, name)];
/* 530 */ resultValidValues[count] = pld.getParamValueRange(name);
/* */ }
/* 532 */ for (int i = 0; i < thisExtraLength; i++) {
/* 533 */ String name = (String)thisExtras.elementAt(i);
/* 534 */ resultClasses[(count + i)] = thisClasses[getIndex(thisHash, name)];
/* 535 */ resultDefaults[(count + i)] = thisDefaults[getIndex(thisHash, name)];
/* */
/* 537 */ resultValidValues[(count + i)] = pld.getParamValueRange(name);
/* */ }
/* 539 */ count += thisExtraLength;
/* 540 */ for (int i = 0; i < otherExtraLength; i++) {
/* 541 */ String name = (String)otherExtras.elementAt(i);
/* 542 */ resultClasses[(i + count)] = otherClasses[getIndex(otherHash, name)];
/* */
/* 544 */ resultDefaults[(i + count)] = otherDefaults[getIndex(otherHash, name)];
/* */
/* 546 */ resultValidValues[(i + count)] = otherPld.getParamValueRange(name);
/* */ }
/* */
/* 549 */ resultPLD = new ParameterListDescriptorImpl(null, resultNames, resultClasses, resultDefaults, resultValidValues);
/* */
/* 557 */ result = new NegotiableCapability(this.category, this.capabilityName, resultGenerators, resultPLD, true);
/* */
/* 563 */ for (int i = 0; i < commonNames.size(); i++) {
/* 564 */ String currParam = (String)commonNames.elementAt(i);
/* 565 */ Negotiable thisValue = (Negotiable)getObjectParameter(currParam);
/* 566 */ Negotiable otherValue = (Negotiable)capability.getObjectParameter(currParam);
/* */
/* 576 */ if (thisValue == null) {
/* 577 */ result.setParameter(currParam, otherValue);
/* */ }
/* 581 */ else if (otherValue == null) {
/* 582 */ result.setParameter(currParam, thisValue);
/* */ }
/* */ else
/* */ {
/* 590 */ Negotiable resultValue = thisValue.negotiate(otherValue);
/* 591 */ if (resultValue == null) {
/* 592 */ return null;
/* */ }
/* */
/* 595 */ result.setParameter(currParam, resultValue);
/* */ }
/* */ }
/* */
/* 599 */ for (int i = 0; i < thisExtraLength; i++) {
/* 600 */ String currParam = (String)thisExtras.elementAt(i);
/* 601 */ result.setParameter(currParam, (Negotiable)getObjectParameter(currParam));
/* */ }
/* */
/* 605 */ for (int i = 0; i < otherExtraLength; i++) {
/* 606 */ String currParam = (String)otherExtras.elementAt(i);
/* 607 */ result.setParameter(currParam, (Negotiable)capability.getObjectParameter(currParam));
/* */ }
/* */
/* 611 */ break;
/* */ case 1:
/* 616 */ commonNames = commonElements(thisHash, otherHash);
/* 617 */ commonHash = hashNames(commonNames);
/* 618 */ thisExtras = removeAll(thisHash, commonHash);
/* */
/* 622 */ resultParams = new Vector(commonNames);
/* 623 */ resultParams.addAll(thisExtras);
/* 624 */ resultLength = resultParams.size();
/* 625 */ resultNames = new String[resultLength];
/* 626 */ for (int i = 0; i < resultLength; i++) {
/* 627 */ resultNames[i] = ((String)resultParams.elementAt(i));
/* */ }
/* */
/* 630 */ resultClasses = new Class[resultLength];
/* 631 */ resultDefaults = new Object[resultLength];
/* 632 */ resultValidValues = new Object[resultLength];
/* */
/* 634 */ count = 0;
/* 635 */ for (count = 0; count < commonNames.size(); count++) {
/* 636 */ String name = (String)commonNames.elementAt(count);
/* 637 */ resultClasses[count] = thisClasses[getIndex(thisHash, name)];
/* 638 */ resultDefaults[count] = thisDefaults[getIndex(thisHash, name)];
/* 639 */ resultValidValues[count] = pld.getParamValueRange(name);
/* */ }
/* 641 */ for (int i = 0; i < thisExtras.size(); i++) {
/* 642 */ String name = (String)thisExtras.elementAt(i);
/* 643 */ resultClasses[(i + count)] = thisClasses[getIndex(thisHash, name)];
/* 644 */ resultDefaults[(i + count)] = thisDefaults[getIndex(thisHash, name)];
/* */
/* 646 */ resultValidValues[(i + count)] = pld.getParamValueRange(name);
/* */ }
/* */
/* 649 */ resultPLD = new ParameterListDescriptorImpl(null, resultNames, resultClasses, resultDefaults, resultValidValues);
/* */
/* 655 */ result = new NegotiableCapability(this.category, this.capabilityName, resultGenerators, resultPLD, false);
/* */
/* 661 */ for (int i = 0; i < commonNames.size(); i++) {
/* 662 */ String currParam = (String)commonNames.elementAt(i);
/* 663 */ Negotiable thisValue = (Negotiable)getObjectParameter(currParam);
/* 664 */ Negotiable otherValue = (Negotiable)capability.getObjectParameter(currParam);
/* */
/* 667 */ if (thisValue == null)
/* */ {
/* 670 */ return null;
/* */ }
/* */
/* 673 */ if (otherValue == null)
/* */ {
/* 678 */ result.setParameter(currParam, thisValue);
/* */ }
/* */ else {
/* 681 */ Negotiable resultValue = thisValue.negotiate(otherValue);
/* */
/* 683 */ if (resultValue == null)
/* */ {
/* 687 */ return null;
/* */ }
/* 689 */ result.setParameter(currParam, resultValue);
/* */ }
/* */
/* */ }
/* */
/* 695 */ for (int i = 0; i < thisExtras.size(); i++) {
/* 696 */ String currParam = (String)thisExtras.elementAt(i);
/* 697 */ Negotiable resultValue = (Negotiable)getObjectParameter(currParam);
/* 698 */ if (resultValue == null)
/* 699 */ return null;
/* 700 */ result.setParameter(currParam, resultValue);
/* */ }
/* */
/* 703 */ break;
/* */ case 2:
/* 708 */ commonNames = commonElements(thisHash, otherHash);
/* 709 */ commonHash = hashNames(commonNames);
/* 710 */ otherExtras = removeAll(otherHash, commonHash);
/* */
/* 714 */ resultParams = new Vector(commonNames);
/* 715 */ resultParams.addAll(otherExtras);
/* 716 */ resultLength = resultParams.size();
/* 717 */ resultNames = new String[resultLength];
/* 718 */ for (int i = 0; i < resultLength; i++) {
/* 719 */ resultNames[i] = ((String)resultParams.elementAt(i));
/* */ }
/* */
/* 722 */ resultClasses = new Class[resultLength];
/* 723 */ resultDefaults = new Object[resultLength];
/* 724 */ resultValidValues = new Object[resultLength];
/* 725 */ count = 0;
/* 726 */ for (count = 0; count < commonNames.size(); count++) {
/* 727 */ String name = (String)commonNames.elementAt(count);
/* 728 */ resultClasses[count] = thisClasses[getIndex(thisHash, name)];
/* 729 */ resultDefaults[count] = thisDefaults[getIndex(thisHash, name)];
/* 730 */ resultValidValues[count] = pld.getParamValueRange(name);
/* */ }
/* */
/* 733 */ for (int i = 0; i < otherExtras.size(); i++) {
/* 734 */ String name = (String)otherExtras.elementAt(i);
/* 735 */ resultClasses[(i + count)] = otherClasses[getIndex(otherHash, name)];
/* */
/* 737 */ resultDefaults[(i + count)] = otherDefaults[getIndex(otherHash, name)];
/* */
/* 739 */ resultValidValues[(i + count)] = otherPld.getParamValueRange(name);
/* */ }
/* */
/* 742 */ resultPLD = new ParameterListDescriptorImpl(null, resultNames, resultClasses, resultDefaults, resultValidValues);
/* */
/* 748 */ result = new NegotiableCapability(this.category, this.capabilityName, resultGenerators, resultPLD, false);