本文整理汇总了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;
}