Java Code Examples for org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory

The following examples show how to use org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: mybaties   Source File: MetaObject.java    License: Apache License 2.0 6 votes vote down vote up
private MetaObject(Object object, ObjectFactory objectFactory, ObjectWrapperFactory objectWrapperFactory) {
  this.originalObject = object;
  this.objectFactory = objectFactory;
  this.objectWrapperFactory = objectWrapperFactory;

  if (object instanceof ObjectWrapper) {
      //如果对象本身已经是ObjectWrapper型,则直接赋给objectWrapper
    this.objectWrapper = (ObjectWrapper) object;
  } else if (objectWrapperFactory.hasWrapperFor(object)) {
      //如果有包装器,调用ObjectWrapperFactory.getWrapperFor
    this.objectWrapper = objectWrapperFactory.getWrapperFor(this, object);
  } else if (object instanceof Map) {
      //如果是Map型,返回MapWrapper
    this.objectWrapper = new MapWrapper(this, (Map) object);
  } else if (object instanceof Collection) {
      //如果是Collection型,返回CollectionWrapper
    this.objectWrapper = new CollectionWrapper(this, (Collection) object);
  } else {
      //除此以外,返回BeanWrapper
    this.objectWrapper = new BeanWrapper(this, object);
  }
}
 
Example 2
Source Project: mybatis   Source File: MetaObject.java    License: Apache License 2.0 6 votes vote down vote up
private MetaObject(Object object, ObjectFactory objectFactory, ObjectWrapperFactory objectWrapperFactory) {
  this.originalObject = object;
  this.objectFactory = objectFactory;
  this.objectWrapperFactory = objectWrapperFactory;

  if (object instanceof ObjectWrapper) {
      //如果对象本身已经是ObjectWrapper型,则直接赋给objectWrapper
    this.objectWrapper = (ObjectWrapper) object;
  } else if (objectWrapperFactory.hasWrapperFor(object)) {
      //如果有包装器,调用ObjectWrapperFactory.getWrapperFor
    this.objectWrapper = objectWrapperFactory.getWrapperFor(this, object);
  } else if (object instanceof Map) {
      //如果是Map型,返回MapWrapper
    this.objectWrapper = new MapWrapper(this, (Map) object);
  } else if (object instanceof Collection) {
      //如果是Collection型,返回CollectionWrapper
    this.objectWrapper = new CollectionWrapper(this, (Collection) object);
  } else {
      //除此以外,返回BeanWrapper
    this.objectWrapper = new BeanWrapper(this, object);
  }
}
 
Example 3
private void objectWrapperFactoryElement(XNode context) throws Exception {
  if (context != null) {
    String type = context.getStringAttribute("type");
    ObjectWrapperFactory factory = (ObjectWrapperFactory) resolveClass(type).newInstance();
    configuration.setObjectWrapperFactory(factory);
  }
}
 
Example 4
Source Project: mybaties   Source File: MetaObject.java    License: Apache License 2.0 5 votes vote down vote up
public static MetaObject forObject(Object object, ObjectFactory objectFactory, ObjectWrapperFactory objectWrapperFactory) {
  if (object == null) {
      //处理一下null,将null包装起来
    return SystemMetaObject.NULL_META_OBJECT;
  } else {
    return new MetaObject(object, objectFactory, objectWrapperFactory);
  }
}
 
Example 5
Source Project: mybaties   Source File: XMLConfigBuilder.java    License: Apache License 2.0 5 votes vote down vote up
private void objectWrapperFactoryElement(XNode context) throws Exception {
  if (context != null) {
    String type = context.getStringAttribute("type");
    ObjectWrapperFactory factory = (ObjectWrapperFactory) resolveClass(type).newInstance();
    configuration.setObjectWrapperFactory(factory);
  }
}
 
Example 6
Source Project: mybaties   Source File: DefaultMapResultHandler.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public DefaultMapResultHandler(String mapKey, ObjectFactory objectFactory, ObjectWrapperFactory objectWrapperFactory) {
  this.objectFactory = objectFactory;
  this.objectWrapperFactory = objectWrapperFactory;
  this.mappedResults = objectFactory.create(Map.class);
  this.mapKey = mapKey;
}
 
Example 7
Source Project: mybatis   Source File: MetaObject.java    License: Apache License 2.0 5 votes vote down vote up
public static MetaObject forObject(Object object, ObjectFactory objectFactory, ObjectWrapperFactory objectWrapperFactory) {
  if (object == null) {
      //处理一下null,将null包装起来
    return SystemMetaObject.NULL_META_OBJECT;
  } else {
    return new MetaObject(object, objectFactory, objectWrapperFactory);
  }
}
 
