name mode size
FlatFileAdaptor.xcodeproj 040000
LoginPanel.bproj 040000
CustomInfo.plist 100644 0 kb
FileScanning.h 100644 3 kb
FileScanning.m 100644 3 kb
FlatFileAdaptor.h 100644 4 kb
FlatFileAdaptor.m 100644 6 kb
FlatFileChannel.h 100644 4 kb
FlatFileChannel.m 100644 20 kb
FlatFileColumn.h 100644 4 kb
FlatFileColumn.m 100644 6 kb
FlatFileContext.h 100644 3 kb
FlatFileContext.m 100644 13 kb
FlatFileDescription.h 100644 3 kb
FlatFileDescription.m 100644 6 kb
FlatFileSQLExpression.h 100644 3 kb
FlatFileSQLExpression.m 100644 5 kb
Import Log.rtf 100644 3 kb
Makefile.postamble 100644 5 kb
Makefile.preamble 100644 3 kb
PB.project 100644 2 kb
README.md 100644 5 kb
ReadMe.orig.html 100644 6 kb
README.md
# 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._