org.edg.data.util.attribute
Class AttributeHandler
java.lang.Object
|
+--org.edg.data.util.attribute.AttributeHandler
- public final class AttributeHandler
- extends java.lang.Object
This class handles the storage of "attributes" in a db table. Attributes
are typed columns in the db, with a special prefix to differentiate them from
any other columns.
We expect a certain layout to the table. The table should have a name,
tableName
and a primary key of type integer
called
tableName_id
.
- Version:
- $Id: AttributeHandler.java,v 1.23 2004/04/16 14:37:36 jamesc Exp $
- Author:
- James Casey, Sophie Lemaitre
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MYSQL_STRING_ATTR_VALUE_LENGTH
public static final int MYSQL_STRING_ATTR_VALUE_LENGTH
- See Also:
- Constant Field Values
ORACLE_STRING_ATTR_VALUE_LENGTH
public static final int ORACLE_STRING_ATTR_VALUE_LENGTH
- See Also:
- Constant Field Values
AttributeHandler
public AttributeHandler(java.lang.String type,
ConnectionFactory connFactory,
int maxStringAttrLength,
MethodLogger log)
throws InvalidCatalogException,
ConnectionException
- Create a new AttributeHandler.
- Parameters:
type
- the type of the db - i.e. it's name.connFactory
- The connection factory from which to get connections
to connect to the tablelog
- a method level logger
getMaxAttributeDefinitionLength
public int getMaxAttributeDefinitionLength()
throws ConnectionException
ConnectionException
getMaxStringAttributeLength
public int getMaxStringAttributeLength()
getDefaultMaxStringAttributeLength
public static int getDefaultMaxStringAttributeLength(java.lang.String vendor)
- return the default, hard-coded maximum string attribute length.
- Returns:
- the default maximum string attribute length.
createAttributeDefinition
public void createAttributeDefinition(AttributeDefinition attrDefn)
throws ConnectionException,
AttributeDefinitionExistsException,
ValueTooLongException,
UnsupportedAttributeTypeException
ConnectionException
AttributeDefinitionExistsException
ValueTooLongException
UnsupportedAttributeTypeException
isStringType
public static boolean isStringType(AttributeDefinition defn)
isIntType
public static boolean isIntType(AttributeDefinition defn)
isFloatType
public static boolean isFloatType(AttributeDefinition defn)
attributeDefinitionExists
public boolean attributeDefinitionExists(java.lang.String attrName)
getAttributeDefinitions
public AttributeDefinition[] getAttributeDefinitions()
getAttributeDefinition
public AttributeDefinition getAttributeDefinition(java.lang.String attrName)
throws NoSuchAttributeDefinitionException
NoSuchAttributeDefinitionException
removeAttributeDefinition
public void removeAttributeDefinition(java.lang.String attrName)
throws NoSuchAttributeDefinitionException,
ConnectionException
NoSuchAttributeDefinitionException
ConnectionException
setAttribute
public java.lang.String setAttribute(java.lang.String name,
java.lang.String attrName,
java.lang.String attrValue)
throws ConnectionException,
InvalidNameException,
UnappropriateAttributeTypeException,
NoSuchAttributeDefinitionException
ConnectionException
InvalidNameException
UnappropriateAttributeTypeException
NoSuchAttributeDefinitionException
getIntAttribute
public int getIntAttribute(java.lang.String name,
java.lang.String attrName)
throws InvalidNameException,
NoSuchAttributeDefinitionException,
ConnectionException,
UnappropriateAttributeTypeException
InvalidNameException
NoSuchAttributeDefinitionException
ConnectionException
UnappropriateAttributeTypeException
getFloatAttribute
public float getFloatAttribute(java.lang.String name,
java.lang.String attrName)
throws InvalidNameException,
UnappropriateAttributeTypeException,
NoSuchAttributeDefinitionException,
ConnectionException
InvalidNameException
UnappropriateAttributeTypeException
NoSuchAttributeDefinitionException
ConnectionException
getStringAttribute
public java.lang.String getStringAttribute(java.lang.String name,
java.lang.String attrName)
throws InvalidNameException,
ConnectionException,
UnappropriateAttributeTypeException,
NoSuchAttributeDefinitionException
- returns the attribute value, or
null
if there
is no attribute value set
InvalidNameException
ConnectionException
UnappropriateAttributeTypeException
NoSuchAttributeDefinitionException
removeAttribute
public void removeAttribute(java.lang.String name,
java.lang.String attrName)
throws InvalidNameException,
ConnectionException,
UnsupportedAttributeTypeException,
NoSuchAttributeDefinitionException
InvalidNameException
ConnectionException
UnsupportedAttributeTypeException
NoSuchAttributeDefinitionException