186 * initNumFields (<= 0) |
184 * initNumFields (<= 0) |
187 * @exception MBeanException Wraps a distributed communication Exception. |
185 * @exception MBeanException Wraps a distributed communication Exception. |
188 */ |
186 */ |
189 public DescriptorSupport(int initNumFields) |
187 public DescriptorSupport(int initNumFields) |
190 throws MBeanException, RuntimeOperationsException { |
188 throws MBeanException, RuntimeOperationsException { |
191 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
189 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
192 MODELMBEAN_LOGGER.logp(Level.FINEST, |
190 MODELMBEAN_LOGGER.log(Level.TRACE, |
193 DescriptorSupport.class.getName(), |
191 "Descriptor(initNumFields = " + initNumFields + ") " + |
194 "Descriptor(initNumFields = " + initNumFields + ")", |
|
195 "Constructor"); |
192 "Constructor"); |
196 } |
193 } |
197 if (initNumFields <= 0) { |
194 if (initNumFields <= 0) { |
198 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
195 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
199 MODELMBEAN_LOGGER.logp(Level.FINEST, |
196 MODELMBEAN_LOGGER.log(Level.TRACE, |
200 DescriptorSupport.class.getName(), |
|
201 "Descriptor(initNumFields)", |
|
202 "Illegal arguments: initNumFields <= 0"); |
197 "Illegal arguments: initNumFields <= 0"); |
203 } |
198 } |
204 final String msg = |
199 final String msg = |
205 "Descriptor field limit invalid: " + initNumFields; |
200 "Descriptor field limit invalid: " + initNumFields; |
206 final RuntimeException iae = new IllegalArgumentException(msg); |
201 final RuntimeException iae = new IllegalArgumentException(msg); |
266 public DescriptorSupport(String inStr) |
260 public DescriptorSupport(String inStr) |
267 throws MBeanException, RuntimeOperationsException, |
261 throws MBeanException, RuntimeOperationsException, |
268 XMLParseException { |
262 XMLParseException { |
269 /* parse an XML-formatted string and populate internal |
263 /* parse an XML-formatted string and populate internal |
270 * structure with it */ |
264 * structure with it */ |
271 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
265 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
272 MODELMBEAN_LOGGER.logp(Level.FINEST, |
266 MODELMBEAN_LOGGER.log(Level.TRACE, |
273 DescriptorSupport.class.getName(), |
267 "Descriptor(String = '" + inStr + "') Constructor"); |
274 "Descriptor(String = '" + inStr + "')", "Constructor"); |
|
275 } |
268 } |
276 if (inStr == null) { |
269 if (inStr == null) { |
277 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
270 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
278 MODELMBEAN_LOGGER.logp(Level.FINEST, |
271 MODELMBEAN_LOGGER.log(Level.TRACE, |
279 DescriptorSupport.class.getName(), |
272 "Descriptor(String = null) Illegal arguments"); |
280 "Descriptor(String = null)", "Illegal arguments"); |
|
281 } |
273 } |
282 final String msg = "String in parameter is null"; |
274 final String msg = "String in parameter is null"; |
283 final RuntimeException iae = new IllegalArgumentException(msg); |
275 final RuntimeException iae = new IllegalArgumentException(msg); |
284 throw new RuntimeOperationsException(iae, msg); |
276 throw new RuntimeOperationsException(iae, msg); |
285 } |
277 } |
378 * exception will be thrown. |
369 * exception will be thrown. |
379 * |
370 * |
380 */ |
371 */ |
381 public DescriptorSupport(String[] fieldNames, Object[] fieldValues) |
372 public DescriptorSupport(String[] fieldNames, Object[] fieldValues) |
382 throws RuntimeOperationsException { |
373 throws RuntimeOperationsException { |
383 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
374 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
384 MODELMBEAN_LOGGER.logp(Level.FINEST, |
375 MODELMBEAN_LOGGER.log(Level.TRACE, |
385 DescriptorSupport.class.getName(), |
376 "Descriptor(fieldNames,fieldObjects) Constructor"); |
386 "Descriptor(fieldNames,fieldObjects)", "Constructor"); |
|
387 } |
377 } |
388 |
378 |
389 if ((fieldNames == null) || (fieldValues == null) || |
379 if ((fieldNames == null) || (fieldValues == null) || |
390 (fieldNames.length != fieldValues.length)) { |
380 (fieldNames.length != fieldValues.length)) { |
391 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
381 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
392 MODELMBEAN_LOGGER.logp(Level.FINEST, |
382 MODELMBEAN_LOGGER.log(Level.TRACE, |
393 DescriptorSupport.class.getName(), |
383 "Descriptor(fieldNames,fieldObjects)" + |
394 "Descriptor(fieldNames,fieldObjects)", |
384 " Illegal arguments"); |
395 "Illegal arguments"); |
|
396 } |
385 } |
397 |
386 |
398 final String msg = |
387 final String msg = |
399 "Null or invalid fieldNames or fieldValues"; |
388 "Null or invalid fieldNames or fieldValues"; |
400 final RuntimeException iae = new IllegalArgumentException(msg); |
389 final RuntimeException iae = new IllegalArgumentException(msg); |
480 // = is not in last character |
466 // = is not in last character |
481 fieldValue = fields[i].substring(eq_separator+1); |
467 fieldValue = fields[i].substring(eq_separator+1); |
482 } |
468 } |
483 |
469 |
484 if (fieldName.equals("")) { |
470 if (fieldName.equals("")) { |
485 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
471 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
486 MODELMBEAN_LOGGER.logp(Level.FINEST, |
472 MODELMBEAN_LOGGER.log(Level.TRACE, |
487 DescriptorSupport.class.getName(), |
473 "Descriptor(String... fields) " + |
488 "Descriptor(String... fields)", |
|
489 "Illegal arguments: fieldName is empty"); |
474 "Illegal arguments: fieldName is empty"); |
490 } |
475 } |
491 |
476 |
492 final String msg = "Field in invalid format: no fieldName"; |
477 final String msg = "Field in invalid format: no fieldName"; |
493 final RuntimeException iae = new IllegalArgumentException(msg); |
478 final RuntimeException iae = new IllegalArgumentException(msg); |
494 throw new RuntimeOperationsException(iae, msg); |
479 throw new RuntimeOperationsException(iae, msg); |
495 } |
480 } |
496 |
481 |
497 setField(fieldName,fieldValue); |
482 setField(fieldName,fieldValue); |
498 } |
483 } |
499 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
484 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
500 MODELMBEAN_LOGGER.logp(Level.FINEST, |
485 MODELMBEAN_LOGGER.log(Level.TRACE, |
501 DescriptorSupport.class.getName(), |
486 "Descriptor(String... fields) Exit"); |
502 "Descriptor(String... fields)", "Exit"); |
|
503 } |
487 } |
504 } |
488 } |
505 |
489 |
506 private void init(Map<String, ?> initMap) { |
490 private void init(Map<String, ?> initMap) { |
507 descriptorMap = |
491 descriptorMap = |
515 |
499 |
516 public synchronized Object getFieldValue(String fieldName) |
500 public synchronized Object getFieldValue(String fieldName) |
517 throws RuntimeOperationsException { |
501 throws RuntimeOperationsException { |
518 |
502 |
519 if ((fieldName == null) || (fieldName.equals(""))) { |
503 if ((fieldName == null) || (fieldName.equals(""))) { |
520 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
504 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
521 MODELMBEAN_LOGGER.logp(Level.FINEST, |
505 MODELMBEAN_LOGGER.log(Level.TRACE, |
522 DescriptorSupport.class.getName(), |
|
523 "getFieldValue(String fieldName)", |
|
524 "Illegal arguments: null field name"); |
506 "Illegal arguments: null field name"); |
525 } |
507 } |
526 final String msg = "Fieldname requested is null"; |
508 final String msg = "Fieldname requested is null"; |
527 final RuntimeException iae = new IllegalArgumentException(msg); |
509 final RuntimeException iae = new IllegalArgumentException(msg); |
528 throw new RuntimeOperationsException(iae, msg); |
510 throw new RuntimeOperationsException(iae, msg); |
529 } |
511 } |
530 Object retValue = descriptorMap.get(fieldName); |
512 Object retValue = descriptorMap.get(fieldName); |
531 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
513 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
532 MODELMBEAN_LOGGER.logp(Level.FINEST, |
514 MODELMBEAN_LOGGER.log(Level.TRACE, |
533 DescriptorSupport.class.getName(), |
515 "getFieldValue(String fieldName = " + fieldName + ") " + |
534 "getFieldValue(String fieldName = " + fieldName + ")", |
|
535 "Returns '" + retValue + "'"); |
516 "Returns '" + retValue + "'"); |
536 } |
517 } |
537 return(retValue); |
518 return(retValue); |
538 } |
519 } |
539 |
520 |
540 public synchronized void setField(String fieldName, Object fieldValue) |
521 public synchronized void setField(String fieldName, Object fieldValue) |
541 throws RuntimeOperationsException { |
522 throws RuntimeOperationsException { |
542 |
523 |
543 // field name cannot be null or empty |
524 // field name cannot be null or empty |
544 if ((fieldName == null) || (fieldName.equals(""))) { |
525 if ((fieldName == null) || (fieldName.equals(""))) { |
545 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
526 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
546 MODELMBEAN_LOGGER.logp(Level.FINEST, |
527 MODELMBEAN_LOGGER.log(Level.TRACE, |
547 DescriptorSupport.class.getName(), |
|
548 "setField(fieldName,fieldValue)", |
|
549 "Illegal arguments: null or empty field name"); |
528 "Illegal arguments: null or empty field name"); |
550 } |
529 } |
551 |
530 |
552 final String msg = "Field name to be set is null or empty"; |
531 final String msg = "Field name to be set is null or empty"; |
553 final RuntimeException iae = new IllegalArgumentException(msg); |
532 final RuntimeException iae = new IllegalArgumentException(msg); |
554 throw new RuntimeOperationsException(iae, msg); |
533 throw new RuntimeOperationsException(iae, msg); |
555 } |
534 } |
556 |
535 |
557 if (!validateField(fieldName, fieldValue)) { |
536 if (!validateField(fieldName, fieldValue)) { |
558 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
537 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
559 MODELMBEAN_LOGGER.logp(Level.FINEST, |
538 MODELMBEAN_LOGGER.log(Level.TRACE, |
560 DescriptorSupport.class.getName(), |
|
561 "setField(fieldName,fieldValue)", |
|
562 "Illegal arguments"); |
539 "Illegal arguments"); |
563 } |
540 } |
564 |
541 |
565 final String msg = |
542 final String msg = |
566 "Field value invalid: " + fieldName + "=" + fieldValue; |
543 "Field value invalid: " + fieldName + "=" + fieldValue; |
567 final RuntimeException iae = new IllegalArgumentException(msg); |
544 final RuntimeException iae = new IllegalArgumentException(msg); |
568 throw new RuntimeOperationsException(iae, msg); |
545 throw new RuntimeOperationsException(iae, msg); |
569 } |
546 } |
570 |
547 |
571 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
548 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
572 MODELMBEAN_LOGGER.logp(Level.FINEST, |
549 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry: setting '" |
573 DescriptorSupport.class.getName(), |
|
574 "setField(fieldName,fieldValue)", "Entry: setting '" |
|
575 + fieldName + "' to '" + fieldValue + "'"); |
550 + fieldName + "' to '" + fieldValue + "'"); |
576 } |
551 } |
577 |
552 |
578 // Since we do not remove any existing entry with this name, |
553 // Since we do not remove any existing entry with this name, |
579 // the field will preserve whatever case it had, ignoring |
554 // the field will preserve whatever case it had, ignoring |
580 // any difference there might be in fieldName. |
555 // any difference there might be in fieldName. |
581 descriptorMap.put(fieldName, fieldValue); |
556 descriptorMap.put(fieldName, fieldValue); |
582 } |
557 } |
583 |
558 |
584 public synchronized String[] getFields() { |
559 public synchronized String[] getFields() { |
585 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
560 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
586 MODELMBEAN_LOGGER.logp(Level.FINEST, |
561 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); |
587 DescriptorSupport.class.getName(), |
|
588 "getFields()", "Entry"); |
|
589 } |
562 } |
590 int numberOfEntries = descriptorMap.size(); |
563 int numberOfEntries = descriptorMap.size(); |
591 |
564 |
592 String[] responseFields = new String[numberOfEntries]; |
565 String[] responseFields = new String[numberOfEntries]; |
593 Set<Map.Entry<String, Object>> returnedSet = descriptorMap.entrySet(); |
566 Set<Map.Entry<String, Object>> returnedSet = descriptorMap.entrySet(); |
594 |
567 |
595 int i = 0; |
568 int i = 0; |
596 |
569 |
597 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
570 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
598 MODELMBEAN_LOGGER.logp(Level.FINEST, |
571 MODELMBEAN_LOGGER.log(Level.TRACE, |
599 DescriptorSupport.class.getName(), |
572 "Returning " + numberOfEntries + " fields"); |
600 "getFields()", "Returning " + numberOfEntries + " fields"); |
|
601 } |
573 } |
602 for (Iterator<Map.Entry<String, Object>> iter = returnedSet.iterator(); |
574 for (Iterator<Map.Entry<String, Object>> iter = returnedSet.iterator(); |
603 iter.hasNext(); i++) { |
575 iter.hasNext(); i++) { |
604 Map.Entry<String, Object> currElement = iter.next(); |
576 Map.Entry<String, Object> currElement = iter.next(); |
605 |
577 |
606 if (currElement == null) { |
578 if (currElement == null) { |
607 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
579 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
608 MODELMBEAN_LOGGER.logp(Level.FINEST, |
580 MODELMBEAN_LOGGER.log(Level.TRACE, |
609 DescriptorSupport.class.getName(), |
581 "Element is null"); |
610 "getFields()", "Element is null"); |
|
611 } |
582 } |
612 } else { |
583 } else { |
613 Object currValue = currElement.getValue(); |
584 Object currValue = currElement.getValue(); |
614 if (currValue == null) { |
585 if (currValue == null) { |
615 responseFields[i] = currElement.getKey() + "="; |
586 responseFields[i] = currElement.getKey() + "="; |
624 } |
595 } |
625 } |
596 } |
626 } |
597 } |
627 } |
598 } |
628 |
599 |
629 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
600 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
630 MODELMBEAN_LOGGER.logp(Level.FINEST, |
601 MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); |
631 DescriptorSupport.class.getName(), |
|
632 "getFields()", "Exit"); |
|
633 } |
602 } |
634 |
603 |
635 return responseFields; |
604 return responseFields; |
636 } |
605 } |
637 |
606 |
638 public synchronized String[] getFieldNames() { |
607 public synchronized String[] getFieldNames() { |
639 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
608 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
640 MODELMBEAN_LOGGER.logp(Level.FINEST, |
609 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); |
641 DescriptorSupport.class.getName(), |
|
642 "getFieldNames()", "Entry"); |
|
643 } |
610 } |
644 int numberOfEntries = descriptorMap.size(); |
611 int numberOfEntries = descriptorMap.size(); |
645 |
612 |
646 String[] responseFields = new String[numberOfEntries]; |
613 String[] responseFields = new String[numberOfEntries]; |
647 Set<Map.Entry<String, Object>> returnedSet = descriptorMap.entrySet(); |
614 Set<Map.Entry<String, Object>> returnedSet = descriptorMap.entrySet(); |
648 |
615 |
649 int i = 0; |
616 int i = 0; |
650 |
617 |
651 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
618 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
652 MODELMBEAN_LOGGER.logp(Level.FINEST, |
619 MODELMBEAN_LOGGER.log(Level.TRACE, |
653 DescriptorSupport.class.getName(), |
|
654 "getFieldNames()", |
|
655 "Returning " + numberOfEntries + " fields"); |
620 "Returning " + numberOfEntries + " fields"); |
656 } |
621 } |
657 |
622 |
658 for (Iterator<Map.Entry<String, Object>> iter = returnedSet.iterator(); |
623 for (Iterator<Map.Entry<String, Object>> iter = returnedSet.iterator(); |
659 iter.hasNext(); i++) { |
624 iter.hasNext(); i++) { |
660 Map.Entry<String, Object> currElement = iter.next(); |
625 Map.Entry<String, Object> currElement = iter.next(); |
661 |
626 |
662 if (( currElement == null ) || (currElement.getKey() == null)) { |
627 if (( currElement == null ) || (currElement.getKey() == null)) { |
663 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
628 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
664 MODELMBEAN_LOGGER.logp(Level.FINEST, |
629 MODELMBEAN_LOGGER.log(Level.TRACE, "Field is null"); |
665 DescriptorSupport.class.getName(), |
|
666 "getFieldNames()", "Field is null"); |
|
667 } |
630 } |
668 } else { |
631 } else { |
669 responseFields[i] = currElement.getKey().toString(); |
632 responseFields[i] = currElement.getKey().toString(); |
670 } |
633 } |
671 } |
634 } |
672 |
635 |
673 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
636 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
674 MODELMBEAN_LOGGER.logp(Level.FINEST, |
637 MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); |
675 DescriptorSupport.class.getName(), |
|
676 "getFieldNames()", "Exit"); |
|
677 } |
638 } |
678 |
639 |
679 return responseFields; |
640 return responseFields; |
680 } |
641 } |
681 |
642 |
682 |
643 |
683 public synchronized Object[] getFieldValues(String... fieldNames) { |
644 public synchronized Object[] getFieldValues(String... fieldNames) { |
684 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
645 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
685 MODELMBEAN_LOGGER.logp(Level.FINEST, |
646 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); |
686 DescriptorSupport.class.getName(), |
|
687 "getFieldValues(String... fieldNames)", "Entry"); |
|
688 } |
647 } |
689 // if fieldNames == null return all values |
648 // if fieldNames == null return all values |
690 // if fieldNames is String[0] return no values |
649 // if fieldNames is String[0] return no values |
691 |
650 |
692 final int numberOfEntries = |
651 final int numberOfEntries = |
693 (fieldNames == null) ? descriptorMap.size() : fieldNames.length; |
652 (fieldNames == null) ? descriptorMap.size() : fieldNames.length; |
694 final Object[] responseFields = new Object[numberOfEntries]; |
653 final Object[] responseFields = new Object[numberOfEntries]; |
695 |
654 |
696 int i = 0; |
655 int i = 0; |
697 |
656 |
698 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
657 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
699 MODELMBEAN_LOGGER.logp(Level.FINEST, |
658 MODELMBEAN_LOGGER.log(Level.TRACE, |
700 DescriptorSupport.class.getName(), |
|
701 "getFieldValues(String... fieldNames)", |
|
702 "Returning " + numberOfEntries + " fields"); |
659 "Returning " + numberOfEntries + " fields"); |
703 } |
660 } |
704 |
661 |
705 if (fieldNames == null) { |
662 if (fieldNames == null) { |
706 for (Object value : descriptorMap.values()) |
663 for (Object value : descriptorMap.values()) |
713 responseFields[i] = getFieldValue(fieldNames[i]); |
670 responseFields[i] = getFieldValue(fieldNames[i]); |
714 } |
671 } |
715 } |
672 } |
716 } |
673 } |
717 |
674 |
718 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
675 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
719 MODELMBEAN_LOGGER.logp(Level.FINEST, |
676 MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); |
720 DescriptorSupport.class.getName(), |
|
721 "getFieldValues(String... fieldNames)", "Exit"); |
|
722 } |
677 } |
723 |
678 |
724 return responseFields; |
679 return responseFields; |
725 } |
680 } |
726 |
681 |
727 public synchronized void setFields(String[] fieldNames, |
682 public synchronized void setFields(String[] fieldNames, |
728 Object[] fieldValues) |
683 Object[] fieldValues) |
729 throws RuntimeOperationsException { |
684 throws RuntimeOperationsException { |
730 |
685 |
731 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
686 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
732 MODELMBEAN_LOGGER.logp(Level.FINEST, |
687 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); |
733 DescriptorSupport.class.getName(), |
|
734 "setFields(fieldNames,fieldValues)", "Entry"); |
|
735 } |
688 } |
736 |
689 |
737 if ((fieldNames == null) || (fieldValues == null) || |
690 if ((fieldNames == null) || (fieldValues == null) || |
738 (fieldNames.length != fieldValues.length)) { |
691 (fieldNames.length != fieldValues.length)) { |
739 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
692 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
740 MODELMBEAN_LOGGER.logp(Level.FINEST, |
693 MODELMBEAN_LOGGER.log(Level.TRACE, |
741 DescriptorSupport.class.getName(), |
|
742 "setFields(fieldNames,fieldValues)", |
|
743 "Illegal arguments"); |
694 "Illegal arguments"); |
744 } |
695 } |
745 |
696 |
746 final String msg = "fieldNames and fieldValues are null or invalid"; |
697 final String msg = "fieldNames and fieldValues are null or invalid"; |
747 final RuntimeException iae = new IllegalArgumentException(msg); |
698 final RuntimeException iae = new IllegalArgumentException(msg); |
748 throw new RuntimeOperationsException(iae, msg); |
699 throw new RuntimeOperationsException(iae, msg); |
749 } |
700 } |
750 |
701 |
751 for (int i=0; i < fieldNames.length; i++) { |
702 for (int i=0; i < fieldNames.length; i++) { |
752 if (( fieldNames[i] == null) || (fieldNames[i].equals(""))) { |
703 if (( fieldNames[i] == null) || (fieldNames[i].equals(""))) { |
753 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
704 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
754 MODELMBEAN_LOGGER.logp(Level.FINEST, |
705 MODELMBEAN_LOGGER.log(Level.TRACE, |
755 DescriptorSupport.class.getName(), |
|
756 "setFields(fieldNames,fieldValues)", |
|
757 "Null field name encountered at element " + i); |
706 "Null field name encountered at element " + i); |
758 } |
707 } |
759 final String msg = "fieldNames is null or invalid"; |
708 final String msg = "fieldNames is null or invalid"; |
760 final RuntimeException iae = new IllegalArgumentException(msg); |
709 final RuntimeException iae = new IllegalArgumentException(msg); |
761 throw new RuntimeOperationsException(iae, msg); |
710 throw new RuntimeOperationsException(iae, msg); |
762 } |
711 } |
763 setField(fieldNames[i], fieldValues[i]); |
712 setField(fieldNames[i], fieldValues[i]); |
764 } |
713 } |
765 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
714 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
766 MODELMBEAN_LOGGER.logp(Level.FINEST, |
715 MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); |
767 DescriptorSupport.class.getName(), |
|
768 "setFields(fieldNames,fieldValues)", "Exit"); |
|
769 } |
716 } |
770 } |
717 } |
771 |
718 |
772 /** |
719 /** |
773 * Returns a new Descriptor which is a duplicate of the Descriptor. |
720 * Returns a new Descriptor which is a duplicate of the Descriptor. |
896 * @exception RuntimeOperationsException If the validity checking |
841 * @exception RuntimeOperationsException If the validity checking |
897 * fails for any reason, this exception will be thrown. |
842 * fails for any reason, this exception will be thrown. |
898 */ |
843 */ |
899 |
844 |
900 public synchronized boolean isValid() throws RuntimeOperationsException { |
845 public synchronized boolean isValid() throws RuntimeOperationsException { |
901 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
846 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
902 MODELMBEAN_LOGGER.logp(Level.FINEST, |
847 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); |
903 DescriptorSupport.class.getName(), |
|
904 "isValid()", "Entry"); |
|
905 } |
848 } |
906 // verify that the descriptor is valid, by iterating over each field... |
849 // verify that the descriptor is valid, by iterating over each field... |
907 |
850 |
908 Set<Map.Entry<String, Object>> returnedSet = descriptorMap.entrySet(); |
851 Set<Map.Entry<String, Object>> returnedSet = descriptorMap.entrySet(); |
909 |
852 |
910 if (returnedSet == null) { // null descriptor, not valid |
853 if (returnedSet == null) { // null descriptor, not valid |
911 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
854 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
912 MODELMBEAN_LOGGER.logp(Level.FINEST, |
855 MODELMBEAN_LOGGER.log(Level.TRACE, |
913 DescriptorSupport.class.getName(), |
856 "isValid() Returns false (null set)"); |
914 "isValid()", "Returns false (null set)"); |
|
915 } |
857 } |
916 return false; |
858 return false; |
917 } |
859 } |
918 // must have a name and descriptor type field |
860 // must have a name and descriptor type field |
919 String thisName = (String)(this.getFieldValue("name")); |
861 String thisName = (String)(this.getFieldValue("name")); |
1285 * field Names or field Values. If the descriptor string fails |
1224 * field Names or field Values. If the descriptor string fails |
1286 * for any reason, this exception will be thrown. |
1225 * for any reason, this exception will be thrown. |
1287 */ |
1226 */ |
1288 @Override |
1227 @Override |
1289 public synchronized String toString() { |
1228 public synchronized String toString() { |
1290 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
1229 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
1291 MODELMBEAN_LOGGER.logp(Level.FINEST, |
1230 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); |
1292 DescriptorSupport.class.getName(), |
|
1293 "toString()", "Entry"); |
|
1294 } |
1231 } |
1295 |
1232 |
1296 String respStr = ""; |
1233 String respStr = ""; |
1297 String[] fields = getFields(); |
1234 String[] fields = getFields(); |
1298 |
1235 |
1299 if ((fields == null) || (fields.length == 0)) { |
1236 if ((fields == null) || (fields.length == 0)) { |
1300 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
1237 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
1301 MODELMBEAN_LOGGER.logp(Level.FINEST, |
1238 MODELMBEAN_LOGGER.log(Level.TRACE, "Empty Descriptor"); |
1302 DescriptorSupport.class.getName(), |
|
1303 "toString()", "Empty Descriptor"); |
|
1304 } |
1239 } |
1305 return respStr; |
1240 return respStr; |
1306 } |
1241 } |
1307 |
1242 |
1308 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
1243 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
1309 MODELMBEAN_LOGGER.logp(Level.FINEST, |
1244 MODELMBEAN_LOGGER.log(Level.TRACE, |
1310 DescriptorSupport.class.getName(), |
1245 "Printing " + fields.length + " fields"); |
1311 "toString()", "Printing " + fields.length + " fields"); |
|
1312 } |
1246 } |
1313 |
1247 |
1314 for (int i=0; i < fields.length; i++) { |
1248 for (int i=0; i < fields.length; i++) { |
1315 if (i == (fields.length - 1)) { |
1249 if (i == (fields.length - 1)) { |
1316 respStr = respStr.concat(fields[i]); |
1250 respStr = respStr.concat(fields[i]); |
1317 } else { |
1251 } else { |
1318 respStr = respStr.concat(fields[i] + ", "); |
1252 respStr = respStr.concat(fields[i] + ", "); |
1319 } |
1253 } |
1320 } |
1254 } |
1321 |
1255 |
1322 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
1256 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
1323 MODELMBEAN_LOGGER.logp(Level.FINEST, |
1257 MODELMBEAN_LOGGER.log(Level.TRACE, "Exit returning " + respStr); |
1324 DescriptorSupport.class.getName(), |
|
1325 "toString()", "Exit returning " + respStr); |
|
1326 } |
1258 } |
1327 |
1259 |
1328 return respStr; |
1260 return respStr; |
1329 } |
1261 } |
1330 |
1262 |