Project Wonder 2.0

er.extensions
Class ERXEOEncodingUtilities

java.lang.Object
  extended byer.extensions.ERXEOEncodingUtilities

public class ERXEOEncodingUtilities
extends Object


Field Summary
protected static NSMutableDictionary _encodedEntityNames
          This dictionary contains the encoded entity names used in the defaultGroup
static String EncodedEntityNameKey
          Key used in EOModeler to specify the encoded (or abbreviated) entity named used when encoding an enterprise-object is an url.
static ERXLogger log
          logging support
 
Constructor Summary
ERXEOEncodingUtilities()
           
 
Method Summary
static NSArray decodeEnterpriseObjectsFromFormValues(EOEditingContext ec, NSDictionary values)
          Decodes all of the objects for a given set of form values in the given editing context.
static NSDictionary dictionaryOfFormValuesForEnterpriseObjects(NSArray eos, String separator, boolean encrypt)
          Constructs the form values dictionary by first calling the method encodeEnterpriseObjectsPrimaryKeyForUrl and then using the results of that to construct the dictionary.
protected static NSDictionary encodedEntityNames()
          This method constructs a dictionary with encoded entity names as keys and entity names as values.
static String encodeEnterpriseObjectPrimaryKeyForUrl(EOEnterpriseObject eo, String seperator, boolean encrypt)
          Simple cover method that calls the method: encodeEnterpriseObjectsPrimaryKeyForUrl with an array containing the single object passed in.
static String encodeEnterpriseObjectsPrimaryKeyForUrl(NSArray eos, String separator, boolean encrypt)
          Encodes an array of enterprise objects for use in a url.
static EOEnterpriseObject enterpriseObjectForEntityNamedFromFormValues(EOEditingContext ec, String entityName, NSDictionary formValues)
          Returns the enterprise object fetched with decoded formValues from entityName.
static NSArray enterpriseObjectsForEntityNamedFromFormValues(EOEditingContext ec, String entityName, NSDictionary formValues)
          Returns the enterprise objects fetched with decoded formValues from entityName.
static NSArray enterpriseObjectsFromFormValues(EOEditingContext ec, NSDictionary formValues)
          Deprecated. use decodeEnterpriseObjectsFromFormValues instead
static String entityNameDecode(String encodedName)
          Decodes the encoded entity name.
static String entityNameEncode(EOEnterpriseObject eo)
          This method encodes the entity name of the enterprise object by searching in the default model group wether it can find the key EncodedEntityNameKey in the user info dictionary.
static String entityNameSeparator()
           
static NSDictionary groupedEnterpriseObjectsFromFormValues(EOEditingContext ec, NSDictionary formValues)
          Returns enterprise objects grouped by entity name.
static void init()
          Class initialization
static boolean isSpecifySeparatorInURL()
           
static void setEntityNameSeparator(String entityNameSeparator)
           
static void setSpecifySeparatorInURL(boolean specifySeparatorInURL)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final ERXLogger log
logging support


EncodedEntityNameKey

public static final String EncodedEntityNameKey
Key used in EOModeler to specify the encoded (or abbreviated) entity named used when encoding an enterprise-object is an url.

See Also:
Constant Field Values

_encodedEntityNames

protected static NSMutableDictionary _encodedEntityNames
This dictionary contains the encoded entity names used in the defaultGroup

Constructor Detail

ERXEOEncodingUtilities

public ERXEOEncodingUtilities()
Method Detail

init

public static void init()
Class initialization


setSpecifySeparatorInURL

public static void setSpecifySeparatorInURL(boolean specifySeparatorInURL)

isSpecifySeparatorInURL

public static boolean isSpecifySeparatorInURL()

setEntityNameSeparator

public static void setEntityNameSeparator(String entityNameSeparator)

entityNameSeparator

public static String entityNameSeparator()

enterpriseObjectsFromFormValues

public static NSArray enterpriseObjectsFromFormValues(EOEditingContext ec,
                                                      NSDictionary formValues)
Deprecated. use decodeEnterpriseObjectsFromFormValues instead


groupedEnterpriseObjectsFromFormValues

public static NSDictionary groupedEnterpriseObjectsFromFormValues(EOEditingContext ec,
                                                                  NSDictionary formValues)
Returns enterprise objects grouped by entity name. The specific encoding is specified in the method: encodeEnterpriseObjectsPrimaryKeyForUrl

Parameters:
ec - the editing context to fetch the objects from
formValues - dictionary where the values are an encoded representation of the primary key values in either cleartext or encrypted format.
Returns:
enterprise objects grouped by entity name

enterpriseObjectForEntityNamedFromFormValues

public static EOEnterpriseObject enterpriseObjectForEntityNamedFromFormValues(EOEditingContext ec,
                                                                              String entityName,
                                                                              NSDictionary formValues)
Returns the enterprise object fetched with decoded formValues from entityName.

Parameters:
ec - the editing context to fetch the object from
entityName - the entity to fetch the object from
formValues - dictionary where the values are an encoded representation of the primary key values in either cleartext or encrypted format.
Returns:
the enterprise object

enterpriseObjectsForEntityNamedFromFormValues