Example 8
Source Project: mybatis   Source File: XMLConfigBuilder.java    License: Apache License 2.0 5 votes vote down vote up
private void objectWrapperFactoryElement(XNode context) throws Exception {
  if (context != null) {
    String type = context.getStringAttribute("type");
    ObjectWrapperFactory factory = (ObjectWrapperFactory) resolveClass(type).newInstance();
    configuration.setObjectWrapperFactory(factory);
  }
}
 
Example 9
Source Project: mybatis   Source File: DefaultMapResultHandler.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public DefaultMapResultHandler(String mapKey, ObjectFactory objectFactory, ObjectWrapperFactory objectWrapperFactory) {
  this.objectFactory = objectFactory;
  this.objectWrapperFactory = objectWrapperFactory;
  this.mappedResults = objectFactory.create(Map.class);
  this.mapKey = mapKey;
}
 
Example 10
Source Project: QuickProject   Source File: XMLConfigBuilder.java    License: Apache License 2.0 5 votes vote down vote up
private void objectWrapperFactoryElement(XNode context) throws Exception {
  if (context != null) {
    String type = context.getStringAttribute("type");
    ObjectWrapperFactory factory = (ObjectWrapperFactory) resolveClass(type).newInstance();
    configuration.setObjectWrapperFactory(factory);
  }
}
 
Example 11
Source Project: Shop-for-JavaWeb   Source File: Configuration.java    License: MIT License 4 votes vote down vote up
public ObjectWrapperFactory getObjectWrapperFactory() {
	return objectWrapperFactory;
}
 
Example 12
Source Project: Shop-for-JavaWeb   Source File: Configuration.java    License: MIT License 4 votes vote down vote up
public void setObjectWrapperFactory(
		ObjectWrapperFactory objectWrapperFactory) {
	this.objectWrapperFactory = objectWrapperFactory;
}
 
Example 13
Source Project: mybaties   Source File: MetaObject.java    License: Apache License 2.0 4 votes vote down vote up
public ObjectWrapperFactory getObjectWrapperFactory() {
  return objectWrapperFactory;
}
 
Example 14
Source Project: mybaties   Source File: Configuration.java    License: Apache License 2.0 4 votes vote down vote up
public ObjectWrapperFactory getObjectWrapperFactory() {
  return objectWrapperFactory;
}
 
Example 15
Source Project: mybaties   Source File: Configuration.java    License: Apache License 2.0 4 votes vote down vote up
public void setObjectWrapperFactory(ObjectWrapperFactory objectWrapperFactory) {
  this.objectWrapperFactory = objectWrapperFactory;
}
 
Example 16
Source Project: mybatis   Source File: MetaObject.java    License: Apache License 2.0 4 votes vote down vote up
public ObjectWrapperFactory getObjectWrapperFactory() {
  return objectWrapperFactory;
}
 
Example 17
Source Project: mybatis   Source File: Configuration.java    License: Apache License 2.0 4 votes vote down vote up
public ObjectWrapperFactory getObjectWrapperFactory() {
  return objectWrapperFactory;
}
 
Example 18
Source Project: mybatis   Source File: Configuration.java    License: Apache License 2.0 4 votes vote down vote up
public void setObjectWrapperFactory(ObjectWrapperFactory objectWrapperFactory) {
  this.objectWrapperFactory = objectWrapperFactory;
}
 
Example 19
/**
 * Sets the ObjectWrapperFactory.
 *
 * @since 1.1.2
 * @param objectWrapperFactory ObjectWrapperFactory
 */
public void setObjectWrapperFactory(ObjectWrapperFactory objectWrapperFactory) {
    this.objectWrapperFactory = objectWrapperFactory;
}
 
Example 20
Source Project: Shop-for-JavaWeb   Source File: SqlSessionFactoryBean.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the ObjectWrapperFactory.
 * 
 * @since 1.1.2
 * @param objectWrapperFactory
 */
public void setObjectWrapperFactory(
		ObjectWrapperFactory objectWrapperFactory) {
	this.objectWrapperFactory = objectWrapperFactory;
}
 
Example 21
Source Project: QuickProject   Source File: SqlSessionFactoryBean.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the ObjectWrapperFactory.
 *
 * @since 1.1.2
 * @param objectWrapperFactory
 */
public void setObjectWrapperFactory(ObjectWrapperFactory objectWrapperFactory) {
    this.objectWrapperFactory = objectWrapperFactory;
}