name mode size
FlatFileAdaptor.xcodeproj 040000
LoginPanel.bproj 040000
CustomInfo.plist 100644 79B
FileScanning.h 100644 2.69kB
FileScanning.m 100644 3.34kB
FlatFileAdaptor.h 100644 3.8kB
FlatFileAdaptor.m 100644 5.92kB
FlatFileChannel.h 100644 3.94kB
FlatFileChannel.m 100644 20.45kB
FlatFileColumn.h 100644 3.71kB
FlatFileColumn.m 100644 6.25kB
FlatFileContext.h 100644 3.53kB
FlatFileContext.m 100644 13.48kB
FlatFileDescription.h 100644 2.89kB
FlatFileDescription.m 100644 6.02kB
FlatFileSQLExpression.h 100644 3.07kB
FlatFileSQLExpression.m 100644 5.37kB
Import Log.rtf 100644 3.56kB
Makefile.postamble 100644 5.12kB
Makefile.preamble 100644 3.57kB
PB.project 100644 2.34kB 100644 5.34kB
ReadMe.orig.html 100644 6.08kB
# FlatFile Adaptor The **FlatFileAdaptor** provides **EOF** with access to ASCII text files. Its purpose is not to take the place of a real SQL database, but to elucidate the issues you might encounter when implementing your own custom adaptor. These include: * Connecting to your database via a connection dictionary and a login panel. * Mapping external data types like DATETIME and VARCHAR2 to object values such as <tt>NSCalendarDate</tt> and <tt>NSString</tt>. * Supporting your database's transactional features (e.g. nesting and rollback). * Generating a schema from a given <tt>EOModel</tt> and configuring an <tt>EOModel</tt> from an existing database. * Generating and executing SQL statements for operations like insert, update, delete and select. While this adaptor addresses these problems, it handles some of them differently than a normal SQL adaptor would. **FlatFileAdaptor** defines a database as a collection of files within a directory. Rather than connecting to a server, it reads these files and parses them according to the row and column separators specified in its connection dictionary. It only supports a few simple external data types: Number, String, Data and Date, whose default internal mappings are <tt>NSDecimalNumber</tt>, <tt>NSString</tt>, <tt>NSData</tt>, and <tt>NSCalendarDate</tt>, respectively. Within the scope of a transaction, all files are cached in memory as <tt>NSData</tt>s. Modified files are saved when the transaction is committed. If it's aborted, their cached editions are released and reread the next time they are needed. Nested transactions are not supported. Generating a Flat File schema consists of writing simple column headers to a set of files. These headers are later used to map <tt>EOAttributes</tt> to their corresponding columns. Because there is no SQL server behind the scenes, **FlatFileChannel** has to perform basic database operations itself. It evaluates <tt>EOQualifiers</tt> in memory via `evaluateWithObject:` and sorts its results using EOF's extensions to <tt>NSArray</tt>. A normal adaptor would simply pass SQL strings generated by its <tt>EOSQLExpression</tt> subclass to a server via `evaluateExpression:` and process the results. Its <tt>EOAdaptorChannel</tt> subclass's `deleteRowsDescribedByQualifier:` might look like: ``` - (void)deleteRowsDescribedByQualifier:(EOQualifier *)qualifier entity:(EOEntity *)entity { EOSQLExpression *sqlExpression; NSDictionary *pkDict = nil; if (_delegateRespondsTo.willDeleteRows) { EODelegateResponse response; response = [_delegate adaptorChannel:self willDeleteRowsDescribedByQualifier:qualifier entity:entity]; if (response != EODelegateApproves) return; } sqlExpression = [[[_context adaptor] expressionClass] deleteStatementWithQualifier:qualifier entity:entity]; [self evaluateExpression:sqlExpression]; if (_cda.rpc == 0) { // check database error return code [NSException raise:EOGeneralAdaptorException format:@"%@ -- %@ 0x%x: Attempted to delete a row that is not in the database", NSStringFromSelector(_cmd), NSStringFromClass([self class]), self]; } if (_delegateRespondsTo.didDeleteRows) [_delegate adaptorChannel:self didDeleteRowsDescribedByQualifier:qualifier entity:entity]; } ``` Despite such implementation differences, FlatFileAdaptor is structured the same way a SQL adaptor would be. **Classes** <table border="0"> <tbody> <tr align="LEFT" valign="TOP"> <td>FlatFileAdaptor</td> <td>Manages connection information and type mappings.</td> </tr> <tr align="LEFT" valign="TOP"> <td>FlatFileContext</td> <td>Maintains files' state within a transaction scope.</td> </tr> <tr> <td>FlatFileChannel</td> <td>Manipulates the NSData representations of the files.</td> </tr> <tr align="LEFT" valign="TOP"> <td align="LEFT" valign="TOP">FlatFileColumn</td> <td>Facilitates conversion of ASCII strings to object values.</td> </tr> <tr align="LEFT" valign="TOP"> <td align="LEFT" valign="TOP">FlatFileSQLExpression</td> <td>Provides support for creating and removing files via FlatFileChannel's evaluateExpression: which parses simple (nonñSQL) statements. Don't be fooled by the class name.</td> </tr> </tbody> </table> **Other Components** <table border="0"> <tbody> <tr align="LEFT" valign="TOP"> <td>FlatFileDescription</td> <td>Adds a category on FlatFileChannel to configure an EOModel to reflect the structure of an existing database.</td> </tr> <tr align="LEFT" valign="TOP"> <td>FileScanning</td> <td>Contains a simple function (FFNextTokenIn) for parsing ASCII text (read: char *) into a stream of tokens.</td> </tr> <tr align="LEFT" valign="TOP"> <td>FlatFileLoginPanel</td> <td>Provides a simple UI for connecting to a "database," which is really just a set of files.</td> </tr> </tbody> </table> **Open Issues** * nested transactions * string values with the row or column separator as a substring * joins * file timestamps * locking * * * ## Using FlatFile Adaptor Place the FlatFile adaptor in `$(NEXT_ROOT)/Library/Framework`, and the EnterpriseObjects framework will automatically find it for use with EOModeler and your application. * * * _Example by: Patrick Gates._ _Last updated: September 1, 1998._