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


Java BeanUtil类代码示例

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


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

示例1: invoke

import org.databene.commons.BeanUtil; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args)
		throws Throwable {
	try {
		String methodName = method.getName();
		if ("close".equals(methodName)) {
			openResultSetCount.decrementAndGet();
			if (openResultSetMonitor != null)
				openResultSetMonitor.unregister(this);
			JDBC_LOGGER.debug("closing result set {}", this);
		} else if ("toString".equals(methodName)) {
			return "ResultSet (" + statement + ")";
		} else if ("getStatement".equals(methodName)) {
			return statement;
		}
		return BeanUtil.invoke(realResultSet, method, args);
	} catch (ConfigurationError e) {
		if (e.getCause() instanceof InvocationTargetException && e.getCause().getCause() instanceof SQLException)
			throw e.getCause().getCause();
		else
			throw e;
	}
}
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:24,代码来源:LoggingResultSetHandler.java

示例2: invoke

import org.databene.commons.BeanUtil; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args)
		throws Throwable {
	try {
		String methodName = method.getName();
		Method localMethod = BeanUtil.findMethod(this.getClass(), methodName, method.getParameterTypes());
		if (localMethod != null)
			return BeanUtil.invoke(this, localMethod, args);
		else {
			if ("setNull".equals(methodName) && args != null && args.length >= 2)
				params[(Integer) args[0] - 1] = null;
			else if (methodName.startsWith("set") && args != null && args.length >= 2 && args[0] instanceof Integer)
				params[(Integer) args[0] - 1] = args[1];
			Object result = BeanUtil.invoke(realStatement, method, args);
			if (result instanceof ResultSet)
				result = DBUtil.createLoggingResultSet((ResultSet) result, (PreparedStatement) proxy);
			return result;
		}
	} catch (ConfigurationError e) {
		if (e.getCause() instanceof InvocationTargetException && e.getCause().getCause() instanceof SQLException)
			throw e.getCause().getCause();
		else
			throw e;
	}
}
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:26,代码来源:LoggingPreparedStatementHandler.java

示例3: AludraTestJUnitSuite

import org.databene.commons.BeanUtil; //导入依赖的package包/类
/** Standard JUnit {@link Runner} constructor which takes the JUnit test class as argument.
 * @param testClass JUnit test class.
 * @throws InitializationError if the test suite is empty */
