Alias.java

00001 /*
00002  * Copyright (c) 2003-2006, KNOPFLERFISH project
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following
00007  * conditions are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  *
00012  * - Redistributions in binary form must reproduce the above
00013  *   copyright notice, this list of conditions and the following
00014  *   disclaimer in the documentation and/or other materials
00015  *   provided with the distribution.
00016  *
00017  * - Neither the name of the KNOPFLERFISH project nor the names of its
00018  *   contributors may be used to endorse or promote products derived
00019  *   from this software without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00027  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00028  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00029  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00030  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00031  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
00032  * OF THE POSSIBILITY OF SUCH DAMAGE.
00033  */
00034 
00035 package org.knopflerfish.framework;
00036 
00037 import java.util.ArrayList;
00038 
00044 public class Alias {
00045 
00049   final public static String[][] processorAliases = {
00050     { "Ignite", "psc1k" },
00051     { "PowerPC", "power", "ppc", "ppcbe" },
00052     { "x86", "pentium", "i386", "i486", "i586", "i686" },
00053     { "x86-64", "amd64" }
00054   };
00055 
00056 
00061   final public static String[][] osNameAliases = {
00062     { "MacOSX", "Mac OS X" },
00063     { "OS2", "os/2" },
00064     { "QNX", "procnto" },
00065     { "windows95", "windows 95", "win95" },
00066     { "Windows98", "windows 98", "win98" },
00067     { "WindowsNT", "windows nt", "winnt" },
00068     { "WindowsCE", "windows ce", "wince" },
00069     { "Windows2000", "windows 2000", "win2000" },
00070     { "WindowsXP", "windows xp", "winxp" },
00071     { "Win32", "win*" },
00072   };
00073 
00074 
00081   static public ArrayList unifyProcessor(String name) {
00082     ArrayList res = new ArrayList(2);
00083     for (int i = 0; i < processorAliases.length; i++) {
00084       for (int j = 1; j < processorAliases[i].length; j++) {
00085         if (name.equalsIgnoreCase(processorAliases[i][j])) {
00086           res.add(processorAliases[i][0]);
00087           break;
00088         }
00089       }
00090     }
00091     res.add(name);
00092     return res;
00093   }
00094 
00095 
00102   static public ArrayList unifyOsName(String name) {
00103     ArrayList res = new ArrayList(3);
00104     String lname = name.toLowerCase();
00105     for (int i = 0; i < osNameAliases.length; i++) {
00106       for (int j = 1; j < osNameAliases[i].length; j++) {
00107         int last = osNameAliases[i][j].length() - 1;
00108         if (lname.equals(osNameAliases[i][j]) ||
00109             osNameAliases[i][j].charAt(last) == '*' &&
00110             lname.startsWith(osNameAliases[i][j].substring(0, last))) {
00111           if (!lname.equals(osNameAliases[i][0])) {
00112             res.add(osNameAliases[i][0]);
00113           }
00114           break;
00115         }
00116       }
00117     }
00118     res.add(name);
00119     return res;
00120   }
00121 
00122 }

Generated on Mon Jan 11 21:19:13 2010 for OpenMobileIS by  doxygen 1.5.4