org.teiid.metadata.Datatype.getName()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(14.0k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中org.teiid.metadata.Datatype.getName()方法的一些代码示例,展示了Datatype.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Datatype.getName()方法的具体详情如下:
包路径:org.teiid.metadata.Datatype
类名称:Datatype
方法名:getName

Datatype.getName介绍

暂无

代码示例

代码示例来源:origin: teiid/teiid

/**
 * Get the type information excluding aliases and case sensitive by name
 * @return
 */
public NavigableMap<String, Datatype> getDatatypesExcludingAliases() {
  TreeMap<String, Datatype> result = new TreeMap<String, Datatype>();
  for (Map.Entry<String, Datatype> entry : this.datatypes.entrySet()) {
    if (entry.getKey().equals(entry.getValue().getName())) {
      result.put(entry.getKey(), entry.getValue());
    }
  }
  return result;
}

代码示例来源:origin: teiid/teiid

public int getScale() {
  if (this.getDatatype() != null && getDatatype().getName().equals(DataTypeManager.DefaultDataTypes.BIG_DECIMAL)) {
    if (precision == 0 && scale == 0) {
      return DEFAULT_SCALE;
    }
    int effectivePrecision = precision == 0?DEFAULT_PRECISION:precision;
    if (Math.abs(scale) > effectivePrecision) {
      return Integer.signum(scale)*effectivePrecision;
    }
  }
  return scale;
}

代码示例来源:origin: teiid/teiid

public String toString() {
  StringBuffer sb = new StringBuffer(100);
  sb.append(getClass().getSimpleName());
  sb.append(" name="); //$NON-NLS-1$
  sb.append(getName());
  sb.append(", basetype name="); //$NON-NLS-1$
  sb.append(getBasetypeName());
  sb.append(", runtimeType="); //$NON-NLS-1$
  sb.append(getRuntimeTypeName());
  sb.append(", javaClassName="); //$NON-NLS-1$
  sb.append(getJavaClassName());
  sb.append(", ObjectID="); //$NON-NLS-1$
  sb.append(getUUID());
  return sb.toString();
}

代码示例来源:origin: teiid/teiid

public int getPrecision() {
  if (precision == 0 && this.getDatatype() != null && getDatatype().getName().equals(DataTypeManager.DefaultDataTypes.BIG_DECIMAL)) {
    return DEFAULT_PRECISION;
  }
  return precision;
}

代码示例来源:origin: org.teiid/teiid-olingo-common

public static EdmPrimitiveTypeKind odataType(BaseColumn c) {
  String runtimeType = c.getRuntimeType();
  //try to map to the specific type
  if (c.getDatatype() != null 
      && (c.getDatatype().getName().equalsIgnoreCase(DataTypeManager.DefaultDataTypes.GEOMETRY)
        || c.getDatatype().getName().equalsIgnoreCase(DataTypeManager.DefaultDataTypes.GEOGRAPHY))) {
    boolean geometry = c.getDatatype().getName().equalsIgnoreCase(DataTypeManager.DefaultDataTypes.GEOMETRY);
    String type = c.getProperty(BaseColumn.SPATIAL_TYPE, false);
    if (type != null) {
      try {
        return StringUtil.caseInsensitiveValueOf(EdmPrimitiveTypeKind.class, 
            (geometry?"Geometry":"Geography")+type); //$NON-NLS-1$ //$NON-NLS-2$
      } catch (IllegalArgumentException e) {
        
      }
    }
    //unknown or null case
    if (geometry) {
      return EdmPrimitiveTypeKind.Geometry;
    }
    return EdmPrimitiveTypeKind.Geography;
  }
  return odataType(runtimeType);
}

代码示例来源:origin: org.teiid.connectors/translator-odata4

private void handleGeometryTypes(SRID srid, String type, BaseColumn c) {
  //TODO: geometry arrays
  if (!TypeFacility.RUNTIME_NAMES.GEOMETRY.equals(c.getDatatype().getName())) {
    return;
  }
  if (type.startsWith(EDM_GEOMETRY)) {
    if (type.length() > EDM_GEOMETRY.length()) {
      c.setProperty(BaseColumn.SPATIAL_TYPE, type.substring(EDM_GEOMETRY.length()).toUpperCase());
    } else {
      c.setProperty(BaseColumn.SPATIAL_TYPE, "GEOMETRY"); //$NON-NLS-1$
    }
  } else if (type.startsWith(EDM_GEOGRAPHY)) {
    c.setProperty(BaseColumn.SPATIAL_SRID, "4326"); //$NON-NLS-1$
    if (type.length() > EDM_GEOGRAPHY.length()) {
      c.setProperty(BaseColumn.SPATIAL_TYPE, type.substring(EDM_GEOGRAPHY.length()).toUpperCase());
    } else {
      c.setProperty(BaseColumn.SPATIAL_TYPE, "GEOMETRY"); //$NON-NLS-1$
    }
  }
  if (srid != null && srid.isNotDefault()) {
    String value = srid.toString();
    
    if (!value.equalsIgnoreCase("VARIABLE")) { //$NON-NLS-1$
      c.setProperty(BaseColumn.SPATIAL_SRID, value);
    }
  }
}

代码示例来源:origin: teiid/teiid

public static EdmPrimitiveTypeKind odataType(BaseColumn c) {
  String runtimeType = c.getRuntimeType();
  //try to map to the specific type
  if (c.getDatatype() != null 
      && (c.getDatatype().getName().equalsIgnoreCase(DataTypeManager.DefaultDataTypes.GEOMETRY)
        || c.getDatatype().getName().equalsIgnoreCase(DataTypeManager.DefaultDataTypes.GEOGRAPHY))) {
    boolean geometry = c.getDatatype().getName().equalsIgnoreCase(DataTypeManager.DefaultDataTypes.GEOMETRY);
    String type = c.getProperty(BaseColumn.SPATIAL_TYPE, false);
    if (type != null) {
      try {
        return StringUtil.caseInsensitiveValueOf(EdmPrimitiveTypeKind.class, 
            (geometry?"Geometry":"Geography")+type); //$NON-NLS-1$ //$NON-NLS-2$
      } catch (IllegalArgumentException e) {
        
      }
    }
    //unknown or null case
    if (geometry) {
      return EdmPrimitiveTypeKind.Geometry;
    }
    return EdmPrimitiveTypeKind.Geography;
  }
  return odataType(runtimeType);
}

代码示例来源:origin: teiid/teiid

private void correctDataTypes(List<? extends BaseColumn> cols) {
  if (cols == null) {
    return;
  }
  for (BaseColumn c : cols) {
    Datatype datatype = c.getDatatype();
    String name = null;
    if (datatype == null) {
      name = c.getRuntimeType();
    } else {
      name = datatype.getName();
    }
    Datatype dt = this.dataTypes.get(name);
    if (dt != null) {
      c.setDatatype(dt, false, c.getArrayDimensions());
    }
  }
}

代码示例来源:origin: teiid/teiid

public void setDatatype(Datatype datatype, boolean copyAttributes, int arrayDimensions) {
  this.datatype = datatype;
  this.arrayDimensions = arrayDimensions;
  if (datatype != null) {
    this.datatypeUUID = this.datatype.getUUID();
    this.runtimeType = this.datatype.getRuntimeTypeName();
    if (arrayDimensions > 0) {
      this.runtimeType += StringUtil.join(Collections.nCopies(arrayDimensions, "[]"), ""); //$NON-NLS-1$ //$NON-NLS-2$
    }
    if (copyAttributes) {
      this.radix = this.datatype.getRadix();
      this.length = this.datatype.getLength();
      if (!datatype.getName().equals(DataTypeManager.DefaultDataTypes.BIG_DECIMAL)) {
        this.precision = this.datatype.getPrecision();
        this.scale = this.datatype.getScale();
      }
      this.nullType = this.datatype.getNullType();
    }
  }
}

代码示例来源:origin: teiid/teiid

@Test
public void testUDT() throws Exception {
  String ddl = "CREATE FOREIGN TABLE G1( e1 integer, e2 varchar OPTIONS (UDT 'NMTOKENS(12,13,11)'))";
  Schema s = helpParse(ddl, "model").getSchema();
  Map<String, Table> tableMap = s.getTables();    
  
  assertTrue("Table not found", tableMap.containsKey("G1"));
  Table table = tableMap.get("G1");
  
  assertEquals("NMTOKENS", table.getColumns().get(1).getDatatype().getName());
  assertEquals(12, table.getColumns().get(1).getLength());
  assertEquals(13, table.getColumns().get(1).getPrecision());
  assertEquals(11, table.getColumns().get(1).getScale());		
}

代码示例来源:origin: org.jboss.teiid/teiid-engine

private void appendColumnOptions(BaseColumn column) {
  StringBuilder options = new StringBuilder();
  addCommonOptions(options, column);
  
  if (!column.getDatatype().isBuiltin() && column.getDatatype().getType() != Datatype.Type.Domain) {
    //an enterprise type
    addOption(options, UDT, column.getDatatype().getName() + "("+column.getLength()+ ", " +column.getPrecision()+", " + column.getScale()+ ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
  }
  
  if (column.getDatatype().getRadix() != 0 && column.getRadix() != column.getDatatype().getRadix()) {
    addOption(options, RADIX, column.getRadix());
  }
  
  buildColumnOptions(column, options);
  
  if (options.length() != 0) {
    append(SPACE).append(OPTIONS).append(SPACE).append(LPAREN).append(options).append(RPAREN);
  }
}

代码示例来源:origin: org.teiid/teiid-engine

private void appendColumnOptions(BaseColumn column) {
  StringBuilder options = new StringBuilder();
  addCommonOptions(options, column);
  
  if (!column.getDatatype().isBuiltin() && column.getDatatype().getType() != Datatype.Type.Domain) {
    //an enterprise type
    addOption(options, UDT, column.getDatatype().getName() + "("+column.getLength()+ ", " +column.getPrecision()+", " + column.getScale()+ ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
  }
  
  if (column.getDatatype().getRadix() != 0 && column.getRadix() != column.getDatatype().getRadix()) {
    addOption(options, RADIX, column.getRadix());
  }
  
  buildColumnOptions(column, options);
  
  if (options.length() != 0) {
    append(SPACE).append(OPTIONS).append(SPACE).append(LPAREN).append(options).append(RPAREN);
  }
}

代码示例来源:origin: teiid/teiid

private void appendColumnOptions(BaseColumn column) {
  StringBuilder options = new StringBuilder();
  addCommonOptions(options, column);
  
  if (!column.getDatatype().isBuiltin() && column.getDatatype().getType() != Datatype.Type.Domain) {
    //an enterprise type
    addOption(options, UDT, column.getDatatype().getName() + "("+column.getLength()+ ", " +column.getPrecision()+", " + column.getScale()+ ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
  }
  
  if (column.getDatatype().getRadix() != 0 && column.getRadix() != column.getDatatype().getRadix()) {
    addOption(options, RADIX, column.getRadix());
  }
  
  buildColumnOptions(column, options);
  
  if (options.length() != 0) {
    append(SPACE).append(OPTIONS).append(SPACE).append(LPAREN).append(options).append(RPAREN);
  }
}

代码示例来源:origin: teiid/teiid

@Test public void testTypeCorrection() throws Exception {
  MetadataFactory mf = new MetadataFactory(null, 1, "x", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null); //$NON-NLS-1$
  
  Table t = mf.addTable("y"); //$NON-NLS-1$
  mf.addColumn("test", "string", t);
  mf.addColumn("array", "string[]", t);
  Datatype unknown = new Datatype();
  unknown.setName("unknown");
  Column col = mf.addColumn("arg", "string", t);
  col.setDatatype(unknown, false, 0);
  MetadataFactory mf1 = UnitTestUtil.helpSerialize(mf);
  
  Column column = mf1.getSchema().getTable("y").getColumns().get(0);
  Datatype dt = column.getDatatype();
  
  assertNotSame(mf.getDataTypes().get(dt.getName()), column.getDatatype());
  
  assertEquals(1, mf1.getSchema().getTable("y").getColumns().get(1).getArrayDimensions());
  
  mf1.correctDatatypes(mf.getDataTypes());
  
  assertSame(mf.getDataTypes().get(dt.getName()), column.getDatatype());
  
  assertEquals(1, mf1.getSchema().getTable("y").getColumns().get(1).getArrayDimensions());
}

代码示例来源:origin: teiid/teiid

assertEquals("boolean", proc.getParameters().get(0).getDatatype().getName());
assertEquals(ProcedureParameter.Type.Out, proc.getParameters().get(0).getType());
assertEquals("string", proc.getParameters().get(1).getDatatype().getName());
assertEquals(ProcedureParameter.Type.In, proc.getParameters().get(1).getType());
assertEquals("bigdecimal", proc.getParameters().get(2).getDatatype().getName());
assertEquals(ProcedureParameter.Type.InOut, proc.getParameters().get(2).getType());		
assertEquals(2, ret.getColumns().size());
assertEquals("r1", ret.getColumns().get(0).getName());
assertEquals("string", ret.getColumns().get(0).getDatatype().getName());	
assertEquals("r2", ret.getColumns().get(1).getName());
assertEquals("bigdecimal", ret.getColumns().get(1).getDatatype().getName());

代码示例来源:origin: org.jboss.teiid/teiid-engine

private void visit(Datatype dt) {
  append(CREATE).append(SPACE).append(DOMAIN).append(SPACE);
  append(SQLStringVisitor.escapeSinglePart(dt.getName())).append(SPACE).append(AS).append(SPACE);
  String runtimeTypeName = dt.getBasetypeName();
  append(runtimeTypeName);
  Datatype base = SystemMetadata.getInstance().getRuntimeTypeMap().get(runtimeTypeName);
  if (LENGTH_DATATYPES.contains(runtimeTypeName)) {
    if (dt.getLength() != base.getLength()) {
      append(LPAREN).append(dt.getLength()).append(RPAREN);
    }
  } else if (PRECISION_DATATYPES.contains(runtimeTypeName)
      && (dt.getPrecision() != base.getPrecision() || dt.getScale() != base.getScale())) {
    append(LPAREN).append(dt.getPrecision());
    if (dt.getScale() != 0) {
      append(COMMA).append(dt.getScale());
    }
    append(RPAREN);
  }
  if (dt.getNullType() == NullType.No_Nulls) {
    append(SPACE).append(NOT_NULL);
  }
  append(SEMICOLON);
}

代码示例来源:origin: teiid/teiid

@Test
public void testDefaultPrecision() throws Exception {
  String ddl = "CREATE FOREIGN TABLE G1(e4 decimal)";
      
  Schema s = helpParse(ddl, "model").getSchema();
  Map<String, Table> tableMap = s.getTables();
  
  assertTrue("Table not found", tableMap.containsKey("G1"));
  Table table = tableMap.get("G1");
  Column e4 = table.getColumns().get(0);
  
  assertEquals("e4", e4.getName());
  assertEquals("bigdecimal", e4.getDatatype().getName());
  assertEquals(false, e4.isAutoIncremented());
  assertEquals(Short.MAX_VALUE, e4.getPrecision());
  assertEquals(Short.MAX_VALUE/2, e4.getScale());
  assertEquals(SearchType.Searchable, e4.getSearchType());
}

代码示例来源:origin: org.teiid/teiid-engine

private void visit(Datatype dt) {
  append(CREATE).append(SPACE).append(DOMAIN).append(SPACE);
  append(SQLStringVisitor.escapeSinglePart(dt.getName())).append(SPACE).append(AS).append(SPACE);
  String runtimeTypeName = dt.getBasetypeName();
  append(runtimeTypeName);
  Datatype base = SystemMetadata.getInstance().getRuntimeTypeMap().get(runtimeTypeName);
  if (DataTypeManager.hasLength(runtimeTypeName)) {
    if (dt.getLength() != base.getLength()) {
      append(LPAREN).append(dt.getLength()).append(RPAREN);
    }
  } else if (PRECISION_DATATYPES.contains(runtimeTypeName)
      && (dt.getPrecision() != base.getPrecision() || dt.getScale() != base.getScale())) {
    append(LPAREN).append(dt.getPrecision());
    if (dt.getScale() != 0) {
      append(COMMA).append(dt.getScale());
    }
    append(RPAREN);
  }
  if (dt.getNullType() == NullType.No_Nulls) {
    append(SPACE).append(NOT_NULL);
  }
  append(SEMICOLON);
}

代码示例来源:origin: teiid/teiid

assertEquals("string", e1.getDatatype().getName());
assertEquals(100, e1.getLength());
assertEquals("bigdecimal", e3.getDatatype().getName());
assertEquals(14, e3.getPrecision());
assertEquals(5, e3.getScale());

代码示例来源:origin: teiid/teiid

private void visit(Datatype dt) {
  append(CREATE).append(SPACE).append(DOMAIN).append(SPACE);
  append(SQLStringVisitor.escapeSinglePart(dt.getName())).append(SPACE).append(AS).append(SPACE);
  String runtimeTypeName = dt.getBasetypeName();
  append(runtimeTypeName);
  Datatype base = SystemMetadata.getInstance().getRuntimeTypeMap().get(runtimeTypeName);
  if (DataTypeManager.hasLength(runtimeTypeName)) {
    if (dt.getLength() != base.getLength()) {
      append(LPAREN).append(dt.getLength()).append(RPAREN);
    }
  } else if (PRECISION_DATATYPES.contains(runtimeTypeName)
      && (dt.getPrecision() != base.getPrecision() || dt.getScale() != base.getScale())) {
    append(LPAREN).append(dt.getPrecision());
    if (dt.getScale() != 0) {
      append(COMMA).append(dt.getScale());
    }
    append(RPAREN);
  }
  if (dt.getNullType() == NullType.No_Nulls) {
    append(SPACE).append(NOT_NULL);
  }
  append(SEMICOLON);
}

相关文章