public AludraTestJUnitSuite(Class<?> testClass) throws InitializationError {
    aludraTest = AludraTest.startFramework();
    this.testClass = testClass;
    String suiteName = System.getProperty(SUITE_SYSPROP);

    if (StringUtil.isEmpty(suiteName)) {
        throw new InitializationError("No suite configured");
    }

    RunnerTreeBuilder builder = aludraTest.getServiceManager().newImplementorInstance(RunnerTreeBuilder.class);
    tree = builder.buildRunnerTree(BeanUtil.forName(suiteName));

    // register this class as listener for events
    RunnerListenerRegistry registry = aludraTest.getServiceManager().newImplementorInstance(RunnerListenerRegistry.class);
    registry.addRunnerListener(this);
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:20,代码来源:AludraTestJUnitSuite.java

示例4: TestClassList

import org.databene.commons.BeanUtil; //导入依赖的package包/类
/** Constructor.
 *  @param rootPackage The root package */
public TestClassList(String rootPackage) {
    super(new DefaultListModel());
    setCellRenderer(new ClassNameCellRenderer());
    setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    List<Class<?>> classes = BeanUtil.getClasses(rootPackage);
    Iterator<Class<?>> iterator = classes.iterator();
    while (iterator.hasNext()) {
        Class<?> clazz = iterator.next();
        if (!WizardUtil.isAludraTestClassWithExcelBasedTests(clazz)) {
            iterator.remove();
        }
    }
    this.testClasses = new ArrayList<Class<?>>(classes);
    updateFilter("");
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:18,代码来源:TestClassList.java

示例5: configure

import org.databene.commons.BeanUtil; //导入依赖的package包/类
@Override
public void configure(Preferences preferences) {
    entries = new ArrayList<AutoRetryEntry>();

    for (String nodeName : preferences.getChildNodeNames()) {
        if (nodeName.matches("retry[0-9]+")) {
            AutoRetryEntry entry = new AutoRetryEntry();
            ValidatingPreferencesWrapper values = new ValidatingPreferencesWrapper(preferences.getChildNode(nodeName));
            entry.maxCount = values.getRequiredIntValue("maxCount");
            entry.methodName = values.getRequiredStringValue("method");
            entry.exceptionClass = BeanUtil.forName(values.getRequiredStringValue("exception"));
            entry.interfaceClass = BeanUtil.forName(values.getRequiredStringValue("interface"));
            entries.add(entry);
        }
    }
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:17,代码来源:AutoRetryImpl.java

示例6: testCreationFromScratch

import org.databene.commons.BeanUtil; //导入依赖的package包/类
@Test
public void testCreationFromScratch() throws Exception {
    File createdFile = null;
    try {
        Method testMethod = BeanUtil.getMethod(TEST_CLASS, "creationFromScratch", TEST_PARAMS);
        Collection<WorkbookTracker> trackers = JavaBeanExcelDocumentMapper.createOrMergeDocuments(testMethod, TARGET_CLASSES);
        createdFile = trackers.iterator().next().getFile();
        verifyExcelDocument(trackers, "test_from_scratch.xls", new String[] { "name1", "name2" },
                new String[] { "sub.name" },
                null);
    }
    finally {
        if (createdFile != null) {
            FileUtil.deleteIfExists(createdFile);
        }
    }
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:18,代码来源:JavaBeanExcelDocumentMapperTest.java

示例7: testAdditionalExcelColumns

import org.databene.commons.BeanUtil; //导入依赖的package包/类
@Test
public void testAdditionalExcelColumns() throws Exception {
    final String EXCEL_URI = "test_additional_columns.xls";
    copyToTarget(EXCEL_URI);
    Method testMethod = BeanUtil.getMethod(TEST_CLASS, "additionalColumns", TEST_PARAMS);
    Collection<WorkbookTracker> trackers = JavaBeanExcelDocumentMapper.createOrMergeDocuments(testMethod, TARGET_CLASSES);
    verifyExcelDocument(trackers, EXCEL_URI, new String[] { "name1", "name2" }, new String[] { "sub.name" },
            new String[] { "Alice", "Bob", "x", "Charly", "y" });
    // verify warnings
    WorkbookTracker tracker = trackers.iterator().next();
    List<String> warnings = tracker.getWarnings();
    assertEquals(2, warnings.size());
    assertEquals("Unmappable column 'add' in sheet 'sheet1' of file 'test_additional_columns.xls'", warnings.get(0));
    assertEquals("Unmappable column 'sub.add' in sheet 'sheet1' of file 'test_additional_columns.xls'", warnings.get(1));
    Workbook workbook = tracker.getWorkbook();
    Sheet sheet1 = workbook.getSheet("sheet1");
    Row headerRow = sheet1.getRow(0);
    assertNotNull(headerRow);
    assertEquals(HSSFColor.RED.index, headerRow.getCell(2).getCellStyle().getFillForegroundColor());
    assertEquals(HSSFColor.RED.index, headerRow.getCell(4).getCellStyle().getFillForegroundColor());
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:22,代码来源:JavaBeanExcelDocumentMapperTest.java

示例8: createNumberGenerator

import org.databene.commons.BeanUtil; //导入依赖的package包/类
@Override
public <T extends Number> NonNullGenerator<T> createNumberGenerator(Class<T> numberType, T min, T max, T granularity, boolean unique) {
   	NonNullGenerator<? extends Number> base;
   	if (unique) {
   		return SequenceManager.EXPAND_SEQUENCE.createNumberGenerator(numberType, min, max, granularity, unique);
   	} else if (BeanUtil.isIntegralNumberType(numberType)) {
       	long lMax = (max != null ? max.longValue() :
       			Math.min(RandomLongGenerator.DEFAULT_MAX, NumberUtil.maxValue(numberType).longValue()));
		if (Integer.class.equals(numberType.getClass()))
			base = new RandomIntegerGenerator(toInteger(min), toInteger(lMax), toInteger(granularity));
		else if (BigInteger.class.equals(numberType.getClass()))
			base = new RandomBigIntegerGenerator(toBigInteger(min), toBigInteger(lMax), toBigInteger(granularity));
		else if (BigDecimal.class.equals(numberType.getClass()))
			base = new RandomBigDecimalGenerator(toBigDecimal(min), toBigDecimal(lMax), toBigDecimal(granularity));
		else
			base = new RandomLongGenerator(toLong(min), lMax, toLong(granularity));
   	} else {
   		double dMax = (max != null ? max.doubleValue() : Long.MAX_VALUE);
		base = new RandomDoubleGenerator(toDouble(min), dMax, toDouble(granularity));
   	}
	return WrapperFactory.asNonNullNumberGeneratorOfType(numberType, base, min, granularity);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:23,代码来源:RandomSequence.java

示例9: createNumberGenerator

import org.databene.commons.BeanUtil; //导入依赖的package包/类
@Override
public <T extends Number> NonNullGenerator<T> createNumberGenerator(
   		Class<T> numberType, T min, T max, T granularity, boolean unique) {
       Number deltaToUse = deltaToUse(granularity);
   	if (unique && deltaToUse.doubleValue() == 0)
   		throw new InvalidGeneratorSetupException("Can't generate unique numbers with an increment of 0.");
   	NonNullGenerator<? extends Number> base;
	if (BeanUtil.isIntegralNumberType(numberType)) {
		if (max == null)
			max = NumberUtil.maxValue(numberType);
        base = new StepLongGenerator(
				toLong(min), toLong(max), toLong(deltaToUse), toLong(initial));
	} else
		base = new StepDoubleGenerator(
				toDouble(min), toDouble(max), toDouble(deltaToUse), toDouble(initial));
	return WrapperFactory.asNonNullNumberGeneratorOfType(numberType, base, min, granularity);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:18,代码来源:StepSequence.java

示例10: createNumberGenerator

import org.databene.commons.BeanUtil; //导入依赖的package包/类
@Override
public <T extends Number> NonNullGenerator<T> createNumberGenerator(
   		Class<T> numberType, T min, T max, T granularity, boolean unique) {
   	if (increment == null)
   		increment = BigDecimal.valueOf(2);
   	if (max == null)
   		max = NumberUtil.maxValue(numberType);
	NonNullGenerator<? extends Number> base;
	if (BeanUtil.isIntegralNumberType(numberType))
		base = new ShuffleLongGenerator(
				toLong(min), toLong(max), toLong(granularity), toLong(increment));
	else
		base = new ShuffleDoubleGenerator(
				toDouble(min), toDouble(max), toDouble(granularity), toDouble(increment));
	return WrapperFactory.asNonNullNumberGeneratorOfType(numberType, base, min, granularity);
   }
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:17,代码来源:ShuffleSequence.java

示例11: createNativeParamsDescriptor

import org.databene.commons.BeanUtil; //导入依赖的package包/类
protected ArrayTypeDescriptor createNativeParamsDescriptor(MethodDescriptor testMethod) {
	ArrayTypeDescriptor nativeDescriptor = new ArrayTypeDescriptor(testMethod.getName() + "_native", this);
	Class<?>[] paramTypes = testMethod.getParameterTypes();
	for (int i = 0; i < paramTypes.length; i++) {
		TypeDescriptor elementType = dataModel.getTypeDescriptor(paramTypes[i].getName());
		BeanDescriptorProvider beanDescriptorProvider = dataModel.getBeanDescriptorProvider();
		ArrayElementDescriptor elementDescriptor = new ArrayElementDescriptor(i, beanDescriptorProvider, elementType);
	    if (elementDescriptor.isNullable() == null) { // assure an explicit setting for nullability
	    	if (BeanUtil.isPrimitiveType(paramTypes[i].getName()))
	    		elementDescriptor.setNullable(false); // primitives can never be null
	    	else if (elementDescriptor.getNullQuota() != null && 
	    			((Double) elementDescriptor.getDeclaredDetailValue("nullQuota")) == 0.)
	    		elementDescriptor.setNullable(false); // if nullQuota == 0, then set nullable to false
	    	else
	    		elementDescriptor.setNullable(true);
	    }
		nativeDescriptor.addElement(elementDescriptor);
	}
	return nativeDescriptor;
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:21,代码来源:AnnotationMapper.java

示例12: applyGeneratorFactory

import org.databene.commons.BeanUtil; //导入依赖的package包/类
protected boolean applyGeneratorFactory(Annotation[] annotations, BeneratorContext context) {
	boolean configured = false;
	for (Annotation annotation : annotations) {
		if (annotation instanceof Factory) {
			GeneratorFactory factory = BeanUtil.newInstance(((Factory) annotation).value());
			factory.setDefaultsProvider(context.getDefaultsProvider());
			context.setGeneratorFactory(factory);
			return true;
		} else if (annotation instanceof Equivalence) {
			context.setGeneratorFactory(new EquivalenceGeneratorFactory());
			return true;
		} else if (annotation instanceof Coverage) {
			context.setGeneratorFactory(new CoverageGeneratorFactory());
			return true;
		} else if (annotation instanceof Stochastic) {
			context.setGeneratorFactory(new StochasticGeneratorFactory());
			return true;
		} else if (annotation instanceof Serial) {
			context.setGeneratorFactory(new SerialGeneratorFactory());
			return true;
		}
	}
	return configured;
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:25,代码来源:AnnotationMapper.java

示例13: instantiateBean

import org.databene.commons.BeanUtil; //导入依赖的package包/类
private static Object instantiateBean(Bean beanAnno, BeneratorContext context) {
	String beanSpec = beanAnno.spec();
	Class<?> beanClass = beanAnno.type();
	if (!StringUtil.isEmpty(beanSpec)) {
		try {
			if (beanClass != Object.class)
				throw new ConfigurationError("'type' and 'spec' exclude each other in a @Bean");
	        return DatabeneScriptParser.parseBeanSpec(beanSpec).evaluate(context);
		} catch (ParseException e) {
			throw new ConfigurationError("Error parsing bean spec: " + beanSpec, e);
		}
	} else if (beanClass != Object.class) {
	    return BeanUtil.newInstance(beanClass);
	} else
		throw new ConfigurationError("@Bean is missing 'type' or 'spec' attribute");
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:17,代码来源:AnnotationMapper.java

示例14: addConsumer

import org.databene.commons.BeanUtil; //导入依赖的package包/类
@SuppressWarnings("resource")
public static void addConsumer(BeanSpec beanSpec, BeneratorContext context, ConsumerChain chain) {
   	Consumer consumer;
   	Object bean = beanSpec.getBean();
   	// check consumer type
   	if (bean instanceof Consumer) {
   		consumer = (Consumer) bean;
   	} else if (bean instanceof StorageSystem) {
   		consumer = new StorageSystemInserter((StorageSystem) bean);
   	} else
   		throw new UnsupportedOperationException("Consumer type not supported: " + BeanUtil.simpleClassName(bean));
   	consumer = BeneratorFactory.getInstance().configureConsumer(consumer, context);
   	if (beanSpec.isReference())
   		consumer = new NonClosingConsumerProxy(consumer);
   	chain.addComponent(consumer);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:17,代码来源:XMLConsumerExpression.java

示例15: execute

import org.databene.commons.BeanUtil; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes" })
  @Override
  public boolean execute(BeneratorContext context) {
// invoke constructor
      Object bean = constructionExpression.evaluate(context);
      // post construction steps
      super.execute(context);
      if (!StringUtil.isEmpty(id)) {
      	PropertyDescriptor descriptor = BeanUtil.getPropertyDescriptor(bean.getClass(), "id");
      	if (descriptor != null && descriptor.getWriteMethod() != null)
      		BeanUtil.setPropertyValue(bean, "id", id, false);
      }
      if (bean instanceof ContextAware)
	((ContextAware) bean).setContext(context);
if (bean instanceof DescriptorProvider)
	context.getDataModel().addDescriptorProvider((DescriptorProvider) bean);
if (bean instanceof Closeable && resourceManager != null)
	resourceManager.addResource((Closeable) bean);
if (bean instanceof Generator && constructionExpression instanceof BeanConstruction)
	((Generator) bean).init(context);
context.setGlobal(id, bean);
  	return true;
  }
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:24,代码来源:BeanStatement.java


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