public static NSArray enterpriseObjectsForEntityNamedFromFormValues(EOEditingContext ec,
                                                                    String entityName,
                                                                    NSDictionary formValues)
Returns the enterprise objects fetched with decoded formValues from entityName.

Parameters:
ec - the editing context to fetch the objects from
entityName - the entity to fetch the objects from
formValues - dictionary where the values are an encoded representation of the primary key values in either cleartext or encrypted format.
Returns:
the enterprise objects

entityNameEncode

public static String entityNameEncode(EOEnterpriseObject eo)
This method encodes the entity name of the enterprise object by searching in the default model group wether it can find the key EncodedEntityNameKey in the user info dictionary.

Parameters:
eo - the enterprise object
Returns:
the encoded entity name defaulting to the given eo's entityName

encodedEntityNames

protected static final NSDictionary encodedEntityNames()
This method constructs a dictionary with encoded entity names as keys and entity names as values.

Returns:
the shared dictionary containing encoded entity names.

entityNameDecode

public static String entityNameDecode(String encodedName)
Decodes the encoded entity name.

Returns:
the decoded entity name.

dictionaryOfFormValuesForEnterpriseObjects

public static NSDictionary dictionaryOfFormValuesForEnterpriseObjects(NSArray eos,
                                                                      String separator,
                                                                      boolean encrypt)
Constructs the form values dictionary by first calling the method encodeEnterpriseObjectsPrimaryKeyForUrl and then using the results of that to construct the dictionary.

Parameters:
eos - array of enterprise objects to be encoded in the url
separator - to be used to separate entity names
encrypt - flag to determine if the primary key of the objects should be encrypted.
Returns:
dictionary containing all of the key value pairs where the keys denote the entity names and the values denote the possibly encrypted primary keys.

encodeEnterpriseObjectPrimaryKeyForUrl

public static String encodeEnterpriseObjectPrimaryKeyForUrl(EOEnterpriseObject eo,
                                                            String seperator,
                                                            boolean encrypt)
Simple cover method that calls the method: encodeEnterpriseObjectsPrimaryKeyForUrl with an array containing the single object passed in.

Parameters:
eo - enterprise object to encode in a url.
seperator - to be used for the entity name.
encrypt - flag to determine if the primary key of the object should be encrypted.
Returns:
url string containing the encoded enterprise object plus the entity name seperator used.

encodeEnterpriseObjectsPrimaryKeyForUrl

public static String encodeEnterpriseObjectsPrimaryKeyForUrl(NSArray eos,
                                                             String separator,
                                                             boolean encrypt)
Encodes an array of enterprise objects for use in a url. The basic idea is is to have an entity name to primary key map that makes it easy to retrieve at a later date. In addition the entity name key will be able to tell if the value is an encrypted key or not. In this way given a key value pair the object can be fetched from an editing context given that at point you will know the entity name and the primary key.

For example imagine that an array containing two User objects(pk 13 and 24) and one Company object(pk 56) are passed to this method, null is passed in for the separator which means the default seperator will be used which is '_' and false is passed for encryption. Then the url that would be generated would be: sep=_&User_1=13&User_2=24&Company_3=56

If on the other hand let's say you use the _ character in entity names and you want the primary keys encrypted then passing in the same array up above but with "##" specified as the separator and true for the encrypt boolean would yield: sep=##&User##E1=SOMEGARBAGE8723&User##E2=SOMEGARBAGE23W&Company##E3=SOMEGARBAGE8723
Note that in the above encoding the seperator is always passed and the upper case E specifies if the corresponding value should be decrypted. Compound primary keys are supported, giving the following url: sep=_&EntityName_1=1.1&EntityName_2=1.2 where 1.1 and 1.2 are the primary key values. Key values follow alphabetical order for their attribute names, just like ERXEOControlUtilities.primaryKeyArrayForObject. Note: At the moment the attribute value separator cannot be changed.
EncodedEntityName
You can specify an abbreviation for the encoded entityName. This is very useful when you don't want to disclose the internals of your application or simply because the entity name is rather long.
To do this:
  • open EOModeler,
  • click on the entity you want to edit,
  • get the "Info Panel"
  • go to the "User Info" tab (the last tab represented by a book)
  • add a key named EncodedEntityName with the value you want

Parameters:
eos - array of enterprise objects to be encoded in the url
separator - to be used between the entity name and a sequence number
encrypt - indicates if the primary keys of the objects should be encrypted
Returns:
encoding of the objects passed that can be used as parameters in a url.

decodeEnterpriseObjectsFromFormValues

public static NSArray decodeEnterpriseObjectsFromFormValues(EOEditingContext ec,
                                                            NSDictionary values)
Decodes all of the objects for a given set of form values in the given editing context. The object encoding is very simple, just a generic entity name primary key pair where the key is potentially encrypted using blowfish. The specific encoding is specified in the method: encodeEnterpriseObjectsPrimaryKeyForUrl .

Parameters:
ec - editingcontext to fetch the objects from
values - form value dictionary where the values are an encoded representation of the primary key values in either cleartext or encrypted format.
Returns:
array of enterprise objects corresponding to the passed in form values.

Last updated: Do, Dez 9, 2004 • 12:46 PM CET

Copyright © 2002 – 2004 Project Wonder.