44
44
import java .util .ArrayList ;
45
45
import java .util .Collections ;
46
46
import java .util .Iterator ;
47
- import java .util .List ;
48
47
import java .util .Locale ;
49
- import java .util .Map ;
48
+ import java .util .Map . Entry ;
50
49
51
50
import org .apache .commons .digester .Digester ;
52
51
@@ -370,10 +369,7 @@ public Element generateXml(Element parent) {
370
369
371
370
// <documenttypes>
372
371
Element documenttypesElement = searchElement .addElement (N_DOCUMENTTYPES );
373
- List docTypeKeyList = m_searchManager .getDocumentTypeConfigs ();
374
- Iterator docTypeIterator = docTypeKeyList .iterator ();
375
- while (docTypeIterator .hasNext ()) {
376
- CmsSearchDocumentType currSearchDocType = (CmsSearchDocumentType )docTypeIterator .next ();
372
+ for (CmsSearchDocumentType currSearchDocType : m_searchManager .getDocumentTypeConfigs ()) {
377
373
// add the next <documenttype> element
378
374
Element documenttypeElement = documenttypesElement .addElement (N_DOCUMENTTYPE );
379
375
// add <name> element
@@ -383,30 +379,30 @@ public Element generateXml(Element parent) {
383
379
// add <mimetypes> element
384
380
Element mimetypesElement = documenttypeElement .addElement (N_MIMETYPES );
385
381
// get the list of mimetypes to trigger the document factory class
386
- Iterator mimeTypesIterator = currSearchDocType .getMimeTypes ().iterator ();
382
+ Iterator < String > mimeTypesIterator = currSearchDocType .getMimeTypes ().iterator ();
387
383
while (mimeTypesIterator .hasNext ()) {
388
384
// add <mimetype> element(s)
389
- mimetypesElement .addElement (N_MIMETYPE ).addText (( String ) mimeTypesIterator .next ());
385
+ mimetypesElement .addElement (N_MIMETYPE ).addText (mimeTypesIterator .next ());
390
386
}
391
387
// add <resourcetypes> element
392
388
Element restypesElement = documenttypeElement .addElement (N_RESOURCETYPES );
393
389
// get the list of Cms resource types to trigger the document factory
394
- Iterator resTypesIterator = currSearchDocType .getResourceTypes ().iterator ();
390
+ Iterator < String > resTypesIterator = currSearchDocType .getResourceTypes ().iterator ();
395
391
while (resTypesIterator .hasNext ()) {
396
392
// add <resourcetype> element(s)
397
- restypesElement .addElement (N_RESOURCETYPE ).addText (( String ) resTypesIterator .next ());
393
+ restypesElement .addElement (N_RESOURCETYPE ).addText (resTypesIterator .next ());
398
394
}
399
395
}
400
396
// </documenttypes>
401
397
402
398
// <analyzers>
403
399
Element analyzersElement = searchElement .addElement (N_ANALYZERS );
404
- List analyzerLocaleList = new ArrayList (m_searchManager .getAnalyzers ().keySet ());
400
+ ArrayList < Locale > analyzerLocaleList = new ArrayList < Locale > (m_searchManager .getAnalyzers ().keySet ());
405
401
// sort Analyzers in ascending order
406
402
Collections .sort (analyzerLocaleList , CmsLocaleComparator .getComparator ());
407
- Iterator analyzersLocaleInterator = analyzerLocaleList .iterator ();
403
+ Iterator < Locale > analyzersLocaleInterator = analyzerLocaleList .iterator ();
408
404
while (analyzersLocaleInterator .hasNext ()) {
409
- CmsSearchAnalyzer searchAnalyzer = m_searchManager .getCmsSearchAnalyzer (( Locale ) analyzersLocaleInterator .next ());
405
+ CmsSearchAnalyzer searchAnalyzer = m_searchManager .getCmsSearchAnalyzer (analyzersLocaleInterator .next ());
410
406
// add the next <analyzer> element
411
407
Element analyzerElement = analyzersElement .addElement (N_ANALYZER );
412
408
// add <class> element
@@ -422,9 +418,7 @@ public Element generateXml(Element parent) {
422
418
423
419
// <indexes>
424
420
Element indexesElement = searchElement .addElement (N_INDEXES );
425
- Iterator indexIterator = m_searchManager .getSearchIndexes ().iterator ();
426
- while (indexIterator .hasNext ()) {
427
- CmsSearchIndex searchIndex = (CmsSearchIndex )indexIterator .next ();
421
+ for (CmsSearchIndex searchIndex : m_searchManager .getSearchIndexes ()) {
428
422
// add the next <index> element
429
423
Element indexElement = indexesElement .addElement (N_INDEX );
430
424
// add class attribute (if required)
@@ -447,10 +441,10 @@ public Element generateXml(Element parent) {
447
441
// add <sources> element
448
442
Element sourcesElement = indexElement .addElement (N_SOURCES );
449
443
// iterate above sourcenames
450
- Iterator sourcesIterator = searchIndex .getSourceNames ().iterator ();
444
+ Iterator < String > sourcesIterator = searchIndex .getSourceNames ().iterator ();
451
445
while (sourcesIterator .hasNext ()) {
452
446
// add <source> element
453
- sourcesElement .addElement (N_SOURCE ).addText (( String ) sourcesIterator .next ());
447
+ sourcesElement .addElement (N_SOURCE ).addText (sourcesIterator .next ());
454
448
}
455
449
// iterate additional params
456
450
CmsParameterConfiguration indexConfiguration = searchIndex .getConfiguration ();
@@ -462,10 +456,7 @@ public Element generateXml(Element parent) {
462
456
463
457
// <indexsources>
464
458
Element indexsourcesElement = searchElement .addElement (N_INDEXSOURCES );
465
- List indexSources = new ArrayList (m_searchManager .getSearchIndexSources ().values ());
466
- Iterator indexsourceIterator = indexSources .iterator ();
467
- while (indexsourceIterator .hasNext ()) {
468
- CmsSearchIndexSource searchIndexSource = (CmsSearchIndexSource )indexsourceIterator .next ();
459
+ for (CmsSearchIndexSource searchIndexSource : m_searchManager .getSearchIndexSources ().values ()) {
469
460
// add <indexsource> element(s)
470
461
Element indexsourceElement = indexsourcesElement .addElement (N_INDEXSOURCE );
471
462
// add <name> element
@@ -474,39 +465,32 @@ public Element generateXml(Element parent) {
474
465
Element indexerElement = indexsourceElement .addElement (N_INDEXER ).addAttribute (
475
466
N_CLASS ,
476
467
searchIndexSource .getIndexerClassName ());
477
- Map params = searchIndexSource .getParams ();
478
- Iterator paramIterator = params .entrySet ().iterator ();
479
- while (paramIterator .hasNext ()) {
480
- Map .Entry entry = (Map .Entry )paramIterator .next ();
481
- String name = (String )entry .getKey ();
482
- String value = (String )entry .getValue ();
468
+ for (Entry <String , String > entry : searchIndexSource .getParams ().entrySet ()) {
483
469
// add <param name=""> element(s)
484
470
indexerElement .addElement (I_CmsXmlConfiguration .N_PARAM ).addAttribute (
485
471
I_CmsXmlConfiguration .A_NAME ,
486
- name ) .addText (value );
472
+ entry . getKey ()) .addText (entry . getValue () );
487
473
}
488
474
// add <resources> element
489
475
Element resourcesElement = indexsourceElement .addElement (N_RESOURCES );
490
- Iterator resourceIterator = searchIndexSource .getResourcesNames ().iterator ();
476
+ Iterator < String > resourceIterator = searchIndexSource .getResourcesNames ().iterator ();
491
477
while (resourceIterator .hasNext ()) {
492
478
// add <resource> element(s)
493
- resourcesElement .addElement (N_RESOURCE ).addText (( String ) resourceIterator .next ());
479
+ resourcesElement .addElement (N_RESOURCE ).addText (resourceIterator .next ());
494
480
}
495
481
// add <documenttypes-indexed> element
496
482
Element doctypes_indexedElement = indexsourceElement .addElement (N_DOCUMENTTYPES_INDEXED );
497
- Iterator doctypesIterator = searchIndexSource .getDocumentTypes ().iterator ();
483
+ Iterator < String > doctypesIterator = searchIndexSource .getDocumentTypes ().iterator ();
498
484
while (doctypesIterator .hasNext ()) {
499
485
// add <name> element(s)
500
- doctypes_indexedElement .addElement (N_NAME ).addText (( String ) doctypesIterator .next ());
486
+ doctypes_indexedElement .addElement (N_NAME ).addText (doctypesIterator .next ());
501
487
}
502
488
}
503
489
// </indexsources>
504
490
505
491
// <fieldconfigurations>
506
492
Element fieldConfigurationsElement = searchElement .addElement (N_FIELDCONFIGURATIONS );
507
- Iterator configs = m_searchManager .getFieldConfigurations ().iterator ();
508
- while (configs .hasNext ()) {
509
- CmsSearchFieldConfiguration fieldConfiguration = (CmsSearchFieldConfiguration )configs .next ();
493
+ for (CmsSearchFieldConfiguration fieldConfiguration : m_searchManager .getFieldConfigurations ()) {
510
494
Element fieldConfigurationElement = fieldConfigurationsElement .addElement (N_FIELDCONFIGURATION );
511
495
// add class attribute (if required)
512
496
if (!fieldConfiguration .getClass ().equals (CmsSearchFieldConfiguration .class )) {
@@ -518,9 +502,7 @@ public Element generateXml(Element parent) {
518
502
}
519
503
// search fields
520
504
Element fieldsElement = fieldConfigurationElement .addElement (N_FIELDS );
521
- Iterator fields = fieldConfiguration .getFields ().iterator ();
522
- while (fields .hasNext ()) {
523
- CmsSearchField field = (CmsSearchField )fields .next ();
505
+ for (CmsSearchField field : fieldConfiguration .getFields ()) {
524
506
Element fieldElement = fieldsElement .addElement (N_FIELD );
525
507
fieldElement .addAttribute (A_NAME , field .getName ());
526
508
if (CmsStringUtil .isNotEmptyOrWhitespaceOnly (field .getDisplayNameForConfiguration ())) {
@@ -562,9 +544,7 @@ public Element generateXml(Element parent) {
562
544
fieldElement .addAttribute (A_ANALYZER , className );
563
545
}
564
546
// field mappings
565
- Iterator mappings = field .getMappings ().iterator ();
566
- while (mappings .hasNext ()) {
567
- CmsSearchFieldMapping mapping = (CmsSearchFieldMapping )mappings .next ();
547
+ for (CmsSearchFieldMapping mapping : field .getMappings ()) {
568
548
Element mappingElement = fieldElement .addElement (N_MAPPING );
569
549
mappingElement .addAttribute (A_TYPE , mapping .getType ().toString ());
570
550
if (CmsStringUtil .isNotEmptyOrWhitespaceOnly (mapping .getDefaultValue ())) {
0 commit comments