📄 variableinstanceimpl.java
字号:
package org.jbpm.model.execution.impl;
import java.io.*;
import java.util.*;
import org.jbpm.model.definition.*;
import org.jbpm.model.definition.impl.*;
import org.jbpm.model.execution.*;
import org.jbpm.model.log.impl.*;
public class VariableInstanceImpl implements Serializable {
private Long id = null;
private String name = null;
private DefaultType defaultType = null;
private TypeImpl type = null;
private TokenImpl token = null;
private String serializedValue = null;
private SortedSet updateLogs = null;
private boolean isValueCached = false;
private Object cachedValue = null;
public VariableInstanceImpl() {}
public VariableInstanceImpl(String name, TokenImpl token, TypeImpl type) {
this.name = name;
this.type = type;
token.add( this );
}
public VariableInstanceImpl(String name, TokenImpl token, DefaultType defaultType) {
this.name = name;
this.defaultType = defaultType;
token.add( this );
}
public Long getId() { return this.id; }
public void setId(Long id) { this.id = id; }
public String getName() { return this.name; }
public void setName(String name) { this.name = name; }
public DefaultType getDefaultType() { return this.defaultType; }
public void setDefaultType(DefaultType defaultType) { this.defaultType = defaultType; }
public Type getType() { return this.type; }
public void setType(TypeImpl type) { this.type = type; }
public Token getToken() { return this.token; }
public void setToken(TokenImpl token) { this.token = token; }
public String getSerializedValue() { return this.serializedValue; }
public void setSerializedValue(String serializedValue) { this.serializedValue = serializedValue; }
public SortedSet getUpdateLogs() { return this.updateLogs; }
public void setUpdateLogs(SortedSet updateLogs) { this.updateLogs = updateLogs; }
public void add( VariableUpdateLogImpl updateLog ) {
if ( updateLogs == null ) {
updateLogs = new TreeSet();
}
updateLogs.add( updateLog );
}
public Object getValue() {
if ( ! isValueCached ) {
cachedValue = deserialize( serializedValue );
isValueCached = true;
}
return cachedValue;
}
public Object deserialize( String text ) {
Object objectValue = null;
if ( text != null ) {
if ( defaultType != null ) {
objectValue = defaultType.getSerializer().deserialize( text );
} else {
objectValue = type.deserialize( text );
}
}
return objectValue;
}
public void setValue(Object newValue) {
String oldSerializedValue = serializedValue;
serializedValue = serialize(newValue);
if ( token != null ) {
VariableUpdateLogImpl log = new VariableUpdateLogImpl( this, oldSerializedValue, getValue(), serializedValue, newValue );
// mind the sequence of the next two instructions ! read on...
// adding the log to the token will attach the the log to the event
token.add( log );
// adding this as an updateLog (SortedSet), will perform the VariableUpdateLogImpl-comparison which
// is based on the event of the log.
add( log );
}
cachedValue = newValue;
isValueCached = true;
}
private String serialize(Object value) {
String text = null;
if ( value != null ) {
if ( defaultType != null ) {
text = defaultType.getSerializer().serialize( value );
} else {
text = type.serialize( value );
}
}
return text;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -