mirror of https://github.com/apache/openjpa.git
changed AutoDetachValue to extend StringListValue, more closely modeling its behavior in the Kodo configuration system; changed visibility of XML name conversion method
git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@425499 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e9aa22eddc
commit
bbb2d060b0
|
@ -16,8 +16,7 @@
|
||||||
package org.apache.openjpa.conf;
|
package org.apache.openjpa.conf;
|
||||||
|
|
||||||
import org.apache.openjpa.kernel.AutoDetach;
|
import org.apache.openjpa.kernel.AutoDetach;
|
||||||
import org.apache.openjpa.lib.conf.Value;
|
import org.apache.openjpa.lib.conf.StringListValue;
|
||||||
import serp.util.Strings;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value type used to represent auto detach flags. Separate to
|
* Value type used to represent auto detach flags. Separate to
|
||||||
|
@ -27,7 +26,7 @@ import serp.util.Strings;
|
||||||
* @nojavadoc
|
* @nojavadoc
|
||||||
*/
|
*/
|
||||||
class AutoDetachValue
|
class AutoDetachValue
|
||||||
extends Value {
|
extends StringListValue {
|
||||||
|
|
||||||
public static final String DETACH_CLOSE = "close";
|
public static final String DETACH_CLOSE = "close";
|
||||||
public static final String DETACH_COMMIT = "commit";
|
public static final String DETACH_COMMIT = "commit";
|
||||||
|
@ -43,49 +42,30 @@ class AutoDetachValue
|
||||||
};
|
};
|
||||||
|
|
||||||
private int _flags;
|
private int _flags;
|
||||||
|
private boolean _flagsSet;
|
||||||
|
|
||||||
public AutoDetachValue() {
|
public AutoDetachValue() {
|
||||||
super("AutoDetach");
|
super("AutoDetach");
|
||||||
setAliases(ALIASES);
|
setAliases(ALIASES);
|
||||||
|
setAliasListComprehensive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class getValueType() {
|
public Class getValueType() {
|
||||||
return String[].class;
|
return String[].class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(int flags) {
|
public void setConstant(int flags) {
|
||||||
_flags = flags;
|
_flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int get() {
|
public int getConstant() {
|
||||||
|
if (!_flagsSet) {
|
||||||
|
String[] vals = get();
|
||||||
|
for (int i = 0; i < vals.length; i++)
|
||||||
|
_flags |= Integer.parseInt(unalias(vals[i]));
|
||||||
|
_flagsSet = true;
|
||||||
|
}
|
||||||
|
|
||||||
return _flags;
|
return _flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getInternalString() {
|
|
||||||
StringBuffer buf = new StringBuffer();
|
|
||||||
String[] aliases = getAliases();
|
|
||||||
boolean start = false;
|
|
||||||
for (int i = 0; i < aliases.length; i += 2) {
|
|
||||||
if ((_flags & Integer.parseInt(aliases[i + 1])) != 0) {
|
|
||||||
buf.append(aliases[i]);
|
|
||||||
if (start)
|
|
||||||
buf.append(", ");
|
|
||||||
else
|
|
||||||
start = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return buf.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInternalString(String val) {
|
|
||||||
String[] vals = Strings.split(val, ",", 0);
|
|
||||||
for (int i = 0; i < vals.length; i++)
|
|
||||||
_flags |= Integer.parseInt(unalias(vals[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInternalObject(Object val) {
|
|
||||||
String[] vals = (String[]) val;
|
|
||||||
for (int i = 0; i < vals.length; i++)
|
|
||||||
_flags |= Integer.parseInt(unalias(vals[i]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1105,11 +1105,11 @@ public class OpenJPAConfigurationImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAutoDetach(int autoDetachFlags) {
|
public void setAutoDetach(int autoDetachFlags) {
|
||||||
autoDetach.set(autoDetachFlags);
|
autoDetach.setConstant(autoDetachFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAutoDetachConstant() {
|
public int getAutoDetachConstant() {
|
||||||
return autoDetach.get();
|
return autoDetach.getConstant();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDetachState(String detachState) {
|
public void setDetachState(String detachState) {
|
||||||
|
|
Loading…
Reference in New Issue