Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
package com.esotericsoftware.scar;

import java.io.*;
import java.util.*;
import java.util.regex.*;

import com.esotericsoftware.filesystem.*;
import com.esotericsoftware.scar.support.*;
import com.esotericsoftware.utils.*;

import static com.esotericsoftware.scar.support.Parameter.*;

@SuppressWarnings({"UnusedDeclaration"})
public class ProjectParameters extends FileUtil
{
    public static final Parameter NAME = def( "name", Form.STRING, "The name of the project. Used to name the JAR.", //
                                              "Default:\n" + //
                                              "  The name of the directory containing the project YAML file, or\n" + //
                                              "  the name of the YAML file if it is not 'build'." );

    public static final Parameter VERSION = def( "version", Form.STRING, "The version of the project. If available, used to name the 'default' named JAR." );

    public static final Parameter MAIN = def( "main", Form.STRING, "Name of the main class." );

    public static final Parameter TARGET = def( "target", Form.STRING, "The directory to output build artifacts.", //
                                                "Default: The directory containing the project YAML file, plus 'build'." );

    public static final Parameter DEPENDENCIES = def( "dependencies", Form.STRING_LIST, "Relative or absolute path(s) to dependency project directories or YAML files." );

    public static final Parameter COMPILECLASSPATH = def( "compileclasspath", Form.PATHS, "Wildcard patterns for the file(s) to include on the 'compile' classpath.", //
                                                          "Note: automatically includes the ClassPath(s)." );

    public static final Parameter CLASSPATH = def( "classpath", Form.PATHS, "Wildcard patterns for the file(s) to include on the classpath (both, compile & runtime/deployment).", //
                                                   "Default: 'lib|**.jar'." );

    public static final Parameter SOURCE = def( "source", Form.PATHS, "Wildcard patterns for the Java file(s) to compile.", //
                                                "Default: 'src|**.java' or 'src/main/java|**.java'." );

    public static final Parameter RESOURCES = def( "resources", Form.PATHS, "Wildcard patterns for the file(s) to include in the JAR.", //
                                                   "Default: 'resources' or 'src/main/resources'." );

    public static final Parameter JAR = def( "jar", Form.STRING, "JAR name w/ optional path for the JAR ('.jar' added to the end if does not end with 'jar', case insensitive).", //
                                             "Default: '$target$[-$version$]'." );

    public static final Parameter DIST = def( "dist", Form.PATHS, "Wildcard patterns for the file(s) to include in the distribution, outside the JAR.", //
                                              "Default: 'war' (if there)." );

    // ------------------------------- Packaging Options, these are mutually exclusive ---------------------------------

    public static final Parameter APPDIR = def( "appdir", Form.STRING, "Directory path to bring together all files (both JARs and 'dist', for this project " + "and all dependencies, recursively) the application needs to be run from JAR files." );

    public static final Parameter ONEJAR = def( "onejar", Form.STRING, "JAR name w/ optional path for the JAR ('.jar' added to the end if does not end with 'jar', case insensitive), that all 'exploded' dependendend JARs and dist files will be JAR'd into (this should make a single JAR application)." );

    public static final Parameter WAR = def( "war", Form.STRING, "Target WAR directory or WAR name (if ends w/ '.war'), produces a war directory (as specified, or a default one if a '.war' is requested) then if a '.war' is requested, packages the war directory into the specified '.war' file." );

    // ------------------------------------------------ GWT Parameters -------------------------------------------------

    public static final Parameter GWT = def( "GWT", Form.STRING, "The 'package' Name of the 'root' '.gwt.xml' file. e.g. 'org.sample.MyGwtApplication'" );

    public static final Parameter GWTat = def( "GWTat", Form.STRING, "The directory to find the GWT JARs.  Required if 'GWT' indicated" );

    public static final Parameter GWTwar = def( "GWTwar", Form.STRING, "The directory to put the GWT Compiler's output in.", //
                                                "Default: '$target$/GWTCompilerOutput'." );

    public static final Parameter GWTstyle = def( "GWTstyle", Form.STRING, "GWT Compiler's output 'style'.  Options are: OBF, PRETTY, or DETAILED.  Note: OBF == Obfuscated.", //
                                                  "Default: 'OBF'." );

