Author: michiel
Date: 2010-02-09 17:39:30 +0100 (Tue, 09 Feb 2010)
New Revision: 40946
Modified:
mmbase/trunk/core/src/main/java/org/mmbase/datatypes/BasicDataType.java
Log:
using some switches for the silly 'action' arguments. At least you have
illegalargument exceptions now for nonsensical values of that
Modified:
mmbase/trunk/core/src/main/java/org/mmbase/datatypes/BasicDataType.java
===================================================================
--- mmbase/trunk/core/src/main/java/org/mmbase/datatypes/BasicDataType.java
2010-02-09 15:38:05 UTC (rev 40945)
+++ mmbase/trunk/core/src/main/java/org/mmbase/datatypes/BasicDataType.java
2010-02-09 16:39:30 UTC (rev 40946)
@@ -968,16 +968,23 @@
deleteProcessor = cp;
}
+
/**
* {...@inheritdoc}
*/
public Processor getProcessor(int action) {
Processor processor;
- if (action == PROCESS_GET) {
+ switch(action) {
+ case PROCESS_GET: {
processor = getProcessors == null ? null : getProcessors[0];
- } else {
+ break;
+ }
+ case PROCESS_SET: {
processor = setProcessors == null ? null : setProcessors[0];
+ break;
}
+ default: throw new IllegalArgumentException();
+ }
return processor == null ? CopyProcessor.getInstance() : processor;
}
@@ -989,10 +996,10 @@
return getProcessor(action);
} else {
Processor processor;
- if (action == PROCESS_GET) {
- processor = getProcessors == null ? null :
getProcessors[processingType];
- } else {
- processor = setProcessors == null ? null :
setProcessors[processingType];
+ switch(action) {
+ case PROCESS_GET: processor = getProcessors == null ? null :
getProcessors[processingType]; break;
+ case PROCESS_SET: processor = setProcessors == null ? null :
setProcessors[processingType]; break;
+ default: throw new IllegalArgumentException();
}
return processor == null ? getProcessor(action) : processor;
}
@@ -1002,10 +1009,10 @@
if (processingType == -1) {
processingType = 0;
}
- if (action == PROCESS_GET) {
- return getProcessors == null ? null :
getProcessors[processingType];
- } else {
- return setProcessors == null ? null :
setProcessors[processingType];
+ switch(action) {
+ case PROCESS_GET: return getProcessors == null ? null :
getProcessors[processingType];
+ case PROCESS_SET: return setProcessors == null ? null :
setProcessors[processingType];
+ default: throw new IllegalArgumentException();
}
}
@@ -1027,15 +1034,22 @@
if (processingType == Field.TYPE_UNKNOWN) {
processingType = 0;
}
- if (action == PROCESS_GET) {
+ switch (action) {
+ case PROCESS_GET: {
if (getProcessors == null) getProcessors = newProcessorsArray();
getProcessors[processingType] = processor;
- } else {
+ break;
+ }
+ case PROCESS_SET: {
if (setProcessors == null) setProcessors = newProcessorsArray();
setProcessors[processingType] = processor;
+ break;
}
+ default: throw new IllegalArgumentException();
+ }
}
+
private static final String[] EMPTY_STRING_ARRAY = new String[0];
public String[] getStyleClasses() {
if (styleClasses != null) {
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs