com.cassinidivision.core.eoaccess
Class EOLoader

java.lang.Object
  extended bycom.webobjects.eocontrol.EOCustomObject
      extended bycom.cassinidivision.core.eoaccess.EOLoader
All Implemented Interfaces:
_EOPrivateMemento, EODeferredFaulting, EOEnterpriseObject, EOFaulting, EOKeyValueCoding, EOKeyValueCoding._BestBindingCreation._ForwardingBindingCheck, EOKeyValueCoding._KeyBindingCreation, EOKeyValueCodingAdditions, EORelationshipManipulation, EOValidation, NSKeyValueCoding, NSKeyValueCoding._KeyBindingCreation, NSKeyValueCoding._ReflectionKeyBindingCreation.Callback, NSKeyValueCoding.ErrorHandling, NSKeyValueCodingAdditions, NSValidation, Serializable

public class EOLoader
extends EOCustomObject

Core enterprise object to XML import/export functionality.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.webobjects.eocontrol.EOCustomObject
EOCustomObject._BooleanFieldBinding, EOCustomObject._FieldBinding, EOCustomObject._LazyFieldBinding, EOCustomObject._NumberFieldBinding
 
Nested classes inherited from class com.webobjects.eocontrol.EOKeyValueCodingAdditions
EOKeyValueCodingAdditions.DefaultImplementation, EOKeyValueCodingAdditions.Utility
 
Nested classes inherited from class com.webobjects.foundation.NSKeyValueCoding
NSKeyValueCoding._BooleanMethodBinding, NSKeyValueCoding._ForwardingBinding, NSKeyValueCoding._KeyBinding, NSKeyValueCoding._KeyBindingCreation, NSKeyValueCoding._MethodBinding, NSKeyValueCoding._NumberMethodBinding, NSKeyValueCoding._ReflectionKeyBindingCreation, NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.Null, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.ValueAccessor
 
Nested classes inherited from class com.webobjects.eocontrol.EOKeyValueCoding
EOKeyValueCoding._BestBindingCreation, EOKeyValueCoding._KeyBindingCreation, EOKeyValueCoding._StoredForwardingBinding
 
Nested classes inherited from class com.webobjects.foundation.NSValidation
NSValidation._MethodBinding, NSValidation._ValidationBinding, NSValidation.DefaultImplementation, NSValidation.Utility, NSValidation.ValidationException
 
Nested classes inherited from class com.webobjects.eocontrol._EOPrivateMemento
_EOPrivateMemento.DefaultImplementation
 
Field Summary
 
Fields inherited from class com.webobjects.eocontrol.EOCustomObject
_CLASS
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
_KeyPathSeparatorChar, KeyPathSeparator
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding
NullValue
 
Constructor Summary
EOLoader()
           
 
Method Summary
 NSArray allEntities()
          Convenience method: return all known entities across all known EOModels.
 boolean charLegalInXML(char c)
          Determine if a character value can be represented in XML.
 boolean charMayAppearUnescapedInXML(char c)
          Determine if a character value can appear without escape sequences in XML.
 NSMutableDictionary contentDictionaryForAllEntities()
          Convenience method: return a content dictionary containing data for all entities.
 NSMutableDictionary contentDictionaryForEntities(NSArray entityList)
          Retrieve all data corresponding to the entities supplied into a single dictionary.
 NSMutableDictionary contentDictionaryForEntity(EOEntity entity)
          Retrieve all data corresponding to the entity supplied into a single dictionary.
 String decodeAmpersands(String s)
          Unescape any XML-encoded ampersands found in the string supplied.
 NSData decodeFromBase64(NSData data)
          Decode data provided from a Base64 representation.
 String encodeAmpersands(String s)
          XML-escape any ampersands found in the string supplied.
 NSData encodeToBase64(NSData data)
          Encode data provided into a Base64 representation.
 String exportAllContent()
          Retrieve XML export data for all known entities.
 void importContent(String theXML)
          Read XML data and use to build new EO instances.
 void importFromFolder(String path)
          Read XML import data from the directory path specified.
 void processDictionary(NSDictionary dict, boolean stringwards)
          Convert a raw row data dictionary into a format suitable for importing or exporting data.
 void processInnerDictionary(NSMutableDictionary row, boolean stringwards)
          Convert a raw row into a format suitable for importing or exporting data.
 NSArray rowsForEntity(EOEntity entity, EOEditingContext ec)
          Return all rows for the entity requested.
 String stringWithDodgyUnicodeEscaped(String s)
          Escape unicode characters that may cause problems in XML documents, including the null (0) character.
 String stringWithDodgyUnicodeEscapedIncludeZero(String s, boolean includeZero)
          Escape unicode characters that may cause problems in XML documents, optionally including the null (0) character.
 String stringWithDodgyUnicodeUnescaped(String s)
          Unescape encoded unicode characters from XML documents.
 void writeAllContentToFolder(String path)
          Write out all EO data to the top-level directory specified.
 void writeContentForEntityIntoFolder(EOEntity entity, String path)
          Export XML data for the given entity to the directory path specified.
 void writeObjectsForEntity(NSArray objects, EOEntity entity, EOEditingContext ec)
          Insert an array of newly-generated enterprise objects into the database.
 String xmlEncodeNonASCIICharacters(String string)
          Convert string into an XML-compatible format.
 String xmlStringForDictionary(NSDictionary dict)
          Convert a dictionary containing raw row entity data into an XML format.
 
