Beispiel #1
0
  private static <P extends DatabaseObjectReference> void setColumnTypeAttributes(
      final Element e, final BaseColumn<P> bc, final String description) {
    final ColumnDataType cdt = bc.getColumnDataType();

    //		if (bc.getParent ().getName ().equalsIgnoreCase ("MessageNote") && bc.getName ().equals
    // ("Message_Id"))
    //		{
    //		    final Column column = (Column) bc;
    //			System.out.printf ("  Column [%s]%n", column.getName ());
    //
    //			System.out.printf ("    column.getDefaultValue [%s]%n", column.getDefaultValue ());
    //			System.out.printf ("    column.getPrivileges [%s]%n", column.getPrivileges ().toString ());
    //			System.out.printf ("    column.getReferencedColumn [%s]%n", column.getReferencedColumn ());
    //			System.out.printf ("    column.isPartOfForeignKey [%s]%n", column.isPartOfForeignKey ());
    //			System.out.printf ("    column.isPartOfPrimaryKey [%s]%n", column.isPartOfPrimaryKey ());
    //			System.out.printf ("    column.isPartOfUniqueIndex [%s]%n", column.isPartOfUniqueIndex ());
    //			System.out.printf ("    column.getDecimalDigits [%s]%n", column.getDecimalDigits ());
    //			System.out.printf ("    column.getOrdinalPosition [%s]%n", column.getOrdinalPosition ());
    //			System.out.printf ("    column.getSize [%s]%n", column.getSize ());
    //			System.out.printf ("    column.getWidth [%s]%n", column.getWidth ());
    //			System.out.printf ("    column.isNullable [%s]%n", column.isNullable ());
    //
    //			System.out.printf ("    cdt.getBaseType [%s]%n", cdt.getBaseType ());
    //			System.out.printf ("    cdt.getCreateParameters [%s]%n", cdt.getCreateParameters ());
    //			System.out.printf ("    cdt.getDatabaseSpecificTypeName [%s]%n",
    // cdt.getDatabaseSpecificTypeName ());
    //			System.out.printf ("    cdt.getLiteralPrefix [%s]%n", cdt.getLiteralPrefix ());
    //			System.out.printf ("    cdt.getLiteralSuffix [%s]%n", cdt.getLiteralSuffix ());
    //			System.out.printf ("    cdt.getLocalTypeName [%s]%n", cdt.getLocalTypeName ());
    //			System.out.printf ("    cdt.getMaximumScale [%s]%n", cdt.getMaximumScale ());
    //			System.out.printf ("    cdt.getMinimumScale [%s]%n", cdt.getMinimumScale ());
    //			System.out.printf ("    cdt.getNumPrecisionRadix [%s]%n", cdt.getNumPrecisionRadix ());
    //			System.out.printf ("    cdt.getPrecision [%s]%n", cdt.getPrecision ());
    //			System.out.printf ("    cdt.getSearchable [%s]%n", cdt.getSearchable ());
    //			System.out.printf ("    cdt.getType [%s]%n", cdt.getType ());
    //			System.out.printf ("    cdt.getTypeClassName [%s]%n", cdt.getTypeClassName ());
    //			System.out.printf ("    cdt.getTypeName [%s]%n", cdt.getTypeName ());
    //			System.out.printf ("    cdt.isAutoIncrementable [%s]%n", cdt.isAutoIncrementable ());
    //			System.out.printf ("    cdt.isBinaryType [%s]%n", cdt.isBinaryType ());
    //			System.out.printf ("    cdt.isCaseSensitive [%s]%n", cdt.isCaseSensitive ());
    //			System.out.printf ("    cdt.isCharacterType [%s]%n", cdt.isCharacterType ());
    //			System.out.printf ("    cdt.isDateType [%s]%n", cdt.isDateType ());
    //			System.out.printf ("    cdt.isFixedPrecisionScale [%s]%n", cdt.isFixedPrecisionScale ());
    //			System.out.printf ("    cdt.isIntegralType [%s]%n", cdt.isIntegralType ());
    //			System.out.printf ("    cdt.isNullable [%s]%n", cdt.isNullable ());
    //			System.out.printf ("    cdt.isRealType [%s]%n", cdt.isRealType ());
    //			System.out.printf ("    cdt.isUnsigned [%s]%n", cdt.isUnsigned ());
    //			System.out.printf ("    cdt.isUserDefined [%s]%n", cdt.isUserDefined ());
    //		}

    final String typeName = cdt.getLocalTypeName();
    if (typeName == null) {
      ThreadContext.assertInformation(
          false,
          "Unknown column type (null) for %s[%s] column[%s]",
          description,
          bc.getParent().getName(),
          bc.getName());
      e.setAttribute("type", "(unknown)");
    } else if (typeName.equalsIgnoreCase("char")) {
      setCharacterColumnAttributes(e, bc, "fixed");
    } else if (typeName.equalsIgnoreCase("varchar") || typeName.equalsIgnoreCase("varchar2")) {
      setCharacterColumnAttributes(e, bc, "varying");
    } else if (typeName.equalsIgnoreCase("int")) {
      e.setAttribute("type", "integer");
    } else if (typeName.equalsIgnoreCase("number") || typeName.equalsIgnoreCase("numeric")) {
      e.setAttribute("type", "decimal");
      e.setAttribute("precision", String.valueOf(bc.getSize()));
      e.setAttribute("scale", String.valueOf(bc.getDecimalDigits()));
    } else if (typeName.equalsIgnoreCase("float")
        || typeName.equalsIgnoreCase("double precision")) {
      e.setAttribute("type", "floatingpoint");
    } else if (typeName.equalsIgnoreCase("money")) {
      // TODO 7 support sybase money
      e.setAttribute("type", "floatingpoint");
    } else if (typeName.equalsIgnoreCase("text")) {
      e.setAttribute("type", "text");
    } else if (typeName.equalsIgnoreCase("date")
        || typeName.equalsIgnoreCase("datetime")
        || typeName.equalsIgnoreCase("timestamp")) {
      e.setAttribute("type", "date");
    } else if (typeName.equalsIgnoreCase("long raw") || typeName.equalsIgnoreCase("varbinary")) {
      e.setAttribute("type", "blob");
    } else {
      ThreadContext.assertInformation(
          false,
          "Unsupported column type [%s] for %s[%s] column[%s]",
          typeName,
          description,
          bc.getParent().getName(),
          bc.getName());
      e.setAttribute("type", "(unsupported)");
    }
  }
Beispiel #2
0
 private static <P extends DatabaseObjectReference> void setCharacterColumnAttributes(
     final Element e, final BaseColumn<P> bc, final String charStyle) {
   e.setAttribute("type", "char");
   e.setAttribute("mode", charStyle);
   e.setAttribute("size", String.valueOf(bc.getSize()));
 }