当前位置: 首页>>代码示例>>Java>>正文


Java ObjectRenderer类代码示例

本文整理汇总了Java中org.apache.log4j.or.ObjectRenderer的典型用法代码示例。如果您正苦于以下问题:Java ObjectRenderer类的具体用法?Java ObjectRenderer怎么用?Java ObjectRenderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ObjectRenderer类属于org.apache.log4j.or包,在下文中一共展示了ObjectRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: noDelegationTest

import org.apache.log4j.or.ObjectRenderer; //导入依赖的package包/类
@Test
public void noDelegationTest() {
	JCategory context = new JCategory();
	//instantiating categories
	TypeCategory<Animal> animalCategory = context.forClass(Animal.class); //type category for Animal
	TypeCategory<HasLegs> hasLegsCategory = context.forClass(HasLegs.class); //type category for HasLegs
	TypeCategory<Cat> catCategory = context.forClass(Cat.class); //type category for Cat
	
	//setting properties
	animalCategory.setProperty(OBJECT_RENDERER_KEY, new AnimalRenderer()); //ObjectRenderer property is an instance of AnimalRenderer for Animal
	hasLegsCategory.setProperty(OBJECT_RENDERER_KEY, new HasLegsRenderer()); //ObjectRenderer property is an instance of HasLegsRenderer for HasLegs
	
	//testing
	ObjectRenderer renderer = catCategory.getStrategy(ObjectRenderer.class);
	assertEquals("animal", renderer.doRender(new Cat()));
}
 
开发者ID:jcategory,项目名称:jcategory,代码行数:17,代码来源:StrategyTutorialTest.java

示例2: delegationTest

import org.apache.log4j.or.ObjectRenderer; //导入依赖的package包/类
@Test
public void delegationTest() {
	JCategory context = new JCategory();
	//instantiating categories
	TypeCategory<Animal> animalCategory = context.forClass(Animal.class); //type category for Animal
	TypeCategory<HasLegs> hasLegsCategory = context.forClass(HasLegs.class); //type category for HasLegs
	TypeCategory<Cat> catCategory = context.forClass(Cat.class); //type category for Cat
	
	//setting properties
	animalCategory.setProperty(OBJECT_RENDERER_KEY, new DelegationAnimalRenderer()); //ObjectRenderer property is an instance of DelegationAnimalRenderer for Animal
	hasLegsCategory.setProperty(OBJECT_RENDERER_KEY, new HasLegsRenderer()); //ObjectRenderer property is an instance of HasLegsRenderer for HasLegs
	
	//testing
	ObjectRenderer renderer = catCategory.getStrategy(ObjectRenderer.class);
	assertEquals("has-legs", renderer.doRender(new Cat()));
}
 
开发者ID:jcategory,项目名称:jcategory,代码行数:17,代码来源:StrategyTutorialTest.java

示例3: test1

import org.apache.log4j.or.ObjectRenderer; //导入依赖的package包/类
public
void test1() {
  RendererMap map = new RendererMap();
  ObjectRenderer dr = map.getDefaultRenderer();
  ObjectRenderer r = map.get(Integer.class);
  assertEquals(r, dr);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:8,代码来源:ORTestCase.java

示例4: test2

import org.apache.log4j.or.ObjectRenderer; //导入依赖的package包/类
public
void test2() {
  RendererMap map = new RendererMap();
  map.put(Integer.class, ior);
  ObjectRenderer r = map.get(Integer.class);
  assertEquals(r, ior);

}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:9,代码来源:ORTestCase.java

示例5: test3

import org.apache.log4j.or.ObjectRenderer; //导入依赖的package包/类
public
void test3() {
  RendererMap map = new RendererMap();
  map.put(Number.class, ior);
  ObjectRenderer r = map.get(Integer.class);
  assertEquals(r, ior);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:8,代码来源:ORTestCase.java

示例6: test4

import org.apache.log4j.or.ObjectRenderer; //导入依赖的package包/类
public
void test4() {
  RendererMap map = new RendererMap();
  map.put(Object.class, oor);
  ObjectRenderer r = map.get(Integer.class);
  assertEquals(r, oor);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:8,代码来源:ORTestCase.java

示例7: test5

import org.apache.log4j.or.ObjectRenderer; //导入依赖的package包/类
public
void test5() {
  RendererMap map = new RendererMap();

  map.put(Object.class, oor);
  map.put(Number.class, nor);
  map.put(Integer.class, ior);

  ObjectRenderer r = map.get(Integer.class);
  assertEquals(r, ior);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:12,代码来源:ORTestCase.java

示例8: test6

import org.apache.log4j.or.ObjectRenderer; //导入依赖的package包/类
public
void test6() {
  RendererMap map = new RendererMap();

  map.put(Object.class, oor);
  map.put(Number.class, nor);
 
  ObjectRenderer r = map.get(Integer.class);
  assertEquals(r, nor);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:11,代码来源:ORTestCase.java

示例9: test7

import org.apache.log4j.or.ObjectRenderer; //导入依赖的package包/类
public
void test7() throws Exception {
  RendererMap map = new RendererMap();
  Class comparable = null; 
  try {
      comparable = getClass().forName("java.lang.Comparable");
  } catch(Exception ex) {
      //  likely JDK 1.1
      return;
  }
  map.put(comparable, cor);
  ObjectRenderer r = map.get(Integer.class);
  assertEquals(r, cor);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:15,代码来源:ORTestCase.java

示例10: test8

import org.apache.log4j.or.ObjectRenderer; //导入依赖的package包/类
public
void test8() {
  RendererMap map = new RendererMap();
  map.put(Serializable.class, sor); 
  ObjectRenderer r = map.get(Integer.class);
  assertEquals(r, sor);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:8,代码来源:ORTestCase.java

示例11: test9

import org.apache.log4j.or.ObjectRenderer; //导入依赖的package包/类
public
void test9() {
  RendererMap map = new RendererMap();
  map.put(Y.class, yor); 
  ObjectRenderer r = map.get(B.class);
  assertEquals(r, yor);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:8,代码来源:ORTestCase.java

示例12: test10

import org.apache.log4j.or.ObjectRenderer; //导入依赖的package包/类
public
void test10() {
  RendererMap map = new RendererMap();
  map.put(X.class, xor); 
  ObjectRenderer r = map.get(B.class);
  assertEquals(r, xor);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:8,代码来源:ORTestCase.java

示例13: setRenderer

import org.apache.log4j.or.ObjectRenderer; //导入依赖的package包/类
public
void setRenderer(Class renderedClass, ObjectRenderer renderer);
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:3,代码来源:RendererSupport.java

示例14: addRenderer

import org.apache.log4j.or.ObjectRenderer; //导入依赖的package包/类
/**
   Add an object renderer for a specific class.
 */
public
void addRenderer(Class classToRender, ObjectRenderer or) {
  rendererMap.put(classToRender, or);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:8,代码来源:Hierarchy.java

示例15: setRenderer

import org.apache.log4j.or.ObjectRenderer; //导入依赖的package包/类
/**
   Used by subclasses to add a renderer to the hierarchy passed as parameter.
 */
public
void setRenderer(Class renderedClass, ObjectRenderer renderer) {
  rendererMap.put(renderedClass, renderer);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:8,代码来源:Hierarchy.java


注:本文中的org.apache.log4j.or.ObjectRenderer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。