    public static final Parameter GWTlogging = def( "GWTlogging", Form.STRING, "Logging level for the GWT Compiler.  Options are: ERROR, WARN, INFO, TRACE, DEBUG, SPAM, or ALL.", //
                                                    "Default: 'INFO'." );

    public static final Parameter GWTmx = def( "GWTmx", Form.STRING, "the -Xmx value for the GWT Compiler.", //
                                               "Default: '128m'." );

    public static final String GWT_DEV = "gwt-dev.jar";
    public static final String GWT_USER = "gwt-user.jar";
    public static final String GWT_SERVLET = "gwt-servlet.jar";

    private static final String[] GWT_JARS = {GWT_DEV, GWT_USER, GWT_SERVLET};

    // -------------------------------------------------- Validation ---------------------------------------------------

    public ProjectParameters validate()
    {
        int zHas = intForNotNull( 1, getAppDir() ) + //
                   intForNotNull( 2, getOneJar() ) + //
                   intForNotNull( 4, getWar() );
        switch ( zHas )
        {
            default:
            case 1:
            case 2:
            case 4:
                break; // Happy Cases
            case 3:
                throw new IllegalArgumentException( "May not specify both: AppDir & OneJAR" );
            case 5:
                throw new IllegalArgumentException( "May not specify both: AppDir & WAR" );
            case 6:
                throw new IllegalArgumentException( "May not specify both: OneJAR & WAR" );
            case 7:
                throw new IllegalArgumentException( "May only specify one of: AppDir, OneJAR, or WAR" );
        }
        return this;
    }

    // ------------------------------------------------ Default Support ------------------------------------------------

    protected synchronized void applyDefaults()
    {
        defaultTARGET();
        defaultCLASSPATH();
        defaultSOURCE();
        defaultRESOURCES();
        defaultJAR();
        defaultDIST();
        defaultGWT();
        defaultOneJar();
    }

    protected void defaultOneJar()
    {
        enforceJarExtension( ONEJAR.getName() );
    }

    protected void defaultDIST()
    {
        defaultSubDirOptional( DIST, "war" );
    }

    protected void defaultJAR()
    {
        if ( null == enforceJarExtension( JAR.getName() ) )
        {
            mManager.put( JAR.getName(), "$target$/$name$" + (hasVersion() ? "-$version$" : "") + ".jar" );
        }
    }

    protected void defaultTARGET()
    {
        defaultKey( TARGET, "build" );
    }

    protected void defaultCLASSPATH()
    {
        defaultSubDirOptional( CLASSPATH, "lib|**.jar" );
    }

    protected void defaultRESOURCES()
    {
        defaultSubDirOptional( RESOURCES, "src/main/resources", "resources" );
    }

    protected void defaultSOURCE()
    {
        defaultSubDirOptional( SOURCE, "src/main/java|**.java", "src|**.java" );
    }

    protected void defaultGWT()
    {
        String zGWT = getGWT();
        if ( null != zGWT )
        {
            verifyGWTlibs( getGWTatDir() );
            defaultKey( GWTwar, "$target$/GWTCompilerOutput" );
            defaultKey( GWTstyle, "OBF" );
            defaultKey( GWTlogging, "INFO" );
            defaultKey( GWTmx, "512m" );
        }
    }

    protected void verifyGWTlibs( File pGWTdir )
    {
        if ( pGWTdir == null )
        {
            throw new IllegalStateException( "GWT specified, but NO GWTat!" );
        }
        if ( !pGWTdir.isDirectory() )
        {
            throw new IllegalStateException( "GWTat '" + pGWTdir + "' is not a directory!" );
        }
        for ( String zGwtJar : GWT_JARS )
        {
            if ( !new File( pGWTdir, zGwtJar ).isFile() )
            {
                throw new IllegalStateException( "GWTat '" + pGWTdir.getPath() + "' did not contain: " + zGwtJar );
            }
        }
    }

    protected String enforceJarExtension( String pEntryName )
    {
        String zJar = get( pEntryName );
        if ( null != zJar )
        {
            int at = zJar.lastIndexOf( '.' );
            if ( at == -1 || !".jar".equalsIgnoreCase( zJar.substring( at ) ) )
            {
                mManager.put( pEntryName, zJar += ".jar" );
            }
        }
        return zJar;
    }

    // ------------------------------------------- Special Property Accessors ------------------------------------------