Methods inherited from class com.webobjects.eocontrol.EOCustomObject
__classDescription, __clearPendingChanges, __editingContext, __globalID, __hasAuxillaryObservers, __hasPendingChanges, __hasPendingUpdate, __isInitialized, __isPendingDeletion, __isPendingInsertion, __isShared, __lastSnapshot, __originalSnapshot, __retainCount, __setAuxillaryObservers, __setClassDescription, __setEditingContext, __setGlobalID, __setInitialized, __setLastSnapshot, __setOriginalSnapshot, __setPendingDeletion, __setPendingInsertion, __setPendingUpdate, __setRetainCount, __setShared, _createKeyGetBindingForKey, _createKeySetBindingForKey, _createStoredKeyGetBindingForKey, _createStoredKeySetBindingForKey, _fieldKeyBinding, _forwardingBindingNeededForClass, _keyGetBindingForKey, _keySetBindingForKey, _methodKeyGetBinding, _methodKeySetBinding, _otherStorageBinding, _storedKeyGetBindingForKey, _storedKeySetBindingForKey, addObjectToBothSidesOfRelationshipWithKey, addObjectToPropertyWithKey, allPropertyKeys, attributeKeys, awakeFromClientUpdate, awakeFromFetch, awakeFromInsertion, canAccessFieldsDirectly, changesFromSnapshot, classDescription, classDescriptionForDestinationKey, clearFault, clearProperties, deleteRuleForRelationshipKey, editingContext, entityName, eoDescription, eoShallowDescription, equals, faultHandler, handleQueryWithUnboundKey, handleTakeValueForUnboundKey, hashCode, inverseForRelationshipKey, invokeRemoteMethod, isFault, isToManyKey, opaqueState, ownsDestinationObjectsForRelationshipKey, prepareValuesForClient, propagateDeleteWithEditingContext, reapplyChangesFromDictionary, removeObjectFromBothSidesOfRelationshipWithKey, removeObjectFromPropertyWithKey, shouldUseStoredAccessors, snapshot, storedValueForKey, takeStoredValueForKey, takeValueForKey, takeValueForKeyPath, takeValuesFromDictionary, takeValuesFromDictionaryWithMapping, toManyRelationshipKeys, toOneRelationshipKeys, toString, turnIntoFault, unableToSetNullForKey, updateFromSnapshot, userPresentableDescription, usesDeferredFaultCreation, validateClientUpdate, validateForDelete, validateForInsert, validateForSave, validateForUpdate, validateTakeValueForKeyPath, validateValueForKey, valueForKey, valueForKeyPath, valuesForKeys, valuesForKeysWithMapping, willChange, willRead, willReadRelationship
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EOLoader

public EOLoader()
Method Detail

writeAllContentToFolder

public void writeAllContentToFolder(String path)
Write out all EO data to the top-level directory specified.

Parameters:
path - Location of the directory where XML datafiles should be written.

writeContentForEntityIntoFolder

public void writeContentForEntityIntoFolder(EOEntity entity,
                                            String path)
                                     throws IOException
Export XML data for the given entity to the directory path specified.

Parameters:
entity - The EO entity in question.
path - Location of the directory where XML datafiles should be written.
Throws:
IOException

contentDictionaryForAllEntities

public NSMutableDictionary contentDictionaryForAllEntities()
Convenience method: return a content dictionary containing data for all entities.

Returns:
The content dictionary.

allEntities

public NSArray allEntities()
Convenience method: return all known entities across all known EOModels.

Returns:
Array containing all entities.

rowsForEntity

public NSArray rowsForEntity(EOEntity entity,
                             EOEditingContext ec)
Return all rows for the entity requested.

Parameters:
entity - The entity in question.
ec - The editing context to fetch the rows with.
Returns:
An array of raw rows (NSDictionary instances).

contentDictionaryForEntity

