File: ClockResolutionUtility.cs

package info (click to toggle)
cadencii 3.3.9%2Bsvn20110818.r1732-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 35,764 kB
  • ctags: 26,929
  • sloc: cs: 160,836; java: 42,449; cpp: 7,605; ansic: 1,728; perl: 1,087; makefile: 236; php: 142; xml: 117; sh: 21
file content (87 lines) | stat: -rw-r--r-- 3,346 bytes parent folder | download | duplicates (6)
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
/*
 * ClockResolutionUtility.cs
 * Copyright © 2010-2011 kbinani
 *
 * This file is part of org.kbinani.cadencii.
 *
 * org.kbinani.cadencii is free software; you can redistribute it and/or
 * modify it under the terms of the GPLv3 License.
 *
 * org.kbinani.cadencii is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */
#if JAVA
package org.kbinani.cadencii;

import java.util.*;
#else
using System;
using org.kbinani.java.util;

namespace org.kbinani.cadencii {
#endif

    public class ClockResolutionUtility {
        private ClockResolutionUtility() {
        }

        public static int getValue( ClockResolution value ) {
            if ( value == ClockResolution.Free ) {
                return 1;
            } else if ( value == ClockResolution.L1 ) {
                return 1;
            } else if ( value == ClockResolution.L2 ) {
                return 2;
            } else if ( value == ClockResolution.L4 ) {
                return 4;
            } else if ( value == ClockResolution.L8 ) {
                return 8;
            } else if ( value == ClockResolution.L16 ) {
                return 16;
            } else if ( value == ClockResolution.L30 ) {
                return 30;
            } else if ( value == ClockResolution.L60 ) {
                return 60;
            } else if ( value == ClockResolution.L90 ) {
                return 90;
            } else if ( value == ClockResolution.L120 ) {
                return 120;
            } else if ( value == ClockResolution.L240 ) {
                return 240;
            } else if ( value == ClockResolution.L480 ) {
                return 480;
            } else if ( value == ClockResolution.Free ) {
                return 1;
            }
            return 1;
        }

        public static String toString( ClockResolution value ) {
            if ( value == ClockResolution.Free ) {
                return "Free";
            } else {
                return getValue( value ) + "";
            }
        }

        public static Iterator<ClockResolution> iterator() {
            ClockResolution[] arr = new ClockResolution[] { ClockResolution.L1, 
                                                            ClockResolution.L2, 
                                                            ClockResolution.L4, 
                                                            ClockResolution.L8, 
                                                            ClockResolution.L16, 
                                                            ClockResolution.L30, 
                                                            ClockResolution.L60, 
                                                            ClockResolution.L90, 
                                                            ClockResolution.L120, 
                                                            ClockResolution.L240, 
                                                            ClockResolution.L480, 
                                                            ClockResolution.Free };
            return Arrays.asList( arr ).iterator();
        }
    }

#if !JAVA
}
#endif