    public boolean hasVersion()
    {
        return (null != getVersion());
    }

    public String getVersion()
    {
        return get( VERSION.getName() );
    }

    public boolean hasMain()
    {
        return (null != getMain());
    }

    public String getMain()
    {
        return get( MAIN.getName() );
    }

    public String getTarget()
    {
        return get( TARGET.getName() );
    }

    public String getTargetPath()
    {
        return getPath( TARGET.getName() );
    }

    public List<String> getDependencies()
    {
        return getListNotNull( DEPENDENCIES.getName() );
    }

    public Paths getCompileClasspath()
    {
        return getPaths( COMPILECLASSPATH.getName() );
    }

    public Paths getClasspath()
    {
        return getPaths( CLASSPATH.getName() );
    }

    public Paths getSource()
    {
        return getPaths( SOURCE.getName() );
    }

    public Paths getResources()
    {
        return getPaths( RESOURCES.getName() );
    }

    public String getJar()
    {
        return get( JAR.getName() );
    }

    public String getJarPath()
    {
        return getPath( JAR.getName() );
    }

    public File getJarPathFile()
    {
        return new File( getJarPath() );
    }

    public Paths getDist()
    {
        return getPaths( DIST.getName() );
    }

    public String getAppDir()
    {
        return get( APPDIR.getName() );
    }

    public String getAppDirPath()
    {
        return getPath( APPDIR.getName() );
    }

    public String getOneJar()
    {
        return get( ONEJAR.getName() );
    }

    public String getOneJarPath()
    {
        return getPath( ONEJAR.getName() );
    }

    public File getOneJarPathFile()
    {
        String zJar = getOneJarPath();
        if ( zJar == null )
        {
            return null;
        }
        int at = zJar.lastIndexOf( '.' );
        if ( at == -1 || !".jar".equalsIgnoreCase( zJar.substring( at ) ) )
        {
            zJar += ".jar";
        }
        return new File( zJar );
    }

    public String getWar()
    {
        return get( WAR.getName() );
    }

    public String getWarPath()
    {
        return getPath( WAR.getName() );
    }

    public File getWarPathFile()
    {
        return new File( getWarPath() );
    }

    public String getGWT()
    {
        return get( GWT.getName() );
    }

    public String getGWTat()
    {
        return get( GWTat.getName() );
    }

    public File getGWTatDir()
    {
        return new File( getPath( GWTat.getName() ) );
    }

    public String getGWTwar()
    {
        return get( GWTwar.getName() );
    }

    public String getGWTwarPath()
    {
        return getPath( GWTwar.getName() );
    }

    public String getGWTstyle()
    {
        return get( GWTstyle.getName() );
    }

    public String getGWTlogging()
    {
        return get( GWTlogging.getName() );
    }

    public String getGWTmx()
    {
        return get( GWTmx.getName() );
    }

    // ---------------------------------- Generic accessors for the underlying Data (map) ------------------------------

    public boolean has( Object key )
    {
        return null != getObject( key );
    }

    public Object getObject( Object key )
    {
        return mManager.get( mManager.normalizeKey( key ) );
    }

    public Object getObject( Object key, Object defaultValue )
    {
        return Util.deNull( getObject( key ), defaultValue );
    }

    public String get( Object key )
    {
        Object zValue = getObject( key );
        return (zValue != null) ? zValue.toString() : null;
    }

    public String get( Object key, String defaultValue )
    {
        return Util.deNull( get( key ), defaultValue );
    }

    public int get_int( Object key )
    {
        return get_int( key, 0 );
    }

    public int get_int( Object key, int defaultValue )
    {
        return getInteger( key, defaultValue );
    }

    public Integer getInteger( Object key, int defaultValue )
    {
        return Util.deNull( getInteger( key ), defaultValue );
    }

    public Integer getInteger( Object key )
    {
        return getCachedWithConvertion( key, INTEGER, null );
    }

    public float get_float( Object key )
    {
        return get_float( key, 0 );
    }

    public float get_float( Object key, float defaultValue )
    {
        return getFloat( key, defaultValue );
    }

    public Float getFloat( Object key, float defaultValue )
    {
        return Util.deNull( getFloat( key ), defaultValue );
    }

    public Float getFloat( Object key )
    {
        return getCachedWithConvertion( key, FLOAT, null );
    }

    public boolean get_boolean( Object key )
    {
        return get_boolean( key, false );
    }

    public boolean get_boolean( Object key, boolean defaultValue )
    {
        return getBoolean( key, defaultValue );
    }

    public Boolean getBoolean( Object key, boolean defaultValue )
    {
        return Util.deNull( getBoolean( key ), defaultValue );
    }

    public Boolean getBoolean( Object key )
    {
        return getCachedWithConvertion( key, BOOLEAN, null );
    }

    /**
     * Returns a list of objects under the specified key. If the key is a single value, it is placed in a list and returned. If the
     * key does not exist, a list with the defaultValues is returned.
     */
    public List<?> getObjectListNotNull( Object key, Object... defaultValues )
    {
        List<?> zList = getObjectList( key );
        return (zList != null) ? zList : (defaultValues == null) ? Collections.emptyList() : Arrays.asList( defaultValues );
    }

    /**
     * Returns a list of objects under the specified key. If the key is a single value, it is placed in a list and returned. If the
     * key does not exist, a 'null' is returned.
     */
    public List<?> getObjectList( Object key )
    {
        return getCachedWithConvertion( key, LIST_OBJECT, null );
    }

    /**
     * Returns a list of strings under the specified key. If the key is a single value, it is placed in a list and returned. If the
     * key does not exist, a list with the defaultValues is returned.
     */
    public List<String> getListNotNull( Object key, String... defaultValues )
    {
        List<String> zList = getList( key );
        return (zList != null) ? zList : (defaultValues == null) ? Collections.<String>emptyList() : Arrays.asList( defaultValues );
    }

    /**
     * Returns a list of strings under the specified key. If the key is a single value, it is placed in a list and returned. If the
     * key does not exist, a 'null' is returned.
     */
    public List<String> getList( Object key )
    {
        return getCachedWithConvertion( key, LIST_STRING, null );
    }

    /**
     * Returns a Map<Object,Object> under the specified key. If the key does not exist, a Map with the defaultValues (as Key/Value pairs) is returned.
     */
    public Map<?, ?> getObjectMapNotNull( Object key, Object... defaultValues )
    {
        Util.assertPairedEntries( "defaultValues", defaultValues );
        Map<?, ?> map = getObjectMap( key );
        return (map != null) ? map : createMap( defaultValues );
    }

    /**
     * Returns a Map<Object,Object> under the specified key. If the key does not exist, a 'null' is returned.
     */
    public Map<?, ?> getObjectMap( Object key )
    {
        return getCachedWithConvertion( key, MAP_OBJECT, null );
    }

    /**
     * Returns a Map<String,String> under the specified key. If the key does not exist, a Map with the defaultValues (as Key/Value pairs) is returned.
     */
    public Map<String, String> getMapNotNull( Object key, String... defaultValues )
    {
        Util.assertPairedEntries( "defaultValues", defaultValues );
        Map<String, String> map = getMap( key );
        return (map != null) ? map : createMap( defaultValues );
    }

    /**
     * Returns a Map<String, String> under the specified key. If the key does not exist, a 'null' is returned.
     */
    public Map<String, String> getMap( Object key )
    {
        return getCachedWithConvertion( key, MAP_STRING, null );
    }

    /**
     * Uses the strings under the specified key to {@link Paths#glob(String, String...) glob} paths.
     */
    public Paths getPaths( String key )
    {
        return getCachedWithConvertion( key, PATHS, PATHS_DEFAULTER );
    }

    /**
     * Uses the strings under the specified key to {@link Paths#glob(String, String...) glob} paths.
     */
    public String getPath( String key )
    {
        return getCachedWithConvertion( key, PATH, null );
    }

    /**
     * Returns a canonicalizePath built from the specified path.
     * If the specified path is a relative path, it is made absolute relative to this project's directory.
     */
    public String path( String path )
    {
        if ( path == null )
        {
            return null;
        }
        path = format( path );
        String zSuffix = "";
        int pipeIndex = path.indexOf( '|' );
        if ( pipeIndex > -1 )
        {
            // Handle wildcard search patterns.
            zSuffix = path.substring( pipeIndex );
            path = path.substring( 0, pipeIndex );
        }
        return canonicalizePath( getCanonicalProjectDir(), path ).getPath() + zSuffix;
    }

    /**
     * Replaces property names surrounded by dollar-signs ('$') with the value from this project.
     */
    public String format( String text )
    {
        Matcher matcher = formatPattern.matcher( text );
        StringBuilder buffer = new StringBuilder( 128 );
        while ( matcher.find() )
        {
            buffer.append( matcher.group( 1 ) );
            String name = matcher.group( 2 );
            Object value = getObject( name );
            if ( value instanceof String )
            {
                buffer.append( format( (String) value ) );
            }
            else if ( value != null )
            {
                buffer.append( value );
            }
            else
            {
                buffer.append( name );
            }
            buffer.append( matcher.group( 3 ) );
        }
        if ( buffer.length() == 0 )
        {
            return text;
        }
        return buffer.toString();
    }

    public Object[] keys()
    {
        return mManager.keys();
    }

    public File getCanonicalProjectDir()
    {
        return mCanonicalProjectDir;
    }

    public String getName()
    {
        return mName;
    }

    public ProjectParameters( File pProjectFile, String pName, File pCanonicalProjectDir, Map<Object, Object> pData )
    {
        this( pProjectFile.lastModified(), pName, pCanonicalProjectDir, new Manager( pData ) );
    }

    // ---------------------------------------------------- Support ----------------------------------------------------

    protected ProjectParameters( ProjectParameters pParameters )
    {
        this( pParameters.mProjectFileLastModified, pParameters.getName(), pParameters.getCanonicalProjectDir(), pParameters.mManager );
    }

    private ProjectParameters( long pProjectFileLastModified, String pName, File pCanonicalProjectDir, Manager pManager )
    {
        mProjectFileLastModified = pProjectFileLastModified;
        mCanonicalProjectDir = pCanonicalProjectDir;
        mManager = pManager;
        Object zName = mManager.get( NAME.getName() );
        mManager.put( NAME.getName(), mName = (zName != null) ? zName.toString() : pName );
    }

    protected final long mProjectFileLastModified;
    protected final File mCanonicalProjectDir;
    protected final Manager mManager;
    protected final String mName;

    static private final java.util.regex.Pattern formatPattern = java.util.regex.Pattern.compile( "([^\\$]*)\\$([^\\$]+)\\$([^\\$]*)" );

    @SuppressWarnings({"unchecked"})
    private <T> Map<T, T> getAsMap( Object pKey )
    {
        Object zValue = getObject( pKey );
        return (zValue instanceof Map) ? (Map<T, T>) zValue : null;
    }

    @Override
    public String toString()
    {
        return getName();
    }

    protected void defaultSubDirOptional( Parameter pParameter, String... pOptions )
    {
        Object o = mManager.get( pParameter.getName() );
        if ( o == null )
        {
            for ( String zOption : pOptions )
            {
                int at = zOption.indexOf( '|' );
                if ( dirExists( (at == -1) ? zOption : zOption.substring( 0, at ) ) )
                {
                    mManager.put( pParameter.getName(), zOption );
                    return;
                }
            }
        }
    }

    protected boolean dirExists( String pPath )
    {
        int pipeAt = pPath.indexOf( '|' );
        if ( pipeAt != -1 )
        {
            pPath = pPath.substring( pipeAt );
        }
        return new File( getCanonicalProjectDir(), pPath ).isDirectory();
    }

    protected void defaultKey( Parameter pParameter, String pDefault )
    {
        if ( null == get( pParameter.getName() ) )
        {
            mManager.put( pParameter.getName(), pDefault );
        }
    }

    protected <T> Map<T, T> createMap( T[] defaultValues )
    {
        Map<T, T> map = new HashMap<T, T>();
        if ( defaultValues != null )
        {
            for ( int i = 0; i < defaultValues.length; )
            {
                T defaultKey = defaultValues[i++];
                T defaultValue = defaultValues[i++];
                map.put( defaultKey, defaultValue );
            }
        }
        return map;
    }

    protected <T> T getCachedWithConvertion( Object pKey, DataConverter<T> pConverter, DataDefaulter<T> pDefaulter )
    {
        Object zValue = mManager.getCachedResponse( pKey = mManager.normalizeKey( pKey ) );
        if ( zValue != null )
        {
            //noinspection unchecked
            return (T) zValue;
        }
        zValue = mManager.get( pKey );
        T zConverted = null;
        if ( zValue != null )
        {
            zConverted = pConverter.convert( zValue );
        }
        else if ( pDefaulter != null )
        {
            zConverted = pDefaulter.createDefault();
        }
        if ( zConverted != null )
        {
            mManager.addCachedResponse( pKey, zConverted );
        }
        return zConverted;
    }

