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


Java FieldDescriptor.getScale方法代码示例

本文整理汇总了Java中org.apache.ojb.broker.metadata.FieldDescriptor.getScale方法的典型用法代码示例。如果您正苦于以下问题:Java FieldDescriptor.getScale方法的具体用法?Java FieldDescriptor.getScale怎么用?Java FieldDescriptor.getScale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ojb.broker.metadata.FieldDescriptor的用法示例。


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

示例1: getAnnotationNodes

import org.apache.ojb.broker.metadata.FieldDescriptor; //导入方法依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
    final FieldDescriptor fd = OjbUtil.findFieldDescriptor(mappedClass, fieldName, descriptorRepositories);

    if (fd != null) {
        List<MemberValuePair> pairs = new ArrayList<MemberValuePair>();
        final String access = fd.getAccess();
        if ("readonly".equals(access)) {
            pairs.add(new MemberValuePair("insertable", new BooleanLiteralExpr(false)));
            pairs.add(new MemberValuePair("updatable", new BooleanLiteralExpr(false)));
        } else if ("readwrite".equals(access)) {
            LOG.debug(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field access is readwrite keeping @Column attributes (insertable, updatable) at defaults");
        } else if ("anonymous".equals(access)) {
            LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field access is anonymous, the field should not exist in the java class as is the meaning anonymous access");
        } else if (access == null) {
            LOG.debug(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field access is null keeping @Column attributes (insertable, updatable) at defaults");
        } else {
            LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field access is " + access + ", unsupported conversion to @Column attributes");
        }

        final String columnName = fd.getColumnName();
        if (StringUtils.isNotBlank(columnName)) {
            pairs.add(new MemberValuePair("name", new StringLiteralExpr(upperCaseTableName ? columnName.toUpperCase() : columnName)));
        } else {
            LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field column is blank");
        }
        /*  don't bother with column type attribute...this is mostly taken care of automatically by JPA
        final String columnType = fd.getColumnType();
        if (StringUtils.isNotBlank(columnType)) {
            LOG.error(enclosingClass + "." + fieldName + " for the mapped class " + mappedClass + " field column type is " + columnType + ", unsupported conversion to @Column attributes");
        }
        */
        final boolean required = fd.isRequired();
        if (required) {
            pairs.add(new MemberValuePair("nullable", new BooleanLiteralExpr(false)));
        } else {
            LOG.debug(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field is nullable keeping @Column attribute (nullable) at default");
        }

        final int length = fd.getLength();
        if (length > 0) {
            pairs.add(new MemberValuePair("length", new IntegerLiteralExpr(String.valueOf(length))));
        } else {
            LOG.debug(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field length is not set keeping @Column attribute (length) at default");
        }

        final int precision = fd.getPrecision();
        if (precision > 0) {
            pairs.add(new MemberValuePair("precision", new IntegerLiteralExpr(String.valueOf(precision))));
        } else {
            LOG.debug(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field precision is not set keeping @Column attribute (precision) at default");
        }

        final int scale = fd.getScale();
        if (scale > 0) {
            pairs.add(new MemberValuePair("scale", new IntegerLiteralExpr(String.valueOf(scale))));
        } else {
            LOG.debug(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field scale is not set keeping @Column attribute (scale) at default");
        }
        return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), pairs),
                new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
    }
    return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:65,代码来源:ColumnResolver.java


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