class Unit extends EnumeratedAttribute { private static final String MILLISECOND = "millisecond"; private static final String SECOND = "second"; private static final String MINUTE = "minute"; private static final String HOUR = "hour"; private static final String DAY = "day"; private static final String WEEK = "week"; private static final String MONTH = "month"; private static final String YEAR = "year"; private static final String[] UNITS = { MILLISECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, YEAR }; private Map calendarFields = new HashMap(); /** Constructor for Unit enumerated type. */ public Unit() { calendarFields.put(MILLISECOND, new Integer(Calendar.MILLISECOND)); calendarFields.put(SECOND, new Integer(Calendar.SECOND)); calendarFields.put(MINUTE, new Integer(Calendar.MINUTE)); calendarFields.put(HOUR, new Integer(Calendar.HOUR_OF_DAY)); calendarFields.put(DAY, new Integer(Calendar.DATE)); calendarFields.put(WEEK, new Integer(Calendar.WEEK_OF_YEAR)); calendarFields.put(MONTH, new Integer(Calendar.MONTH)); calendarFields.put(YEAR, new Integer(Calendar.YEAR)); } /** * Convert the value to int unit value. * @return an int value. */ public int getCalendarField() { String key = getValue().toLowerCase(); Integer i = (Integer) calendarFields.get(key); return i.intValue(); } /** * Get the valid values. * @return the value values. */ public String[] getValues() { return UNITS; }
class Unit extends EnumeratedAttribute { private static final String MILLISECOND = "millisecond"; private static final String SECOND = "second"; private static final String MINUTE = "minute"; private static final String HOUR = "hour"; private static final String DAY = "day"; private static final String WEEK = "week"; private static final String MONTH = "month"; private static final String YEAR = "year"; private static final String[] UNITS = {MILLISECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, YEAR }; private Map calendarFields = new HashMap(); /** no arg constructor */ public Unit() { calendarFields.put(MILLISECOND, new Integer(Calendar.MILLISECOND)); calendarFields.put(SECOND, new Integer(Calendar.SECOND)); calendarFields.put(MINUTE, new Integer(Calendar.MINUTE)); calendarFields.put(HOUR, new Integer(Calendar.HOUR_OF_DAY)); calendarFields.put(DAY, new Integer(Calendar.DATE)); calendarFields.put(WEEK, new Integer(Calendar.WEEK_OF_YEAR)); calendarFields.put(MONTH, new Integer(Calendar.MONTH)); calendarFields.put(YEAR, new Integer(Calendar.YEAR)); } /** * Convert the value to a Calendar field index. * @return the calander value. */ public int getCalendarField() { String key = getValue().toLowerCase(); Integer i = (Integer) calendarFields.get(key); return i.intValue(); } /** {@inheritDoc}. */ public String[] getValues() { return UNITS; }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/Tstamp.java File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/optional/PropertyFile.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
class Unit extends EnumeratedAttribute {
1
class Unit extends EnumeratedAttribute {
2
        private static final String MILLISECOND = "millisecond";
2
        private static final String MILLISECOND = "millisecond";
3
        private static final String SECOND = "second";
3
        private static final String SECOND = "second";
4
        private static final String MINUTE = "minute";
4
        private static final String MINUTE = "minute";
5
        private static final String HOUR = "hour";
5
        private static final String HOUR = "hour";
6
        private static final String DAY = "day";
6
        private static final String DAY = "day";
7
        private static final String WEEK = "week";
7
        private static final String WEEK = "week";
8
        private static final String MONTH = "month";
8
        private static final String MONTH = "month";
9
        private static final String YEAR = "year";
9
        private static final String YEAR = "year";
10
        private static final String[] UNITS = {
10
        private static final String[] UNITS
11
                                                MILLISECOND,
11
            
12
                                                SECOND,
13
                                                MINUTE,
14
                                                HOUR,
15
                                                DAY,
16
                                                WEEK,
17
                                                MONTH,
18
                                                YEAR
19
                                             
12
= {MILLISECOND, SECOND, MINUTE, HOUR,
20
 };
13
               DAY, WEEK, MONTH, YEAR };
21
        private Map calendarFields = new HashMap();
14
        private Map calendarFields = new HashMap();
22
        /** Constructor for Unit enumerated type. */
15
        /** no arg constructor */
23
        public Unit() {
16
        public Unit() {
24
            calendarFields.put(MILLISECOND,
17
            calendarFields.put(MILLISECOND,
25
                               new Integer(Calendar.MILLISECOND));
18
                                    new Integer(Calendar.MILLISECOND));
26
            calendarFields.put(SECOND, new Integer(Calendar.SECOND));
19
            calendarFields.put(SECOND, new Integer(Calendar.SECOND));
27
            calendarFields.put(MINUTE, new Integer(Calendar.MINUTE));
20
            calendarFields.put(MINUTE, new Integer(Calendar.MINUTE));
28
            calendarFields.put(HOUR, new Integer(Calendar.HOUR_OF_DAY));
21
            calendarFields.put(HOUR, new Integer(Calendar.HOUR_OF_DAY));
29
            calendarFields.put(DAY, new Integer(Calendar.DATE));
22
            calendarFields.put(DAY, new Integer(Calendar.DATE));
30
            calendarFields.put(WEEK, new Integer(Calendar.WEEK_OF_YEAR));
23
            calendarFields.put(WEEK, new Integer(Calendar.WEEK_OF_YEAR));
31
            calendarFields.put(MONTH, new Integer(Calendar.MONTH));
24
            calendarFields.put(MONTH, new Integer(Calendar.MONTH));
32
            calendarFields.put(YEAR, new Integer(Calendar.YEAR));
25
            calendarFields.put(YEAR, new Integer(Calendar.YEAR));
33
        }
26
        }
34
        /**
27
        /**
35
         * Convert the value to int unit value.
28
         * Convert the value to a Calendar field index.
36
         * @return an int value.
29
         * @return the calander value.
37
         */
30
         */
38
        public int getCalendarField() {
31
        public int getCalendarField() {
39
            String key = getValue().toLowerCase();
32
            String key = getValue().toLowerCase();
40
            Integer i = (Integer) calendarFields.get(key);
33
            Integer i = (Integer) calendarFields.get(key);
41
            return i.intValue();
34
            return i.intValue();
42
        }
35
        }
43
        /**
36
        /**
44
         * Get the valid values.
45
         * @return the value values.
46
         */
37
 {@inheritDoc}. */
47
        public String[] getValues() {
38
        public String[] getValues() {
48
            return UNITS;
39
            return UNITS;
49
        }
40
        }
50
    
41
    
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0