Copyright (c) 2008-2011 Vrije Universiteit, The Netherlands
All rights reserved.
Redistribution and use in source and binary forms,
with or without modification, are permitted provided
that the follo...
If you think the Android project interdroid-swan listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package interdroid.swan.swansong;
//fromwww.java2s.com/**
* Represents the way an expression reduces the history it examines and performs
* matching.
*
* @author roelof <rkemp@cs.vu.nl>
* @author nick <palmer@cs.vu.nl>
*
*/publicenum HistoryReductionMode implements ParseableEnum<HistoryReductionMode> {
/** No reduction is performed, matching is against all values. */
ALL(0, "ALL"),
/** Takes the maximum value. */
MAX(1, "MAX"),
/** Takes the minimum value. */
MIN(2, "MIN"),
/** Takes the mean value. */
MEAN(3, "MEAN"),
/** Takes the median value. */
MEDIAN(4, "MEDIAN"),
/** No reduction is performed, matching is against any value. */
ANY(5, "ANY");
/** The default HistoryReductionMode for all expressions. */publicstaticfinal HistoryReductionMode DEFAULT_MODE = HistoryReductionMode.ALL;
/** The convert value. */privatefinalint mValue;
/** The name for the mode. */privatefinal String mName;
/**
* Construct with the given convert value.
*
* @param value
* the convert value.
* @param name
* the name
*/private HistoryReductionMode(finalint value, final String name) {
mValue = value;
mName = name;
}
@Override
publicint convert() {
return mValue;
}
@Override
public HistoryReductionMode convertInt(finalint val) {
HistoryReductionMode ret = null;
for (HistoryReductionMode mode : HistoryReductionMode.values()) {
if (mode.convert() == val) {
ret = mode;
break;
}
}
return ret;
}
/**
* Parses a string and returns the appropriate mode.
*
* @param val
* the string to parse
* @return the reduction mode
*/privatestatic HistoryReductionMode parseString(final String val) {
HistoryReductionMode ret = null;
for (HistoryReductionMode mode : HistoryReductionMode.values()) {
if (mode.toParseString().equals(val)) {
ret = mode;
break;
}
}
return ret;
}
/**
* Parse a string and return the value.
*
* @param value
* the value to parse
* @return the enum which matches the string.
*/publicstatic HistoryReductionMode parse(final String value) {
return HistoryReductionMode.parseString(value);
}
/**
* Converts a persisted int to the matching enumeration value.
*
* @param value
* the value to get the enumeration for
* @return the enumeration matching this value
*/publicstatic HistoryReductionMode convert(finalint value) {
return ALL.convertInt(value);
}
@Override
publicfinal String toString() {
return mName;
}
@Override
publicfinal String toParseString() {
return mName;
}
}