1 11 12 package org.eclipse.pde.internal.core.builders; 13 14 import java.io.IOException ; 15 import java.io.InputStream ; 16 import java.util.ArrayList ; 17 import java.util.Iterator ; 18 import java.util.List ; 19 import java.util.Map ; 20 import java.util.Properties ; 21 import java.util.SortedSet ; 22 import java.util.StringTokenizer ; 23 import java.util.TreeSet ; 24 import java.util.zip.ZipEntry ; 25 import java.util.zip.ZipFile ; 26 27 import org.eclipse.osgi.service.resolver.BundleDescription; 28 import org.eclipse.pde.core.plugin.IPluginModelBase; 29 import org.eclipse.pde.internal.core.PDECore; 30 31 public class NativeCodeAttributeValues { 32 33 public final static int LANGUAGE_NAME= 0; 35 public final static int LANGUAGE_CODE= 1; 36 public final static String [][] LANGUAGES= 37 { 38 {"Abkhazian", "ab"}, {"Afan (Oromo)", "om"}, {"Afar", "aa"}, {"Afrikaans", "af"}, {"Albanian", "sq"}, {"Amharic", "am"}, {"Arabic", "ar"}, {"Armenian", "hy"}, {"Assamese", "as"}, {"Aymara", "ay"}, {"Azerbaijani", "az"}, 50 {"Bashkir", "ba"}, {"Basque", "eu"}, {"Bengali;Bangla", "bn"}, {"Bhutani", "dz"}, {"Bihari", "bh"}, {"Bislama", "bi"}, {"Breton", "br"}, {"Bulgarian", "bg"}, {"Burmese", "my"}, {"Byelorussian", "be"}, 61 {"Cambodian", "km"}, {"Catalan", "ca"}, {"Chinese", "zh"}, {"Corsican", "co"}, {"Croatian", "hr"}, {"Czech", "cs"}, 68 {"Danish", "da"}, {"Dutch", "nl"}, 71 {"English", "en"}, {"Esperanto", "eo"}, {"Estonian", "et"}, 75 {"Faroese", "fo"}, {"Fiji", "fj"}, {"Finnish", "fi"}, {"French", "fr"}, {"Frisian", "fy"}, 81 {"Galician", "gl"}, {"Georgian", "ka"}, {"German", "de"}, {"Greek", "el"}, {"Greenlandic", "kl"}, {"Guarani", "gn"}, {"Gujarati", "gu"}, 89 {"Hausa", "ha"}, {"Hebrew", "he"}, {"Hindi", "hi"}, {"Hungarian", "hu"}, 94 {"Icelandic", "is"}, {"Indonesian", "id"}, {"Interlingua", "ia"}, {"Interlingue", "ie"}, {"Inuktitut", "iu"}, {"Inupiak", "ik"}, {"Irish", "ga"}, {"Italian", "it"}, 103 {"Japanese", "ja"}, {"Javanese", "jv"}, 106 {"Kannada", "kn"}, {"Kashmiri", "ks"}, {"Kazakh", "kk"}, {"Kinyarwanda", "rw"}, {"Kirghiz", "ky"}, {"Kurundi", "rn"}, {"Korean", "ko"}, {"Kurdish", "ku"}, 115 {"Laothian", "lo"}, {"Latin", "la"}, {"Latvian;Lettish", "lv"}, {"Lingala", "ln"}, {"Lithuanian", "lt"}, 121 {"Macedonian", "mk"}, {"Malagasy", "mg"}, {"Malay", "ms"}, {"Malayalam", "ml"}, {"Maltese", "mt"}, {"Maori", "mi"}, {"Marathi", "mr"}, {"Moldavian", "mo"}, {"Mongolian", "mn"}, 131 {"Nauru", "na"}, {"Nepali", "ne"}, {"Norwegian", "no"}, 135 {"Occitan", "oc"}, {"Oriya", "or"}, 138 {"Pashto;Pushto", "ps"}, {"Persian (Farsi)", "fa"}, {"Polish", "pl"}, {"Portuguese", "pt"}, {"Punjabi", "pa"}, 144 {"Quechua", "qu"}, 146 {"Rhaeto-Romance", "rm"}, {"Romanian", "ro"}, {"Russian", "ru"}, 150 {"Samoan", "sm"}, {"Sangho", "sg"}, {"Sanskrit", "sa"}, {"Scots Gaelic", "gd"}, {"Serbian", "sr"}, {"Serbo-Croatian", "sh"}, {"Sesotho", "st"}, {"Setswana", "tn"}, {"Shona", "sn"}, {"Sindhi", "sd"}, {"Singhalese", "si"}, {"Siswati", "ss"}, {"Slovak", "sk"}, {"Slovenian", "sl"}, {"Somali", "so"}, {"Spanish", "es"}, {"Sundanese", "su"}, {"Swahili", "sw"}, {"Swedish", "sv"}, 170 {"Tagalog", "tl"}, {"Tajik", "tg"}, {"Tamil", "ta"}, {"Tatar", "tt"}, {"Telugu", "te"}, {"Thai", "th"}, {"Tibetan", "bo"}, {"Tigrinya", "ti"}, {"Tonga", "to"}, {"Tsonga", "ts"}, {"Turkish", "tr"}, {"Turkmen", "tk"}, {"Twi", "tw"}, 184 {"Uigur", "ug"}, {"Ukrainian", "uk"}, {"Urdu", "ur"}, {"Uzbek", "uz"}, 189 {"Vietnamese", "vi"}, {"Volapuk", "vo"}, 192 {"Welsh", "cy"}, {"Wolof", "wo"}, 195 {"Xhosa", "xh"}, 197 {"Yiddish", "yi"}, {"Yoruba", "yo"}, 200 {"Zhuang", "za"}, {"Zulu", "zu"}, }; 203 204 public final static String [] EXCLUDE_FILES= new String [] 205 { ".classpath", ".project", "plugin.xml", "fragment.xml", "build.properties", "META-INF/MANIFEST.MF" }; 212 private static final String OSNAME_ALIASES_LOCATION= "org/eclipse/osgi/framework/internal/core/osname.aliases"; private static final String PROCESSOR_ALIASES_LOCATION= "org/eclipse/osgi/framework/internal/core/processor.aliases"; 215 private static final String SPACE= " "; private static final String QUOTE= "\""; private static final String COMMENT= "#"; 220 public static String [] OS_TYPES= new String [0]; 222 public static String [] ADDITIONAL_OS_ALIASES= new String [0]; 223 public static String [] PROCESSOR_TYPES= new String [0]; 224 public static String [] ADDITIONAL_PROCESSOR_ALIASES= new String [0]; 225 static { 226 ZipFile smfJar= null; 227 try { 228 229 IPluginModelBase model = PDECore.getDefault().getModelManager().findModel("org.eclipse.osgi"); if (model!=null) 231 { 232 BundleDescription desc = model.getBundleDescription(); 233 if (desc != null) 234 { 235 String path = desc.getLocation(); 237 smfJar= new ZipFile (path+"\\core.jar"); if (smfJar!=null) 239 { 240 initializeOSTypes(smfJar); 241 initializeProcessorTypes(smfJar); 242 } 243 } 244 } 245 246 } catch (IOException ex) { 247 248 } finally { 249 try { 250 if (smfJar != null) 251 smfJar.close(); 252 } catch (IOException ex) { 253 } 254 } 255 } 256 257 static void initializeOSTypes(ZipFile smfJar) { 258 try { 259 ZipEntry aliasFile= smfJar.getEntry(OSNAME_ALIASES_LOCATION); 260 InputStream is= smfJar.getInputStream(aliasFile); 261 Properties properties= new Properties (); 262 properties.load(is); 263 SortedSet osTypes= new TreeSet (); 264 List additionalOSAliases= new ArrayList (); 265 266 Iterator it= properties.entrySet().iterator(); 267 while (it.hasNext()) { 268 Map.Entry entry= (Map.Entry ) it.next(); 269 osTypes.add(entry.getKey()); 270 parseAliases((String ) entry.getValue(), additionalOSAliases); 271 } 272 273 OS_TYPES= new String [osTypes.size()]; 274 osTypes.toArray(OS_TYPES); 275 276 ADDITIONAL_OS_ALIASES= new String [additionalOSAliases.size()]; 277 additionalOSAliases.toArray(ADDITIONAL_OS_ALIASES); 278 279 } catch (IOException ex) { 280 PDECore.logException(ex); 281 } 282 } 283 284 static void initializeProcessorTypes(ZipFile smfJar) { 285 try { 286 ZipEntry aliasFile= smfJar.getEntry(PROCESSOR_ALIASES_LOCATION); 287 InputStream is= smfJar.getInputStream(aliasFile); 288 Properties properties= new Properties (); 289 properties.load(is); 290 SortedSet processorTypes= new TreeSet (); 291 List additionalProcessorAliases= new ArrayList (); 292 293 Iterator it= properties.entrySet().iterator(); 294 while (it.hasNext()) { 295 Map.Entry entry= (Map.Entry ) it.next(); 296 processorTypes.add(entry.getKey()); 297 parseAliases((String ) entry.getValue(), additionalProcessorAliases); 298 } 299 300 PROCESSOR_TYPES= new String [processorTypes.size()]; 301 processorTypes.toArray(PROCESSOR_TYPES); 302 303 ADDITIONAL_PROCESSOR_ALIASES= new String [additionalProcessorAliases.size()]; 304 additionalProcessorAliases.toArray(ADDITIONAL_PROCESSOR_ALIASES); 305 306 } catch (IOException ex) { 307 PDECore.logException(ex); 308 } 309 } 310 311 static void parseAliases(String line, List aliases) { 312 boolean inQuote= false; 313 StringTokenizer outer= new StringTokenizer (line, QUOTE, true); 314 while (outer.hasMoreTokens()) { 315 String token= outer.nextToken(); 316 if (token.equals(QUOTE)) { 317 inQuote= !inQuote; 318 } else if (inQuote) { 319 aliases.add(token); 320 } else { 321 StringTokenizer inner= new StringTokenizer (token, SPACE, false); 322 while (inner.hasMoreTokens()) { 323 String next= inner.nextToken(); 324 if (next.startsWith(COMMENT)) return; 326 aliases.add(next); 327 } 328 } 329 } 330 } 331 332 } 333 | Popular Tags |