code
stringlengths
67
466k
docstring
stringlengths
1
13.2k
public void processAnonymousField(Properties attributes) throws XDocletException { if (!attributes.containsKey(ATTRIBUTE_NAME)) { throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class, XDocletModulesOjbMessages.PARAMETER_IS_REQUIRED, new String[]{ATTRIBUTE_NAME})); } String name = attributes.getProperty(ATTRIBUTE_NAME); FieldDescriptorDef fieldDef = _curClassDef.getField(name); String attrName; if (fieldDef == null) { fieldDef = new FieldDescriptorDef(name); _curClassDef.addField(fieldDef); } fieldDef.setAnonymous(); LogHelper.debug(false, OjbTagsHandler.class, "processAnonymousField", " Processing anonymous field "+fieldDef.getName()); attributes.remove(ATTRIBUTE_NAME); for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); ) { attrName = (String)attrNames.nextElement(); fieldDef.setProperty(attrName, attributes.getProperty(attrName)); } fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_ACCESS, "anonymous"); }
Processes an anonymous field definition specified at the class level. @param attributes The attributes of the tag @exception XDocletException if an error occurs @doc.tag type="content" @doc.param name="attributes" optional="true" description="Attributes of the field as name-value pairs 'name=value', separated by commas" @doc.param name="autoincrement" optional="true" description="Whether the field is auto-incremented" values="true,false" @doc.param name="column" optional="true" description="The column for the field" @doc.param name="conversion" optional="true" description="The fully qualified name of the conversion for the field" @doc.param name="default-fetch" optional="true" description="The default-fetch setting" values="true,false" @doc.param name="documentation" optional="true" description="Documentation on the field" @doc.param name="id" optional="true" description="The position of the field in the class descriptor" @doc.param name="indexed" optional="true" description="Whether the field is indexed" values="true,false" @doc.param name="jdbc-type" optional="true" description="The jdbc type of the column" @doc.param name="length" optional="true" description="The length of the column" @doc.param name="locking" optional="true" description="Whether the field supports locking" values="true,false" @doc.param name="name" optional="false" description="The name of the field" @doc.param name="nullable" optional="true" description="Whether the field is nullable" values="true,false" @doc.param name="precision" optional="true" description="The precision of the column" @doc.param name="primarykey" optional="true" description="Whether the field is a primarykey" values="true,false" @doc.param name="scale" optional="true" description="The scale of the column" @doc.param name="sequence-name" optional="true" description="The name of the sequence for incrementing the field" @doc.param name="table" optional="true" description="The table of the field (not implemented yet)" @doc.param name="update-lock" optional="true" description="Can be set to false if the persistent attribute is used for optimistic locking AND the dbms should update the lock column itself (default is true). Can only be set for TIMESTAMP and INTEGER columns" values="true,false"
public void processField(String template, Properties attributes) throws XDocletException { String name = OjbMemberTagsHandler.getMemberName(); String defaultType = getDefaultJdbcTypeForCurrentMember(); String defaultConversion = getDefaultJdbcConversionForCurrentMember(); FieldDescriptorDef fieldDef = _curClassDef.getField(name); String attrName; if (fieldDef == null) { fieldDef = new FieldDescriptorDef(name); _curClassDef.addField(fieldDef); } LogHelper.debug(false, OjbTagsHandler.class, "processField", " Processing field "+fieldDef.getName()); for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); ) { attrName = (String)attrNames.nextElement(); fieldDef.setProperty(attrName, attributes.getProperty(attrName)); } // storing additional info for later use fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_JAVA_TYPE, OjbMemberTagsHandler.getMemberType().getQualifiedName()); fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_JDBC_TYPE, defaultType); if (defaultConversion != null) { fieldDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_CONVERSION, defaultConversion); } _curFieldDef = fieldDef; generate(template); _curFieldDef = null; }
Sets the current field definition derived from the current member, and optionally some attributes. @param template The template @param attributes The attributes of the tag @exception XDocletException if an error occurs @doc.tag type="block" @doc.param name="access" optional="true" description="The accessibility of the column" values="readonly,readwrite" @doc.param name="attributes" optional="true" description="Attributes of the field as name-value pairs 'name=value', separated by commas" @doc.param name="autoincrement" optional="true" description="Whether the field is auto-incremented" values="none,ojb,database" @doc.param name="column" optional="true" description="The column for the field" @doc.param name="column-documentation" optional="true" description="Documentation on the column" @doc.param name="conversion" optional="true" description="The fully qualified name of the conversion for the field" @doc.param name="default-fetch" optional="true" description="The default-fetch setting" values="true,false" @doc.param name="documentation" optional="true" description="Documentation on the field" @doc.param name="id" optional="true" description="The position of the field in the class descriptor" @doc.param name="indexed" optional="true" description="Whether the field is indexed" values="true,false" @doc.param name="jdbc-type" optional="true" description="The jdbc type of the column" @doc.param name="length" optional="true" description="The length of the column" @doc.param name="locking" optional="true" description="Whether the field supports locking" values="true,false" @doc.param name="nullable" optional="true" description="Whether the field is nullable" values="true,false" @doc.param name="precision" optional="true" description="The precision of the column" @doc.param name="primarykey" optional="true" description="Whether the field is a primarykey" values="true,false" @doc.param name="scale" optional="true" description="The scale of the column" @doc.param name="sequence-name" optional="true" description="The name of the sequence for incrementing the field" @doc.param name="table" optional="true" description="The table of the field (not implemented yet)" @doc.param name="update-lock" optional="true" description="Can be set to false if the persistent attribute is used for optimistic locking AND the dbms should update the lock column itself (default is true). Can only be set for TIMESTAMP and INTEGER columns" values="true,false"
public void forAllFieldDefinitions(String template, Properties attributes) throws XDocletException { for (Iterator it = _curClassDef.getFields(); it.hasNext(); ) { _curFieldDef = (FieldDescriptorDef)it.next(); if (!isFeatureIgnored(LEVEL_FIELD) && !_curFieldDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false)) { generate(template); } } _curFieldDef = null; }
Processes the template for all field definitions of the current class definition (including inherited ones if required) @param template The template @param attributes The attributes of the tag @exception XDocletException if an error occurs @doc.tag type="block"
public void processAnonymousReference(Properties attributes) throws XDocletException { ReferenceDescriptorDef refDef = _curClassDef.getReference("super"); String attrName; if (refDef == null) { refDef = new ReferenceDescriptorDef("super"); _curClassDef.addReference(refDef); } refDef.setAnonymous(); LogHelper.debug(false, OjbTagsHandler.class, "processAnonymousReference", " Processing anonymous reference"); for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); ) { attrName = (String)attrNames.nextElement(); refDef.setProperty(attrName, attributes.getProperty(attrName)); } }
Processes an anonymous reference definition. @param attributes The attributes of the tag @exception XDocletException If an error occurs @doc.tag type="content" @doc.param name="attributes" optional="true" description="Attributes of the reference as name-value pairs 'name=value', separated by commas" @doc.param name="auto-delete" optional="true" description="Whether to automatically delete the referenced object on object deletion" @doc.param name="auto-retrieve" optional="true" description="Whether to automatically retrieve the referenced object" @doc.param name="auto-update" optional="true" description="Whether to automatically update the referenced object" @doc.param name="class-ref" optional="false" description="The fully qualified name of the class owning the referenced field" @doc.param name="documentation" optional="true" description="Documentation on the reference" @doc.param name="foreignkey" optional="true" description="The fields in the current type used for implementing the reference" @doc.param name="otm-dependent" optional="true" description="Whether the reference is dependent on otm" @doc.param name="proxy" optional="true" description="Whether to use a proxy for the reference" @doc.param name="proxy-prefetching-limit" optional="true" description="Specifies the amount of objects to prefetch" @doc.param name="refresh" optional="true" description="Whether to automatically refresh the reference" @doc.param name="remote-foreignkey" optional="true" description="The fields in the referenced type corresponding to the local fields (is only used for the table definition)"
public void processReference(String template, Properties attributes) throws XDocletException { String name = OjbMemberTagsHandler.getMemberName(); XClass type = OjbMemberTagsHandler.getMemberType(); int dim = OjbMemberTagsHandler.getMemberDimension(); ReferenceDescriptorDef refDef = _curClassDef.getReference(name); String attrName; if (refDef == null) { refDef = new ReferenceDescriptorDef(name); _curClassDef.addReference(refDef); } LogHelper.debug(false, OjbTagsHandler.class, "processReference", " Processing reference "+refDef.getName()); for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); ) { attrName = (String)attrNames.nextElement(); refDef.setProperty(attrName, attributes.getProperty(attrName)); } // storing default info for later use if (type == null) { throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class, XDocletModulesOjbMessages.COULD_NOT_DETERMINE_TYPE_OF_MEMBER, new String[]{name})); } if (dim > 0) { throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class, XDocletModulesOjbMessages.MEMBER_CANNOT_BE_A_REFERENCE, new String[]{name, _curClassDef.getName()})); } refDef.setProperty(PropertyHelper.OJB_PROPERTY_VARIABLE_TYPE, type.getQualifiedName()); // searching for default type String typeName = searchForPersistentSubType(type); if (typeName != null) { refDef.setProperty(PropertyHelper.OJB_PROPERTY_DEFAULT_CLASS_REF, typeName); } _curReferenceDef = refDef; generate(template); _curReferenceDef = null; }
Sets the current reference definition derived from the current member, and optionally some attributes. @param template The template @param attributes The attributes of the tag @exception XDocletException If an error occurs @doc.tag type="block" @doc.param name="attributes" optional="true" description="Attributes of the reference as name-value pairs 'name=value', separated by commas" @doc.param name="auto-delete" optional="true" description="Whether to automatically delete the referenced object on object deletion" @doc.param name="auto-retrieve" optional="true" description="Whether to automatically retrieve the referenced object" @doc.param name="auto-update" optional="true" description="Whether to automatically update the referenced object" @doc.param name="class-ref" optional="true" description="The fully qualified name of the class owning the referenced field" @doc.param name="database-foreignkey" optional="true" description="Whether a database foreignkey shall be created" values="true,false" @doc.param name="documentation" optional="true" description="Documentation on the reference" @doc.param name="foreignkey" optional="true" description="The fields in the current type used for implementing the reference" @doc.param name="otm-dependent" optional="true" description="Whether the reference is dependent on otm" @doc.param name="proxy" optional="true" description="Whether to use a proxy for the reference" @doc.param name="proxy-prefetching-limit" optional="true" description="Specifies the amount of objects to prefetch" @doc.param name="refresh" optional="true" description="Whether to automatically refresh the reference" @doc.param name="remote-foreignkey" optional="true" description="The fields in the referenced type corresponding to the local fields (is only used for the table definition)"
public void forAllReferenceDefinitions(String template, Properties attributes) throws XDocletException { for (Iterator it = _curClassDef.getReferences(); it.hasNext(); ) { _curReferenceDef = (ReferenceDescriptorDef)it.next(); // first we check whether it is an inherited anonymous reference if (_curReferenceDef.isAnonymous() && (_curReferenceDef.getOwner() != _curClassDef)) { continue; } if (!isFeatureIgnored(LEVEL_REFERENCE) && !_curReferenceDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false)) { generate(template); } } _curReferenceDef = null; }
Processes the template for all reference definitions of the current class definition. @param template The template @param attributes The attributes of the tag @exception XDocletException if an error occurs @doc.tag type="block"
public void processCollection(String template, Properties attributes) throws XDocletException { String name = OjbMemberTagsHandler.getMemberName(); CollectionDescriptorDef collDef = _curClassDef.getCollection(name); String attrName; if (collDef == null) { collDef = new CollectionDescriptorDef(name); _curClassDef.addCollection(collDef); } LogHelper.debug(false, OjbTagsHandler.class, "processCollection", " Processing collection "+collDef.getName()); for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); ) { attrName = (String)attrNames.nextElement(); collDef.setProperty(attrName, attributes.getProperty(attrName)); } if (OjbMemberTagsHandler.getMemberDimension() > 0) { // we store the array-element type for later use collDef.setProperty(PropertyHelper.OJB_PROPERTY_ARRAY_ELEMENT_CLASS_REF, OjbMemberTagsHandler.getMemberType().getQualifiedName()); } else { collDef.setProperty(PropertyHelper.OJB_PROPERTY_VARIABLE_TYPE, OjbMemberTagsHandler.getMemberType().getQualifiedName()); } _curCollectionDef = collDef; generate(template); _curCollectionDef = null; }
Sets the current collection definition derived from the current member, and optionally some attributes. @param template The template @param attributes The attributes of the tag @exception XDocletException If an error occurs @doc.tag type="block" @doc.param name="attributes" optional="true" description="Attributes of the collection as name-value pairs 'name=value', separated by commas" @doc.param name="auto-delete" optional="true" description="Whether to automatically delete the collection on object deletion" @doc.param name="auto-retrieve" optional="true" description="Whether to automatically retrieve the collection" @doc.param name="auto-update" optional="true" description="Whether to automatically update the collection" @doc.param name="collection-class" optional="true" description="The type of the collection if not a java.util type or an array" @doc.param name="database-foreignkey" optional="true" description="Whether a database foreignkey shall be created" values="true,false" @doc.param name="documentation" optional="true" description="Documentation on the collection" @doc.param name="element-class-ref" optional="true" description="The fully qualified name of the element type" @doc.param name="foreignkey" optional="true" description="The name of the foreign keys (columns when an indirection table is given)" @doc.param name="foreignkey-documentation" optional="true" description="Documentation on the foreign keys as a comma-separated list if using an indirection table" @doc.param name="indirection-table" optional="true" description="The name of the indirection table for m:n associations" @doc.param name="indirection-table-documentation" optional="true" description="Documentation on the indirection table" @doc.param name="indirection-table-primarykeys" optional="true" description="Whether the fields referencing the collection and element classes, should also be primarykeys" @doc.param name="otm-dependent" optional="true" description="Whether the collection is dependent on otm" @doc.param name="proxy" optional="true" description="Whether to use a proxy for the collection" @doc.param name="proxy-prefetching-limit" optional="true" description="Specifies the amount of objects to prefetch" @doc.param name="query-customizer" optional="true" description="The query customizer for this collection" @doc.param name="query-customizer-attributes" optional="true" description="Attributes for the query customizer" @doc.param name="refresh" optional="true" description="Whether to automatically refresh the collection" @doc.param name="remote-foreignkey" optional="true" description="The name of the foreign key columns pointing to the elements if using an indirection table" @doc.param name="remote-foreignkey-documentation" optional="true" description="Documentation on the remote foreign keys as a comma-separated list if using an indirection table"
public void forAllCollectionDefinitions(String template, Properties attributes) throws XDocletException { for (Iterator it = _curClassDef.getCollections(); it.hasNext(); ) { _curCollectionDef = (CollectionDescriptorDef)it.next(); if (!isFeatureIgnored(LEVEL_COLLECTION) && !_curCollectionDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false)) { generate(template); } } _curCollectionDef = null; }
Processes the template for all collection definitions of the current class definition. @param template The template @param attributes The attributes of the tag @exception XDocletException if an error occurs @doc.tag type="block"
public String processNested(Properties attributes) throws XDocletException { String name = OjbMemberTagsHandler.getMemberName(); XClass type = OjbMemberTagsHandler.getMemberType(); int dim = OjbMemberTagsHandler.getMemberDimension(); NestedDef nestedDef = _curClassDef.getNested(name); if (type == null) { throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class, XDocletModulesOjbMessages.COULD_NOT_DETERMINE_TYPE_OF_MEMBER, new String[]{name})); } if (dim > 0) { throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class, XDocletModulesOjbMessages.MEMBER_CANNOT_BE_NESTED, new String[]{name, _curClassDef.getName()})); } ClassDescriptorDef nestedTypeDef = _model.getClass(type.getQualifiedName()); if (nestedTypeDef == null) { throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class, XDocletModulesOjbMessages.COULD_NOT_DETERMINE_TYPE_OF_MEMBER, new String[]{name})); } if (nestedDef == null) { nestedDef = new NestedDef(name, nestedTypeDef); _curClassDef.addNested(nestedDef); } LogHelper.debug(false, OjbTagsHandler.class, "processNested", " Processing nested object "+nestedDef.getName()+" of type "+nestedTypeDef.getName()); String attrName; for (Enumeration attrNames = attributes.propertyNames(); attrNames.hasMoreElements(); ) { attrName = (String)attrNames.nextElement(); nestedDef.setProperty(attrName, attributes.getProperty(attrName)); } return ""; }
Addes the current member as a nested object. @param template The template @param attributes The attributes of the tag @exception XDocletException If an error occurs @doc.tag type="content"
public String processModification(Properties attributes) throws XDocletException { String name = attributes.getProperty(ATTRIBUTE_NAME); Properties mods = _curClassDef.getModification(name); String key; String value; if (mods == null) { mods = new Properties(); _curClassDef.addModification(name, mods); } attributes.remove(ATTRIBUTE_NAME); for (Enumeration en = attributes.keys(); en.hasMoreElements();) { key = (String)en.nextElement(); value = attributes.getProperty(key); mods.setProperty(key, value); } return ""; }
Processes a modification tag containing changes to properties of an inherited field/reference/collection. @param template The template @param attributes The attributes of the tag @exception XDocletException If an error occurs @doc.tag type="content" @doc.param name="attributes" optional="true" description="Attributes of the field as name-value pairs 'name=value', separated by commas" @doc.param name="autoincrement" optional="true" description="Whether the field is auto-incremented" values="true,false" @doc.param name="auto-delete" optional="true" description="Whether to automatically delete the referenced object/the collection on object deletion" @doc.param name="auto-retrieve" optional="true" description="Whether to automatically retrieve the referenced object/the collection" @doc.param name="auto-update" optional="true" description="Whether to automatically update the referenced object/the collection" @doc.param name="class-ref" optional="true" description="The fully qualified name of the class owning the referenced field" @doc.param name="collection-class" optional="true" description="The type of the collection if not a java.util type or an array" @doc.param name="column" optional="true" description="The column for the field" @doc.param name="column-documentation" optional="true" description="Documentation on the column" @doc.param name="conversion" optional="true" description="The fully qualified name of the conversion for the field" @doc.param name="database-foreignkey" optional="true" description="Whether a database foreignkey shall be created" values="true,false" @doc.param name="default-fetch" optional="true" description="The default-fetch setting" values="true,false" @doc.param name="documentation" optional="true" description="Documentation on the field" @doc.param name="element-class-ref" optional="true" description="The fully qualified name of the element type" @doc.param name="foreignkey" optional="true" description="The name of the foreign key (a column when an indirection table is given)" @doc.param name="id" optional="true" description="The position of the field in the class descriptor" @doc.param name="ignore" optional="true" description="Whether the feature shall be ignored" values="true,false" @doc.param name="indexed" optional="true" description="Whether the field is indexed" values="true,false" @doc.param name="jdbc-type" optional="true" description="The jdbc type of the column" @doc.param name="length" optional="true" description="The length of the column" @doc.param name="locking" optional="true" description="Whether the field supports locking" values="true,false" @doc.param name="name" optional="false" description="The name of the inherited field, reference or collection" @doc.param name="nullable" optional="true" description="Whether the field is nullable" values="true,false" @doc.param name="precision" optional="true" description="The precision of the column" @doc.param name="primarykey" optional="true" description="Whether the field is a primarykey" values="true,false" @doc.param name="proxy" optional="true" description="Whether to use a proxy for the reference/collection" @doc.param name="query-customizer" optional="true" description="The query customizer for the collection" @doc.param name="query-customizer-attributes" optional="true" description="Attributes for the query customizer for the collection" @doc.param name="refresh" optional="true" description="Whether to automatically refresh the reference/collection" @doc.param name="scale" optional="true" description="The scale of the column" @doc.param name="sequence-name" optional="true" description="The name of the sequence for incrementing the field" @doc.param name="table" optional="true" description="The table of the field (not implemented yet)"
public String createTorqueSchema(Properties attributes) throws XDocletException { String dbName = (String)getDocletContext().getConfigParam(CONFIG_PARAM_DATABASENAME); _torqueModel = new TorqueModelDef(dbName, _model); return ""; }
Generates a torque schema for the model. @param attributes The attributes of the tag @return The property value @exception XDocletException If an error occurs @doc.tag type="content"
public void forAllTables(String template, Properties attributes) throws XDocletException { for (Iterator it = _torqueModel.getTables(); it.hasNext(); ) { _curTableDef = (TableDef)it.next(); generate(template); } _curTableDef = null; }
Processes the template for all table definitions in the torque model. @param template The template @param attributes The attributes of the tag @exception XDocletException if an error occurs @doc.tag type="block"
public void forAllColumns(String template, Properties attributes) throws XDocletException { for (Iterator it = _curTableDef.getColumns(); it.hasNext(); ) { _curColumnDef = (ColumnDef)it.next(); generate(template); } _curColumnDef = null; }
Processes the template for all column definitions of the current table. @param template The template @param attributes The attributes of the tag @exception XDocletException if an error occurs @doc.tag type="block"
public void forAllForeignkeys(String template, Properties attributes) throws XDocletException { for (Iterator it = _curTableDef.getForeignkeys(); it.hasNext(); ) { _curForeignkeyDef = (ForeignkeyDef)it.next(); generate(template); } _curForeignkeyDef = null; }
Processes the template for all foreignkeys of the current table. @param template The template @param attributes The attributes of the tag @exception XDocletException if an error occurs @doc.tag type="block"
public void forAllForeignkeyColumnPairs(String template, Properties attributes) throws XDocletException { for (int idx = 0; idx < _curForeignkeyDef.getNumColumnPairs(); idx++) { _curPairLeft = _curForeignkeyDef.getLocalColumn(idx); _curPairRight = _curForeignkeyDef.getRemoteColumn(idx); generate(template); } _curPairLeft = null; _curPairRight = null; }
Processes the template for all column pairs of the current foreignkey. @param template The template @param attributes The attributes of the tag @exception XDocletException if an error occurs @doc.tag type="block"
public void forAllIndices(String template, Properties attributes) throws XDocletException { boolean processUnique = TypeConversionUtil.stringToBoolean(attributes.getProperty(ATTRIBUTE_UNIQUE), false); // first the default index _curIndexDef = _curTableDef.getIndex(null); if ((_curIndexDef != null) && (processUnique == _curIndexDef.isUnique())) { generate(template); } for (Iterator it = _curTableDef.getIndices(); it.hasNext(); ) { _curIndexDef = (IndexDef)it.next(); if (!_curIndexDef.isDefault() && (processUnique == _curIndexDef.isUnique())) { generate(template); } } _curIndexDef = null; }
Processes the template for all indices of the current table. @param template The template @param attributes The attributes of the tag @exception XDocletException if an error occurs @doc.tag type="block" @doc.param name="unique" optional="true" description="Whether to process the unique indices or not" values="true,false"
public void forAllIndexColumns(String template, Properties attributes) throws XDocletException { for (Iterator it = _curIndexDef.getColumns(); it.hasNext(); ) { _curColumnDef = _curTableDef.getColumn((String)it.next()); generate(template); } _curColumnDef = null; }
Processes the template for all columns of the current table index. @param template The template @param attributes The attributes of the tag @exception XDocletException if an error occurs @doc.tag type="block"
public String name(Properties attributes) throws XDocletException { return getDefForLevel(attributes.getProperty(ATTRIBUTE_LEVEL)).getName(); }
Returns the name of the current object on the specified level. @param attributes The attributes of the tag @return The property value @exception XDocletException If an error occurs @doc.tag type="content" @doc.param name="level" optional="false" description="The level for the current object" values="class,field,reference,collection"
public void ifHasName(String template, Properties attributes) throws XDocletException { String name = getDefForLevel(attributes.getProperty(ATTRIBUTE_LEVEL)).getName(); if ((name != null) && (name.length() > 0)) { generate(template); } }
Processes the template if the current object on the specified level has a non-empty name. @param attributes The attributes of the tag @return The property value @exception XDocletException If an error occurs @doc.tag type="block" @doc.param name="level" optional="false" description="The level for the current object" values="class,field,reference,collection"
public void ifHasProperty(String template, Properties attributes) throws XDocletException { String value = getPropertyValue(attributes.getProperty(ATTRIBUTE_LEVEL), attributes.getProperty(ATTRIBUTE_NAME)); if (value != null) { generate(template); } }
Determines whether the current object on the specified level has a specific property, and if so, processes the template @param template The template @param attributes The attributes of the tag @exception XDocletException If an error occurs @doc.tag type="block" @doc.param name="level" optional="false" description="The level for the current object" values="class,field,reference,collection" @doc.param name="name" optional="false" description="The name of the property"
public String propertyValue(Properties attributes) throws XDocletException { String value = getPropertyValue(attributes.getProperty(ATTRIBUTE_LEVEL), attributes.getProperty(ATTRIBUTE_NAME)); if (value == null) { value = attributes.getProperty(ATTRIBUTE_DEFAULT); } return value; }
Returns the value of a property of the current object on the specified level. @param attributes The attributes of the tag @return The property value @exception XDocletException If an error occurs @doc.tag type="content" @doc.param name="level" optional="false" description="The level for the current object" values="class,field,reference,collection" @doc.param name="name" optional="false" description="The name of the property" @doc.param name="default" optional="true" description="A default value to use if the property is not defined"
public void ifPropertyValueEquals(String template, Properties attributes) throws XDocletException { String value = getPropertyValue(attributes.getProperty(ATTRIBUTE_LEVEL), attributes.getProperty(ATTRIBUTE_NAME)); String expected = attributes.getProperty(ATTRIBUTE_VALUE); if (value == null) { value = attributes.getProperty(ATTRIBUTE_DEFAULT); } if (expected.equals(value)) { generate(template); } }
Processes the template if the property value of the current object on the specified level equals the given value. @param template The template @param attributes The attributes of the tag @exception XDocletException If an error occurs @doc.tag type="block" @doc.param name="level" optional="false" description="The level for the current object" values="class,field,reference,collection" @doc.param name="name" optional="false" description="The name of the property" @doc.param name="value" optional="false" description="The value to check for" @doc.param name="default" optional="true" description="A default value to use if the property is not defined"
public void forAllValuePairs(String template, Properties attributes) throws XDocletException { String name = attributes.getProperty(ATTRIBUTE_NAME, "attributes"); String defaultValue = attributes.getProperty(ATTRIBUTE_DEFAULT_RIGHT, ""); String attributePairs = getPropertyValue(attributes.getProperty(ATTRIBUTE_LEVEL), name); if ((attributePairs == null) || (attributePairs.length() == 0)) { return; } String token; int pos; for (CommaListIterator it = new CommaListIterator(attributePairs); it.hasNext();) { token = it.getNext(); pos = token.indexOf('='); if (pos >= 0) { _curPairLeft = token.substring(0, pos); _curPairRight = (pos < token.length() - 1 ? token.substring(pos + 1) : defaultValue); } else { _curPairLeft = token; _curPairRight = defaultValue; } if (_curPairLeft.length() > 0) { generate(template); } } _curPairLeft = null; _curPairRight = null; }
Processes the template for the comma-separated value pairs in an attribute of the current object on the specified level. @param template The template @param attributes The attributes of the tag @exception XDocletException if an error occurs @doc.tag type="block" @doc.param name="level" optional="false" description="The level for the current object" values="class,field,reference,collection" @doc.param name="name" optional="true" description="The name of the attribute containg attributes (defaults to 'attributes')" @doc.param name="default-right" optional="true" description="The default right value if none is given (defaults to empty value)"
private ClassDescriptorDef ensureClassDef(XClass original) { String name = original.getQualifiedName(); ClassDescriptorDef classDef = _model.getClass(name); if (classDef == null) { classDef = new ClassDescriptorDef(original); _model.addClass(classDef); } return classDef; }
Makes sure that there is a class definition for the given qualified name, and returns it. @param original The XDoclet class object @return The class definition
private void addDirectSubTypes(XClass type, ArrayList subTypes) { if (type.isInterface()) { if (type.getExtendingInterfaces() != null) { subTypes.addAll(type.getExtendingInterfaces()); } // we have to traverse the implementing classes as these array contains all classes that // implement the interface, not only those who have an "implement" declaration // note that for whatever reason the declared interfaces are not exported via the XClass interface // so we have to get them via the underlying class which is hopefully a subclass of AbstractClass if (type.getImplementingClasses() != null) { Collection declaredInterfaces = null; XClass subType; for (Iterator it = type.getImplementingClasses().iterator(); it.hasNext(); ) { subType = (XClass)it.next(); if (subType instanceof AbstractClass) { declaredInterfaces = ((AbstractClass)subType).getDeclaredInterfaces(); if ((declaredInterfaces != null) && declaredInterfaces.contains(type)) { subTypes.add(subType); } } else { // Otherwise we have to live with the bug subTypes.add(subType); } } } } else { subTypes.addAll(type.getDirectSubclasses()); } }
Adds all direct subtypes to the given list. @param type The type for which to determine the direct subtypes @param subTypes The list to receive the subtypes
public static String getDefaultJdbcTypeForCurrentMember() throws XDocletException { if (OjbMemberTagsHandler.getMemberDimension() > 0) { return JdbcTypeHelper.JDBC_DEFAULT_TYPE_FOR_ARRAY; } String type = OjbMemberTagsHandler.getMemberType().getQualifiedName(); return JdbcTypeHelper.getDefaultJdbcTypeFor(type); }
Determines the default mapping for the type of the current member. If the current member is a field, the type of the field is used. If the current member is an accessor, then the return type (get/is) or parameter type (set) is used. @return The jdbc type @exception XDocletException If an error occurs
private static String getDefaultJdbcConversionForCurrentMember() throws XDocletException { if (OjbMemberTagsHandler.getMemberDimension() > 0) { return JdbcTypeHelper.JDBC_DEFAULT_CONVERSION; } String type = OjbMemberTagsHandler.getMemberType().getQualifiedName(); return JdbcTypeHelper.getDefaultConversionFor(type); }
Determines the default conversion for the type of the current member. If the current member is a field, the type of the field is used. If the current member is an accessor, then the return type (get/is) or parameter type (set) is used. @return The jdbc type @exception XDocletException If an error occurs
private String searchForPersistentSubType(XClass type) { ArrayList queue = new ArrayList(); XClass subType; queue.add(type); while (!queue.isEmpty()) { subType = (XClass)queue.get(0); queue.remove(0); if (_model.hasClass(subType.getQualifiedName())) { return subType.getQualifiedName(); } addDirectSubTypes(subType, queue); } return null; }
Searches the type and its sub types for the nearest ojb-persistent type and returns its name. @param type The type to search @return The qualified name of the found type or <code>null</code> if no type has been found
private DefBase getDefForLevel(String level) { if (LEVEL_CLASS.equals(level)) { return _curClassDef; } else if (LEVEL_FIELD.equals(level)) { return _curFieldDef; } else if (LEVEL_REFERENCE.equals(level)) { return _curReferenceDef; } else if (LEVEL_COLLECTION.equals(level)) { return _curCollectionDef; } else if (LEVEL_OBJECT_CACHE.equals(level)) { return _curObjectCacheDef; } else if (LEVEL_INDEX_DESC.equals(level)) { return _curIndexDescriptorDef; } else if (LEVEL_TABLE.equals(level)) { return _curTableDef; } else if (LEVEL_COLUMN.equals(level)) { return _curColumnDef; } else if (LEVEL_FOREIGNKEY.equals(level)) { return _curForeignkeyDef; } else if (LEVEL_INDEX.equals(level)) { return _curIndexDef; } else if (LEVEL_PROCEDURE.equals(level)) { return _curProcedureDef; } else if (LEVEL_PROCEDURE_ARGUMENT.equals(level)) { return _curProcedureArgumentDef; } else { return null; } }
Returns the current definition on the indicated level. @param level The level @return The definition
private String getPropertyValue(String level, String name) { return getDefForLevel(level).getProperty(name); }
Returns the value of the indicated property of the current object on the specified level. @param level The level @param name The name of the property @return The property value
final void compress(final File backupFile, final AppenderRollingProperties properties) { if (this.isCompressed(backupFile)) { LogLog.debug("Backup log file " + backupFile.getName() + " is already compressed"); return; // try not to do unnecessary work } final long lastModified = backupFile.lastModified(); if (0L == lastModified) { LogLog.debug("Backup log file " + backupFile.getName() + " may have been scavenged"); return; // backup file may have been scavenged } final File deflatedFile = this.createDeflatedFile(backupFile); if (deflatedFile == null) { LogLog.debug("Backup log file " + backupFile.getName() + " may have been scavenged"); return; // an error occurred creating the file } if (this.compress(backupFile, deflatedFile, properties)) { deflatedFile.setLastModified(lastModified); FileHelper.getInstance().deleteExisting(backupFile); LogLog.debug("Compressed backup log file to " + deflatedFile.getName()); } else { FileHelper.getInstance().deleteExisting(deflatedFile); // clean up LogLog .debug("Unable to compress backup log file " + backupFile.getName()); } }
Template method responsible for file compression checks, file creation, and delegation to specific strategy implementations. @param backupFile The file to be compressed. @param properties The appender's configuration.
public void initializeJdbcConnection(JdbcConnectionDescriptor jcd, Connection conn) throws PlatformException { // Do origial init super.initializeJdbcConnection(jcd, conn); // Execute a statement setting the tempory option try { Statement stmt = conn.createStatement(); stmt.executeUpdate("set temporary option RETURN_DATE_TIME_AS_STRING = On"); } catch (SQLException e) { throw new PlatformException(e); } }
Sybase Adaptive Server Enterprise (ASE) support timestamp to a precision of 1/300th of second. Adaptive Server Anywhere (ASA) support timestamp to a precision of 1/1000000tho of second. Sybase JDBC driver (JConnect) retrieving timestamp always rounds to 1/300th sec., causing rounding problems with ASA when retrieving Timestamp fields. This work around was suggested by Sybase Support. Unfortunately it works only with ASA. <br/> author Lorenzo Nicora
public Properties getDefaultSmtpProperties() { final Properties defaults = new Properties(); defaults.put(MAIL_SMTP_AUTH, false); defaults.put(MAIL_SMTP_STARTTLS_ENABLE, false); return defaults; }
default values
public String toXML() { RepositoryTags tags = RepositoryTags.getInstance(); String eol = System.getProperty( "line.separator" ); // The result StringBuffer result = new StringBuffer( 1024 ); result.append( eol ); result.append( " " ); // Opening tag and attributes result.append( " " ); result.append( tags.getOpeningTagNonClosingById( DELETE_PROCEDURE ) ); result.append( " " ); result.append( tags.getAttribute( NAME, this.getName() ) ); if( this.hasReturnValue() ) { result.append( " " ); result.append( tags.getAttribute( RETURN_FIELD_REF, this.getReturnValueFieldRefName() ) ); } result.append( " " ); result.append( tags.getAttribute( INCLUDE_PK_FIELDS_ONLY, String.valueOf( this.getIncludePkFieldsOnly() ) ) ); result.append( ">" ); result.append( eol ); // Write all arguments only if we're not including all fields. if( !this.getIncludePkFieldsOnly() ) { Iterator args = this.getArguments().iterator(); while( args.hasNext() ) { result.append( ( ( ArgumentDescriptor ) args.next() ).toXML() ); } } // Closing tag result.append( " " ); result.append( tags.getClosingTagById( DELETE_PROCEDURE ) ); result.append( eol ); return result.toString(); }
/* @see XmlCapable#toXML()
public void writeObject(Object o, GraphicsDocument document, boolean asChild) throws RenderException { document.writeElement("path", asChild); document.writeAttributeStart("d"); document.writePathContent(((LineString) o).getCoordinates()); document.writeAttributeEnd(); }
Writes a {@link LineString} object. LineStrings are encoded into SVG path elements. This function writes: "&lt;path d=". @param o The {@link LineString} to be encoded.
public static PersistenceBroker createPersistenceBroker(String jcdAlias, String user, String password) throws PBFactoryException { return PersistenceBrokerFactoryFactory.instance(). createPersistenceBroker(jcdAlias, user, password); }
Creates a new broker instance. @param jcdAlias The jdbc connection descriptor name as defined in the repository @param user The user name to be used for connecting to the database @param password The password to be used for connecting to the database @return The persistence broker @see org.apache.ojb.broker.core.PersistenceBrokerFactoryIF#createPersistenceBroker(java.lang.String, java.lang.String, java.lang.String)
public BaseAuthorization[] getAuthorizations() { BaseAuthorization[] res = new BaseAuthorization[authorizations.length]; try { for (int i = 0; i < authorizations.length; i++) { ByteArrayInputStream bais = new ByteArrayInputStream(authorizations[i]); JBossObjectInputStream deserialize = new JBossObjectInputStream(bais); Object obj = deserialize.readObject(); res[i] = (BaseAuthorization) obj; } } catch (ClassNotFoundException cnfe) { Logger log = LoggerFactory.getLogger(SavedAuthenticationImpl.class); log.error("Can not deserialize object, may cause rights to be lost.", cnfe); res = new BaseAuthorization[0]; // assure empty list, otherwise risk of NPE } catch (IOException ioe) { Logger log = LoggerFactory.getLogger(SavedAuthenticationImpl.class); log.error("Can not deserialize object, may cause rights to be lost.", ioe); res = new BaseAuthorization[0]; // assure empty list, otherwise risk of NPE } return res; }
Get array of authorizations which apply for the user. In many cases there is one object for each role. A union is used to combine these authorizations (and any other which may apply for the authentication token). @return array of {@link org.geomajas.security.BaseAuthorization} objects
public void setAuthorizations(BaseAuthorization[] authorizations) { BaseAuthorization ba = null; try { this.authorizations = new byte[authorizations.length][]; for (int i = 0; i < authorizations.length; i++) { ba = authorizations[i]; ByteArrayOutputStream baos = new ByteArrayOutputStream(256); JBossObjectOutputStream serialize = new JBossObjectOutputStream(baos); serialize.writeObject(ba); serialize.flush(); serialize.close(); this.authorizations[i] = baos.toByteArray(); } } catch (IOException ioe) { Logger log = LoggerFactory.getLogger(SavedAuthenticationImpl.class); log.error("Could not serialize " + ba + ", may cause rights to be lost.", ioe); } }
Set the {@link org.geomajas.security.Authorization}s which apply for this authentication. They are included here in serialized form. @param authorizations array of authentications
public void setRegistrationConfig(RegistrationConfig registrationConfig) { this.registrationConfig = registrationConfig; if (registrationConfig.getDefaultConfig()!=null) { for (String key : registrationConfig.getDefaultConfig().keySet()) { dynamicConfig.put(key, registrationConfig.getDefaultConfig().get(key)); } } }
The mediator registration config. If it contains default config and definitions, then the dynamic config will be initialized with those values. @see org.openhim.mediator.engine.RegistrationConfig @see #getDynamicConfig()
public void startElement(String uri, String name, String qName, Attributes atts) { boolean isDebug = logger.isDebugEnabled(); m_CurrentString = null; try { switch (getLiteralId(qName)) { case MAPPING_REPOSITORY: { if (isDebug) logger.debug(" > " + tags.getTagById(MAPPING_REPOSITORY)); this.m_CurrentAttrContainer = m_repository; String defIso = atts.getValue(tags.getTagById(ISOLATION_LEVEL)); this.m_repository.setDefaultIsolationLevel(LockHelper.getIsolationLevelFor(defIso)); if (isDebug) logger.debug(" " + tags.getTagById(ISOLATION_LEVEL) + ": " + defIso); String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT)); if (isDebug) logger.debug(" " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit); if (proxyPrefetchingLimit != null) { defProxyPrefetchingLimit = Integer.parseInt(proxyPrefetchingLimit); } // check repository version: String version = atts.getValue(tags.getTagById(REPOSITORY_VERSION)); if (DescriptorRepository.getVersion().equals(version)) { if (isDebug) logger.debug(" " + tags.getTagById(REPOSITORY_VERSION) + ": " + version); } else { throw new MetadataException("Repository version does not match. expected " + DescriptorRepository.getVersion() + " but found: " + version+". Please update your repository.dtd and your repository.xml"+ " version attribute entry"); } break; } case CLASS_DESCRIPTOR: { if (isDebug) logger.debug(" > " + tags.getTagById(CLASS_DESCRIPTOR)); m_CurrentCLD = new ClassDescriptor(m_repository); // prepare for custom attributes this.m_CurrentAttrContainer = this.m_CurrentCLD; // set isolation-level attribute String isoLevel = atts.getValue(tags.getTagById(ISOLATION_LEVEL)); if (isDebug) logger.debug(" " + tags.getTagById(ISOLATION_LEVEL) + ": " + isoLevel); /* arminw: only when an isolation-level is set in CLD, set it. Else the CLD use the default iso-level defined in the repository */ if(checkString(isoLevel)) m_CurrentCLD.setIsolationLevel(LockHelper.getIsolationLevelFor(isoLevel)); // set class attribute String classname = atts.getValue(tags.getTagById(CLASS_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(CLASS_NAME) + ": " + classname); try { m_CurrentCLD.setClassOfObject(ClassHelper.getClass(classname)); } catch (ClassNotFoundException e) { m_CurrentCLD = null; throw new MetadataException("Class "+classname+" could not be found" +" in the classpath. This could cause unexpected behaviour of OJB,"+ " please remove or comment out this class descriptor" + " in the repository.xml file.", e); } // set schema attribute String schema = atts.getValue(tags.getTagById(SCHEMA_NAME)); if (schema != null) { if (isDebug) logger.debug(" " + tags.getTagById(SCHEMA_NAME) + ": " + schema); m_CurrentCLD.setSchema(schema); } // set proxy attribute String proxy = atts.getValue(tags.getTagById(CLASS_PROXY)); if (isDebug) logger.debug(" " + tags.getTagById(CLASS_PROXY) + ": " + proxy); if (checkString(proxy)) { if (proxy.equalsIgnoreCase(ClassDescriptor.DYNAMIC_STR)) { m_CurrentCLD.setProxyClassName(ClassDescriptor.DYNAMIC_STR); } else { m_CurrentCLD.setProxyClassName(proxy); } } // set proxyPrefetchingLimit attribute String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT)); if (isDebug) logger.debug(" " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit); if (proxyPrefetchingLimit == null) { m_CurrentCLD.setProxyPrefetchingLimit(defProxyPrefetchingLimit); } else { m_CurrentCLD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit)); } // set table attribute: String table = atts.getValue(tags.getTagById(TABLE_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(TABLE_NAME) + ": " + table); m_CurrentCLD.setTableName(table); if (table == null) { m_CurrentCLD.setIsInterface(true); } // set row-reader attribute String rowreader = atts.getValue(tags.getTagById(ROW_READER)); if (isDebug) logger.debug(" " + tags.getTagById(ROW_READER) + ": " + rowreader); if (rowreader != null) { m_CurrentCLD.setRowReader(rowreader); } // set if extends // arminw: TODO: this feature doesn't work, remove this stuff? String extendsAtt = atts.getValue(tags.getTagById(EXTENDS)); if (isDebug) logger.debug(" " + tags.getTagById(EXTENDS) + ": " + extendsAtt); if (checkString(extendsAtt)) { m_CurrentCLD.setSuperClass(extendsAtt); } //set accept-locks attribute String acceptLocks = atts.getValue(tags.getTagById(ACCEPT_LOCKS)); if (acceptLocks==null) acceptLocks="true"; // default is true logger.debug(" " + tags.getTagById(ACCEPT_LOCKS) + ": " + acceptLocks); if (isDebug) logger.debug(" " + tags.getTagById(ACCEPT_LOCKS) + ": " + acceptLocks); boolean b = (Boolean.valueOf(acceptLocks)).booleanValue(); m_CurrentCLD.setAcceptLocks(b); //set initializationMethod attribute String initializationMethod = atts.getValue(tags.getTagById(INITIALIZATION_METHOD)); if (isDebug) logger.debug(" " + tags.getTagById(INITIALIZATION_METHOD) + ": " + initializationMethod); if (initializationMethod != null) { m_CurrentCLD.setInitializationMethod(initializationMethod); } // set factoryClass attribute String factoryClass = atts.getValue(tags.getTagById(FACTORY_CLASS)); if (isDebug) logger.debug(" " + tags.getTagById(FACTORY_CLASS) + ": " + factoryClass); if (factoryClass != null) { m_CurrentCLD.setFactoryClass(factoryClass); } //set factoryMethod attribute String factoryMethod = atts.getValue(tags.getTagById(FACTORY_METHOD)); if (isDebug) logger.debug(" " + tags.getTagById(FACTORY_METHOD) + ": " + factoryMethod); if (factoryMethod != null) { m_CurrentCLD.setFactoryMethod(factoryMethod); } // set refresh attribute String refresh = atts.getValue(tags.getTagById(REFRESH)); if (isDebug) logger.debug(" " + tags.getTagById(REFRESH) + ": " + refresh); b = (Boolean.valueOf(refresh)).booleanValue(); m_CurrentCLD.setAlwaysRefresh(b); // TODO: remove this or make offical feature // persistent field String pfClassName = atts.getValue("persistent-field-class"); if (isDebug) logger.debug(" persistent-field-class: " + pfClassName); m_CurrentCLD.setPersistentFieldClassName(pfClassName); // put cld to the metadata repository m_repository.put(classname, m_CurrentCLD); break; } case OBJECT_CACHE: { // we only interessted in object-cache tags declared within // an class-descriptor if(m_CurrentCLD != null) { String className = atts.getValue(tags.getTagById(CLASS_NAME)); if(checkString(className)) { if (isDebug) logger.debug(" > " + tags.getTagById(OBJECT_CACHE)); ObjectCacheDescriptor ocd = new ObjectCacheDescriptor(); this.m_CurrentAttrContainer = ocd; ocd.setObjectCache(ClassHelper.getClass(className)); if(m_CurrentCLD != null) { m_CurrentCLD.setObjectCacheDescriptor(ocd); } if (isDebug) logger.debug(" " + tags.getTagById(CLASS_NAME) + ": " + className); } } break; } case CLASS_EXTENT: { String classname = atts.getValue("class-ref"); if (isDebug) logger.debug(" " + tags.getTagById(CLASS_EXTENT) + ": " + classname); m_CurrentCLD.addExtentClass(classname); break; } case FIELD_DESCRIPTOR: { if (isDebug) logger.debug(" > " + tags.getTagById(FIELD_DESCRIPTOR)); String strId = atts.getValue(tags.getTagById(ID)); m_lastId = (strId == null ? m_lastId + 1 : Integer.parseInt(strId)); String strAccess = atts.getValue(tags.getTagById(ACCESS)); if (RepositoryElements.TAG_ACCESS_ANONYMOUS.equalsIgnoreCase(strAccess)) { m_CurrentFLD = new AnonymousFieldDescriptor(m_CurrentCLD, m_lastId); } else { m_CurrentFLD = new FieldDescriptor(m_CurrentCLD, m_lastId); } m_CurrentFLD.setAccess(strAccess); m_CurrentCLD.addFieldDescriptor(m_CurrentFLD); // prepare for custom attributes this.m_CurrentAttrContainer = this.m_CurrentFLD; String fieldName = atts.getValue(tags.getTagById(FIELD_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + fieldName); if (RepositoryElements.TAG_ACCESS_ANONYMOUS.equalsIgnoreCase(strAccess)) { AnonymousFieldDescriptor anonymous = (AnonymousFieldDescriptor) m_CurrentFLD; anonymous.setPersistentField(null,fieldName); } else { String classname = m_CurrentCLD.getClassNameOfObject(); PersistentField pf = PersistentFieldFactory.createPersistentField(m_CurrentCLD.getPersistentFieldClassName(),ClassHelper.getClass(classname),fieldName); m_CurrentFLD.setPersistentField(pf); } String columnName = atts.getValue(tags.getTagById(COLUMN_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(COLUMN_NAME) + ": " + columnName); m_CurrentFLD.setColumnName(columnName); String jdbcType = atts.getValue(tags.getTagById(JDBC_TYPE)); if (isDebug) logger.debug(" " + tags.getTagById(JDBC_TYPE) + ": " + jdbcType); m_CurrentFLD.setColumnType(jdbcType); String primaryKey = atts.getValue(tags.getTagById(PRIMARY_KEY)); if (isDebug) logger.debug(" " + tags.getTagById(PRIMARY_KEY) + ": " + primaryKey); boolean b = (Boolean.valueOf(primaryKey)).booleanValue(); m_CurrentFLD.setPrimaryKey(b); String nullable = atts.getValue(tags.getTagById(NULLABLE)); if (nullable != null) { if (isDebug) logger.debug(" " + tags.getTagById(NULLABLE) + ": " + nullable); b = !(Boolean.valueOf(nullable)).booleanValue(); m_CurrentFLD.setRequired(b); } String indexed = atts.getValue(tags.getTagById(INDEXED)); if (isDebug) logger.debug(" " + tags.getTagById(INDEXED) + ": " + indexed); b = (Boolean.valueOf(indexed)).booleanValue(); m_CurrentFLD.setIndexed(b); String autoincrement = atts.getValue(tags.getTagById(AUTO_INCREMENT)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_INCREMENT) + ": " + autoincrement); b = (Boolean.valueOf(autoincrement)).booleanValue(); m_CurrentFLD.setAutoIncrement(b); String sequenceName = atts.getValue(tags.getTagById(SEQUENCE_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(SEQUENCE_NAME) + ": " + sequenceName); m_CurrentFLD.setSequenceName(sequenceName); String locking = atts.getValue(tags.getTagById(LOCKING)); if (isDebug) logger.debug(" " + tags.getTagById(LOCKING) + ": " + locking); b = (Boolean.valueOf(locking)).booleanValue(); m_CurrentFLD.setLocking(b); String updateLock = atts.getValue(tags.getTagById(UPDATE_LOCK)); if (isDebug) logger.debug(" " + tags.getTagById(UPDATE_LOCK) + ": " + updateLock); if(checkString(updateLock)) { b = (Boolean.valueOf(updateLock)).booleanValue(); m_CurrentFLD.setUpdateLock(b); } String fieldConversion = atts.getValue(tags.getTagById(FIELD_CONVERSION)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_CONVERSION) + ": " + fieldConversion); if (fieldConversion != null) { m_CurrentFLD.setFieldConversionClassName(fieldConversion); } // set length attribute String length = atts.getValue(tags.getTagById(LENGTH)); if (length != null) { int i = Integer.parseInt(length); if (isDebug) logger.debug(" " + tags.getTagById(LENGTH) + ": " + i); m_CurrentFLD.setLength(i); m_CurrentFLD.setLengthSpecified(true); } // set precision attribute String precision = atts.getValue(tags.getTagById(PRECISION)); if (precision != null) { int i = Integer.parseInt(precision); if (isDebug) logger.debug(" " + tags.getTagById(PRECISION) + ": " + i); m_CurrentFLD.setPrecision(i); m_CurrentFLD.setPrecisionSpecified(true); } // set scale attribute String scale = atts.getValue(tags.getTagById(SCALE)); if (scale != null) { int i = Integer.parseInt(scale); if (isDebug) logger.debug(" " + tags.getTagById(SCALE) + ": " + i); m_CurrentFLD.setScale(i); m_CurrentFLD.setScaleSpecified(true); } break; } case REFERENCE_DESCRIPTOR: { if (isDebug) logger.debug(" > " + tags.getTagById(REFERENCE_DESCRIPTOR)); // set name attribute name = atts.getValue(tags.getTagById(FIELD_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + name); // set class-ref attribute String classRef = atts.getValue(tags.getTagById(REFERENCED_CLASS)); if (isDebug) logger.debug(" " + tags.getTagById(REFERENCED_CLASS) + ": " + classRef); ObjectReferenceDescriptor ord; if (name.equals(TAG_SUPER)) { // no longer needed sine SuperReferenceDescriptor was used // checkThis(classRef); // AnonymousObjectReferenceDescriptor aord = // new AnonymousObjectReferenceDescriptor(m_CurrentCLD); // aord.setPersistentField(null, TAG_SUPER); // ord = aord; ord = new SuperReferenceDescriptor(m_CurrentCLD); } else { ord = new ObjectReferenceDescriptor(m_CurrentCLD); PersistentField pf = PersistentFieldFactory.createPersistentField(m_CurrentCLD.getPersistentFieldClassName(),m_CurrentCLD.getClassOfObject(),name); ord.setPersistentField(pf); } m_CurrentORD = ord; // now we add the new descriptor m_CurrentCLD.addObjectReferenceDescriptor(m_CurrentORD); m_CurrentORD.setItemClass(ClassHelper.getClass(classRef)); // prepare for custom attributes this.m_CurrentAttrContainer = m_CurrentORD; // set proxy attribute String proxy = atts.getValue(tags.getTagById(PROXY_REFERENCE)); if (isDebug) logger.debug(" " + tags.getTagById(PROXY_REFERENCE) + ": " + proxy); boolean b = (Boolean.valueOf(proxy)).booleanValue(); m_CurrentORD.setLazy(b); // set proxyPrefetchingLimit attribute String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT)); if (isDebug) logger.debug(" " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit); if (proxyPrefetchingLimit == null) { m_CurrentORD.setProxyPrefetchingLimit(defProxyPrefetchingLimit); } else { m_CurrentORD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit)); } // set refresh attribute String refresh = atts.getValue(tags.getTagById(REFRESH)); if (isDebug) logger.debug(" " + tags.getTagById(REFRESH) + ": " + refresh); b = (Boolean.valueOf(refresh)).booleanValue(); m_CurrentORD.setRefresh(b); // set auto-retrieve attribute String autoRetrieve = atts.getValue(tags.getTagById(AUTO_RETRIEVE)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_RETRIEVE) + ": " + autoRetrieve); b = (Boolean.valueOf(autoRetrieve)).booleanValue(); m_CurrentORD.setCascadeRetrieve(b); // set auto-update attribute String autoUpdate = atts.getValue(tags.getTagById(AUTO_UPDATE)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_UPDATE) + ": " + autoUpdate); if(autoUpdate != null) { m_CurrentORD.setCascadingStore(autoUpdate); } //set auto-delete attribute String autoDelete = atts.getValue(tags.getTagById(AUTO_DELETE)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_DELETE) + ": " + autoDelete); if(autoDelete != null) { m_CurrentORD.setCascadingDelete(autoDelete); } //set otm-dependent attribute String otmDependent = atts.getValue(tags.getTagById(OTM_DEPENDENT)); if (isDebug) logger.debug(" " + tags.getTagById(OTM_DEPENDENT) + ": " + otmDependent); b = (Boolean.valueOf(otmDependent)).booleanValue(); m_CurrentORD.setOtmDependent(b); break; } case FOREIGN_KEY: { if (isDebug) logger.debug(" > " + tags.getTagById(FOREIGN_KEY)); String fieldIdRef = atts.getValue(tags.getTagById(FIELD_ID_REF)); if (fieldIdRef != null) { if (isDebug) logger.debug(" " + tags.getTagById(FIELD_ID_REF) + ": " + fieldIdRef); try { int fieldId; fieldId = Integer.parseInt(fieldIdRef); m_CurrentORD.addForeignKeyField(fieldId); } catch (NumberFormatException rex) { throw new MetadataException(tags.getTagById(FIELD_ID_REF) + " attribute must be an int. Found: " + fieldIdRef + ". Please check your repository file.", rex); } } else { String fieldRef = atts.getValue(tags.getTagById(FIELD_REF)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_REF) + ": " + fieldRef); m_CurrentORD.addForeignKeyField(fieldRef); } break; } case COLLECTION_DESCRIPTOR: { if (isDebug) logger.debug(" > " + tags.getTagById(COLLECTION_DESCRIPTOR)); m_CurrentCOD = new CollectionDescriptor(m_CurrentCLD); // prepare for custom attributes this.m_CurrentAttrContainer = m_CurrentCOD; // set name attribute name = atts.getValue(tags.getTagById(FIELD_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + name); PersistentField pf = PersistentFieldFactory.createPersistentField(m_CurrentCLD.getPersistentFieldClassName(),m_CurrentCLD.getClassOfObject(),name); m_CurrentCOD.setPersistentField(pf); // set collection-class attribute String collectionClassName = atts.getValue(tags.getTagById(COLLECTION_CLASS)); if (collectionClassName != null) { if (isDebug) logger.debug(" " + tags.getTagById(COLLECTION_CLASS) + ": " + collectionClassName); m_CurrentCOD.setCollectionClass(ClassHelper.getClass(collectionClassName)); } // set element-class-ref attribute String elementClassRef = atts.getValue(tags.getTagById(ITEMS_CLASS)); if (isDebug) logger.debug(" " + tags.getTagById(ITEMS_CLASS) + ": " + elementClassRef); if (elementClassRef != null) { m_CurrentCOD.setItemClass(ClassHelper.getClass(elementClassRef)); } //set orderby and sort attributes: String orderby = atts.getValue(tags.getTagById(ORDERBY)); String sort = atts.getValue(tags.getTagById(SORT)); if (isDebug) logger.debug(" " + tags.getTagById(SORT) + ": " + orderby + ", " + sort); if (orderby != null) { m_CurrentCOD.addOrderBy(orderby, "ASC".equalsIgnoreCase(sort)); } // set indirection-table attribute String indirectionTable = atts.getValue(tags.getTagById(INDIRECTION_TABLE)); if (isDebug) logger.debug(" " + tags.getTagById(INDIRECTION_TABLE) + ": " + indirectionTable); m_CurrentCOD.setIndirectionTable(indirectionTable); // set proxy attribute String proxy = atts.getValue(tags.getTagById(PROXY_REFERENCE)); if (isDebug) logger.debug(" " + tags.getTagById(PROXY_REFERENCE) + ": " + proxy); boolean b = (Boolean.valueOf(proxy)).booleanValue(); m_CurrentCOD.setLazy(b); // set proxyPrefetchingLimit attribute String proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT)); if (isDebug) logger.debug(" " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit); if (proxyPrefetchingLimit == null) { m_CurrentCOD.setProxyPrefetchingLimit(defProxyPrefetchingLimit); } else { m_CurrentCOD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit)); } // set refresh attribute String refresh = atts.getValue(tags.getTagById(REFRESH)); if (isDebug) logger.debug(" " + tags.getTagById(REFRESH) + ": " + refresh); b = (Boolean.valueOf(refresh)).booleanValue(); m_CurrentCOD.setRefresh(b); // set auto-retrieve attribute String autoRetrieve = atts.getValue(tags.getTagById(AUTO_RETRIEVE)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_RETRIEVE) + ": " + autoRetrieve); b = (Boolean.valueOf(autoRetrieve)).booleanValue(); m_CurrentCOD.setCascadeRetrieve(b); // set auto-update attribute String autoUpdate = atts.getValue(tags.getTagById(AUTO_UPDATE)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_UPDATE) + ": " + autoUpdate); if(autoUpdate != null) { m_CurrentCOD.setCascadingStore(autoUpdate); } //set auto-delete attribute String autoDelete = atts.getValue(tags.getTagById(AUTO_DELETE)); if (isDebug) logger.debug(" " + tags.getTagById(AUTO_DELETE) + ": " + autoDelete); if(autoDelete != null) { m_CurrentCOD.setCascadingDelete(autoDelete); } //set otm-dependent attribute String otmDependent = atts.getValue(tags.getTagById(OTM_DEPENDENT)); if (isDebug) logger.debug(" " + tags.getTagById(OTM_DEPENDENT) + ": " + otmDependent); b = (Boolean.valueOf(otmDependent)).booleanValue(); m_CurrentCOD.setOtmDependent(b); m_CurrentCLD.addCollectionDescriptor(m_CurrentCOD); break; } case ORDERBY : { if (isDebug) logger.debug(" > " + tags.getTagById(ORDERBY)); name = atts.getValue(tags.getTagById(FIELD_NAME)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + name); String sort = atts.getValue(tags.getTagById(SORT)); if (isDebug) logger.debug(" " + tags.getTagById(SORT) + ": " + name + ", " + sort); m_CurrentCOD.addOrderBy(name, "ASC".equalsIgnoreCase(sort)); break; } case INVERSE_FK: { if (isDebug) logger.debug(" > " + tags.getTagById(INVERSE_FK)); String fieldIdRef = atts.getValue(tags.getTagById(FIELD_ID_REF)); if (fieldIdRef != null) { if (isDebug) logger.debug(" " + tags.getTagById(FIELD_ID_REF) + ": " + fieldIdRef); try { int fieldId; fieldId = Integer.parseInt(fieldIdRef); m_CurrentCOD.addForeignKeyField(fieldId); } catch (NumberFormatException rex) { throw new MetadataException(tags.getTagById(FIELD_ID_REF) + " attribute must be an int. Found: " + fieldIdRef + " Please check your repository file.", rex); } } else { String fieldRef = atts.getValue(tags.getTagById(FIELD_REF)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_REF) + ": " + fieldRef); m_CurrentCOD.addForeignKeyField(fieldRef); } break; } case FK_POINTING_TO_THIS_CLASS: { if (isDebug) logger.debug(" > " + tags.getTagById(FK_POINTING_TO_THIS_CLASS)); String column = atts.getValue("column"); if (isDebug) logger.debug(" " + "column" + ": " + column); m_CurrentCOD.addFkToThisClass(column); break; } case FK_POINTING_TO_ITEMS_CLASS: { if (isDebug) logger.debug(" > " + tags.getTagById(FK_POINTING_TO_ITEMS_CLASS)); String column = atts.getValue("column"); if (isDebug) logger.debug(" " + "column" + ": " + column); m_CurrentCOD.addFkToItemClass(column); break; } case ATTRIBUTE: { //handle custom attributes String attributeName = atts.getValue(tags.getTagById(ATTRIBUTE_NAME)); String attributeValue = atts.getValue(tags.getTagById(ATTRIBUTE_VALUE)); // If we have a container to store this attribute in, then do so. if (this.m_CurrentAttrContainer != null) { if (isDebug) logger.debug(" > " + tags.getTagById(ATTRIBUTE)); if (isDebug) logger.debug(" " + tags.getTagById(ATTRIBUTE_NAME) + ": " + attributeName); if (isDebug) logger.debug(" " + tags.getTagById(ATTRIBUTE_VALUE) + ": " + attributeValue); this.m_CurrentAttrContainer.addAttribute(attributeName, attributeValue); } else { // logger.debug("Found attribute (name="+attributeName+", value="+attributeValue+ // ") but I can not assign them to a descriptor"); } break; } // case SEQUENCE_MANAGER: // { // if (isDebug) logger.debug(" > " + tags.getTagById(SEQUENCE_MANAGER)); // // currently it's not possible to specify SM on class-descriptor level // // thus we use a dummy object to prevent ATTRIBUTE container report // // unassigned attributes // this.m_CurrentAttrContainer = new SequenceDescriptor(null); // break; // } case QUERY_CUSTOMIZER: { // set collection-class attribute String className = atts.getValue("class"); QueryCustomizer queryCust; if (className != null) { if (isDebug) logger.debug(" " + "class" + ": " + className); queryCust = (QueryCustomizer)ClassHelper.newInstance(className); m_CurrentAttrContainer = queryCust; m_CurrentCOD.setQueryCustomizer(queryCust); } break; } case INDEX_DESCRIPTOR: { m_CurrentIndexDescriptor = new IndexDescriptor(); m_CurrentIndexDescriptor.setName(atts.getValue(tags.getTagById(NAME))); m_CurrentIndexDescriptor.setUnique(Boolean.valueOf(atts.getValue(tags.getTagById(UNIQUE))).booleanValue()); break; } case INDEX_COLUMN: { m_CurrentIndexDescriptor.getIndexColumns().add(atts.getValue(tags.getTagById(NAME))); break; } case INSERT_PROCEDURE: { if (isDebug) logger.debug(" > " + tags.getTagById(INSERT_PROCEDURE)); // Get the proc name and the 'include all fields' setting String procName = atts.getValue(tags.getTagById(NAME)); String includeAllFields = atts.getValue(tags.getTagById(INCLUDE_ALL_FIELDS)); if (isDebug) logger.debug(" " + tags.getTagById(NAME) + ": " + procName); if (isDebug) logger.debug(" " + tags.getTagById(INCLUDE_ALL_FIELDS) + ": " + includeAllFields); // create the procedure descriptor InsertProcedureDescriptor proc = new InsertProcedureDescriptor(m_CurrentCLD, procName, Boolean.valueOf(includeAllFields).booleanValue()); m_CurrentProcedure = proc; // Get the name of the field ref that will receive the // return value. String returnFieldRefName = atts.getValue(tags.getTagById(RETURN_FIELD_REF)); if (isDebug) logger.debug(" " + tags.getTagById(RETURN_FIELD_REF) + ": " + returnFieldRefName); proc.setReturnValueFieldRef(returnFieldRefName); break; } case UPDATE_PROCEDURE: { if (isDebug) logger.debug(" > " + tags.getTagById(UPDATE_PROCEDURE)); // Get the proc name and the 'include all fields' setting String procName = atts.getValue(tags.getTagById(NAME)); String includeAllFields = atts.getValue(tags.getTagById(INCLUDE_ALL_FIELDS)); if (isDebug) logger.debug(" " + tags.getTagById(NAME) + ": " + procName); if (isDebug) logger.debug(" " + tags.getTagById(INCLUDE_ALL_FIELDS) + ": " + includeAllFields); // create the procedure descriptor UpdateProcedureDescriptor proc = new UpdateProcedureDescriptor(m_CurrentCLD, procName, Boolean.valueOf(includeAllFields).booleanValue()); m_CurrentProcedure = proc; // Get the name of the field ref that will receive the // return value. String returnFieldRefName = atts.getValue(tags.getTagById(RETURN_FIELD_REF)); if (isDebug) logger.debug(" " + tags.getTagById(RETURN_FIELD_REF) + ": " + returnFieldRefName); proc.setReturnValueFieldRef(returnFieldRefName); break; } case DELETE_PROCEDURE: { if (isDebug) logger.debug(" > " + tags.getTagById(DELETE_PROCEDURE)); // Get the proc name and the 'include all fields' setting String procName = atts.getValue(tags.getTagById(NAME)); String includeAllPkFields = atts.getValue(tags.getTagById(INCLUDE_PK_FIELDS_ONLY)); if (isDebug) logger.debug(" " + tags.getTagById(NAME) + ": " + procName); if (isDebug) logger.debug(" " + tags.getTagById(INCLUDE_PK_FIELDS_ONLY) + ": " + includeAllPkFields); // create the procedure descriptor DeleteProcedureDescriptor proc = new DeleteProcedureDescriptor(m_CurrentCLD, procName, Boolean.valueOf(includeAllPkFields).booleanValue()); m_CurrentProcedure = proc; // Get the name of the field ref that will receive the // return value. String returnFieldRefName = atts.getValue(tags.getTagById(RETURN_FIELD_REF)); if (isDebug) logger.debug(" " + tags.getTagById(RETURN_FIELD_REF) + ": " + returnFieldRefName); proc.setReturnValueFieldRef(returnFieldRefName); break; } case CONSTANT_ARGUMENT: { if (isDebug) logger.debug(" > " + tags.getTagById(CONSTANT_ARGUMENT)); ArgumentDescriptor arg = new ArgumentDescriptor(m_CurrentProcedure); // Get the value String value = atts.getValue(tags.getTagById(VALUE)); if (isDebug) logger.debug(" " + tags.getTagById(VALUE) + ": " + value); // Set the value for the argument arg.setValue(value); // Add the argument to the procedure. m_CurrentProcedure.addArgument(arg); break; } case RUNTIME_ARGUMENT: { if (isDebug) logger.debug(" > " + tags.getTagById(RUNTIME_ARGUMENT)); ArgumentDescriptor arg = new ArgumentDescriptor(m_CurrentProcedure); // Get the name of the field ref String fieldRefName = atts.getValue(tags.getTagById(FIELD_REF)); if (isDebug) logger.debug(" " + tags.getTagById(FIELD_REF) + ": " + fieldRefName); // Get the 'return' value. String returnValue = atts.getValue(tags.getTagById(RETURN)); if (isDebug) logger.debug(" " + tags.getTagById(RETURN) + ": " + returnValue); // Set the value for the argument. if ((fieldRefName != null) && (fieldRefName.trim().length() != 0)) { arg.setValue(fieldRefName, Boolean.valueOf(returnValue).booleanValue()); } // Add the argument to the procedure. m_CurrentProcedure.addArgument(arg); break; } default : { // nop } } } catch (Exception ex) { logger.error("Exception while read metadata", ex); if(ex instanceof MetadataException) throw (MetadataException)ex; else throw new MetadataException("Exception when reading metadata information,"+ " please check your repository.xml file", ex); } }
startElement callback. Only some Elements need special start operations. @throws MetadataException indicating mapping errors
public void endElement(String uri, String name, String qName) { boolean isDebug = logger.isDebugEnabled(); try { switch (getLiteralId(qName)) { case MAPPING_REPOSITORY: { if (isDebug) logger.debug(" < " + tags.getTagById(MAPPING_REPOSITORY)); this.m_CurrentAttrContainer = null; m_CurrentCLD = null; break; } case CLASS_DESCRIPTOR: { if (isDebug) logger.debug(" < " + tags.getTagById(CLASS_DESCRIPTOR)); m_CurrentCLD = null; this.m_CurrentAttrContainer = null; break; } case OBJECT_CACHE: { if(m_CurrentAttrContainer != null) { if (isDebug) logger.debug(" < " + tags.getTagById(OBJECT_CACHE)); } this.m_CurrentAttrContainer = m_CurrentCLD; break; } case CLASS_EXTENT: { break; } case FIELD_DESCRIPTOR: { if (isDebug) logger.debug(" < " + tags.getTagById(FIELD_DESCRIPTOR)); m_CurrentFLD = null; m_CurrentAttrContainer = m_CurrentCLD; break; } case REFERENCE_DESCRIPTOR: { if (isDebug) logger.debug(" < " + tags.getTagById(REFERENCE_DESCRIPTOR)); m_CurrentORD = null; m_CurrentAttrContainer = m_CurrentCLD; break; } case FOREIGN_KEY: { if (isDebug) logger.debug(" < " + tags.getTagById(FOREIGN_KEY)); break; } case COLLECTION_DESCRIPTOR: { if (isDebug) logger.debug(" < " + tags.getTagById(COLLECTION_DESCRIPTOR)); m_CurrentCOD = null; m_CurrentAttrContainer = m_CurrentCLD; break; } case INVERSE_FK: { if (isDebug) logger.debug(" < " + tags.getTagById(INVERSE_FK)); break; } case ORDERBY : { if (isDebug) logger.debug(" < " + tags.getTagById(ORDERBY)); break; } case FK_POINTING_TO_THIS_CLASS: { if (isDebug) logger.debug(" < " + tags.getTagById(FK_POINTING_TO_THIS_CLASS)); break; } case FK_POINTING_TO_ITEMS_CLASS: { if (isDebug) logger.debug(" < " + tags.getTagById(FK_POINTING_TO_ITEMS_CLASS)); break; } case ATTRIBUTE: { if(m_CurrentAttrContainer != null) { if (isDebug) logger.debug(" < " + tags.getTagById(ATTRIBUTE)); } break; } case DOCUMENTATION: { if (isDebug) logger.debug(" < " + tags.getTagById(DOCUMENTATION)); break; } // case SEQUENCE_MANAGER: // { // // currently not used on class-descriptor level // // if (isDebug) logger.debug(" < " + tags.getTagById(SEQUENCE_MANAGER)); // this.m_CurrentAttrContainer = null; // break; // } // case CONNECTION_POOL: // { // // not used on class-descriptor level // // if (isDebug) logger.debug(" < " + tags.getTagById(CONNECTION_POOL)); // this.m_CurrentAttrContainer = null; // break; // } // case JDBC_CONNECTION_DESCRIPTOR: // { // // not used on class-descriptor level // // if (isDebug) logger.debug(" < " + tags.getTagById(JDBC_CONNECTION_DESCRIPTOR)); // this.m_CurrentAttrContainer = null; // break; // } case QUERY_CUSTOMIZER: { m_CurrentAttrContainer = m_CurrentCOD; break; } case INDEX_DESCRIPTOR: { m_CurrentCLD.getIndexes().add(m_CurrentIndexDescriptor); m_CurrentIndexDescriptor = null; break; } case INDEX_COLUMN: { // ignore; all processing done in startElement break; } case INSERT_PROCEDURE: { if (isDebug) logger.debug(" < " + tags.getTagById(INSERT_PROCEDURE)); m_CurrentCLD.setInsertProcedure((InsertProcedureDescriptor)m_CurrentProcedure); m_CurrentProcedure = null; break; } case UPDATE_PROCEDURE: { if (isDebug) logger.debug(" < " + tags.getTagById(UPDATE_PROCEDURE)); m_CurrentCLD.setUpdateProcedure((UpdateProcedureDescriptor)m_CurrentProcedure); m_CurrentProcedure = null; break; } case DELETE_PROCEDURE: { if (isDebug) logger.debug(" < " + tags.getTagById(DELETE_PROCEDURE)); m_CurrentCLD.setDeleteProcedure((DeleteProcedureDescriptor)m_CurrentProcedure); m_CurrentProcedure = null; break; } case CONSTANT_ARGUMENT: { if (isDebug) logger.debug(" < " + tags.getTagById(CONSTANT_ARGUMENT)); break; } case RUNTIME_ARGUMENT: { if (isDebug) logger.debug(" < " + tags.getTagById(RUNTIME_ARGUMENT)); break; } // handle failure: default : { logger.debug("Ignoring unused Element " + qName); } } } catch (Exception ex) { if(ex instanceof MetadataException) throw (MetadataException) ex; else throw new MetadataException("Exception when reading metadata information,"+ " please check your repository.xml file", ex); } }
endElement callback. most elements are build up from here.
public void characters(char ch[], int start, int length) { if (m_CurrentString == null) m_CurrentString = new String(ch, start, length); else m_CurrentString += new String(ch, start, length); }
characters callback.
public synchronized boolean hasNext() { try { if (!isHasCalledCheck()) { setHasCalledCheck(true); setHasNext(getRsAndStmt().m_rs.next()); if (!getHasNext()) { autoReleaseDbResources(); } } } catch (Exception ex) { setHasNext(false); autoReleaseDbResources(); if(ex instanceof ResourceClosedException) { throw (ResourceClosedException)ex; } if(ex instanceof SQLException) { throw new PersistenceBrokerSQLException("Calling ResultSet.next() failed", (SQLException) ex); } else { throw new PersistenceBrokerException("Can't get next row from ResultSet", ex); } } if (logger.isDebugEnabled()) logger.debug("hasNext() -> " + getHasNext()); return getHasNext(); }
returns true if there are still more rows in the underlying ResultSet. Returns false if ResultSet is exhausted.
public synchronized Object next() throws NoSuchElementException { try { if (!isHasCalledCheck()) { hasNext(); } setHasCalledCheck(false); if (getHasNext()) { Object obj = getObjectFromResultSet(); m_current_row++; // Invoke events on PersistenceBrokerAware instances and listeners // set target object if (!disableLifeCycleEvents) { getAfterLookupEvent().setTarget(obj); getBroker().fireBrokerEvent(getAfterLookupEvent()); getAfterLookupEvent().setTarget(null); } return obj; } else { throw new NoSuchElementException("inner hasNext was false"); } } catch (ResourceClosedException ex) { autoReleaseDbResources(); throw ex; } catch (NoSuchElementException ex) { autoReleaseDbResources(); logger.error("Error while iterate ResultSet for query " + m_queryObject, ex); throw new NoSuchElementException("Could not obtain next object: " + ex.getMessage()); } }
moves to the next row of the underlying ResultSet and returns the corresponding Object materialized from this row.
private Collection getOwnerObjects() { Collection owners = new Vector(); while (hasNext()) { owners.add(next()); } return owners; }
read all objects of this iterator. objects will be placed in cache
private void prefetchRelationships(Query query) { List prefetchedRel; Collection owners; String relName; RelationshipPrefetcher[] prefetchers; if (query == null || query.getPrefetchedRelationships() == null || query.getPrefetchedRelationships().isEmpty()) { return; } if (!supportsAdvancedJDBCCursorControl()) { logger.info("prefetching relationships requires JDBC level 2.0"); return; } // prevent releasing of DBResources setInBatchedMode(true); prefetchedRel = query.getPrefetchedRelationships(); prefetchers = new RelationshipPrefetcher[prefetchedRel.size()]; // disable auto retrieve for all prefetched relationships for (int i = 0; i < prefetchedRel.size(); i++) { relName = (String) prefetchedRel.get(i); prefetchers[i] = getBroker().getRelationshipPrefetcherFactory() .createRelationshipPrefetcher(getQueryObject().getClassDescriptor(), relName); prefetchers[i].prepareRelationshipSettings(); } // materialize ALL owners of this Iterator owners = getOwnerObjects(); // prefetch relationships and associate with owners for (int i = 0; i < prefetchedRel.size(); i++) { prefetchers[i].prefetchRelationship(owners); } // reset auto retrieve for all prefetched relationships for (int i = 0; i < prefetchedRel.size(); i++) { prefetchers[i].restoreRelationshipSettings(); } try { getRsAndStmt().m_rs.beforeFirst(); // reposition resultset jdbc 2.0 } catch (SQLException e) { logger.error("beforeFirst failed !", e); } setInBatchedMode(false); setHasCalledCheck(false); }
prefetch defined relationships requires JDBC level 2.0, does not work with Arrays
protected Identity getIdentityFromResultSet() throws PersistenceBrokerException { // fill primary key values from Resultset FieldDescriptor fld; FieldDescriptor[] pkFields = getQueryObject().getClassDescriptor().getPkFields(); Object[] pkValues = new Object[pkFields.length]; for (int i = 0; i < pkFields.length; i++) { fld = pkFields[i]; pkValues[i] = getRow().get(fld.getColumnName()); } // return identity object build up from primary keys return getBroker().serviceIdentity().buildIdentity( getQueryObject().getClassDescriptor().getClassOfObject(), getTopLevelClass(), pkValues); }
returns an Identity object representing the current resultset row
protected Object getObjectFromResultSet() throws PersistenceBrokerException { getRow().clear(); /** * MBAIRD if a proxy is to be used, return a proxy instance and dont * perfom a full materialization. NOTE: Potential problem here with * multi-mapped table. The itemProxyClass is for the m_cld * classdescriptor. The object you are materializing might not be of * that type, it could be a subclass. We should get the concrete class * type out of the resultset then check the proxy from that. * itemProxyClass should NOT be a member variable. */ RowReader rowReader = getQueryObject().getClassDescriptor().getRowReader(); // in any case we need the PK values of result set row // provide m_row with primary key data of current row rowReader.readPkValuesFrom(getRsAndStmt(), getRow()); if (getItemProxyClass() != null) { // assert: m_row is filled with primary key values from db return getProxyFromResultSet(); } else { // 1.read Identity Identity oid = getIdentityFromResultSet(); Object result; // 2. check if Object is in cache. if so return cached version. result = getCache().lookup(oid); if (result == null) { // map all field values from the current result set rowReader.readObjectArrayFrom(getRsAndStmt(), getRow()); // 3. If Object is not in cache // materialize Object with primitive attributes filled from current row result = rowReader.readObjectFrom(getRow()); // result may still be null! if (result != null) { /* * synchronize on result so the ODMG-layer can take a * snapshot only of fully cached (i.e. with all references + * collections) objects */ synchronized (result) { getCache().enableMaterializationCache(); try { getCache().doInternalCache(oid, result, ObjectCacheInternal.TYPE_NEW_MATERIALIZED); /** * MBAIRD if you have multiple classes mapped to a * table, and you query on the base class you could get * back NON base class objects, so we shouldn't pass * m_cld, but rather the class descriptor for the * actual class. */ // fill reference and collection attributes ClassDescriptor cld = getBroker().getClassDescriptor(result.getClass()); // don't force loading of reference final boolean unforced = false; // Maps ReferenceDescriptors to HashSets of owners getBroker().getReferenceBroker().retrieveReferences(result, cld, unforced); getBroker().getReferenceBroker().retrieveCollections(result, cld, unforced); getCache().disableMaterializationCache(); } catch(RuntimeException e) { // catch runtime exc. to guarantee clearing of internal buffer on failure getCache().doLocalClear(); throw e; } } } } else // Object is in cache { ClassDescriptor cld = getBroker().getClassDescriptor(result.getClass()); // if refresh is required, read all values from the result set and // update the cache instance from the db if (cld.isAlwaysRefresh()) { // map all field values from the current result set rowReader.readObjectArrayFrom(getRsAndStmt(), getRow()); rowReader.refreshObject(result, getRow()); } getBroker().checkRefreshRelationships(result, oid, cld); } return result; } }
returns a fully materialized Object from the current row of the underlying resultset. Works as follows: - read Identity from the primary key values of current row - check if Object is in cache - return cached object or read it from current row and put it in cache
protected Object getProxyFromResultSet() throws PersistenceBrokerException { // 1. get Identity of current row: Identity oid = getIdentityFromResultSet(); // 2. return a Proxy instance: return getBroker().createProxy(getItemProxyClass(), oid); }
Reads primary key information from current RS row and generates a corresponding Identity, and returns a proxy from the Identity. @throws PersistenceBrokerException if there was an error creating the proxy class
protected int countedSize() throws PersistenceBrokerException { Query countQuery = getBroker().serviceBrokerHelper().getCountQuery(getQueryObject().getQuery()); ResultSetAndStatement rsStmt; ClassDescriptor cld = getQueryObject().getClassDescriptor(); int count = 0; // BRJ: do not use broker.getCount() because it's extent-aware // the count we need here must not include extents ! if (countQuery instanceof QueryBySQL) { String countSql = ((QueryBySQL) countQuery).getSql(); rsStmt = getBroker().serviceJdbcAccess().executeSQL(countSql, cld, Query.NOT_SCROLLABLE); } else { rsStmt = getBroker().serviceJdbcAccess().executeQuery(countQuery, cld); } try { if (rsStmt.m_rs.next()) { count = rsStmt.m_rs.getInt(1); } } catch (SQLException e) { throw new PersistenceBrokerException(e); } finally { rsStmt.close(); } return count; }
Answer the counted size @return int
public boolean absolute(int row) throws PersistenceBrokerException { boolean retval; if (supportsAdvancedJDBCCursorControl()) { retval = absoluteAdvanced(row); } else { retval = absoluteBasic(row); } return retval; }
Moves the cursor to the given row number in the iterator. If the row number is positive, the cursor moves to the given row number with respect to the beginning of the iterator. The first row is row 1, the second is row 2, and so on. @param row the row to move to in this iterator, by absolute number
private boolean absoluteBasic(int row) { boolean retval = false; if (row > m_current_row) { try { while (m_current_row < row && getRsAndStmt().m_rs.next()) { m_current_row++; } if (m_current_row == row) { retval = true; } else { setHasCalledCheck(true); setHasNext(false); retval = false; autoReleaseDbResources(); } } catch (Exception ex) { setHasCalledCheck(true); setHasNext(false); retval = false; } } else { logger.info("Your driver does not support advanced JDBC Functionality, " + "you cannot call absolute() with a position < current"); } return retval; }
absolute for basicJDBCSupport @param row
private boolean absoluteAdvanced(int row) { boolean retval = false; try { if (getRsAndStmt().m_rs != null) { if (row == 0) { getRsAndStmt().m_rs.beforeFirst(); } else { retval = getRsAndStmt().m_rs.absolute(row); } m_current_row = row; setHasCalledCheck(false); } } catch (SQLException e) { advancedJDBCSupport = false; } return retval; }
absolute for advancedJDBCSupport @param row
public boolean relative(int row) throws PersistenceBrokerException { boolean retval = false; if (supportsAdvancedJDBCCursorControl()) { try { if (getRsAndStmt().m_rs != null) { retval = getRsAndStmt().m_rs.relative(row); m_current_row += row; } } catch (SQLException e) { advancedJDBCSupport = false; } } else { if (row >= 0) { return absolute(m_current_row + row); } else { logger.info("Your driver does not support advanced JDBC Functionality, you cannot call relative() with a negative value"); } } return retval; }
Moves the cursor a relative number of rows, either positive or negative. Attempting to move beyond the first/last row in the iterator positions the cursor before/after the the first/last row. Calling relative(0) is valid, but does not change the cursor position. @param row the row to move to in this iterator, by relative number
private String safeToString(Object obj) { String toString = null; if (obj != null) { try { toString = obj.toString(); } catch (Throwable ex) { toString = "BAD toString() impl for " + obj.getClass().getName(); } } return toString; }
provides a safe toString
public synchronized RowReader getRowReader() { if (m_rowReader == null) { Configurator configurator = OjbConfigurator.getInstance(); Configuration config = configurator.getConfigurationFor(null); Class rrClass = config.getClass("RowReaderDefaultClass", RowReaderDefaultImpl.class); setRowReader(rrClass.getName()); } return m_rowReader; }
Returns the {@link org.apache.ojb.broker.accesslayer.RowReader} for this descriptor.
public void setRowReader(String newReaderClassName) { try { m_rowReader = (RowReader) ClassHelper.newInstance( newReaderClassName, ClassDescriptor.class, this); } catch (Exception e) { throw new MetadataException("Instantiating of current set RowReader failed", e); } }
sets the row reader class name for thie class descriptor
public void setClassOfObject(Class c) { m_Class = c; isAbstract = Modifier.isAbstract(m_Class.getModifiers()); // TODO : Shouldn't the HashMap in DescriptorRepository be updated as well? }
sets the class object described by this descriptor. @param c the class to describe
public void addFieldDescriptor(FieldDescriptor fld) { fld.setClassDescriptor(this); // BRJ if (m_FieldDescriptions == null) { m_FieldDescriptions = new FieldDescriptor[1]; m_FieldDescriptions[0] = fld; } else { int size = m_FieldDescriptions.length; FieldDescriptor[] tmpArray = new FieldDescriptor[size + 1]; System.arraycopy(m_FieldDescriptions, 0, tmpArray, 0, size); tmpArray[size] = fld; m_FieldDescriptions = tmpArray; // 2. Sort fields according to their getOrder() Property Arrays.sort(m_FieldDescriptions, FieldDescriptor.getComparator()); } m_fieldDescriptorNameMap = null; m_PkFieldDescriptors = null; m_nonPkFieldDescriptors = null; m_lockingFieldDescriptors = null; m_RwFieldDescriptors = null; m_RwNonPkFieldDescriptors = null; }
adds a FIELDDESCRIPTOR to this ClassDescriptor. @param fld
public void addCollectionDescriptor(CollectionDescriptor cod) { m_CollectionDescriptors.add(cod); cod.setClassDescriptor(this); // BRJ m_collectionDescriptorNameMap = null; }
Add a {@link CollectionDescriptor}.
public void addObjectReferenceDescriptor(ObjectReferenceDescriptor ord) { m_ObjectReferenceDescriptors.add(ord); ord.setClassDescriptor(this); // BRJ m_objectReferenceDescriptorsNameMap = null; }
Add a {@link ObjectReferenceDescriptor}.
public ObjectReferenceDescriptor getObjectReferenceDescriptorByName(String name) { ObjectReferenceDescriptor ord = (ObjectReferenceDescriptor) getObjectReferenceDescriptorsNameMap().get(name); // // BRJ: if the ReferenceDescriptor is not found // look in the ClassDescriptor referenced by 'super' for it // if (ord == null) { ClassDescriptor superCld = getSuperClassDescriptor(); if (superCld != null) { ord = superCld.getObjectReferenceDescriptorByName(name); } } return ord; }
Get an ObjectReferenceDescriptor by name BRJ @param name @return ObjectReferenceDescriptor or null
public CollectionDescriptor getCollectionDescriptorByName(String name) { if (name == null) { return null; } CollectionDescriptor cod = (CollectionDescriptor) getCollectionDescriptorNameMap().get(name); // // BRJ: if the CollectionDescriptor is not found // look in the ClassDescriptor referenced by 'super' for it // if (cod == null) { ClassDescriptor superCld = getSuperClassDescriptor(); if (superCld != null) { cod = superCld.getCollectionDescriptorByName(name); } } return cod; }
Get an CollectionDescriptor by name BRJ @param name @return CollectionDescriptor or null
public ClassDescriptor getSuperClassDescriptor() { if (!m_superCldSet) { if(getBaseClass() != null) { m_superCld = getRepository().getDescriptorFor(getBaseClass()); if(m_superCld.isAbstract() || m_superCld.isInterface()) { throw new MetadataException("Super class mapping only work for real class, but declared super class" + " is an interface or is abstract. Declared class: " + m_superCld.getClassNameOfObject()); } } m_superCldSet = true; } return m_superCld; }
Answers the ClassDescriptor referenced by 'super' ReferenceDescriptor. @return ClassDescriptor or null
public void addExtentClass(String newExtentClassName) { extentClassNames.add(newExtentClassName); if(m_repository != null) m_repository.addExtent(newExtentClassName, this); }
add an Extent class to the current descriptor @param newExtentClassName name of the class to add
public synchronized Vector getExtentClasses() { if (extentClassNames.size() != extentClasses.size()) { extentClasses.clear(); for (Iterator iter = extentClassNames.iterator(); iter.hasNext();) { String classname = (String) iter.next(); Class extentClass; try { extentClass = ClassHelper.getClass(classname); } catch (ClassNotFoundException e) { throw new MetadataException( "Unable to load class [" + classname + "]. Make sure it is available on the classpath.", e); } extentClasses.add(extentClass); } } return extentClasses; }
return all classes in this extent. Creation date: (02.02.2001 17:49:11) @return java.util.Vector
public synchronized Class getProxyClass() { if ((proxyClass == null) && (proxyClassName != null)) { if (isDynamicProxy()) { /** * AClute: Return the same class back if it is dynamic. This signifies * that this class become the base to a generated sub-class, regadless * of which Proxy implementation is used */ return getClassOfObject(); } else { try { proxyClass = ClassHelper.getClass(proxyClassName); } catch (ClassNotFoundException e) { throw new MetadataException(e); } } } return proxyClass; }
Insert the method's description here. Creation date: (26.01.2001 09:20:09) @return java.lang.Class
public void setProxyClass(Class newProxyClass) { proxyClass = newProxyClass; if (proxyClass == null) { setProxyClassName(null); } else { proxyClassName = proxyClass.getName(); } }
Sets the proxy class to be used. @param newProxyClass java.lang.Class
public FieldDescriptor getFieldDescriptorByName(String name) { if (name == null || m_FieldDescriptions == null) { return null; } if (m_fieldDescriptorNameMap == null) { HashMap nameMap = new HashMap(); FieldDescriptor[] descriptors = getFieldDescriptions(); for (int i = descriptors.length - 1; i >= 0; i--) { FieldDescriptor fld = descriptors[i]; nameMap.put(fld.getPersistentField().getName(), fld); } m_fieldDescriptorNameMap = nameMap; } return (FieldDescriptor) m_fieldDescriptorNameMap.get(name); }
Returns the matching {@link FieldDescriptor} - only fields of the current class will be scanned, to include fields defined the the super-classes too, use method {@link #getFieldDescriptor(boolean)}.
public FieldDescriptor getFieldDescriptorForPath(String aPath, Map pathHints) { ArrayList desc = getAttributeDescriptorsForPath(aPath, pathHints); FieldDescriptor fld = null; Object temp; if (!desc.isEmpty()) { temp = desc.get(desc.size() - 1); if (temp instanceof FieldDescriptor) { fld = (FieldDescriptor) temp; } } return fld; }
return the FieldDescriptor for the Attribute referenced in the path<br> the path may contain simple attribut names, functions and path expressions using relationships <br> ie: name, avg(price), adress.street @param aPath the path to the attribute @param pathHints a Map containing the class to be used for a segment or <em>null</em> if no segment was used. @return the FieldDescriptor or null (ie: for m:n queries)
public FieldDescriptor getAutoIncrementField() { if (m_autoIncrementField == null) { FieldDescriptor[] fds = getPkFields(); for (int i = 0; i < fds.length; i++) { FieldDescriptor fd = fds[i]; if (fd.isAutoIncrement()) { m_autoIncrementField = fd; break; } } } if (m_autoIncrementField == null) { LoggerFactory.getDefaultLogger().warn( this.getClass().getName() + ": " + "Could not find autoincrement attribute for class: " + this.getClassNameOfObject()); } return m_autoIncrementField; }
Returns the first found autoincrement field defined in this class descriptor. Use carefully when multiple autoincrement field were defined. @deprecated does not make sense because it's possible to define more than one autoincrement field. Alternative see {@link #getAutoIncrementFields}
public ValueContainer[] getCurrentLockingValues(Object o) throws PersistenceBrokerException { FieldDescriptor[] fields = getLockingFields(); ValueContainer[] result = new ValueContainer[fields.length]; for (int i = 0; i < result.length; i++) { result[i] = new ValueContainer(fields[i].getPersistentField().get(o), fields[i].getJdbcType()); } return result; }
returns an Array with an Objects CURRENT locking VALUES , BRJ @throws PersistenceBrokerException if there is an erros accessing o field values
public void updateLockingValues(Object obj) throws PersistenceBrokerException { FieldDescriptor[] fields = getLockingFields(); for (int i = 0; i < fields.length; i++) { FieldDescriptor fmd = fields[i]; if (fmd.isUpdateLock()) { PersistentField f = fmd.getPersistentField(); Object cv = f.get(obj); // int if ((f.getType() == int.class) || (f.getType() == Integer.class)) { int newCv = 0; if (cv != null) { newCv = ((Number) cv).intValue(); } newCv++; f.set(obj, new Integer(newCv)); } // long else if ((f.getType() == long.class) || (f.getType() == Long.class)) { long newCv = 0; if (cv != null) { newCv = ((Number) cv).longValue(); } newCv++; f.set(obj, new Long(newCv)); } // Timestamp else if (f.getType() == Timestamp.class) { long newCv = System.currentTimeMillis(); f.set(obj, new Timestamp(newCv)); } } } }
updates the values for locking fields , BRJ handles int, long, Timestamp respects updateLock so locking field are only updated when updateLock is true @throws PersistenceBrokerException if there is an erros accessing obj field values
public FieldDescriptor[] getNonPkFields() { if (m_nonPkFieldDescriptors == null) { // 1. collect all Primary Key fields from Field list Vector vec = new Vector(); for (int i = 0; i < m_FieldDescriptions.length; i++) { FieldDescriptor fd = m_FieldDescriptions[i]; if (!fd.isPrimaryKey()) { vec.add(fd); } } // 2. Sort fields according to their getOrder() Property Collections.sort(vec, FieldDescriptor.getComparator()); m_nonPkFieldDescriptors = (FieldDescriptor[]) vec.toArray(new FieldDescriptor[vec.size()]); } return m_nonPkFieldDescriptors; }
return an array of NONPK-FieldDescription sorted ascending according to the field-descriptions getOrder() property
public FieldDescriptor[] getPkFields() { if (m_PkFieldDescriptors == null) { // 1. collect all Primary Key fields from Field list Vector vec = new Vector(); // 1.a if descriptor describes an interface: take PK fields from an implementors ClassDescriptor if (m_isInterface) { if (getExtentClasses().size() == 0) { throw new PersistenceBrokerException( "No Implementors declared for interface " + this.getClassOfObject().getName()); } Class implementor = (Class) getExtentClasses().get(0); ClassDescriptor implCld = this.getRepository().getDescriptorFor(implementor); m_PkFieldDescriptors = implCld.getPkFields(); } else { FieldDescriptor[] fields; // 1.b if not an interface The classdescriptor must have FieldDescriptors fields = getFieldDescriptions(); // now collect all PK fields for (int i = 0; i < fields.length; i++) { FieldDescriptor fd = fields[i]; if (fd.isPrimaryKey()) { vec.add(fd); } } // 2. Sort fields according to their getOrder() Property Collections.sort(vec, FieldDescriptor.getComparator()); m_PkFieldDescriptors = (FieldDescriptor[]) vec.toArray(new FieldDescriptor[vec.size()]); } } return m_PkFieldDescriptors; }
Return an array of PK FieldDescription sorted ascending according to the field-descriptions getOrder() property
public FieldDescriptor[] getNonPkRwFields() { if (m_RwNonPkFieldDescriptors == null) { FieldDescriptor[] fields = getNonPkFields(); Collection rwFields = new ArrayList(); for (int i = 0; i < fields.length; i++) { FieldDescriptor fd = fields[i]; if (!fd.isAccessReadOnly()) { rwFields.add(fd); } } m_RwNonPkFieldDescriptors = (FieldDescriptor[]) rwFields.toArray(new FieldDescriptor[rwFields.size()]); } return m_RwNonPkFieldDescriptors; }
Returns array of read/write non pk FieldDescriptors.
public FieldDescriptor[] getAllRwFields() { if (m_RwFieldDescriptors == null) { FieldDescriptor[] fields = getFieldDescriptions(); Collection rwFields = new ArrayList(); for (int i = 0; i < fields.length; i++) { FieldDescriptor fd = fields[i]; /* arminw: if locking is enabled and the increment of locking values is done by the database, the field is read-only */ if(fd.isAccessReadOnly() || (fd.isLocking() && !fd.isUpdateLock())) { continue; } rwFields.add(fd); } m_RwFieldDescriptors = (FieldDescriptor[]) rwFields.toArray(new FieldDescriptor[rwFields.size()]); } return m_RwFieldDescriptors; }
Returns array of read/write FieldDescriptors.
public FieldDescriptor[] getLockingFields() { if (m_lockingFieldDescriptors == null) { // 1. collect all Primary Key fields from Field list Vector vec = new Vector(); for (int i = 0; i < m_FieldDescriptions.length; i++) { FieldDescriptor fd = m_FieldDescriptions[i]; if (fd.isLocking()) { vec.add(fd); } } // 2. Sort fields according to their getOrder() Property Collections.sort(vec, FieldDescriptor.getComparator()); m_lockingFieldDescriptors = (FieldDescriptor[]) vec.toArray(new FieldDescriptor[vec.size()]); } return m_lockingFieldDescriptors; }
return an array of FieldDescription for optimistic locking sorted ascending according to the field-descriptions getOrder() property
public ArrayList getAttributeDescriptorsForPath(String aPath, Map pathHints) { return getAttributeDescriptorsForCleanPath(SqlHelper.cleanPath(aPath), pathHints); }
return all AttributeDescriptors for the path<br> ie: partner.addresses.street returns a Collection of 3 AttributeDescriptors (ObjectReferenceDescriptor, CollectionDescriptor, FieldDescriptor)<br> ie: partner.addresses returns a Collection of 2 AttributeDescriptors (ObjectReferenceDescriptor, CollectionDescriptor) @param aPath the cleaned path to the attribute @param pathHints a Map containing the class to be used for a segment or <em>null</em> if no segment was used. @return ArrayList of AttributeDescriptors
private ArrayList getAttributeDescriptorsForCleanPath(String aPath, Map pathHints) { ArrayList result = new ArrayList(); ClassDescriptor cld = this; ObjectReferenceDescriptor ord; FieldDescriptor fld; String currPath = aPath; String segment; StringBuffer processedSegment = new StringBuffer(); int sepPos; Class itemClass; while (currPath.length() > 0) { sepPos = currPath.indexOf("."); if (sepPos >= 0) { segment = currPath.substring(0, sepPos); currPath = currPath.substring(sepPos + 1); } else { segment = currPath; currPath = ""; } if (processedSegment.length() > 0) { processedSegment.append("."); } processedSegment.append(segment); // look for 1:1 or n:1 Relationship ord = cld.getObjectReferenceDescriptorByName(segment); if (ord == null) { // look for 1:n or m:n Relationship ord = cld.getCollectionDescriptorByName(segment); } if (ord != null) { // BRJ : look for hints for the processed segment // ie: ref pointng to ClassA and ref.ref pointing to ClassC List hintClasses = pathHints != null ? (List) pathHints.get(processedSegment.toString()) : null; if (hintClasses != null && hintClasses.get(0) != null) { itemClass = (Class) hintClasses.get(0); } else { itemClass = ord.getItemClass(); } cld = cld.getRepository().getDescriptorFor(itemClass); result.add(ord); } else { // look for Field fld = cld.getFieldDescriptorByName(segment); if (fld != null) { result.add(fld); } } } return result; }
return all AttributeDescriptors for the path<br> ie: partner.addresses.street returns a Collection of 3 AttributeDescriptors (ObjectReferenceDescriptor, CollectionDescriptor, FieldDescriptor)<br> ie: partner.addresses returns a Collection of 2 AttributeDescriptors (ObjectReferenceDescriptor, CollectionDescriptor) @param aPath the cleaned path to the attribute @param pathHints a Map containing the class to be used for a segment or <em>null</em> if no segment is used. @return ArrayList of AttributeDescriptors
public Constructor getZeroArgumentConstructor() { if (zeroArgumentConstructor == null && !alreadyLookedupZeroArguments) { try { zeroArgumentConstructor = getClassOfObject().getConstructor(NO_PARAMS); } catch (NoSuchMethodException e) { //no public zero argument constructor available let's try for a private/protected one try { zeroArgumentConstructor = getClassOfObject().getDeclaredConstructor(NO_PARAMS); //we found one, now let's make it accessible zeroArgumentConstructor.setAccessible(true); } catch (NoSuchMethodException e2) { //out of options, log the fact and let the method return null LoggerFactory.getDefaultLogger().warn( this.getClass().getName() + ": " + "No zero argument constructor defined for " + this.getClassOfObject()); } } alreadyLookedupZeroArguments = true; } return zeroArgumentConstructor; }
returns the zero argument constructor for the class represented by this class descriptor or null if a zero argument constructor does not exist. If the zero argument constructor for this class is not public it is made accessible before being returned.
public String toXML() { RepositoryTags tags = RepositoryTags.getInstance(); String eol = System.getProperty("line.separator"); // comment on class StringBuffer result = new StringBuffer(1024); result.append( eol); result.append( " <!-- Mapping for Class "); result.append( this.getClassNameOfObject()); result.append( " -->"); result.append( eol ); // opening tag and attributes result.append( " "); result.append( tags.getOpeningTagNonClosingById(CLASS_DESCRIPTOR)); result.append( eol ); // class result.append( " "); result.append( tags.getAttribute(CLASS_NAME, this.getClassNameOfObject())); result.append( eol ); // isolation level is optional if (null != getRepository()) { if (getIsolationLevel() != this.getRepository().getDefaultIsolationLevel()) { result.append( " "); result.append( tags.getAttribute(ISOLATION_LEVEL, this.isolationLevelXml()) ); result.append( eol ); } } Class theProxyClass = null; try { theProxyClass = this.getProxyClass(); } catch (Throwable t) { // Ignore this exception, just try to get the Class object of the // proxy class in order to be able to decide, whether the class // is a dynamic proxy or not. } // proxy is optional if (theProxyClass != null) { if (isDynamicProxy()) // tomdz: What about VirtualProxy ? { result.append( " "); result.append( tags.getAttribute(CLASS_PROXY, DYNAMIC_STR)); result.append( eol ); } else { result.append( " "); result.append( tags.getAttribute(CLASS_PROXY, this.getProxyClassName())); result.append( eol ); } result.append( " "); result.append( tags.getAttribute(PROXY_PREFETCHING_LIMIT, "" + this.getProxyPrefetchingLimit())); result.append( eol ); } // schema is optional if (this.getSchema() != null) { result.append( " "); result.append( tags.getAttribute(SCHEMA_NAME, this.getSchema())); result.append( eol ); } // table name if (this.getTableName() != null) { result.append(" "); result.append( tags.getAttribute(TABLE_NAME, this.getTableName())); result.append( eol ); } // rowreader is optional if (this.getRowReaderClassName() != null) { result.append( " "); result.append( tags.getAttribute(ROW_READER, this.getRowReaderClassName())); result.append( eol ); } //accept-locks is optional, enabled by default if (!this.acceptLocks) { result.append( " "); result.append( tags.getAttribute(ACCEPT_LOCKS, "false")); result.append( eol ); } // sequence manager attribute not yet implemented // initialization method is optional if (this.getInitializationMethod() != null) { result.append( " "); result.append( tags.getAttribute(INITIALIZATION_METHOD, this.getInitializationMethod().getName())); result.append( eol ); } // factory class is optional if (this.getFactoryClass() != null) { result.append( " "); result.append( tags.getAttribute(FACTORY_CLASS, this.getFactoryClass().getName()) ); result.append( eol ); } // factory method is optional if (this.getFactoryMethod() != null) { result.append( " "); result.append( tags.getAttribute(FACTORY_METHOD, this.getFactoryMethod().getName()) ); result.append( eol ); } //reference refresh is optional, disabled by default if (isAlwaysRefresh()) { result.append( " "); result.append( tags.getAttribute(REFRESH, "true")); result.append( eol ); } result.append( " >"); result.append( eol ); // end of attributes // begin of elements if (isInterface()) { // extent-class for (int i = 0; i < getExtentClassNames().size(); i++) { result.append( " "); result.append( tags.getOpeningTagNonClosingById(CLASS_EXTENT)); result.append( " " ); result.append( tags.getAttribute(CLASS_REF, getExtentClassNames().get(i).toString()) ); result.append( " />"); result.append( eol ); } } else { // class extent is optional if (isExtent()) { for (int i = 0; i < getExtentClassNames().size(); i++) { result.append( " "); result.append( tags.getOpeningTagNonClosingById(CLASS_EXTENT)); result.append( " " ); result.append( tags.getAttribute(CLASS_REF, getExtentClassNames().get(i).toString()) ); result.append( " />"); result.append( eol ); } } // write all FieldDescriptors FieldDescriptor[] fields = getFieldDescriptions(); for (int i = 0; i < fields.length; i++) { result.append( fields[i].toXML() ); } // write optional ReferenceDescriptors Vector refs = getObjectReferenceDescriptors(); for (int i = 0; i < refs.size(); i++) { result.append( ((ObjectReferenceDescriptor) refs.get(i)).toXML() ); } // write optional CollectionDescriptors Vector cols = getCollectionDescriptors(); for (int i = 0; i < cols.size(); i++) { result.append( ((CollectionDescriptor) cols.get(i)).toXML() ); } // write optional IndexDescriptors for (int i = 0; i < indexes.size(); i++) { IndexDescriptor indexDescriptor = (IndexDescriptor) indexes.elementAt(i); result.append( indexDescriptor.toXML() ); } // Write out the procedures if (this.getInsertProcedure() != null) { result.append( this.getInsertProcedure().toXML() ); } if (this.getUpdateProcedure() != null) { result.append( this.getUpdateProcedure().toXML() ); } if (this.getDeleteProcedure() != null) { result.append( this.getDeleteProcedure().toXML() ); } } result.append( " "); result.append( tags.getClosingTagById(CLASS_DESCRIPTOR) ); return result.toString(); }
/* @see XmlCapable#toXML()
private synchronized void setInitializationMethod(Method newMethod) { if (newMethod != null) { // make sure it's a no argument method if (newMethod.getParameterTypes().length > 0) { throw new MetadataException( "Initialization methods must be zero argument methods: " + newMethod.getClass().getName() + "." + newMethod.getName()); } // make it accessible if it's not already if (!newMethod.isAccessible()) { newMethod.setAccessible(true); } } this.initializationMethod = newMethod; }
sets the initialization method for this descriptor
public synchronized void setInitializationMethod(String newMethodName) { Method newMethod = null; if (newMethodName != null) { initializationMethodName = newMethodName; try { // see if we have a publicly accessible method by the name newMethod = getClassOfObject().getMethod(newMethodName, NO_PARAMS); } catch (NoSuchMethodException e) { try { // no publicly accessible method, see if there is a private/protected one newMethod = getClassOfObject().getDeclaredMethod(newMethodName, NO_PARAMS); } catch (NoSuchMethodException e2) { // there is no such method available throw new MetadataException( "Invalid initialization method, there is not" + " a zero argument method named " + newMethodName + " on class " + getClassOfObject().getName() + "."); } } } setInitializationMethod(newMethod); }
sets the initialization method for this descriptor by name
private synchronized void setFactoryMethod(Method newMethod) { if (newMethod != null) { // make sure it's a no argument method if (newMethod.getParameterTypes().length > 0) { throw new MetadataException( "Factory methods must be zero argument methods: " + newMethod.getClass().getName() + "." + newMethod.getName()); } // make it accessible if it's not already if (!newMethod.isAccessible()) { newMethod.setAccessible(true); } } this.factoryMethod = newMethod; }
Specify the method to instantiate objects represented by this descriptor. @see #setFactoryClass
public synchronized void setFactoryMethod(String factoryMethodName) { Method newMethod = null; this.factoryMethodName = factoryMethodName; if (factoryMethodName != null) { try { // see if we have a publicly accessible method by the name newMethod = getFactoryClass().getMethod(factoryMethodName, NO_PARAMS); } catch (NoSuchMethodException e) { try { // no publicly accessible method, see if there is a private/protected one newMethod = getFactoryClass().getDeclaredMethod(factoryMethodName, NO_PARAMS); } catch (NoSuchMethodException e2) { // there is no such method available throw new MetadataException( "Invalid factory method, there is not" + " a zero argument method named " + factoryMethodName + " on class " + getFactoryClass().getName() + "."); } } } setFactoryMethod(newMethod); }
sets the initialization method for this descriptor by name
public boolean useIdentityColumnField() { if(useIdentityColumn == 0) { useIdentityColumn = -1; FieldDescriptor[] pkFields = getPkFields(); for (int i = 0; i < pkFields.length; i++) { // to find the identity column we search for a autoincrement // read-only field if (pkFields[i].isAutoIncrement() && pkFields[i].isAccessReadOnly()) { useIdentityColumn = 1; break; } } } return useIdentityColumn == 1; }
Returns <em>true</em> if an DB Identity column field based sequence manager was used. In that cases we will find an autoincrement field with read-only access and return true, otherwise false.
public List getObjectReferenceDescriptors(boolean withInherited) { if(withInherited && getSuperClassDescriptor() != null) { List result = new ArrayList(m_ObjectReferenceDescriptors); result.addAll(getSuperClassDescriptor().getObjectReferenceDescriptors(true)); return result; } else { return m_ObjectReferenceDescriptors; } }
Returns all defined {@link ObjectReferenceDescriptor}. @param withInherited If <em>true</em> inherited super class references will be included.
public List getCollectionDescriptors(boolean withInherited) { if(withInherited && getSuperClassDescriptor() != null) { List result = new ArrayList(m_CollectionDescriptors); result.addAll(getSuperClassDescriptor().getCollectionDescriptors(true)); return result; } else { return m_CollectionDescriptors; } }
Returns all defined {@link CollectionDescriptor} for this class descriptor. @param withInherited If <em>true</em> inherited super class references will be included.
public FieldDescriptor[] getFieldDescriptor(boolean withInherited) { if(withInherited && getSuperClassDescriptor() != null) { /* arminw: only return no-PK fields, because all PK fields are declared in sub-class too. */ FieldDescriptor[] superFlds = getSuperClassDescriptor().getFieldDescriptorNonPk(true); if(m_FieldDescriptions == null) { m_FieldDescriptions = new FieldDescriptor[0]; } FieldDescriptor[] result = new FieldDescriptor[m_FieldDescriptions.length + superFlds.length]; System.arraycopy(m_FieldDescriptions, 0, result, 0, m_FieldDescriptions.length); System.arraycopy(superFlds, 0, result, m_FieldDescriptions.length, superFlds.length); // System.out.println("all fields: " + ArrayUtils.toString(result)); return result; } else { return m_FieldDescriptions; } }
Return an array of all {@link FieldDescriptor} for this represented class, if parameter <em>withInherited</em> is <em>true</em> all inherited descriptor of declared super classes are included. @param withInherited If <em>true</em> inherited super class fields will be included.
public FieldDescriptor[] getFieldDescriptorNonPk(boolean withInherited) { if(withInherited && getSuperClassDescriptor() != null) { FieldDescriptor[] flds = getNonPkFields(); FieldDescriptor[] superFlds = getSuperClassDescriptor().getFieldDescriptorNonPk(true); FieldDescriptor[] result = new FieldDescriptor[flds.length + superFlds.length]; System.arraycopy(flds, 0, result, 0, flds.length); System.arraycopy(superFlds, 0, result, flds.length, superFlds.length); return result; } else { return getNonPkFields(); } }
Return an array of NON-PK {@link FieldDescriptor}, if parameter <em>withInherited</em> is <em>true</em> all inherited descriptor of declared super classes are included. @param withInherited If <em>true</em> inherited super class fields will be included.
public void validateOptions() throws XDocletException { if ((_databaseName == null) || (_databaseName.length() == 0)) { throw new XDocletException(Translator.getString(XDocletModulesOjbMessages.class, XDocletModulesOjbMessages.DATABASENAME_IS_REQUIRED)); } }
Called to validate configuration parameters. @exception XDocletException Is not thrown
@Api public List<RasterTile> paint(TiledRasterLayerServiceState tileServiceState, CoordinateReferenceSystem boundsCrs, Envelope bounds, double scale) throws GeomajasException { try { CrsTransform layerToMap = geoService.getCrsTransform(tileServiceState.getCrs(), boundsCrs); CrsTransform mapToLayer = geoService.getCrsTransform(boundsCrs, tileServiceState.getCrs()); bounds = clipBounds(tileServiceState, bounds); if (bounds.isNull()) { return new ArrayList<RasterTile>(); } // find the center of the map in map coordinates (positive y-axis) Coordinate boundsCenter = new Coordinate((bounds.getMinX() + bounds.getMaxX()) / 2, (bounds.getMinY() + bounds.getMaxY()) / 2); // find zoomlevel // scale in pix/m should just above the given scale so we have at least one // screen pixel per google pixel ! (otherwise text unreadable) int zoomLevel = getBestZoomLevelForScaleInPixPerMeter(tileServiceState, mapToLayer, boundsCenter, scale); log.debug("zoomLevel={}", zoomLevel); // find the google indices for the center // google indices determine the row and column of the 256x256 image // in the big google square for the given zoom zoomLevel // the resulting indices are floating point values as the center // is not coincident with an image corner !!!! Coordinate indicesCenter; indicesCenter = getTileIndicesFromMap(mapToLayer, boundsCenter, zoomLevel); // Calculate the width in map units of the image that contains the // center Coordinate indicesUpperLeft = new Coordinate(Math.floor(indicesCenter.x), Math.floor(indicesCenter.y)); Coordinate indicesLowerRight = new Coordinate(indicesUpperLeft.x + 1, indicesUpperLeft.y + 1); Coordinate mapUpperLeft = getMapFromTileIndices(layerToMap, indicesUpperLeft, zoomLevel); Coordinate mapLowerRight = getMapFromTileIndices(layerToMap, indicesLowerRight, zoomLevel); double width = Math.abs(mapLowerRight.x - mapUpperLeft.x); if (0 == width) { width = 1.0; } double height = Math.abs(mapLowerRight.y - mapUpperLeft.y); if (0 == height) { height = 1.0; } // Calculate the position and indices of the center image corner // in map space double xCenter = boundsCenter.x - (indicesCenter.x - indicesUpperLeft.x) * width; double yCenter = boundsCenter.y + (indicesCenter.y - indicesUpperLeft.y) * height; int iCenter = (int) indicesUpperLeft.x; int jCenter = (int) indicesUpperLeft.y; // Calculate the position and indices of the upper left image corner // that just falls off the screen double xMin = xCenter; int iMin = iCenter; while (xMin > bounds.getMinX() && iMin > 0) { xMin -= width; iMin--; } double yMax = yCenter; int jMin = jCenter; while (yMax < bounds.getMaxY() && jMin > 0) { yMax += height; jMin--; } // Calculate the indices of the lower right corner // that just falls off the screen int levelMax = POWERS_OF_TWO[zoomLevel] - 1; double xMax = xCenter; int iMax = iCenter; while (xMax < bounds.getMaxX() && iMax <= levelMax) { xMax += width; iMax++; } double yMin = yCenter; int jMax = jCenter; while (yMin > bounds.getMinY() && jMax <= levelMax) { yMin -= height; jMax++; } Coordinate upperLeft = new Coordinate(xMin, yMax); // calculate the images List<RasterTile> result = new ArrayList<RasterTile>(); if (log.isDebugEnabled()) { log.debug("bounds =" + bounds); log.debug("tilebounds " + xMin + ", " + xMax + ", " + yMin + ", " + yMax); log.debug("indices " + iMin + ", " + iMax + ", " + jMin + ", " + jMax); } int xScreenUpperLeft = (int) Math.round(upperLeft.x * scale); int yScreenUpperLeft = (int) Math.round(upperLeft.y * scale); int screenWidth = (int) Math.round(scale * width); int screenHeight = (int) Math.round(scale * height); for (int i = iMin; i < iMax; i++) { for (int j = jMin; j < jMax; j++) { // Using screen coordinates: int x = xScreenUpperLeft + (i - iMin) * screenWidth; int y = yScreenUpperLeft - (j - jMin) * screenHeight; RasterTile image = new RasterTile(new Bbox(x, -y, screenWidth, screenHeight), tileServiceState.getId() + "." + zoomLevel + "." + i + "," + j); image.setCode(new TileCode(zoomLevel, i, j)); String url = tileServiceState.getUrlSelectionStrategy().next(); url = url.replace("${level}", Integer.toString(zoomLevel)); url = url.replace("${x}", Integer.toString(i)); url = url.replace("${y}", Integer.toString(j)); image.setUrl(url); log.debug("adding image {}", image); result.add(image); } } return result; } catch (TransformException e) { throw new GeomajasException(e, ExceptionCode.RENDER_TRANSFORMATION_FAILED); } }
Paint raster layer. @param tileServiceState state (as this is a singleton) @param boundsCrs crs for bounds @param bounds bounds for which tiles are needed @param scale scale for rendering @return list of raster tiles @throws GeomajasException oops @since 1.8.0
public void setConversionPattern(final String conversionPattern) { this.conversionPattern = OptionConverter.convertSpecialChars(conversionPattern); head = createPatternParser(this.conversionPattern).parse(); }
Set the <b>ConversionPattern</b> option. This is the string which controls formatting and consists of a mix of literal content and conversion specifiers. @param conversionPattern conversion pattern.
protected org.apache.log4j.helpers.PatternParser createPatternParser(final String pattern) { return new FoundationLoggingPatternParser(pattern); }
Returns PatternParser used to parse the conversion string. Subclasses may override this to return a subclass of PatternParser which recognize custom conversion characters. @since 0.9.0
public String format(final LoggingEvent event) { final StringBuffer buf = new StringBuffer(); for (PatternConverter c = head; c != null; c = c.next) { c.format(buf, event); } return buf.toString(); }
Formats a logging event to a writer. @param event logging event to be formatted.
protected String getUniqueString(FieldDescriptor field) throws SequenceManagerException { ResultSetAndStatement rsStmt = null; String returnValue = null; try { rsStmt = getBrokerForClass().serviceJdbcAccess().executeSQL( "select newid()", field.getClassDescriptor(), Query.NOT_SCROLLABLE); if (rsStmt.m_rs.next()) { returnValue = rsStmt.m_rs.getString(1); } else { LoggerFactory.getDefaultLogger().error(this.getClass() + ": Can't lookup new oid for field " + field); } } catch (PersistenceBrokerException e) { throw new SequenceManagerException(e); } catch (SQLException e) { throw new SequenceManagerException(e); } finally { // close the used resources if (rsStmt != null) rsStmt.close(); } return returnValue; }
returns a unique String for given field. the returned uid is unique accross all tables.
public PersistenceBroker getInnermostDelegate() { PersistenceBroker broker = this.m_broker; while (broker != null && broker instanceof DelegatingPersistenceBroker) { broker = ((DelegatingPersistenceBroker) broker).getDelegate(); if (this == broker) { return null; } } return broker; }
If my underlying {@link org.apache.ojb.broker.PersistenceBroker} is not a {@link DelegatingPersistenceBroker}, returns it, otherwise recursively invokes this method on my delegate. <p> Hence this method will return the first delegate that is not a {@link DelegatingPersistenceBroker}, or <tt>null</tt> when no non-{@link DelegatingPersistenceBroker} delegate can be found by transversing this chain. <p> This method is useful when you may have nested {@link DelegatingPersistenceBroker}s, and you want to make sure to obtain a "genuine" {@link org.apache.ojb.broker.PersistenceBroker} implementaion instance.
public static void setJdbcType(String typeName, int typeIndex, JdbcType type) { setJdbcTypeByName(typeName, type); setJdbcTypeByTypesIndex(typeIndex, type); }
Set the {@link JdbcType} by name and index. @param typeName Name of the type @param typeIndex index of the type @param type the type
public static JdbcType getJdbcTypeByName(String typeName) { JdbcType result = null; result = (JdbcType) jdbcObjectTypesFromName.get(typeName.toLowerCase()); if (result == null) { throw new OJBRuntimeException("The type " + typeName + " can not be handled by OJB." + " Please specify only types as defined by java.sql.Types."); } return result; }
Lookup the {@link JdbcType} by name. If name was not found an exception is thrown.