[Title] common-eplugin: added Architecture enumeration class
authorJihoon Song <jihoon80.song@samsung.com>
Wed, 6 Mar 2013 06:53:12 +0000 (15:53 +0900)
committerJihoon Song <jihoon80.song@samsung.com>
Wed, 6 Mar 2013 06:53:12 +0000 (15:53 +0900)
[Desc.]
[Issue]

Change-Id: If5ed6aed0704560dcc5493ea43849791e51b0c11

org.tizen.common/src/org/tizen/common/Architecture.java [new file with mode: 0644]

diff --git a/org.tizen.common/src/org/tizen/common/Architecture.java b/org.tizen.common/src/org/tizen/common/Architecture.java
new file mode 100644 (file)
index 0000000..ab634a1
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>
+ * BonYong Lee <bonyong.lee@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.common;
+
+import org.tizen.common.util.Assert;
+
+/**
+ * Architecture enumerator for easily management
+ */
+public enum Architecture {
+    i386( Group.x86 ),
+    i486( Group.x86 ),
+    i586( Group.x86 ),
+    i686( Group.x86 ),
+    ia32( Group.x86 ),
+    
+    armel( Group.arm ),
+    armv7a( Group.arm, "ARMv7-a" ),
+    armv7l( Group.arm );
+    
+    // kinds of group
+    public enum Group {
+        x86, arm, unknown;
+    }
+    
+    protected Object[] attributes;
+    
+    
+    // Constructor
+    private Architecture(Object ... attributes) {
+        Assert.notNull( attributes );
+        this.attributes = attributes;
+    }
+    
+    /**
+     * Architecture group getter
+     * 
+     * @return If have no group, return the unknown group.
+     */
+    public Group getGroup() {
+        for ( Object attribute : this.attributes ) {
+            if ( attribute instanceof Group ) {
+                return (Group) attribute;
+            }
+        }
+        
+        return Group.unknown;
+    }
+    
+    /**
+     * Architecture detail name getter
+     * 
+     * @return If have a custom name, return it. otherwise, return a default name.
+     */
+    public String getName() {
+        for ( Object attribute : this.attributes ) {
+            if ( attribute instanceof String ) {
+                return (String) attribute;
+            }
+        }
+        
+        return this.name();
+    }
+    
+    /**
+     * Architecture group getter by name
+     * 
+     * @param arch architecture name
+     * @return If cannot find the architecture, return the unknown group. otherwise, return its group.
+     */
+    public static Group getGroup(String arch) {
+        Architecture result = Architecture.valueOf( arch );
+        return ( result != null ) ? result.getGroup() : Group.unknown;
+    }
+}