From c006993071546a77bda6ca980db7b9bd90db1de1 Mon Sep 17 00:00:00 2001 From: Jihoon Song Date: Wed, 6 Mar 2013 16:24:01 +0900 Subject: [PATCH] [Title] common-eplugin: added Architecture enumeration class [Desc.] [Issue] Change-Id: I8d552e2ebe6c8c01bd3284b80a6dc345f6362368 --- .../src/org/tizen/common/Architecture.java | 100 +++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 org.tizen.common/src/org/tizen/common/Architecture.java 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 index 0000000..ab634a1 --- /dev/null +++ b/org.tizen.common/src/org/tizen/common/Architecture.java @@ -0,0 +1,100 @@ +/* + * Common + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyeongseok Heo + * BonYong Lee + * Kangho Kim + * + * 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; + } +} -- 2.7.4