    private static final DataConverter<Integer> INTEGER = new DataConverter<Integer>()
    {
        @Override
        public Integer convert( Object pValue )
        {
            return (pValue instanceof Number) ? ((Number) pValue).intValue() : Integer.parseInt( pValue.toString() );
        }
    };

    private static final DataConverter<Float> FLOAT = new DataConverter<Float>()
    {
        @Override
        public Float convert( Object pValue )
        {
            return (pValue instanceof Number) ? ((Number) pValue).floatValue() : Float.parseFloat( pValue.toString() );
        }
    };

    private static final DataConverter<Boolean> BOOLEAN = new DataConverter<Boolean>()
    {
        @Override
        public Boolean convert( Object pValue )
        {
            return (pValue instanceof Boolean) ? (Boolean) pValue : Boolean.parseBoolean( pValue.toString() );
        }
    };

    private static final DataConverter<List<?>> LIST_OBJECT = new DataConverter<List<?>>()
    {
        @Override
        public List<?> convert( Object pValue )
        {
            return (pValue instanceof List) ? (List<?>) pValue : Arrays.asList( pValue );
        }
    };

    private static final DataConverter<List<String>> LIST_STRING = new DataConverter<List<String>>()
    {
        @Override
        public List<String> convert( Object pValue )
        {
            //noinspection unchecked
            return (pValue instanceof List) ? (List<String>) pValue : Arrays.asList( pValue.toString() );
        }
    };

    private static final DataConverter<Map<?, ?>> MAP_OBJECT = new DataConverter<Map<?, ?>>()
    {
        @Override
        public Map<?, ?> convert( Object pValue )
        {
            return (Map<?, ?>) pValue;
        }
    };

    private static final DataConverter<Map<String, String>> MAP_STRING = new DataConverter<Map<String, String>>()
    {
        @Override
        public Map<String, String> convert( Object pValue )
        {
            //noinspection unchecked
            return (Map<String, String>) pValue;
        }
    };

    private final DataConverter<String> PATH = new DataConverter<String>()
    {
        @Override
        public String convert( Object pValue )
        {
            return path( pValue.toString() );
        }
    };

    private final DataConverter<Paths> PATHS = new DataConverter<Paths>()
    {
        @Override
        public Paths convert( Object pValue )
        {
            Paths paths = new Paths();
            List<String> zList = LIST_STRING.convert( pValue );
            for ( String dirPattern : zList )
            {
                paths.glob( path( dirPattern ) );
            }
            return paths;
        }
    };

    private final DataDefaulter<Paths> PATHS_DEFAULTER = new DataDefaulter<Paths>()
    {
        @Override public Paths createDefault()
        {
            return new Paths();
        }
    };
}

Commits for litesoft/trunk/Java/ScarPlus/src/com/esotericsoftware/scar/ProjectParameters.java

Diff revisions: vs.
Revision Author Commited Message
547 Diff Diff GeorgeS picture GeorgeS Mon 10 Oct, 2011 02:22:01 +0000
424 Diff Diff GeorgeS picture GeorgeS Sat 20 Aug, 2011 17:46:44 +0000
409 Diff Diff GeorgeS picture GeorgeS Wed 17 Aug, 2011 00:37:54 +0000
366 Diff Diff GeorgeS picture GeorgeS Fri 12 Aug, 2011 00:09:39 +0000
364 Diff Diff GeorgeS picture GeorgeS Mon 08 Aug, 2011 18:13:58 +0000
362 Diff Diff GeorgeS picture GeorgeS Mon 08 Aug, 2011 16:51:13 +0000
361 Diff Diff GeorgeS picture GeorgeS Mon 08 Aug, 2011 01:34:17 +0000
360 Diff Diff GeorgeS picture GeorgeS Sun 07 Aug, 2011 04:10:11 +0000
358 Diff Diff GeorgeS picture GeorgeS Fri 05 Aug, 2011 20:00:41 +0000
357 GeorgeS picture GeorgeS Fri 05 Aug, 2011 14:25:00 +0000