alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (DataType.scala)

This example Scala source code file (DataType.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

boolean, boolean, data, datatype, datatype, float, id, id, int, int, object, option, string, type

The Scala DataType.scala source code

/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003-2011, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |                                         **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */



package scala.dbc;


/** An ISO-9075:2003 (SQL) data type. Mappings between SQL types and
 *  database specific types should be provided by the database driver.
 */
@deprecated(DbcIsDeprecated, "2.9.0") abstract class DataType {
  
  /** Tests whether this datatype is equivalent to another. Usually, two
   *  types are defined as equivalent if they are equal. Two types can be
   *  equivalent without being equal if values of those types will be
   *  encoded in the same native Scala type.
   */
  def isEquivalent(datatype: DataType): Boolean;
  
  /** Tests whether this datatype is equivalent or a subtype of another
   *  datatype. Type <code>A is said to be subtype of type
   *  <code>B if any value of type A can be
   *  represented as a value of type <code>B.
   */
  def isSubtypeOf(datatype: DataType): Boolean;

  /** The native Scala type in which values of this SQL type will be
   *  encoded.
   */
  type NativeType <: Any;

  /** The native Scala type in which values of this SQL type will be
   *  encoded. This must point to the same type as <code>NativeType.
   */
  def nativeTypeId: DataType.Id;

  /** Whether the value can take the null value, None when this property is
   *  unknown.
   */
  def nullable: Option[Boolean] = None;

  /** The SQL name of the type */
  def sqlString: String = "UNDEFINED DATA TYPE"

}

@deprecated(DbcIsDeprecated, "2.9.0") object DataType {

  type Id = Int;

  val OBJECT     : Id = 10;
  val BOOLEAN    : Id = 20;
  val BYTE       : Id = 30;
  val SHORT      : Id = 31;
  val INT        : Id = 32;
  val LONG       : Id = 33;
  val BIG_INTEGER: Id = 34;
  val BIG_DECIMAL: Id = 35;
  val FLOAT      : Id = 40;
  val DOUBLE     : Id = 41;
  val STRING     : Id = 50;

}

Other Scala examples (source code examples)

Here is a short list of links related to this Scala DataType.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.