⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 typeimpl.java

📁 一个java工作流引擎
💻 JAVA
字号:
package org.jbpm.model.definition.impl;

import java.util.*;
import org.apache.commons.logging.*;
import org.jbpm.delegation.*;
import org.jbpm.model.definition.*;

public class TypeImpl implements Type {

  private Long id = null;
  private int index = -1;
  private String description = null;
  private DefinitionImpl definition = null;
  private String javaType = null;
  private transient DelegationImpl serializerDelegation = null;
  private Map variables = null;

  public TypeImpl() {}

  public TypeImpl(String javaType) {
    this.javaType = javaType;
  }

  public TypeImpl(String javaType, String serializerClassName) {
    this.javaType = javaType;
    this.serializerDelegation = new DelegationImpl( null, serializerClassName );
  }

	public Long getId() { return this.id; }
  public void setId(Long id) { this.id = id; }
  
	public int getIndex() { return this.index; }
	public void setIndex(int index) { this.index = index; }

  public String getDescription() { return this.description; }
  public void setDescription(String description) { this.description = description; }
  
  public Definition getDefinition() { return this.definition; }
  public void setDefinition(DefinitionImpl definition) { this.definition = definition; }
  
  public String getJavaType() { return this.javaType; }
  public void setJavaType(String javaType) { this.javaType = javaType; }
  
  public DelegationImpl getSerializerDelegation() { return this.serializerDelegation; }
	public void setSerializerDelegation(DelegationImpl serializerDelegation) { this.serializerDelegation = serializerDelegation; }

  public Map getVariables() { return this.variables; }
  public void setVariables(Map variables) { this.variables = variables; }
  public void add(VariableImpl variable) {
    if ( variable != null ) {
      if ( variables == null ) variables = new HashMap();
      String variableName = variable.getName();
      if ( variableName != null ) {
        variables.put( variableName, variable );
      }
    }
  }
  
  public String toString() {
   return "type[java-type(" + javaType +") index(" + index + ")]"; 
  }
  
  public boolean isTransient() {
    return ( serializerDelegation == null ); 
  }

	public String serialize(Object object) {
    String serializedValue = null;
    if ( ( object != null )
         && ( ! isTransient() ) ) {
      Serializer serializer = (Serializer) serializerDelegation.instantiate();
      try {
        serializedValue = serializer.serialize( object );
      } catch (RuntimeException e) {
        log.error( "serializer runtime exception, tsss...", e );
				throw new SerializerException( "couldn't serialize object '" + object + "' with serializer '" + serializerDelegation.getClassName() +"'", e );
      }
    }
    return serializedValue;
	}

  public Object deserialize(String serializedValue) {
    Object object = null;
    if ( ( serializedValue != null )
         && ( ! isTransient() ) ) {
      Serializer serializer = (Serializer) serializerDelegation.instantiate();
      try {
        object = serializer.deserialize( serializedValue );
      } catch (RuntimeException e) {
        log.error( "serializer runtime exception, tsss...", e );
        throw new SerializerException( "couldn't deserialize text '" + serializedValue + "' with serializer '" + serializerDelegation.getClassName() +"'", e );
      }
    }
    return object;
  }

	public void toXml(org.dom4j.Element element) {
    element.addAttribute( "java-type", javaType );
    if ( description != null ) element.addElement("description").addText( description );
    if ( serializerDelegation != null ) {
      serializerDelegation.toXml( element.addElement( "delegation" ) );
    } else {
      element.addElement( "transient" );
    }
    
    if ( variables != null ) {
      Iterator iter = variables.values().iterator();
      while (iter.hasNext()) {
        VariableImpl variable = (VariableImpl) iter.next();
        variable.toXml( element.addElement( "variable" ) );
      }
    }
	}

  private static Log log = LogFactory.getLog(TypeImpl.class);

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -