www.element4solution.com

e4s.db.dict
Class E4DBType

java.lang.Object
  extended by e4s.util.E4Object
      extended by e4s.db.dict.E4DBGeneratedClass
          extended by e4s.db.dict.E4DBType
All Implemented Interfaces:
java.lang.Comparable

public class E4DBType
extends E4DBGeneratedClass
implements java.lang.Comparable

Part of the datadictionary: information for a user defined datatype. A user defined datatype is a name associated with a datatype and in the case of a E4String or e4s.util.StringImage a length. Datatypes can be used in tables or views for getters or setters. For each datatype definition, a Java source file will be created in your system dictionary-source path (defined by E4Settings. By definition, these datatypes may be nullable or not. A datatype may also contain constant definitions. When instanciating a new object of this datatype, there are thre possibilities identified by getInstanceMode(): INSTANCE_MODE_NEW means that there can be new instances created, which should be the default. Either by the new operator or by the newInstance() method provided in the generated class. Use this whenever you expect a wider number of different values but with only a view references (e.g. an article number in a commercial application). INSTANCE_MODE_GET means that there is no free possibility to instanciate a new object, but there will be a getInstance() method available in the created class that either gives back the reference to an existing definition or creates a new definition and holds this definition in a Hashtable for further use. As long as there is no way to change the content of such a type, you also can use for comparison the == operator because your program now only treats references to that kind of type. INSTANCE_MODE_CONSTANTS_ONLY means that there cannot be any instanciation of this type and there are only the constants available that have been defined (example: a datatype that holds values for Mr. or Mrs. does not need any other values, so you cannot create new instances). The structure E4DBTypes holds a collection of all datatypes in your project. The datatype meta-dictionary information is stored in an XML file, propably this will be dict_app_*.xml in your dictionary definition path.

Since:
JDK 1.4
See Also:
E4DBTypes, E4Long, E4String, E4StringImage, E4DBTypeUsage

Nested Class Summary
 class E4DBType.E4DBTypeConst
           
 
Field Summary
static java.lang.String _XML_ATTR_CONST_LABEL
           
static java.lang.String _XML_ATTR_CONST_NAME
           
static java.lang.String _XML_ATTR_CONST_VAL
           
static java.lang.String _XML_ATTR_TYPE_DATATYPE
           
static java.lang.String _XML_ATTR_TYPE_IMPLEMENTS
           
static java.lang.String _XML_ATTR_TYPE_INSTANCE_GET
           
static java.lang.String _XML_ATTR_TYPE_LENGTH
           
static java.lang.String _XML_ATTR_TYPE_NAME
           
static java.lang.String _XML_ATTR_TYPE_NULLABLE
           
static java.lang.String _XML_ATTR_TYPE_SYSTEM
           
static java.lang.String _XML_ATTR_USERDEFINED_CODE_DETECTED
           
static java.lang.String _XML_TAG_CONSTANT
           
static java.lang.String _XML_TAG_TYPE
           
static char INSTANCE_MODE_CONSTANTS_ONLY
           
static char INSTANCE_MODE_GET
           
static char INSTANCE_MODE_NEW
           
 
Fields inherited from class e4s.db.dict.E4DBGeneratedClass
_XML_ATTR_DEPRECATED, _XML_ATTR_SYSTEM, _XML_TAG_PACKAGE
 
Fields inherited from class e4s.util.E4Object
CRLF, E4S_CORE_SYSTEM_LANGUAGE, NBSP, NULLSTR, URL_ENCODING_CHARSET
 
Constructor Summary
E4DBType()
           
E4DBType(java.lang.String name, java.lang.String rem)
           
 
Method Summary
 void addConstant(java.lang.String id, long val, java.lang.String label)
           
 void addConstant(java.lang.String id, java.lang.String val, java.lang.String label)
           
 int compareTo(java.lang.Object o)
           
 void deleteClass()
           
 boolean equals(E4DBType type)
           
static java.lang.String Escape(java.lang.String s)
          Escapes the double quote character (") by backslash followed by double quote.
 E4DBType.E4DBTypeConst findConstant(java.lang.String id)
           
 void generateClass_E4Date(java.lang.String path)
           
 void generateClass_E4Long(java.lang.String path)
           
 void generateClass_E4String(java.lang.String path)
           
 void generateClass()
           
 void generateClass(java.lang.String path)
           
 java.util.Hashtable getConstants()
           
 E4DBType.E4DBTypeConst[] getConstantsArray()
           
 java.lang.Class getDatatype()
           
 java.lang.String getDatatypeStr()
           
 java.lang.String getDatatypeStrClass()
          Return datatype and length as String.
 java.lang.String getDatatypeStrShort()
           
 java.lang.Class[] getImplementsInterface()
           
 char getInstanceMode()
           
 int getLen()
           
 E4DBColumnType getName()
           
 boolean getNullable()
           
 java.lang.String getRem()
           
 java.util.Vector getUsage()
           
 java.util.Vector getUsage(boolean include_views)
           
 boolean is_E4Date()
           
 boolean is_E4Long()
           
 boolean is_E4String()
           
 boolean is_E4StringImage()
           
 boolean isSystemType()
           
 void removeClass()
           
 boolean renameColumn(E4DBTableName tablename, E4DBColumnName from, E4DBColumnName to)
           
 void setDatatype(java.lang.Class datatype)
           
 void setDatatype(java.lang.String datatype)
           
 void setImplementsInterface(java.lang.String implements_interface)
          Set interfaces for the type.
 void setInstanceMode(char mode)
           
 void setLen(int len)
           
 void setName(E4DBColumnType newname)
           
 void setNullable(boolean nullable)
           
 void setRem(java.lang.String rem)
           
 void setSystemType(boolean mode)
           
 void setUserDefinedCode(int modules)
           
 java.lang.String toString()
           
 void toXml(E4PrintStream pstr)
          Writs the current database object into the given XML stream.
 
Methods inherited from class e4s.db.dict.E4DBGeneratedClass
_getSVNVersionString, getCreated, getDeprecated, getGenerationOutputPath, getGenerationOutputPath, getModified, getPackage, getPackagePath, getPlugins, hasChanged, isSystem, printGenerateHeader, resetChanged, setCreated, setDeprecated, setHasChanged, setModified, setPackage, setSystem, toXml_Package
 
Methods inherited from class e4s.util.E4Object
Calendar, CName, CName, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelSys, E4LabelSys, e4sCopyright, e4sVersion, encode, encode, encode, encodeHtml, encodeHtml, encodeHtml, encodeURL, encodeURL, encodeURL, finalize, getLINE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTraceMemory, HtmlEncode, HtmlEncode, HtmlEncode, isdecimal, isdigit, isnotok, isnotok, isnumeric, isok, isok, isok, isok, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingStack, mkdirs, null2nbsp, null2nbsp, null2nbsp, ok, ok, ok, ok, outPrintln, setLogFile4Trace, setTraceMemory, STACKTRACE, toDebug, toDouble, toFloat, toFloat, TRACE_CALLS, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, wait
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_XML_TAG_TYPE

public static final java.lang.String _XML_TAG_TYPE
See Also:
Constant Field Values

_XML_ATTR_TYPE_NAME

public static final java.lang.String _XML_ATTR_TYPE_NAME
See Also:
Constant Field Values

_XML_ATTR_TYPE_SYSTEM

public static final java.lang.String _XML_ATTR_TYPE_SYSTEM
See Also:
Constant Field Values

_XML_ATTR_TYPE_LENGTH

public static final java.lang.String _XML_ATTR_TYPE_LENGTH
See Also:
Constant Field Values

_XML_ATTR_TYPE_DATATYPE

public static final java.lang.String _XML_ATTR_TYPE_DATATYPE
See Also:
Constant Field Values

_XML_ATTR_TYPE_NULLABLE

public static final java.lang.String _XML_ATTR_TYPE_NULLABLE
See Also:
Constant Field Values

_XML_ATTR_TYPE_INSTANCE_GET

public static final java.lang.String _XML_ATTR_TYPE_INSTANCE_GET
See Also:
Constant Field Values

_XML_ATTR_TYPE_IMPLEMENTS

public static final java.lang.String _XML_ATTR_TYPE_IMPLEMENTS
See Also:
Constant Field Values

_XML_ATTR_USERDEFINED_CODE_DETECTED

public static final java.lang.String _XML_ATTR_USERDEFINED_CODE_DETECTED
See Also:
Constant Field Values

INSTANCE_MODE_CONSTANTS_ONLY

public static final char INSTANCE_MODE_CONSTANTS_ONLY
See Also:
Constant Field Values

INSTANCE_MODE_GET

public static final char INSTANCE_MODE_GET
See Also:
Constant Field Values

INSTANCE_MODE_NEW

public static final char INSTANCE_MODE_NEW
See Also:
Constant Field Values

_XML_TAG_CONSTANT

public static final java.lang.String _XML_TAG_CONSTANT
See Also:
Constant Field Values

_XML_ATTR_CONST_NAME

public static final java.lang.String _XML_ATTR_CONST_NAME
See Also:
Constant Field Values

_XML_ATTR_CONST_VAL

public static final java.lang.String _XML_ATTR_CONST_VAL
See Also:
Constant Field Values

_XML_ATTR_CONST_LABEL

public static final java.lang.String _XML_ATTR_CONST_LABEL
See Also:
Constant Field Values
Constructor Detail

E4DBType

public E4DBType()

E4DBType

public E4DBType(java.lang.String name,
                java.lang.String rem)
Method Detail

getName

public E4DBColumnType getName()

getNullable

public boolean getNullable()

setNullable

public void setNullable(boolean nullable)

getLen

public int getLen()

setLen

public void setLen(int len)
            throws java.lang.Exception
Throws:
java.lang.Exception

getRem

public java.lang.String getRem()

setRem

public void setRem(java.lang.String rem)

getConstants

public java.util.Hashtable getConstants()

addConstant

public void addConstant(java.lang.String id,
                        long val,
                        java.lang.String label)
                 throws java.lang.Exception
Throws:
java.lang.Exception

addConstant

public void addConstant(java.lang.String id,
                        java.lang.String val,
                        java.lang.String label)
                 throws java.lang.Exception
Throws:
java.lang.Exception

findConstant

public E4DBType.E4DBTypeConst findConstant(java.lang.String id)
                                    throws java.lang.Exception
Throws:
java.lang.Exception

is_E4String

public boolean is_E4String()

equals

public boolean equals(E4DBType type)

is_E4Long

public boolean is_E4Long()

is_E4Date

public boolean is_E4Date()

is_E4StringImage

public boolean is_E4StringImage()

getDatatype

public java.lang.Class getDatatype()

setDatatype

public void setDatatype(java.lang.Class datatype)
                 throws java.lang.Exception
Throws:
java.lang.Exception

setDatatype

public void setDatatype(java.lang.String datatype)
                 throws java.lang.Exception
Throws:
java.lang.Exception

getDatatypeStrClass

public java.lang.String getDatatypeStrClass()
Return datatype and length as String.

Returns:
the class name of the datatype and propably the length, if length is relevant
See Also:
getDatatypeStr()

generateClass

public void generateClass()
                   throws E4DBException
Throws:
E4DBException

generateClass

public void generateClass(java.lang.String path)
                   throws E4DBException
Throws:
E4DBException

generateClass_E4String

public void generateClass_E4String(java.lang.String path)
                            throws E4DBException
Throws:
E4DBException

deleteClass

public void deleteClass()
                 throws java.io.IOException
Throws:
java.io.IOException

getUsage

public java.util.Vector getUsage()
                          throws java.lang.Exception
Throws:
java.lang.Exception

getUsage

public java.util.Vector getUsage(boolean include_views)
                          throws E4DBException
Throws:
E4DBException

generateClass_E4Long

public void generateClass_E4Long(java.lang.String path)
                          throws E4DBException
Throws:
E4DBException

generateClass_E4Date

public void generateClass_E4Date(java.lang.String path)
                          throws E4DBException
Throws:
E4DBException

getConstantsArray

public E4DBType.E4DBTypeConst[] getConstantsArray()

toXml

public void toXml(E4PrintStream pstr)
           throws java.lang.Exception
Writs the current database object into the given XML stream.

Parameters:
pstr - a stream, opened in write mode
Throws:
java.lang.Exception
See Also:
E4DBDict.readDictionary(), E4DBTypes.toXml(java.lang.String, e4s.util.E4PrintStream)

toString

public java.lang.String toString()
Overrides:
toString in class E4Object

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

Escape

public static java.lang.String Escape(java.lang.String s)
Escapes the double quote character (") by backslash followed by double quote.

Parameters:
s - the string where single quotes need to be replaced
Returns:
the string with the replacements
See Also:
E4DBFilter.Escape(String)

getDatatypeStrShort

public java.lang.String getDatatypeStrShort()

getDatatypeStr

public java.lang.String getDatatypeStr()

isSystemType

public boolean isSystemType()

setSystemType

public void setSystemType(boolean mode)

removeClass

public void removeClass()

renameColumn

public boolean renameColumn(E4DBTableName tablename,
                            E4DBColumnName from,
                            E4DBColumnName to)

setName

public void setName(E4DBColumnType newname)

setInstanceMode

public void setInstanceMode(char mode)

getInstanceMode

public char getInstanceMode()

getImplementsInterface

public java.lang.Class[] getImplementsInterface()
                                         throws java.lang.Exception
Throws:
java.lang.Exception

setImplementsInterface

public void setImplementsInterface(java.lang.String implements_interface)
                            throws java.lang.Exception
Set interfaces for the type.

Parameters:
implements_interface - is a comma (,) seperated list of class names including full qualified package names
Throws:
java.lang.Exception

setUserDefinedCode

public void setUserDefinedCode(int modules)

www.element4solution.com