Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2019-05-21 14:10:01 -0400
committerAlexander Kurtakov2019-06-11 06:40:22 -0400
commit047aa8457b51a60d533bb2c865c9982ade8bf67c (patch)
tree3a8a8b2d9d6f6ec60a500ae07cc3ec51e77718b5
parent9f8a0b0af461c252a526b84ccf586361daa50297 (diff)
downloadrt.equinox.p2-I20190613-1800.tar.gz
rt.equinox.p2-I20190613-1800.tar.xz
rt.equinox.p2-I20190613-1800.zip
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>
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/IUListFormatter.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/Utils.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/pom.xml2
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/BrandingIron.java37
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/FeatureManifestParser.java75
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/internal/p2/publisher/eclipse/ProductFile.java315
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java145
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/CompositeParser.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java46
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Counter.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/CategoryParser.java147
-rw-r--r--bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/DefaultSiteParser.java210
14 files changed, 682 insertions, 416 deletions
diff --git a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/IUListFormatter.java b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/IUListFormatter.java
index bc3259e55..22c5b13de 100644
--- a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/IUListFormatter.java
+++ b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/IUListFormatter.java
@@ -56,15 +56,24 @@ public class IUListFormatter {
String s = formatString;
for (String property : properties) {
Pattern pattern = Pattern.compile(String.format("\\$\\{%s\\}", property)); //$NON-NLS-1$
- if ("id".equals(property)) { //$NON-NLS-1$
- s = insert(iu.getId(), pattern, s);
- } else if ("version".equals(property)) { //$NON-NLS-1$
- s = insert(iu.getVersion().toString(), pattern, s);
- } else {
+ if (null == property) {
String value = iu.getProperty(property, "df_LT"); //$NON-NLS-1$
if (value == null)
value = ""; //$NON-NLS-1$ unknown property
s = insert(value, pattern, s);
+ } else switch (property) {
+ case "id": //$NON-NLS-1$
+ s = insert(iu.getId(), pattern, s);
+ break;
+ case "version": //$NON-NLS-1$
+ s = insert(iu.getVersion().toString(), pattern, s);
+ break;
+ default:
+ String value = iu.getProperty(property, "df_LT"); //$NON-NLS-1$
+ if (value == null)
+ value = ""; //$NON-NLS-1$ unknown property
+ s = insert(value, pattern, s);
+ break;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/Utils.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/Utils.java
index e15f2c653..de66b270e 100644
--- a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/Utils.java
+++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/Utils.java
@@ -100,16 +100,20 @@ public class Utils {
String[] locations = null;
String prop = System.getProperty(PACK200_PROPERTY);
String javaHome = System.getProperty("java.home"); //$NON-NLS-1$
- if (NONE.equals(prop)) {
- return null;
- } else if (JRE.equals(prop)) {
- locations = new String[] {javaHome + "/bin/" + cmd}; //$NON-NLS-1$
- } else if (PATH.equals(prop)) {
- locations = new String[] {cmd};
- } else if (prop == null) {
+ if (null == prop) {
locations = new String[] {javaHome + "/bin/" + cmd, cmd}; //$NON-NLS-1$
- } else {
- locations = new String[] {prop + "/" + cmd}; //$NON-NLS-1$
+ } else switch (prop) {
+ case NONE:
+ return null;
+ case JRE:
+ locations = new String[] {javaHome + "/bin/" + cmd}; //$NON-NLS-1$
+ break;
+ case PATH:
+ locations = new String[] {cmd};
+ break;
+ default:
+ locations = new String[] {prop + "/" + cmd}; //$NON-NLS-1$
+ break;
}
return locations;
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/pom.xml b/bundles/org.eclipse.equinox.p2.metadata.repository/pom.xml
index ed96b91b2..164dd1a61 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/pom.xml
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/pom.xml
@@ -5,7 +5,7 @@
are made available under the terms of the Eclipse Distribution License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/org/documents/edl-v10.php
-
+
Contributors:
Igor Fedorenko - initial implementation
-->
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java
index 6b9496d96..d78381be8 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataParser.java
@@ -769,12 +769,16 @@ public abstract class MetadataParser extends XMLParser implements XMLConstants {
@Override
public void startElement(String elem, Attributes attributes) {
- if (elem.equals(REQUIREMENT_FILTER_ELEMENT)) {
- filterHandler = new TextHandler(this, REQUIREMENT_FILTER_ELEMENT, attributes);
- } else if (elem.equals(REQUIREMENT_DESCRIPTION_ELEMENT)) {
- descriptionHandler = new TextHandler(this, REQUIREMENT_DESCRIPTION_ELEMENT, attributes);
- } else {
- invalidElement(elem, attributes);
+ switch (elem) {
+ case REQUIREMENT_FILTER_ELEMENT:
+ filterHandler = new TextHandler(this, REQUIREMENT_FILTER_ELEMENT, attributes);
+ break;
+ case REQUIREMENT_DESCRIPTION_ELEMENT:
+ descriptionHandler = new TextHandler(this, REQUIREMENT_DESCRIPTION_ELEMENT, attributes);
+ break;
+ default:
+ invalidElement(elem, attributes);
+ break;
}
}
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;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java
index eb6817958..48d80a6ef 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AdviceFileParser.java
@@ -157,12 +157,16 @@ public class AdviceFileParser {
String propertyValue = null;
while (current != null && current.startsWith(prefix)) {
String token = current.substring(prefix.length());
- if (token.equals(NAME)) {
- propertyName = currentValue();
- } else if (token.equals(VALUE)) {
- propertyValue = currentValue();
- } else {
- // we ignore elements we do not understand
+ switch (token) {
+ case NAME:
+ propertyName = currentValue();
+ break;
+ case VALUE:
+ propertyValue = currentValue();
+ break;
+ // we ignore elements we do not understand
+ default:
+ break;
}
next();
}
@@ -179,18 +183,25 @@ public class AdviceFileParser {
while (current != null && current.startsWith(prefix)) {
String token = current;
- if (token.equals(UPDATE_MATCH_EXP)) {
- match = currentValue();
- } else if (token.equals(UPDATE_ID)) {
- name = currentValue();
- } else if (token.equals(UPDATE_DESCRIPTION)) {
- description = currentValue();
- } else if (token.equals(UPDATE_RANGE)) {
- range = currentValue();
- } else if (token.equals(UPDATE_SEVERITY)) {
- severity = currentValue();
- } else {
- // ignore
+ switch (token) {
+ case UPDATE_MATCH_EXP:
+ match = currentValue();
+ break;
+ case UPDATE_ID:
+ name = currentValue();
+ break;
+ case UPDATE_DESCRIPTION:
+ description = currentValue();
+ break;
+ case UPDATE_RANGE:
+ range = currentValue();
+ break;
+ case UPDATE_SEVERITY:
+ severity = currentValue();
+ break;
+ // ignore
+ default:
+ break;
}
next();
}
@@ -224,14 +235,19 @@ public class AdviceFileParser {
Version capabilityVersion = null;
while (current != null && current.startsWith(prefix)) {
String token = current.substring(prefix.length());
- if (token.equals(NAME)) {
- name = currentValue();
- } else if (token.equals(NAMESPACE)) {
- namespace = currentValue();
- } else if (token.equals(VERSION)) {
- capabilityVersion = Version.parseVersion(substituteVersionAndQualifier(currentValue()));
- } else {
- // we ignore elements we do not understand
+ switch (token) {
+ case NAME:
+ name = currentValue();
+ break;
+ case NAMESPACE:
+ namespace = currentValue();
+ break;
+ case VERSION:
+ capabilityVersion = Version.parseVersion(substituteVersionAndQualifier(currentValue()));
+ break;
+ // we ignore elements we do not understand
+ default:
+ break;
}
next();
}
@@ -266,28 +282,40 @@ public class AdviceFileParser {
while (current != null && current.startsWith(prefix)) {
String token = current.substring(prefix.length());
- if (token.equals(GREEDY)) {
- greedy = Boolean.parseBoolean(currentValue());
- } else if (token.equals(OPTIONAL)) {
- optional = Boolean.parseBoolean(currentValue());
- } else if (token.equals(MULTIPLE)) {
- multiple = Boolean.parseBoolean(currentValue());
- } else if (token.equals(FILTER)) {
- filter = currentValue();
- } else if (token.equals(NAME)) {
- name = currentValue();
- } else if (token.equals(NAMESPACE)) {
- namespace = currentValue();
- } else if (token.equals(RANGE)) {
- range = VersionRange.create(substituteVersionAndQualifier(currentValue()));
- } else if (token.equals(MIN)) {
- min = Integer.valueOf(currentValue()).intValue();
- } else if (token.equals(MAX)) {
- max = Integer.valueOf(currentValue()).intValue();
- } else if (token.equals(MATCH_EXP)) {
- matchExp = currentValue();
- } else {
- // we ignore elements we do not understand
+ switch (token) {
+ case GREEDY:
+ greedy = Boolean.parseBoolean(currentValue());
+ break;
+ case OPTIONAL:
+ optional = Boolean.parseBoolean(currentValue());
+ break;
+ case MULTIPLE:
+ multiple = Boolean.parseBoolean(currentValue());
+ break;
+ case FILTER:
+ filter = currentValue();
+ break;
+ case NAME:
+ name = currentValue();
+ break;
+ case NAMESPACE:
+ namespace = currentValue();
+ break;
+ case RANGE:
+ range = VersionRange.create(substituteVersionAndQualifier(currentValue()));
+ break;
+ case MIN:
+ min = Integer.valueOf(currentValue()).intValue();
+ break;
+ case MAX:
+ max = Integer.valueOf(currentValue()).intValue();
+ break;
+ case MATCH_EXP:
+ matchExp = currentValue();
+ break;
+ // we ignore elements we do not understand
+ default:
+ break;
}
next();
}
@@ -550,14 +578,19 @@ public class AdviceFileParser {
Version artifactVersion = null;
while (current != null && current.startsWith(prefix)) {
String token = current.substring(prefix.length());
- if (token.equals(CLASSIFIER)) {
- artifactClassifier = currentValue();
- } else if (token.equals(ID)) {
- artifactId = currentValue();
- } else if (token.equals(VERSION)) {
- artifactVersion = Version.parseVersion(substituteVersionAndQualifier(currentValue()));
- } else {
- // we ignore elements we do not understand
+ switch (token) {
+ case CLASSIFIER:
+ artifactClassifier = currentValue();
+ break;
+ case ID:
+ artifactId = currentValue();
+ break;
+ case VERSION:
+ artifactVersion = Version.parseVersion(substituteVersionAndQualifier(currentValue()));
+ break;
+ // we ignore elements we do not understand
+ default:
+ break;
}
next();
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/CompositeParser.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/CompositeParser.java
index db404cd50..c61d47c11 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/CompositeParser.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/CompositeParser.java
@@ -136,20 +136,26 @@ public class CompositeParser extends XMLParser implements XMLConstants {
@Override
public void startElement(String name, Attributes attributes) {
- if (PROPERTIES_ELEMENT.equals(name)) {
- if (propertiesHandler == null) {
- propertiesHandler = new PropertiesHandler(this, attributes);
- } else {
- duplicateElement(this, name, attributes);
- }
- } else if (CHILDREN_ELEMENT.equals(name)) {
- if (childrenHandler == null) {
- childrenHandler = new ChildrenHandler(this, attributes);
- } else {
- duplicateElement(this, name, attributes);
- }
- } else {
+ if (name==null) {
invalidElement(name, attributes);
+ } else switch (name) {
+ case PROPERTIES_ELEMENT:
+ if (propertiesHandler == null) {
+ propertiesHandler = new PropertiesHandler(this, attributes);
+ } else {
+ duplicateElement(this, name, attributes);
+ }
+ break;
+ case CHILDREN_ELEMENT:
+ if (childrenHandler == null) {
+ childrenHandler = new ChildrenHandler(this, attributes);
+ } else {
+ duplicateElement(this, name, attributes);
+ }
+ break;
+ default:
+ invalidElement(name, attributes);
+ break;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java
index 60325fd62..c2001ef91 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java
@@ -561,14 +561,19 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
RepositoryInfo<T> info = repositories.get(getKey(location));
if (info == null)
return null;// Repository not found
- if (IRepository.PROP_DESCRIPTION.equals(key))
- return info.description;
- else if (IRepository.PROP_NAME.equals(key))
- return info.name;
- else if (IRepository.PROP_SYSTEM.equals(key))
- return Boolean.toString(info.isSystem);
- else if (IRepository.PROP_NICKNAME.equals(key))
- return info.nickname;
+ if (null != key)
+ switch (key) {
+ case IRepository.PROP_DESCRIPTION:
+ return info.description;
+ case IRepository.PROP_NAME:
+ return info.name;
+ case IRepository.PROP_SYSTEM:
+ return Boolean.toString(info.isSystem);
+ case IRepository.PROP_NICKNAME:
+ return info.nickname;
+ default:
+ break;
+ }
// Key not known, return null
return null;
}
@@ -583,15 +588,24 @@ public abstract class AbstractRepositoryManager<T> implements IRepositoryManager
RepositoryInfo<T> info = repositories.get(getKey(location));
if (info == null)
return;// Repository not found
- if (IRepository.PROP_DESCRIPTION.equals(key))
- info.description = value;
- else if (IRepository.PROP_NAME.equals(key))
- info.name = value;
- else if (IRepository.PROP_NICKNAME.equals(key))
- info.nickname = value;
- else if (IRepository.PROP_SYSTEM.equals(key))
- //only true if value.equals("true") which is OK because a repository is only system if it's explicitly set to system.
+ if (null != key)
+ switch (key) {
+ case IRepository.PROP_DESCRIPTION:
+ info.description = value;
+ break;
+ case IRepository.PROP_NAME:
+ info.name = value;
+ break;
+ case IRepository.PROP_NICKNAME:
+ info.nickname = value;
+ break;
+ case IRepository.PROP_SYSTEM:
+ //only true if value.equals("true") which is OK because a repository is only system if it's explicitly set to system.
info.isSystem = Boolean.parseBoolean(value);
+ break;
+ default:
+ break;
+ }
remember(info, true);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java
index b7dea435c..3ec31922a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java
@@ -446,12 +446,15 @@ public class CompositeRepositoryTaskTest extends AbstractAntProvisioningTest {
*/
protected ICompositeRepository getCompositeRepository(String type) {
try {
- if (type == TYPE_ARTIFACT) {
- return (ICompositeRepository) getArtifactRepositoryManager().loadRepository(compositeSite, null);
- } else if (type == TYPE_METADATA)
- return (ICompositeRepository) getMetadataRepositoryManager().loadRepository(compositeSite, null);
- else
- fail("No type specified");
+ if (null == type) fail("No type specified"); else switch (type) {
+ case TYPE_ARTIFACT:
+ return (ICompositeRepository) getArtifactRepositoryManager().loadRepository(compositeSite, null);
+ case TYPE_METADATA:
+ return (ICompositeRepository) getMetadataRepositoryManager().loadRepository(compositeSite, null);
+ default:
+ fail("No type specified");
+ break;
+ }
} catch (ProvisionException e) {
fail("Failed to load repository", e);
} catch (ClassCastException e) {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Counter.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Counter.java
index eb524b293..d24ef622c 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Counter.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Counter.java
@@ -62,12 +62,17 @@ public class Counter extends ProcessingStep {
if (data == null)
return;
try {
- if (data.equals("download"))
- size = Long.parseLong(context.getProperty(IArtifactDescriptor.DOWNLOAD_SIZE));
- else if (data.equals("artifact"))
- size = Long.parseLong(context.getProperty(IArtifactDescriptor.ARTIFACT_SIZE));
- else
- size = Long.parseLong(data);
+ switch (data) {
+ case "download":
+ size = Long.parseLong(context.getProperty(IArtifactDescriptor.DOWNLOAD_SIZE));
+ break;
+ case "artifact":
+ size = Long.parseLong(context.getProperty(IArtifactDescriptor.ARTIFACT_SIZE));
+ break;
+ default:
+ size = Long.parseLong(data);
+ break;
+ }
} catch (NumberFormatException e) {
int code = descriptor.isRequired() ? IStatus.ERROR : IStatus.INFO;
setStatus(new Status(code, Activator.ID, "Counter size specification invalid", e));
diff --git a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/CategoryParser.java b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/CategoryParser.java
index a7c827580..1d79a4e8d 100644
--- a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/CategoryParser.java
+++ b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/CategoryParser.java
@@ -425,14 +425,19 @@ public class CategoryParser extends DefaultHandler {
}
private void handleCategoryDefState(String elementName, Attributes attributes) {
- if (elementName.equals(DESCRIPTION)) {
- stateStack.push(Integer.valueOf(STATE_DESCRIPTION_CATEGORY_DEF));
- processInfo(attributes);
- } else if (elementName.equals(CATEGORY)) {
- stateStack.push(Integer.valueOf(STATE_CATEGORY));
- processCategory(attributes);
- } else
- internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState())})));
+ switch (elementName) {
+ case DESCRIPTION:
+ stateStack.push(Integer.valueOf(STATE_DESCRIPTION_CATEGORY_DEF));
+ processInfo(attributes);
+ break;
+ case CATEGORY:
+ stateStack.push(Integer.valueOf(STATE_CATEGORY));
+ processCategory(attributes);
+ break;
+ default:
+ internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState())})));
+ break;
+ }
}
private void handleCategoryState(String elementName, Attributes attributes) {
@@ -468,65 +473,91 @@ public class CategoryParser extends DefaultHandler {
}
private void handleSiteState(String elementName, Attributes attributes) {
- if (elementName.equals(DESCRIPTION)) {
- stateStack.push(Integer.valueOf(STATE_DESCRIPTION_SITE));
- processInfo(attributes);
- } else if (elementName.equals(FEATURE)) {
- stateStack.push(Integer.valueOf(STATE_FEATURE));
- processFeature(attributes);
- } else if (elementName.equals(BUNDLE)) {
- stateStack.push(Integer.valueOf(STATE_BUNDLE));
- processBundle(attributes);
- } else if (elementName.equals(IU)) {
- stateStack.push(Integer.valueOf(STATE_IU));
- processIU(attributes);
- } else if (elementName.equals(ARCHIVE)) {
- stateStack.push(Integer.valueOf(STATE_ARCHIVE));
- processArchive(attributes);
- } else if (elementName.equals(CATEGORY_DEF)) {
- stateStack.push(Integer.valueOf(STATE_CATEGORY_DEF));
- processCategoryDef(attributes);
- } else if (elementName.equals(REPOSITORY_REF)) {
- stateStack.push(Integer.valueOf(STATE_REPOSITORY_REF));
- processRepositoryReference(attributes);
- } else if (elementName.equals(STATS_URI)) {
- stateStack.push(Integer.valueOf(STATE_STATS));
- processStatsInfo(attributes);
- } else
- internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState())})));
+ switch (elementName) {
+ case DESCRIPTION:
+ stateStack.push(Integer.valueOf(STATE_DESCRIPTION_SITE));
+ processInfo(attributes);
+ break;
+ case FEATURE:
+ stateStack.push(Integer.valueOf(STATE_FEATURE));
+ processFeature(attributes);
+ break;
+ case BUNDLE:
+ stateStack.push(Integer.valueOf(STATE_BUNDLE));
+ processBundle(attributes);
+ break;
+ case IU:
+ stateStack.push(Integer.valueOf(STATE_IU));
+ processIU(attributes);
+ break;
+ case ARCHIVE:
+ stateStack.push(Integer.valueOf(STATE_ARCHIVE));
+ processArchive(attributes);
+ break;
+ case CATEGORY_DEF:
+ stateStack.push(Integer.valueOf(STATE_CATEGORY_DEF));
+ processCategoryDef(attributes);
+ break;
+ case REPOSITORY_REF:
+ stateStack.push(Integer.valueOf(STATE_REPOSITORY_REF));
+ processRepositoryReference(attributes);
+ break;
+ case STATS_URI:
+ stateStack.push(Integer.valueOf(STATE_STATS));
+ processStatsInfo(attributes);
+ break;
+ default:
+ internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState())})));
+ break;
+ }
}
private void handleStatsState(String elementName, Attributes attributes) {
- if (elementName.equals(FEATURE)) {
- stateStack.push(STATE_FEATURE);
- processStatsFeature(attributes);
- } else if (elementName.equals(BUNDLE)) {
- stateStack.push(STATE_BUNDLE);
- processStatsBundle(attributes);
- } else
- internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState())})));
+ switch (elementName) {
+ case FEATURE:
+ stateStack.push(STATE_FEATURE);
+ processStatsFeature(attributes);
+ break;
+ case BUNDLE:
+ stateStack.push(STATE_BUNDLE);
+ processStatsBundle(attributes);
+ break;
+ default:
+ internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState())})));
+ break;
+ }
}
private void handleIUState(String elementName, Attributes attributes) {
- if (elementName.equals(QUERY)) {
- stateStack.push(Integer.valueOf(STATE_QUERY));
- processQuery(attributes);
- } else if (elementName.equals(CATEGORY)) {
- stateStack.push(Integer.valueOf(STATE_CATEGORY));
- processCategory(attributes);
- } else
- internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState())})));
+ switch (elementName) {
+ case QUERY:
+ stateStack.push(Integer.valueOf(STATE_QUERY));
+ processQuery(attributes);
+ break;
+ case CATEGORY:
+ stateStack.push(Integer.valueOf(STATE_CATEGORY));
+ processCategory(attributes);
+ break;
+ default:
+ internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState())})));
+ break;
+ }
}
private void handleQueryState(String elementName, Attributes attributes) {
- if (elementName.equals(EXPRESSION)) {
- stateStack.push(Integer.valueOf(STATE_EXPRESSION));
- processExpression(attributes);
- } else if (elementName.equals(PARAM)) {
- stateStack.push(Integer.valueOf(STATE_PARAM));
- processParam(attributes);
- } else
- internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState())})));
+ switch (elementName) {
+ case EXPRESSION:
+ stateStack.push(Integer.valueOf(STATE_EXPRESSION));
+ processExpression(attributes);
+ break;
+ case PARAM:
+ stateStack.push(Integer.valueOf(STATE_PARAM));
+ processParam(attributes);
+ break;
+ default:
+ internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState())})));
+ break;
+ }
}
private void handleExpression(String elementName, Attributes attributes) {
diff --git a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/DefaultSiteParser.java b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/DefaultSiteParser.java
index 23030a8d2..4d299ce2c 100644
--- a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/DefaultSiteParser.java
+++ b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/DefaultSiteParser.java
@@ -380,83 +380,115 @@ public class DefaultSiteParser extends DefaultHandler {
}
private void handleCategoryDefState(String elementName, Attributes attributes) {
- if (elementName.equals(FEATURE)) {
- stateStack.push(Integer.valueOf(STATE_FEATURE));
- processFeature(attributes);
- } else if (elementName.equals(BUNDLE)) {
- stateStack.push(Integer.valueOf(STATE_BUNDLE));
- processBundle(attributes);
- } else if (elementName.equals(ARCHIVE)) {
- stateStack.push(Integer.valueOf(STATE_ARCHIVE));
- processArchive(attributes);
- } else if (elementName.equals(CATEGORY_DEF)) {
- stateStack.push(Integer.valueOf(STATE_CATEGORY_DEF));
- processCategoryDef(attributes);
- } else if (elementName.equals(DESCRIPTION)) {
- stateStack.push(Integer.valueOf(STATE_DESCRIPTION_CATEGORY_DEF));
- processInfo(attributes);
- } else
- internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState)})));
+ switch (elementName) {
+ case FEATURE:
+ stateStack.push(Integer.valueOf(STATE_FEATURE));
+ processFeature(attributes);
+ break;
+ case BUNDLE:
+ stateStack.push(Integer.valueOf(STATE_BUNDLE));
+ processBundle(attributes);
+ break;
+ case ARCHIVE:
+ stateStack.push(Integer.valueOf(STATE_ARCHIVE));
+ processArchive(attributes);
+ break;
+ case CATEGORY_DEF:
+ stateStack.push(Integer.valueOf(STATE_CATEGORY_DEF));
+ processCategoryDef(attributes);
+ break;
+ case DESCRIPTION:
+ stateStack.push(Integer.valueOf(STATE_DESCRIPTION_CATEGORY_DEF));
+ processInfo(attributes);
+ break;
+ default:
+ internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState)})));
+ break;
+ }
}
private void handleCategoryState(String elementName, Attributes attributes) {
- if (elementName.equals(DESCRIPTION)) {
- stateStack.push(Integer.valueOf(STATE_DESCRIPTION_SITE));
- processInfo(attributes);
- } else if (elementName.equals(FEATURE)) {
- stateStack.push(Integer.valueOf(STATE_FEATURE));
- processFeature(attributes);
- } else if (elementName.equals(BUNDLE)) {
- stateStack.push(Integer.valueOf(STATE_BUNDLE));
- processBundle(attributes);
- } else if (elementName.equals(ARCHIVE)) {
- stateStack.push(Integer.valueOf(STATE_ARCHIVE));
- processArchive(attributes);
- } else if (elementName.equals(CATEGORY_DEF)) {
- stateStack.push(Integer.valueOf(STATE_CATEGORY_DEF));
- processCategoryDef(attributes);
- } else if (elementName.equals(CATEGORY)) {
- stateStack.push(Integer.valueOf(STATE_CATEGORY));
- processCategory(attributes);
- } else
- internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState)})));
+ switch (elementName) {
+ case DESCRIPTION:
+ stateStack.push(Integer.valueOf(STATE_DESCRIPTION_SITE));
+ processInfo(attributes);
+ break;
+ case FEATURE:
+ stateStack.push(Integer.valueOf(STATE_FEATURE));
+ processFeature(attributes);
+ break;
+ case BUNDLE:
+ stateStack.push(Integer.valueOf(STATE_BUNDLE));
+ processBundle(attributes);
+ break;
+ case ARCHIVE:
+ stateStack.push(Integer.valueOf(STATE_ARCHIVE));
+ processArchive(attributes);
+ break;
+ case CATEGORY_DEF:
+ stateStack.push(Integer.valueOf(STATE_CATEGORY_DEF));
+ processCategoryDef(attributes);
+ break;
+ case CATEGORY:
+ stateStack.push(Integer.valueOf(STATE_CATEGORY));
+ processCategory(attributes);
+ break;
+ default:
+ internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState)})));
+ break;
+ }
}
private void handleFeatureState(String elementName, Attributes attributes) {
- if (elementName.equals(DESCRIPTION)) {
- stateStack.push(Integer.valueOf(STATE_DESCRIPTION_SITE));
- processInfo(attributes);
- } else if (elementName.equals(FEATURE)) {
- stateStack.push(Integer.valueOf(STATE_FEATURE));
- processFeature(attributes);
- } else if (elementName.equals(ARCHIVE)) {
- stateStack.push(Integer.valueOf(STATE_ARCHIVE));
- processArchive(attributes);
- } else if (elementName.equals(CATEGORY_DEF)) {
- stateStack.push(Integer.valueOf(STATE_CATEGORY_DEF));
- processCategoryDef(attributes);
- } else if (elementName.equals(CATEGORY)) {
- stateStack.push(Integer.valueOf(STATE_CATEGORY));
- processCategory(attributes);
- } else
- internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState)})));
+ switch (elementName) {
+ case DESCRIPTION:
+ stateStack.push(Integer.valueOf(STATE_DESCRIPTION_SITE));
+ processInfo(attributes);
+ break;
+ case FEATURE:
+ stateStack.push(Integer.valueOf(STATE_FEATURE));
+ processFeature(attributes);
+ break;
+ case ARCHIVE:
+ stateStack.push(Integer.valueOf(STATE_ARCHIVE));
+ processArchive(attributes);
+ break;
+ case CATEGORY_DEF:
+ stateStack.push(Integer.valueOf(STATE_CATEGORY_DEF));
+ processCategoryDef(attributes);
+ break;
+ case CATEGORY:
+ stateStack.push(Integer.valueOf(STATE_CATEGORY));
+ processCategory(attributes);
+ break;
+ default:
+ internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState)})));
+ break;
+ }
}
private void handleBundleState(String elementName, Attributes attributes) {
- if (elementName.equals(DESCRIPTION)) {
- stateStack.push(Integer.valueOf(STATE_DESCRIPTION_SITE));
- processInfo(attributes);
- } else if (elementName.equals(ARCHIVE)) {
- stateStack.push(Integer.valueOf(STATE_ARCHIVE));
- processArchive(attributes);
- } else if (elementName.equals(CATEGORY_DEF)) {
- stateStack.push(Integer.valueOf(STATE_CATEGORY_DEF));
- processCategoryDef(attributes);
- } else if (elementName.equals(CATEGORY)) {
- stateStack.push(Integer.valueOf(STATE_CATEGORY));
- processCategory(attributes);
- } else
- internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState)})));
+ switch (elementName) {
+ case DESCRIPTION:
+ stateStack.push(Integer.valueOf(STATE_DESCRIPTION_SITE));
+ processInfo(attributes);
+ break;
+ case ARCHIVE:
+ stateStack.push(Integer.valueOf(STATE_ARCHIVE));
+ processArchive(attributes);
+ break;
+ case CATEGORY_DEF:
+ stateStack.push(Integer.valueOf(STATE_CATEGORY_DEF));
+ processCategoryDef(attributes);
+ break;
+ case CATEGORY:
+ stateStack.push(Integer.valueOf(STATE_CATEGORY));
+ processCategory(attributes);
+ break;
+ default:
+ internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState)})));
+ break;
+ }
}
private void handleInitialState(String elementName, Attributes attributes) throws SAXException {
@@ -472,23 +504,31 @@ public class DefaultSiteParser extends DefaultHandler {
}
private void handleSiteState(String elementName, Attributes attributes) {
- if (elementName.equals(DESCRIPTION)) {
- stateStack.push(Integer.valueOf(STATE_DESCRIPTION_SITE));
- processInfo(attributes);
- } else if (elementName.equals(FEATURE)) {
- stateStack.push(Integer.valueOf(STATE_FEATURE));
- processFeature(attributes);
- } else if (elementName.equals(BUNDLE)) {
- stateStack.push(Integer.valueOf(STATE_BUNDLE));
- processBundle(attributes);
- } else if (elementName.equals(ARCHIVE)) {
- stateStack.push(Integer.valueOf(STATE_ARCHIVE));
- processArchive(attributes);
- } else if (elementName.equals(CATEGORY_DEF)) {
- stateStack.push(Integer.valueOf(STATE_CATEGORY_DEF));
- processCategoryDef(attributes);
- } else
- internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState)})));
+ switch (elementName) {
+ case DESCRIPTION:
+ stateStack.push(Integer.valueOf(STATE_DESCRIPTION_SITE));
+ processInfo(attributes);
+ break;
+ case FEATURE:
+ stateStack.push(Integer.valueOf(STATE_FEATURE));
+ processFeature(attributes);
+ break;
+ case BUNDLE:
+ stateStack.push(Integer.valueOf(STATE_BUNDLE));
+ processBundle(attributes);
+ break;
+ case ARCHIVE:
+ stateStack.push(Integer.valueOf(STATE_ARCHIVE));
+ processArchive(attributes);
+ break;
+ case CATEGORY_DEF:
+ stateStack.push(Integer.valueOf(STATE_CATEGORY_DEF));
+ processCategoryDef(attributes);
+ break;
+ default:
+ internalErrorUnknownTag(NLS.bind(Messages.DefaultSiteParser_UnknownElement, (new String[] {elementName, getState(currentState)})));
+ break;
+ }
}
/*

Back to the top