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 | 1 | package org.vostokframework.domain.assets |
30 | |
{ |
31 | |
import org.as3collections.IIterator; |
32 | |
import org.as3collections.lists.ArrayList; |
33 | |
import org.as3collections.utils.ListUtil; |
34 | |
import org.as3collections.IList; |
35 | |
import org.as3coreaddendum.system.Enum; |
36 | |
import org.as3utils.StringUtil; |
37 | |
|
38 | |
import flash.errors.IllegalOperationError; |
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
public class AssetType extends Enum |
46 | |
{ |
47 | |
public static const AAC:AssetType = new AssetType("AAC", 0); |
48 | |
public static const CSS:AssetType = new AssetType("CSS", 1); |
49 | |
public static const IMAGE:AssetType = new AssetType("IMAGE", 2); |
50 | |
public static const JSON:AssetType = new AssetType("JSON", 3); |
51 | |
public static const MP3:AssetType = new AssetType("MP3", 4); |
52 | |
public static const SWF:AssetType = new AssetType("SWF", 5); |
53 | |
public static const TXT:AssetType = new AssetType("TXT", 6); |
54 | |
public static const VIDEO:AssetType = new AssetType("VIDEO", 7); |
55 | |
public static const XML:AssetType = new AssetType("XML", 8); |
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
private static var _created :Boolean = false; |
61 | |
|
62 | |
{ |
63 | |
_created = true; |
64 | |
} |
65 | |
|
66 | |
public function AssetType(name:String, ordinal:int) |
67 | |
{ |
68 | 1 | super(name, ordinal); |
69 | 1 | if (_created) throw new IllegalOperationError("The set of acceptable values by this Enumerated Type has already been created internally."); |
70 | 1 | } |
71 | |
|
72 | |
public static function getByName(name:String):AssetType |
73 | |
{ |
74 | 1 | if (StringUtil.isBlank(name)) throw new ArgumentError("Argument <name> must not be null nor an empty String."); |
75 | |
|
76 | 1 | var it:IIterator = getTypes().iterator(); |
77 | |
var type:AssetType; |
78 | |
|
79 | 1 | while (it.hasNext()) |
80 | |
{ |
81 | 1 | type = it.next(); |
82 | 1 | if (type.name == name.toUpperCase()) return type; |
83 | |
} |
84 | |
|
85 | 0 | throw new ArgumentError("There is no AssetType object with <name>: " + name); |
86 | |
} |
87 | |
|
88 | |
public static function getTypes():IList |
89 | |
{ |
90 | 1 | var types:IList = ListUtil.getUniqueTypedList(new ArrayList(), AssetType); |
91 | 1 | types.add(AAC); |
92 | 1 | types.add(CSS); |
93 | 1 | types.add(IMAGE); |
94 | 1 | types.add(JSON); |
95 | 1 | types.add(MP3); |
96 | 1 | types.add(SWF); |
97 | 1 | types.add(TXT); |
98 | 1 | types.add(VIDEO); |
99 | 1 | types.add(XML); |
100 | |
|
101 | 1 | return types; |
102 | |
} |
103 | |
|
104 | |
} |
105 | |
|
106 | |
} |