public NSMutableDictionary contentDictionaryForEntity(EOEntity entity)
Retrieve all data corresponding to the entity supplied into a single dictionary.

Parameters:
entity - The entity in question.
Returns:
The resulting content dictionary, containing entity data (raw rows) keyed by entity name.

contentDictionaryForEntities

public NSMutableDictionary contentDictionaryForEntities(NSArray entityList)
Retrieve all data corresponding to the entities supplied into a single dictionary.

Parameters:
entityList - An array of EOEntity instances.
Returns:
The resulting content dictionary, containing entity data (raw rows) keyed by entity name.

xmlStringForDictionary

public String xmlStringForDictionary(NSDictionary dict)
Convert a dictionary containing raw row entity data into an XML format.

Parameters:
dict - The raw row data dictionary.
Returns:
String containing the XML generated.

exportAllContent

public String exportAllContent()
Retrieve XML export data for all known entities.

Returns:
String containing the XML generated.

importFromFolder

public void importFromFolder(String path)
                      throws IOException
Read XML import data from the directory path specified.

Parameters:
path - The location of the XML data directory.
Throws:
IOException

importContent

public void importContent(String theXML)
Read XML data and use to build new EO instances.

Parameters:
theXML - The XML import data.

processDictionary

public void processDictionary(NSDictionary dict,
                              boolean stringwards)
Convert a raw row data dictionary into a format suitable for importing or exporting data.

The expected property list format is:

{
"anEntityName" = (
{
"rawRowAttribute1" = "value1";
"rawRowAttribute2" = "value2";
...
},
...
);
...
}

Parameters:
dict - The raw row data dictionary.
stringwards - Set to true for exporting data to XML, false for importing data from XML.

processInnerDictionary

public void processInnerDictionary(NSMutableDictionary row,
                                   boolean stringwards)
Convert a raw row into a format suitable for importing or exporting data.

Parameters:
row - The raw row data (corresponding to a single entity instance).
stringwards - Set to true for exporting data to XML, false for importing data from XML.

encodeToBase64

public NSData encodeToBase64(NSData data)
Encode data provided into a Base64 representation.

Parameters:
data - The original (unencoded) data.
Returns:
The Base64 encoded data.

decodeFromBase64

public NSData decodeFromBase64(NSData data)
Decode data provided from a Base64 representation.

Parameters:
data - The original (Base64 encoded) data.
Returns:
The unencoded data.

charLegalInXML

public boolean charLegalInXML(char c)
Determine if a character value can be represented in XML.

Parameters:
c - The character to test.
Returns:
true if the character can be represented, false otherwise.

charMayAppearUnescapedInXML

public boolean charMayAppearUnescapedInXML(char c)
Determine if a character value can appear without escape sequences in XML.

Parameters:
c - The character to test.
Returns:
true if the character may appear without escapes, false otherwise.

xmlEncodeNonASCIICharacters

public String xmlEncodeNonASCIICharacters(String string)
Convert string into an XML-compatible format.

Parameters:
string - Original string contents.
Returns:
XML-compatible version of string.

stringWithDodgyUnicodeEscapedIncludeZero

public String stringWithDodgyUnicodeEscapedIncludeZero(String s,
                                                       boolean includeZero)
Escape unicode characters that may cause problems in XML documents, optionally including the null (0) character.

Parameters:
s - The original string
includeZero - Set true to ignore the zero character, false to escape such characters.
Returns:
An XML-safe string representation.

stringWithDodgyUnicodeUnescaped

public String stringWithDodgyUnicodeUnescaped(String s)
Unescape encoded unicode characters from XML documents.

Parameters:
s - The original XML string data.
Returns:
An unescaped version of the string data.

stringWithDodgyUnicodeEscaped

public String stringWithDodgyUnicodeEscaped(String s)
Escape unicode characters that may cause problems in XML documents, including the null (0) character.

Parameters:
s - The original string
Returns:
An XML-safe string representation.

writeObjectsForEntity

public void writeObjectsForEntity(NSArray objects,
                                  EOEntity entity,
                                  EOEditingContext ec)
Insert an array of newly-generated enterprise objects into the database.

Parameters:
objects - The EOs to be inserted into the database.
entity - The EOEntity in question.
ec - The editing context to use for database operations.

encodeAmpersands

public String encodeAmpersands(String s)
XML-escape any ampersands found in the string supplied.

Parameters:
s - The original string.
Returns:
String with all ampersand characters escaped.

decodeAmpersands

public String decodeAmpersands(String s)
Unescape any XML-encoded ampersands found in the string supplied.

Parameters:
s - The original XML-encoded string.
Returns:
String with all ampersand characters unescaped.