diff options
author | Carsten Hammer | 2019-05-21 18:10:01 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2019-06-11 10:40:22 +0000 |
commit | 047aa8457b51a60d533bb2c865c9982ade8bf67c (patch) | |
tree | 3a8a8b2d9d6f6ec60a500ae07cc3ec51e77718b5 /bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2 | |
parent | 9f8a0b0af461c252a526b84ccf586361daa50297 (diff) | |
download | rt.equinox.p2-047aa8457b51a60d533bb2c865c9982ade8bf67c.tar.gz rt.equinox.p2-047aa8457b51a60d533bb2c865c9982ade8bf67c.tar.xz rt.equinox.p2-047aa8457b51a60d533bb2c865c9982ade8bf67c.zip |
Use switch over strings where possibleI20190620-1800I20190620-0130I20190619-1820I20190619-1800I20190618-1805I20190618-0225I20190617-1800I20190616-1800I20190615-1800I20190614-1800I20190614-0330I20190613-1800I20190613-0210I20190612-1800I20190612-0115
Change cascades of ifs which can be converted to switch over Strings.
Change-Id: Id86536ada5cc4a916fbd5aa31123d1b45d7b5225
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2')
3 files changed, 272 insertions, 155 deletions
diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/BrandingIron.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/BrandingIron.java index 3fd40734f..8ede389c3 100644 --- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/BrandingIron.java +++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/BrandingIron.java @@ -103,20 +103,31 @@ public class BrandingIron { } descriptor.setLocation(root); - if ("win32".equals(os)) //$NON-NLS-1$ - brandWindows(descriptor); - else if ("linux".equals(os)) //$NON-NLS-1$ - brandLinux(descriptor); - else if ("solaris".equals(os)) //$NON-NLS-1$ - brandSolaris(descriptor); - else if ("macosx".equals(os)) //$NON-NLS-1$ - brandMac(descriptor); - else if ("aix".equals(os)) //$NON-NLS-1$ - brandAIX(descriptor); - else if ("hpux".equals(os)) //$NON-NLS-1$ - brandHPUX(descriptor); - else + if (os==null) renameLauncher(descriptor); + else switch (os) { + case "win32": //$NON-NLS-1$ + brandWindows(descriptor); + break; + case "linux": //$NON-NLS-1$ + brandLinux(descriptor); + break; + case "solaris": //$NON-NLS-1$ + brandSolaris(descriptor); + break; + case "macosx": //$NON-NLS-1$ + brandMac(descriptor); + break; + case "aix": //$NON-NLS-1$ + brandAIX(descriptor); + break; + case "hpux": //$NON-NLS-1$ + brandHPUX(descriptor); + break; + default: + renameLauncher(descriptor); + break; + } descriptor.setExecutableName(name, true); } diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/FeatureManifestParser.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/FeatureManifestParser.java index fdd7b478a..6ea401c47 100644 --- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/FeatureManifestParser.java +++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/FeatureManifestParser.java @@ -83,12 +83,18 @@ public class FeatureManifestParser extends DefaultHandler { } if (characters == null) return; - if ("description".equals(localName)) { //$NON-NLS-1$ - result.setDescription(localize(characters.toString().trim())); - } else if ("license".equals(localName)) { //$NON-NLS-1$ - result.setLicense(localize(characters.toString().trim())); - } else if ("copyright".equals(localName)) { //$NON-NLS-1$ - result.setCopyright(localize(characters.toString().trim())); + if (null != localName) switch (localName) { + case "description": //$NON-NLS-1$ + result.setDescription(localize(characters.toString().trim())); + break; + case "license": //$NON-NLS-1$ + result.setLicense(localize(characters.toString().trim())); + break; + case "copyright": //$NON-NLS-1$ + result.setCopyright(localize(characters.toString().trim())); + break; + default: + break; } characters = null; } @@ -270,28 +276,41 @@ public class FeatureManifestParser extends DefaultHandler { @Override public void startElement(String uri, String localName, String qName, Attributes attributes) { - // Utils.debug("Start Element: uri:" + uri + " local Name:" + localName + " qName:" + qName); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if ("plugin".equals(localName)) { //$NON-NLS-1$ - processPlugin(attributes); - } else if ("description".equals(localName)) { //$NON-NLS-1$ - processDescription(attributes); - } else if ("license".equals(localName)) { //$NON-NLS-1$ - processLicense(attributes); - } else if ("copyright".equals(localName)) { //$NON-NLS-1$ - processCopyright(attributes); - } else if ("feature".equals(localName)) { //$NON-NLS-1$ - processFeature(attributes); - } else if ("import".equals(localName)) { //$NON-NLS-1$ - processImport(attributes); - } else if ("includes".equals(localName)) { //$NON-NLS-1$ - processIncludes(attributes); - } else if ("install-handler".equals(localName)) { //$NON-NLS-1$ - processInstallHandler(attributes); - } else if ("update".equals(localName)) { //$NON-NLS-1$ - processUpdateSite(attributes); - } else if ("discovery".equals(localName)) { //$NON-NLS-1$ - processDiscoverySite(attributes); - } + if (null != localName) // Utils.debug("Start Element: uri:" + uri + " local Name:" + localName + " qName:" + qName); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + switch (localName) { + case "plugin": //$NON-NLS-1$ + processPlugin(attributes); + break; + case "description": //$NON-NLS-1$ + processDescription(attributes); + break; + case "license": //$NON-NLS-1$ + processLicense(attributes); + break; + case "copyright": //$NON-NLS-1$ + processCopyright(attributes); + break; + case "feature": //$NON-NLS-1$ + processFeature(attributes); + break; + case "import": //$NON-NLS-1$ + processImport(attributes); + break; + case "includes": //$NON-NLS-1$ + processIncludes(attributes); + break; + case "install-handler": //$NON-NLS-1$ + processInstallHandler(attributes); + break; + case "update": //$NON-NLS-1$ + processUpdateSite(attributes); + break; + case "discovery": //$NON-NLS-1$ + processDiscoverySite(attributes); + break; + default: + break; + } } } diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java index f3ac26805..cd201853b 100644 --- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java +++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java @@ -574,32 +574,49 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor { public String getVMArguments(String os, String arch) { os = os == null ? "" : os; //$NON-NLS-1$ String key = null; - if (os.equals(OS_WIN32)) { - key = VM_ARGS_WIN; - } else if (os.equals(OS_LINUX)) { - key = VM_ARGS_LINUX; - } else if (os.equals(OS_MACOSX)) { - key = VM_ARGS_MAC; - } else if (os.equals(OS_SOLARIS)) { - key = VM_ARGS_SOLARIS; + switch (os) { + case OS_WIN32: + key = VM_ARGS_WIN; + break; + case OS_LINUX: + key = VM_ARGS_LINUX; + break; + case OS_MACOSX: + key = VM_ARGS_MAC; + break; + case OS_SOLARIS: + key = VM_ARGS_SOLARIS; + break; + default: + break; } arch = arch == null ? "" : arch; //$NON-NLS-1$ String archKey = null; - if (arch.equals(ARCH_X86)) { - archKey = EL_ARCH_X86; - } else if (arch.equals(ARCH_X86_64)) { - archKey = EL_ARCH_X86_64; - } else if (arch.equals(ARCH_PPC)) { - archKey = EL_ARCH_PPC; - } else if (arch.equals(ARCH_IA_64)) { - archKey = EL_ARCH_IA_64; - } else if (arch.equals(ARCH_IA_64_32)) { - archKey = EL_ARCH_IA_64_32; - } else if (arch.equals(ARCH_PA_RISC)) { - archKey = EL_ARCH_PA_RISC; - } else if (arch.equals(ARCH_SPARC)) { - archKey = EL_ARCH_SPARC; + switch (arch) { + case ARCH_X86: + archKey = EL_ARCH_X86; + break; + case ARCH_X86_64: + archKey = EL_ARCH_X86_64; + break; + case ARCH_PPC: + archKey = EL_ARCH_PPC; + break; + case ARCH_IA_64: + archKey = EL_ARCH_IA_64; + break; + case ARCH_IA_64_32: + archKey = EL_ARCH_IA_64_32; + break; + case ARCH_PA_RISC: + archKey = EL_ARCH_PA_RISC; + break; + case ARCH_SPARC: + archKey = EL_ARCH_SPARC; + break; + default: + break; } String platformArchKey = null; @@ -655,32 +672,49 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor { public String getProgramArguments(String os, String arch) { os = os == null ? "" : os; //$NON-NLS-1$ String key = null; - if (os.equals(OS_WIN32)) { - key = PROGRAM_ARGS_WIN; - } else if (os.equals(OS_LINUX)) { - key = PROGRAM_ARGS_LINUX; - } else if (os.equals(OS_MACOSX)) { - key = PROGRAM_ARGS_MAC; - } else if (os.equals(OS_SOLARIS)) { - key = PROGRAM_ARGS_SOLARIS; + switch (os) { + case OS_WIN32: + key = PROGRAM_ARGS_WIN; + break; + case OS_LINUX: + key = PROGRAM_ARGS_LINUX; + break; + case OS_MACOSX: + key = PROGRAM_ARGS_MAC; + break; + case OS_SOLARIS: + key = PROGRAM_ARGS_SOLARIS; + break; + default: + break; } arch = arch == null ? "" : arch; //$NON-NLS-1$ String archKey = null; - if (arch.equals(ARCH_X86)) { - archKey = EL_ARCH_X86; - } else if (arch.equals(ARCH_X86_64)) { - archKey = EL_ARCH_X86_64; - } else if (arch.equals(ARCH_PPC)) { - archKey = EL_ARCH_PPC; - } else if (arch.equals(ARCH_IA_64)) { - archKey = EL_ARCH_IA_64; - } else if (arch.equals(ARCH_IA_64_32)) { - archKey = EL_ARCH_IA_64_32; - } else if (arch.equals(ARCH_PA_RISC)) { - archKey = EL_ARCH_PA_RISC; - } else if (arch.equals(ARCH_SPARC)) { - archKey = EL_ARCH_SPARC; + switch (arch) { + case ARCH_X86: + archKey = EL_ARCH_X86; + break; + case ARCH_X86_64: + archKey = EL_ARCH_X86_64; + break; + case ARCH_PPC: + archKey = EL_ARCH_PPC; + break; + case ARCH_IA_64: + archKey = EL_ARCH_IA_64; + break; + case ARCH_IA_64_32: + archKey = EL_ARCH_IA_64_32; + break; + case ARCH_PA_RISC: + archKey = EL_ARCH_PA_RISC; + break; + case ARCH_SPARC: + archKey = EL_ARCH_SPARC; + break; + default: + break; } String platformArchKey = null; @@ -743,44 +777,65 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor { break; case STATE_PRODUCT : - if (EL_CONFIG_INI.equals(localName)) { - processConfigIni(attributes); - state = STATE_CONFIG_INI; - } else if (EL_LAUNCHER.equals(localName)) { - processLauncher(attributes); - state = STATE_LAUNCHER; - } else if (EL_PLUGINS.equals(localName)) { - state = STATE_PLUGINS; - } else if (EL_FEATURES.equals(localName)) { - state = STATE_FEATURES; - } else if (EL_LAUNCHER_ARGS.equals(localName)) { - state = STATE_LAUNCHER_ARGS; - } else if (EL_SPLASH.equals(localName)) { - splashLocation = attributes.getValue(ATTRIBUTE_LOCATION); - } else if (EL_CONFIGURATIONS.equals(localName)) { - state = STATE_CONFIGURATIONS; - } else if (EL_LICENSE.equals(localName)) { - state = STATE_LICENSE; - } else if (EL_REPOSITORIES.equals(localName)) { - state = STATE_REPOSITORIES; - } else if (VM.equals(localName)) { - state = STATE_VM; + if (null != localName) switch (localName) { + case EL_CONFIG_INI: + processConfigIni(attributes); + state = STATE_CONFIG_INI; + break; + case EL_LAUNCHER: + processLauncher(attributes); + state = STATE_LAUNCHER; + break; + case EL_PLUGINS: + state = STATE_PLUGINS; + break; + case EL_FEATURES: + state = STATE_FEATURES; + break; + case EL_LAUNCHER_ARGS: + state = STATE_LAUNCHER_ARGS; + break; + case EL_SPLASH: + splashLocation = attributes.getValue(ATTRIBUTE_LOCATION); + break; + case EL_CONFIGURATIONS: + state = STATE_CONFIGURATIONS; + break; + case EL_LICENSE: + state = STATE_LICENSE; + break; + case EL_REPOSITORIES: + state = STATE_REPOSITORIES; + break; + case VM: + state = STATE_VM; + break; + default: + break; } break; + case STATE_CONFIG_INI : processConfigIniPlatform(localName, true); break; case STATE_LAUNCHER : - if (OS_SOLARIS.equals(localName)) { - processSolaris(attributes); - } else if ("win".equals(localName)) { //$NON-NLS-1$ - processWin(attributes); - } else if (OS_LINUX.equals(localName)) { - processLinux(attributes); - } else if (OS_MACOSX.equals(localName)) { - processMac(attributes); + if (null != localName) switch (localName) { + case OS_SOLARIS: + processSolaris(attributes); + break; + case "win": //$NON-NLS-1$ + processWin(attributes); + break; + case OS_LINUX: + processLinux(attributes); + break; + case OS_MACOSX: + processMac(attributes); + break; + default: + break; } if ("ico".equals(localName)) { //$NON-NLS-1$ processIco(attributes); @@ -789,30 +844,45 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor { } break; + case STATE_LAUNCHER_ARGS : - if (PROGRAM_ARGS.equals(localName)) { - state = STATE_PROGRAM_ARGS; - } else if (PROGRAM_ARGS_LINUX.equals(localName)) { - state = STATE_PROGRAM_ARGS_LINUX; - } else if (PROGRAM_ARGS_MAC.equals(localName)) { - state = STATE_PROGRAM_ARGS_MAC; - } else if (PROGRAM_ARGS_SOLARIS.equals(localName)) { - state = STATE_PROGRAM_ARGS_SOLARIS; - } else if (PROGRAM_ARGS_WIN.equals(localName)) { - state = STATE_PROGRAM_ARGS_WIN; - } else if (VM_ARGS.equals(localName)) { - state = STATE_VM_ARGS; - } else if (VM_ARGS_LINUX.equals(localName)) { - state = STATE_VM_ARGS_LINUX; - } else if (VM_ARGS_MAC.equals(localName)) { - state = STATE_VM_ARGS_MAC; - } else if (VM_ARGS_SOLARIS.equals(localName)) { - state = STATE_VM_ARGS_SOLARIS; - } else if (VM_ARGS_WIN.equals(localName)) { - state = STATE_VM_ARGS_WIN; + if (null != localName) switch (localName) { + case PROGRAM_ARGS: + state = STATE_PROGRAM_ARGS; + break; + case PROGRAM_ARGS_LINUX: + state = STATE_PROGRAM_ARGS_LINUX; + break; + case PROGRAM_ARGS_MAC: + state = STATE_PROGRAM_ARGS_MAC; + break; + case PROGRAM_ARGS_SOLARIS: + state = STATE_PROGRAM_ARGS_SOLARIS; + break; + case PROGRAM_ARGS_WIN: + state = STATE_PROGRAM_ARGS_WIN; + break; + case VM_ARGS: + state = STATE_VM_ARGS; + break; + case VM_ARGS_LINUX: + state = STATE_VM_ARGS_LINUX; + break; + case VM_ARGS_MAC: + state = STATE_VM_ARGS_MAC; + break; + case VM_ARGS_SOLARIS: + state = STATE_VM_ARGS_SOLARIS; + break; + case VM_ARGS_WIN: + state = STATE_VM_ARGS_WIN; + break; + default: + break; } break; + // For all argument states. Set a platform key prefix representing // the outer state (platform) of the launcher arguments and then // set the state of the inner state (architecture). @@ -901,33 +971,50 @@ public class ProductFile extends DefaultHandler implements IProductDescriptor { break; case STATE_VM : - if (OS_LINUX.equals(localName)) { - state = STATE_VM_LINUX; - } else if (OS_WINDOWS.equals(localName)) { - state = STATE_VM_WINDOWS; - } else if (OS_MACOS.equals(localName)) { - state = STATE_VM_MACOS; + if (null != localName) switch (localName) { + case OS_LINUX: + state = STATE_VM_LINUX; + break; + case OS_WINDOWS: + state = STATE_VM_WINDOWS; + break; + case OS_MACOS: + state = STATE_VM_MACOS; + break; + default: + break; } break; + } } private void setArchState(String archName) { outerState = state; - if (EL_ARCH_X86.equals(archName)) { - state = STATE_ARCH_X86; - } else if (EL_ARCH_X86_64.equals(archName)) { - state = STATE_ARCH_X86_64; - } else if (EL_ARCH_PPC.equals(archName)) { - state = STATE_ARCH_PPC; - } else if (EL_ARCH_IA_64.equals(archName)) { - state = STATE_ARCH_IA_64; - } else if (EL_ARCH_IA_64_32.equals(archName)) { - state = STATE_ARCH_IA_64_32; - } else if (EL_ARCH_PA_RISC.equals(archName)) { - state = STATE_ARCH_PA_RISC; - } else if (EL_ARCH_SPARC.equals(archName)) { - state = STATE_ARCH_SPARC; + if (null != archName) switch (archName) { + case EL_ARCH_X86: + state = STATE_ARCH_X86; + break; + case EL_ARCH_X86_64: + state = STATE_ARCH_X86_64; + break; + case EL_ARCH_PPC: + state = STATE_ARCH_PPC; + break; + case EL_ARCH_IA_64: + state = STATE_ARCH_IA_64; + break; + case EL_ARCH_IA_64_32: + state = STATE_ARCH_IA_64_32; + break; + case EL_ARCH_PA_RISC: + state = STATE_ARCH_PA_RISC; + break; + case EL_ARCH_SPARC: + state = STATE_ARCH_SPARC; + break; + default: + break; } } |