Coverage report

  %line %branch
org.apache.commons.configuration.PropertyConverter
99% 
100% 

 1  
 /*
 2  
  * Copyright 2004-2005 The Apache Software Foundation.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License")
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package org.apache.commons.configuration;
 18  
 
 19  
 import java.awt.Color;
 20  
 import java.math.BigDecimal;
 21  
 import java.math.BigInteger;
 22  
 import java.net.MalformedURLException;
 23  
 import java.net.URL;
 24  
 import java.text.ParseException;
 25  
 import java.text.SimpleDateFormat;
 26  
 import java.util.ArrayList;
 27  
 import java.util.Calendar;
 28  
 import java.util.Collection;
 29  
 import java.util.Date;
 30  
 import java.util.Iterator;
 31  
 import java.util.List;
 32  
 import java.util.Locale;
 33  
 
 34  
 import org.apache.commons.collections.IteratorUtils;
 35  
 import org.apache.commons.collections.iterators.IteratorChain;
 36  
 import org.apache.commons.collections.iterators.SingletonIterator;
 37  
 import org.apache.commons.lang.BooleanUtils;
 38  
 import org.apache.commons.lang.StringUtils;
 39  
 
 40  
 /**
 41  
  * A utility class to convert the configuration properties into any type.
 42  
  *
 43  
  * @author Emmanuel Bourg
 44  
  * @version $Revision$, $Date: 2005-12-06 04:10:27 +0100 (Tue, 06 Dec 2005) $
 45  
  * @since 1.1
 46  
  */
 47  
 public final class PropertyConverter
 48  
 {
 49  
     /** Constant for the list delimiter escaping character.*/
 50  
     static final String LIST_ESCAPE = "\\";
 51  
 
 52  
     /** Constant for the prefix of hex numbers.*/
 53  
     private static final String HEX_PREFIX = "0x";
 54  
 
 55  
     /** Constant for the radix of hex numbers.*/
 56  
     private static final int HEX_RADIX = 16;
 57  
 
 58  
     /**
 59  
      * Private constructor prevents instances from being created.
 60  
      */
 61  
     private PropertyConverter()
 62  0
     {
 63  
         // to prevent instanciation...
 64  0
     }
 65  
 
 66  
     /**
 67  88
      * Convert the specified object into a Boolean.
 68  
      *
 69  32
      * @param value the value to convert
 70  
      * @return the converted value
 71  56
      * @throws ConversionException thrown if the value cannot be converted to a boolean
 72  
      */
 73  54
     public static Boolean toBoolean(Object value) throws ConversionException
 74  54
     {
 75  176
         if (value instanceof Boolean)
 76  4
         {
 77  64
             return (Boolean) value;
 78  50
         }
 79  112
         else if (value instanceof String)
 80  
         {
 81  108
             Boolean b = BooleanUtils.toBooleanObject((String) value);
 82  110
             if (b == null)
 83  
             {
 84  8
                 throw new ConversionException("The value " + value + " can't be converted to a Boolean object");
 85  
             }
 86  100
             return b;
 87  
         }
 88  
         else
 89  
         {
 90  4
             throw new ConversionException("The value " + value + " can't be converted to a Boolean object");
 91  
         }
 92  
     }
 93  
 
 94  
     /**
 95  53
      * Convert the specified object into a Byte.
 96  
      *
 97  19
      * @param value the value to convert
 98  
      * @return the converted value
 99  34
      * @throws ConversionException thrown if the value cannot be converted to a byte
 100  
      */
 101  
     public static Byte toByte(Object value) throws ConversionException
 102  
     {
 103  138
         if (value instanceof Byte)
 104  32
         {
 105  38
             return (Byte) value;
 106  1
         }
 107  68
         else if (value instanceof String)
 108  
         {
 109  
             try
 110  31
             {
 111  64
                 String string = (String) value;
 112  64
                 if (string.startsWith(HEX_PREFIX))
 113  
                 {
 114  2
                     return new Byte((byte) Integer.parseInt(string.substring(2), HEX_RADIX));
 115  4
                 }
 116  
                 else
 117  
                 {
 118  62
                     return new Byte(string);
 119  
                 }
 120  2
             }
 121  
             catch (NumberFormatException e)
 122  
             {
 123  8
                 throw new ConversionException("The value " + value + " can't be converted to a Byte object", e);
 124  
             }
 125  
         }
 126  
         else
 127  
         {
 128  4
             throw new ConversionException("The value " + value + " can't be converted to a Byte object");
 129  
         }
 130  
     }
 131  
 
 132  
     /**
 133  58
      * Convert the specified object into a Short.
 134  
      *
 135  19
      * @param value the value to convert
 136  
      * @return the converted value
 137  39
      * @throws ConversionException thrown if the value cannot be converted to a short
 138  
      */
 139  
     public static Short toShort(Object value) throws ConversionException
 140  
     {
 141  153
         if (value instanceof Short)
 142  37
         {
 143  38
             return (Short) value;
 144  1
         }
 145  78
         else if (value instanceof String)
 146  
         {
 147  
             try
 148  36
             {
 149  74
                 String string = (String) value;
 150  74
                 if (string.startsWith(HEX_PREFIX))
 151  
                 {
 152  2
                     return new Short((short) Integer.parseInt(string.substring(2), HEX_RADIX));
 153  
                 }
 154  4
                 else
 155  
                 {
 156  72
                     return new Short(string);
 157  
                 }
 158  
 
 159  2
             }
 160  
             catch (NumberFormatException e)
 161  
             {
 162  8
                 throw new ConversionException("The value " + value + " can't be converted to a Short object", e);
 163  
             }
 164  
         }
 165  
         else
 166  
         {
 167  4
             throw new ConversionException("The value " + value + " can't be converted to a Short object");
 168  
         }
 169  
     }
 170  
 
 171  
     /**
 172  62
      * Convert the specified object into an Integer.
 173  
      *
 174  23
      * @param value the value to convert
 175  
      * @return the converted value
 176  39
      * @throws ConversionException thrown if the value cannot be converted to an integer
 177  
      */
 178  
     public static Integer toInteger(Object value) throws ConversionException
 179  
     {
 180  161
         if (value instanceof Integer)
 181  37
         {
 182  46
             return (Integer) value;
 183  1
         }
 184  78
         else if (value instanceof String)
 185  
         {
 186  
             try
 187  36
             {
 188  74
                 String string = (String) value;
 189  74
                 if (string.startsWith(HEX_PREFIX))
 190  
                 {
 191  2
                     return new Integer((int) Long.parseLong(string.substring(2), HEX_RADIX));
 192  2
                 }
 193  
                 else
 194  
                 {
 195  72
                     return new Integer(string);
 196  
                 }
 197  2
             }
 198  
             catch (NumberFormatException e)
 199  
             {
 200  4
                 throw new ConversionException("The value " + value + " can't be converted to an Integer object", e);
 201  
             }
 202  
         }
 203  
         else
 204  
         {
 205  4
             throw new ConversionException("The value " + value + " can't be converted to an Integer object");
 206  
         }
 207  
     }
 208  
 
 209  
     /**
 210  53
      * Convert the specified object into a Long.
 211  
      *
 212  19
      * @param value the value to convert
 213  
      * @return the converted value
 214  34
      * @throws ConversionException thrown if the value cannot be converted to a Long
 215  
      */
 216  
     public static Long toLong(Object value) throws ConversionException
 217  
     {
 218  138
         if (value instanceof Long)
 219  32
         {
 220  38
             return (Long) value;
 221  1
         }
 222  68
         else if (value instanceof String)
 223  
         {
 224  
             try
 225  31
             {
 226  64
                 String string = (String) value;
 227  64
                 if (string.startsWith(HEX_PREFIX))
 228  
                 {
 229  2
                     return new Long(class="keyword">new BigInteger(string.substring(2), HEX_RADIX).longValue());
 230  4
                 }
 231  
                 else
 232  
                 {
 233  62
                     return new Long(string);
 234  
                 }
 235  2
             }
 236  
             catch (NumberFormatException e)
 237  
             {
 238  8
                 throw new ConversionException("The value " + value + " can't be converted to a Long object", e);
 239  
             }
 240  
         }
 241  
         else
 242  
         {
 243  4
             throw new ConversionException("The value " + value + " can't be converted to a Long object");
 244  
         }
 245  
     }
 246  
 
 247  
     /**
 248  52
      * Convert the specified object into a Float.
 249  
      *
 250  19
      * @param value the value to convert
 251  
      * @return the converted value
 252  33
      * @throws ConversionException thrown if the value cannot be converted to a Float
 253  
      */
 254  
     public static Float toFloat(Object value) throws ConversionException
 255  
     {
 256  135
         if (value instanceof Float)
 257  
         {
 258  38
             return (Float) value;
 259  
         }
 260  70
         else if (value instanceof String)
 261  
         {
 262  
             try
 263  
             {
 264  62
                 return new Float((String) value);
 265  2
             }
 266  
             catch (NumberFormatException e)
 267  
             {
 268  8
                 throw new ConversionException("The value " + value + " can't be converted to a Float object", e);
 269  
             }
 270  
         }
 271  
         else
 272  
         {
 273  4
             throw new ConversionException("The value " + value + " can't be converted to a Float object");
 274  
         }
 275  
     }
 276  
 
 277  
     /**
 278  53
      * Convert the specified object into a Double.
 279  
      *
 280  20
      * @param value the value to convert
 281  
      * @return the converted value
 282  33
      * @throws ConversionException thrown if the value cannot be converted to a Double
 283  
      */
 284  
     public static Double toDouble(Object value) throws ConversionException
 285  
     {
 286  137
         if (value instanceof Double)
 287  
         {
 288  40
             return (Double) value;
 289  
         }
 290  70
         else if (value instanceof String)
 291  
         {
 292  
             try
 293  
             {
 294  62
                 return new Double((String) value);
 295  2
             }
 296  
             catch (NumberFormatException e)
 297  
             {
 298  8
                 throw new ConversionException("The value " + value + " can't be converted to a Double object", e);
 299  
             }
 300  
         }
 301  
         else
 302  
         {
 303  4
             throw new ConversionException("The value " + value + " can't be converted to a Double object");
 304  
         }
 305  
     }
 306  
 
 307  
     /**
 308  40
      * Convert the specified object into a BigInteger.
 309  
      *
 310  14
      * @param value the value to convert
 311  
      * @return the converted value
 312  26
      * @throws ConversionException thrown if the value cannot be converted to a BigInteger
 313  
      */
 314  
     public static BigInteger toBigInteger(Object value) throws ConversionException
 315  
     {
 316  104
         if (value instanceof BigInteger)
 317  24
         {
 318  28
             return (BigInteger) value;
 319  1
         }
 320  52
         else if (value instanceof String)
 321  
         {
 322  
             try
 323  23
             {
 324  48
                 String string = (String) value;
 325  48
                 if (string.startsWith(HEX_PREFIX))
 326  
                 {
 327  2
                     return new BigInteger(string.substring(2), HEX_RADIX);
 328  4
                 }
 329  
                 else
 330  
                 {
 331  46
                     return new BigInteger(string);
 332  
                 }
 333  2
             }
 334  
             catch (NumberFormatException e)
 335  
             {
 336  8
                 throw new ConversionException("The value " + value + " can't be converted to a BigInteger object", e);
 337  
             }
 338  
         }
 339  
         else
 340  
         {
 341  4
             throw new ConversionException("The value " + value + " can't be converted to a BigInteger object");
 342  
         }
 343  
     }
 344  
 
 345  
     /**
 346  39
      * Convert the specified object into a BigDecimal.
 347  
      *
 348  14
      * @param value the value to convert
 349  
      * @return the converted value
 350  25
      * @throws ConversionException thrown if the value cannot be converted to a BigDecimal
 351  
      */
 352  
     public static BigDecimal toBigDecimal(Object value) throws ConversionException
 353  
     {
 354  101
         if (value instanceof BigDecimal)
 355  
         {
 356  28
             return (BigDecimal) value;
 357  
         }
 358  54
         else if (value instanceof String)
 359  
         {
 360  
             try
 361  
             {
 362  46
                 return new BigDecimal((String) value);
 363  2
             }
 364  
             catch (NumberFormatException e)
 365  
             {
 366  8
                 throw new ConversionException("The value " + value + " can't be converted to a BigDecimal object", e);
 367  
             }
 368  
         }
 369  
         else
 370  
         {
 371  4
             throw new ConversionException("The value " + value + " can't be converted to a BigDecimal object");
 372  
         }
 373  
     }
 374  
 
 375  
     /**
 376  35
      * Convert the specified object into an URL.
 377  
      *
 378  15
      * @param value the value to convert
 379  
      * @return the converted value
 380  20
      * @throws ConversionException thrown if the value cannot be converted to an URL
 381  
      */
 382  
     public static URL toURL(Object value) throws ConversionException
 383  
     {
 384  88
         if (value instanceof URL)
 385  
         {
 386  30
             return (URL) value;
 387  
         }
 388  42
         else if (value instanceof String)
 389  
         {
 390  
             try
 391  
             {
 392  36
                 return new URL((String) value);
 393  2
             }
 394  
             catch (MalformedURLException e)
 395  
             {
 396  4
                 throw new ConversionException("The value " + value + " can't be converted to an URL", e);
 397  
             }
 398  
         }
 399  
         else
 400  
         {
 401  4
             throw new ConversionException("The value " + value + " can't be converted to an URL");
 402  
         }
 403  
     }
 404  
 
 405  
     /**
 406  40
      * Convert the specified object into a Locale.
 407  
      *
 408  14
      * @param value the value to convert
 409  
      * @return the converted value
 410  26
      * @throws ConversionException thrown if the value cannot be converted to a Locale
 411  
      */
 412  24
     public static Locale toLocale(Object value) throws ConversionException
 413  24
     {
 414  80
         if (value instanceof Locale)
 415  24
         {
 416  28
             return (Locale) value;
 417  22
         }
 418  74
         else if (value instanceof String)
 419  22
         {
 420  48
             List elements = split((String) value, '_');
 421  70
             int size = elements.size();
 422  
 
 423  48
             if (size >= 1 && (((String) elements.get(0)).length() == 2 || ((String) elements.get(0)).length() == 0))
 424  
             {
 425  46
                 String language = (String) elements.get(0);
 426  44
                 String country = (String) ((size >= 2) ? elements.get(1) : "");
 427  44
                 String variant = (String) ((size >= 3) ? elements.get(2) : "");
 428  
 
 429  44
                 return new Locale(language, country, variant);
 430  2
             }
 431  
             else
 432  
             {
 433  4
                 throw new ConversionException("The value " + value + " can't be converted to a Locale");
 434  
             }
 435  
         }
 436  
         else
 437  
         {
 438  4
             throw new ConversionException("The value " + value + " can't be converted to a Locale");
 439  
         }
 440  
     }
 441  
 
 442  
     /**
 443  
      * Split a string on the specified delimiter. To be removed when
 444  
      * commons-lang has a better replacement available (Tokenizer?).
 445  
      *
 446  7110
      * todo: replace with a commons-lang equivalent
 447  
      *
 448  9
      * @param s          the string to split
 449  
      * @param delimiter  the delimiter
 450  
      * @return a list with the single tokens
 451  7101
      */
 452  
     public static List split(String s, char delimiter)
 453  7101
     {
 454  21321
         if (s == null)
 455  7101
         {
 456  23855
             return new ArrayList();
 457  
         }
 458  
 
 459  23837
         List list = new ArrayList();
 460  
 
 461  14202
         StringBuffer token = new StringBuffer();
 462  23837
         int begin = 0;
 463  14202
         int end = 0;
 464  47674
         while (begin <= s.length())
 465  9635
         {
 466  
             // find the next delimiter
 467  28905
             int index = s.indexOf(delimiter, end);
 468  
 
 469  637
             // move the end index at the end of the string if the delimiter is not found
 470  19907
             end = (index != -1) ? index : s.length();
 471  
 
 472  
             // extract the chunk
 473  19270
             String chunk = s.substring(begin , end);
 474  
 
 475  28268
             if (chunk.endsWith(LIST_ESCAPE) && end != s.length())
 476  
             {
 477  1274
                 token.append(chunk.substring(0, chunk.length() - 1));
 478  10272
                 token.append(delimiter);
 479  
             }
 480  
             else
 481  8998
             {
 482  
                 // append the chunk to the token
 483  17996
                 token.append(chunk);
 484  
 
 485  9635
                 // add the token to the list
 486  27631
                 list.add(token.toString().trim());
 487  
 
 488  
                 // reset the token
 489  25097
                 token = new StringBuffer();
 490  
             }
 491  
 
 492  
             // move to the next chunk
 493  19270
             end = end + 1;
 494  19270
             begin = end;
 495  
         }
 496  
 
 497  14202
         return list;
 498  
     }
 499  
 
 500  
     /**
 501  
      * Escapes the delimiters that might be contained in the given string. This
 502  
      * method ensures that list delimiter characters that are part of a
 503  
      * property's value are correctly escaped when a configuration is saved to a
 504  
      * file. Otherwise when loaded again the property will be treated as a list
 505  102
      * property.
 506  
      *
 507  
      * @param s the string with the value
 508  
      * @param delimiter the list delimiter to use
 509  
      * @return the correctly esaped string
 510  
      */
 511  
     public static String escapeDelimiters(String s, char delimiter)
 512  
     {
 513  204
         return StringUtils.replace(s, String.valueOf(delimiter), LIST_ESCAPE
 514  
                 + delimiter);
 515  
     }
 516  
 
 517  
     /**
 518  
      * Convert the specified object into a Color. If the value is a String,
 519  
      * the format allowed is (#)?[0-9A-F]{6}([0-9A-F]{2})?. Examples:
 520  
      * <ul>
 521  
      *   <li>FF0000 (red)</li>
 522  
      *   <li>0000FFA0 (semi transparent blue)</li>
 523  
      *   <li>#CCCCCC (gray)</li>
 524  
      *   <li>#00FF00A0 (semi transparent green)</li>
 525  36
      * </ul>
 526  
      *
 527  14
      * @param value the value to convert
 528  
      * @return the converted value
 529  22
      * @throws ConversionException thrown if the value cannot be converted to a Color
 530  
      */
 531  
     public static Color toColor(Object value) throws ConversionException
 532  
     {
 533  92
         if (value instanceof Color)
 534  
         {
 535  28
             return (Color) value;
 536  20
         }
 537  44
         else if (value instanceof String && !StringUtils.isBlank((String) value))
 538  2
         {
 539  40
             String color = ((String) value).trim();
 540  
 
 541  60
             int[] components = new class="keyword">int[3];
 542  18
 
 543  18
             // check the size of the string
 544  58
             int minlength = components.length * 2;
 545  40
             if (color.length() < minlength)
 546  
             {
 547  18
                 throw new ConversionException("The value " + value + " can't be converted to a Color");
 548  
             }
 549  1
 
 550  
             // remove the leading #
 551  40
             if (color.startsWith("#"))
 552  18
             {
 553  4
                 color = color.substring(1);
 554  
             }
 555  
 
 556  2
             try
 557  
             {
 558  
                 // parse the components
 559  148
                 for (int i = 0; i < components.length; i++)
 560  
                 {
 561  114
                     components[i] = Integer.parseInt(color.substring(2 * i, 2 * i + 2), HEX_RADIX);
 562  
                 }
 563  
 
 564  
                 // parse the transparency
 565  
                 int alpha;
 566  36
                 if (color.length() >= minlength + 2)
 567  
                 {
 568  2
                     alpha = Integer.parseInt(color.substring(minlength, minlength + 2), HEX_RADIX);
 569  
                 }
 570  
                 else
 571  
                 {
 572  34
                     alpha = Color.black.getAlpha();
 573  
                 }
 574  
 
 575  76
                 return new Color(components[0], components[1], components[2], alpha);
 576  
             }
 577  15
             catch (Exception e)
 578  
             {
 579  29
                 throw new ConversionException("The value " + value + " can't be converted to a Color", e);
 580  
             }
 581  5
         }
 582  
         else
 583  20
         {
 584  4
             throw new ConversionException("The value " + value + " can't be converted to a Color");
 585  
         }
 586  
     }
 587  18
 
 588  
     /**
 589  
      * Convert the specified object into a Date.
 590  
      *
 591  2
      * @param value  the value to convert
 592  
      * @param format the DateFormat pattern to parse String values
 593  
      * @return the converted value
 594  
      * @throws ConversionException thrown if the value cannot be converted to a Calendar
 595  
      */
 596  2
     public static Date toDate(Object value, String format) throws ConversionException
 597  
     {
 598  80
         if (value instanceof Date)
 599  
         {
 600  30
             return (Date) value;
 601  
         }
 602  50
         else if (value instanceof Calendar)
 603  
         {
 604  10
             return ((Calendar) value).getTime();
 605  
         }
 606  40
         else if (value instanceof String)
 607  
         {
 608  
             try
 609  
             {
 610  76
                 return new SimpleDateFormat(format).parse((String) value);
 611  
             }
 612  10
             catch (ParseException e)
 613  
             {
 614  34
                 throw new ConversionException("The value " + value + " can't be converted to a Date", e);
 615  
             }
 616  10
         }
 617  10
         else
 618  10
         {
 619  4
             throw new ConversionException("The value " + value + " can't be converted to a Date");
 620  20
         }
 621  
     }
 622  
 
 623  
     /**
 624  18
      * Convert the specified object into a Calendar.
 625  18
      *
 626  16
      * @param value  the value to convert
 627  
      * @param format the DateFormat pattern to parse String values
 628  
      * @return the converted value
 629  
      * @throws ConversionException thrown if the value cannot be converted to a Calendar
 630  2
      */
 631  
     public static Calendar toCalendar(Object value, String format) throws ConversionException
 632  
     {
 633  80
         if (value instanceof Calendar)
 634  
         {
 635  22
             return (Calendar) value;
 636  
         }
 637  60
         else if (value instanceof Date)
 638  
         {
 639  20
             Calendar calendar = Calendar.getInstance();
 640  20
             calendar.setTime((Date) value);
 641  20
             return calendar;
 642  
         }
 643  40
         else if (value instanceof String)
 644  
         {
 645  
             try
 646  
             {
 647  36
                 Calendar calendar = Calendar.getInstance();
 648  36
                 calendar.setTime(new SimpleDateFormat(format).parse((String) value));
 649  32
                 return calendar;
 650  
             }
 651  
             catch (ParseException e)
 652  
             {
 653  4
                 throw new ConversionException("The value " + value + " can't be converted to a Calendar", e);
 654  
             }
 655  
         }
 656  29122
         else
 657  
         {
 658  7
             throw new ConversionException("The value " + value + " can't be converted to a Calendar");
 659  
         }
 660  29119
     }
 661  
 
 662  16459
     /**
 663  16459
      * Return an iterator over the simple values of a composite value. The value
 664  
      * specified is handled depending on its type:
 665  1413
      * <ul>
 666  
      *   <li>Strings are checked for delimiter characters and splitted if necessary.</li>
 667  
      *   <li>For collections the single elements are checked.</li>
 668  
      *   <li>Arrays are treated like collections.</li>
 669  15046
      *   <li>All other types are directly inserted.</li>
 670  
      *   <li>Recursive combinations are supported, e.g. a collection containing array that contain strings.</li>
 671  
      * </ul>
 672  12660
      *
 673  
      * @param value     the value to "split"
 674  521
      * @param delimiter the delimiter for String values
 675  
      * @return an iterator for accessing the single values
 676  12139
      */
 677  
     public static Iterator toIterator(Object value, char delimiter)
 678  787
     {
 679  58244
         if (value == null)
 680  11352
         {
 681  6
             return IteratorUtils.emptyIterator();
 682  1308
         }
 683  59546
         if (value instanceof String)
 684  5372
         {
 685  32918
             String s = (String) value;
 686  35674
             if (s.indexOf(delimiter) > 0)
 687  
             {
 688  4134
                 return split((String) value, delimiter).iterator();
 689  
             }
 690  
             else
 691  
             {
 692  40136
                 return new SingletonIterator(value);
 693  
             }
 694  
         }
 695  25320
         else if (value instanceof Collection)
 696  
         {
 697  1042
             return toIterator(((Collection) value).iterator(), delimiter);
 698  
         }
 699  24278
         else if (value.getClass().isArray())
 700  
         {
 701  1574
             return toIterator(IteratorUtils.arrayIterator(value), delimiter);
 702  
         }
 703  22704
         else if (value instanceof Iterator)
 704  
         {
 705  2616
             Iterator iterator = (Iterator) value;
 706  2616
             IteratorChain chain = new IteratorChain();
 707  10744
             while (iterator.hasNext())
 708  
             {
 709  5512
                 chain.addIterator(toIterator(iterator.next(), delimiter));
 710  
             }
 711  2616
             return chain;
 712  
         }
 713  
         else
 714  
         {
 715  20088
             return new SingletonIterator(value);
 716  
         }
 717  
     }
 718  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.