Project Wonder 2.0

er.extensions
Class ERXExtensions

java.lang.Object
  extended byer.extensions.ERXExtensions

public class ERXExtensions
extends Object

Principal class of the ERExtensions framework. This class will be loaded at runtime when the ERExtensions bundle is loaded (even before the Application construcor is called) This class has a boat-load of stuff in it that will hopefully be finding better homes in the future. This class serves as the initilization point of this framework, look in the static initializer to see all the stuff that is initially setup when this class is loaded. This class also has a boat load of string, array and eof utilities as well as the factory methods for creating editing contexts with the default delegates set.


Nested Class Summary
static class ERXExtensions.Observer
          This public observer is used to perform basic functions in response to notifications.
 
Field Summary
static ERXLogger adaptorLogger
          logging support for the adaptor channel
static String objectsWillChangeInEditingContext
          Notification name, posted before object will change in an editing context
static ERXExtensions.Observer observer
           
static ERXLogger sharedEOadaptorLogger
          logging support for shared object loading
 
Constructor Summary
ERXExtensions()
           
 
Method Summary
static void addObjectsFromArrayWithoutDuplicates(NSMutableArray a1, NSArray a2)
          Deprecated. use ERXArrayUtilities.addObjectsFromArrayWithoutDuplicates
static void addObjectToBothSidesOfPotentialRelationshipFromObjectWithKeyPath(EOEnterpriseObject to, EOEnterpriseObject from, String keyPath)
          This method handles 3 different cases 1. keyPath is a single key and represents a relationship --> addObjectToBothSidesOfRelationshipWithKey 2. keyPath is a single key and does NOT represents a relationship 3. keyPath is a real key path: break it up, navigate to the last atom --> back to 1. or 2.
static void addRandomizeDirectActionURL(StringBuffer daURL)
          This method can be used with Direct Action URLs to make sure that the browser will reload the page.
static String addWosidFormValue(String url, WOSession s)
          Adds the wosid for a given session to a given url.
static NSArray arrayByAddingObjectsFromArrayWithoutDuplicates(NSArray a1, NSArray a2)
          Deprecated. use ERXArrayUtilities.arrayByAddingObjectsFromArrayWithoutDuplicates
static NSArray arrayFromDataSource(EODataSource dataSource)
          Deprecated. see ERXEOControlUtilities#arrayFromDataSource(NSArray)
static NSArray arrayMinusArray(NSArray main, NSArray minus)
          Deprecated. use ERXArrayUtilities.arrayMinusArray
static boolean arraysAreIdenticalSets(NSArray a1, NSArray a2)
          Deprecated. use ERXArrayUtilities.arraysAreIdenticalSets(NSArray, NSArray)
static NSArray arrayWithoutDuplicateKeyValue(NSArray eos, String key)
          Deprecated. use ERXArrayUtilities.arrayWithoutDuplicateKeyValue
static NSArray arrayWithoutDuplicates(NSArray anArray)
          Deprecated. use ERXArrayUtilities.arrayWithoutDuplicates
static boolean booleanFlagOnSessionForKeyWithDefault(WOSession s, String key, boolean defaultValue)
          Retrieves a value from the session's dictionary and evaulates that object using the method booleanValue off of ERXUtilities.
static String byteArrayToHexString(byte[] data)
          Deprecated. use ERXStringUtilities.byteArrayToHexString instead
static byte[] bytesFromFile(File f)
          Returns the byte array for a given file.
static String capitalize(String s)
          Capitalizes the given string.
static String cleanString(String newString, NSArray toBeCleaneds)
          Removes any occurances of any strings in the array passed in from the string passed in.
static void configureAdaptorContext()
          This method is called by the delegate when the configuration file is changed.
static void configureAdaptorContextRapidTurnAround(Object observer)
          Configures the passed in observer to register a call back when the configuration file is changed.
static EOArrayDataSource dataSourceForArray(NSArray array)
          Deprecated. see ERXEOControlUtilities.dataSourceForArray(NSArray)
static EODetailDataSource dataSourceForObjectAndKey(EOEnterpriseObject eo, String key)
          Deprecated. see ERXEOControlUtilities#arrayFromDataSource(NSArray)
static ERXECNoValidationDelegate defaultECNoValidationDelegate()
          Deprecated. see ERXEC
static ERXEditingContextDelegate defaultEditingContextDelegate()
          Deprecated. see ERXEC
static String emptyStringForNull(String s)
          Deprecated. use {@link ERXStringUtilities#emptyStringForNull(String)
static NSDictionary eosInArrayGroupedByKeyPath(NSArray eos, String keyPath)
          Deprecated. use ERXArrayUtilities.arrayGroupedByKeyPath
static NSDictionary eosInArrayGroupedByKeyPath(NSArray eos, String keyPath, boolean includeNulls, String extraKeyPathForValues)
          Deprecated. use ERXArrayUtilities.arrayGroupedByKeyPath
static void evaluateSQLWithEntityNamed(String entityName, String exp, EOEditingContext ec)
          Deprecated. see { @link ERXEOAccessUtilities#evaluateSQLWithEntityNamed}
static NSArray filteredArrayWithQualifierEvaluation(NSArray a, EOQualifierEvaluation q)
          Deprecated. use ERXArrayUtilities.filteredArrayWithQualifierEvaluation
static NSArray flatten(NSArray array)
          Deprecated. use ERXArrayUtilities.flatten
static void forceGC(int maxLoop)
          Forces the garbage collector to run.
static void freeProcessResources(Process p)
          Frees all of a resources associated with a given process and then destroys it.
static String friendlyEOArrayDisplayForKey(NSArray list, String attribute, String nullArrayDisplay)
          Deprecated. use {@link ERXArrayUtilities#friendlyDisplayForKeyPath(NSArray, String, String, String, String)
static byte[] hexStringToByteArray(String s)
          Deprecated. ERXStringUtilities.hexStringToByteArray instead
static ERXSimpleHTMLFormatter htmlFormatter()
           
static int intFromParseableIntegerString(String s)
          Returns an integer from a parsable string.
static boolean isNewObject(EOEnterpriseObject eo)
          Deprecated. use ERXEOControlUtilities.isNewObject(EOEnterpriseObject)
static long lastModifiedDateForFileInFramework(String fileName, String frameworkName)
          Determines the last modification date for a given file in a framework.
static Logger log()
          creates and caches the logging logger
static EOEditingContext newEditingContext()
          Deprecated. see ERXEC
static EOEditingContext newEditingContext(boolean validation)
          Deprecated. see ERXEC
static EOEditingContext newEditingContext(EOObjectStore objectStore)
          Deprecated. see ERXEC
static EOEditingContext newEditingContext(EOObjectStore objectStore, boolean validation)
          Deprecated. see ERXEC
static String nullForEmptyString(String s)
          Deprecated. use {@link ERXStringUtilities#nullForEmptyString(String)
static int numberOfOccurrencesOfCharInString(char c, String s)
          Deprecated. use {@link ERXStringUtilities#numberOfOccurrencesOfCharInString(char,String)
static boolean objectImplementsMethod(Object object, String methodName, Class[] parameters)
          Determines if a given object implements a method given the name and the array of input parameters.
static String plurify(String s, int howMany, String language)
          Plurifies a given string for a given language.
static NSArray primaryKeyArrayForObject(EOEnterpriseObject obj)
          Deprecated. use ERXEOControlUtilities.primaryKeyArrayForObject instead.
static String primaryKeyForObject(EOEnterpriseObject eo)
          Deprecated. use ERXEOControlUtilities.primaryKeyStringForObject(EOEnterpriseObject)
static String randomizeDirectActionURL(String daURL)
          This method can be used with Direct Action URLs to make sure that the browser will reload the page.
static Object rawPrimaryKeyForObject(EOEnterpriseObject eo)
          Returns the raw primary key of the object.
static Object rawPrimaryKeyFromPrimaryKeyAndEO(NSDictionary primaryKey, EOEnterpriseObject eo)
          Deprecated. use just about anything else, like Random.nextInt() for example
static Object readPropertyListFromFileinFramework(String fileName, String aFrameWorkName)
          Reads a file in from the file system and then parses it as if it were a property list.
static Object readPropertyListFromFileInFramework(String fileName, String aFrameWorkName, NSArray languageList)
          Reads a file in from the file system for the given set of languages and then parses the file as if it were a property list.
static void refreshSharedObjectsWithName(String entityName)
          Useful method to refresh all of the shared enterprise objects for a given shared entity.
static void refreshSharedObjectsWithNames(NSArray names)
          Refreshes all of the objects for an array of entity names.
static String removeHTMLTagsFromString(String s)
          Removes all of the HTML tags from a given string.
static String replaceStringByStringInString(String old, String newString, String s)
          Deprecated. use {@link ERXStringUtilities#replaceStringByStringInString(String, String, String)
static String resolveUnit(String userInfoUnitString, EOEnterpriseObject object, String prefixKeyPath)
          Resolves a given user info unit string for a given object.
static void retainEditingContextForCurrentSession(EOEditingContext ec)
          Retains an editing context for the current session.
static boolean safeDifferent(Object v1, Object v2)
          A safe different comparison method that first checks to see if either of the objects are null before comparing them with the equals method.
static boolean safeEquals(Object v1, Object v2)
          A safe comparison method that first checks to see if either of the objects are null before comparing them with the equals method.
static ERXSession session()
          Returns the current session object for this thread.
static void sessionDidTimeOut(String sessionID)
          This method is called when a session times out.
static void setBooleanFlagOnSessionForKey(WOSession s, String key, boolean newValue)
          Uses the setObjectForKey off of the WOSession class to push a Boolean object onto the session for a given key.
static void setDefaultDelegate(EOEditingContext ec)
          Deprecated. see ERXEC
static void setDefaultDelegate(EOEditingContext ec, boolean validation)
          Deprecated. see ERXEC
static void setDefaultECNoValidationDelegate(ERXECNoValidationDelegate delegate)
          Deprecated. see ERXEC
static void setDefaultEditingContextDelegate(ERXEditingContextDelegate delegate)
          Deprecated. see ERXEC
static void setSession(ERXSession session)
          Sets the current session for this thread.
static String stringFromFile(File f)
          Returns a string from the file using the default encoding.
static String stringFromFile(File f, String encoding)
          Returns a string from the file using the specified encoding.
static boolean stringIsNullOrEmpty(String s)
          Deprecated. use {@link ERXStringUtilities#stringIsNullOrEmpty(String)
static boolean stringIsParseableInteger(String s)
          Tests if a given string object can be parsed into an integer.
static String stringWithNtimesString(int n, String s)
          Deprecated. use {@link ERXStringUtilities#numberOfOccurrencesOfCharInString(int,String)
static String substituteStringByStringInString(String s1, String s2, String s)
           
static String userInfoUnit(EOEnterpriseObject object, String key)
          For a given enterprise object and key path, will return what the key 'unit' returns from the userInfo dictionary of the last property of the key path's EOAttribute or EORelationship.
static String userPreferencesKeyFromContext(String key, NSKeyValueCoding context)
          method used by the preferences mechanism from ERDirectToWeb needs to be in here because shared by ERDirectToWeb and ERCoreBusinessLogic The basic idea of this method is to construct a unique key based on a context.
static String userPresentableEOArray(NSArray array, String attribute)
          Deprecated. use ERXArrayUtilities.friendlyDisplayForKeyPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

observer

public static ERXExtensions.Observer observer

objectsWillChangeInEditingContext

public static final String objectsWillChangeInEditingContext
Notification name, posted before object will change in an editing context

See Also:
Constant Field Values

adaptorLogger

public static ERXLogger adaptorLogger
logging support for the adaptor channel


sharedEOadaptorLogger

public static ERXLogger sharedEOadaptorLogger
logging support for shared object loading

Constructor Detail

ERXExtensions

public ERXExtensions()
Method Detail

log

public static Logger log()
creates and caches the logging logger

Returns:
logging logger

configureAdaptorContextRapidTurnAround

public static void configureAdaptorContextRapidTurnAround(Object observer)
Configures the passed in observer to register a call back when the configuration file is changed. This allows one to change a logger's setting and have that changed value change the NSLog setting to log the generated SQL. This method is called as part of the framework initialization process.

Parameters:
observer - object to register the call back with.

configureAdaptorContext

public static void configureAdaptorContext()
This method is called by the delegate when the configuration file is changed. It's sole purpose is to map a logging logger to a debug group. Hopefully in the future we will have a more generic solution.


defaultEditingContextDelegate

public static ERXEditingContextDelegate defaultEditingContextDelegate()
Deprecated. see ERXEC


setDefaultEditingContextDelegate

public static void setDefaultEditingContextDelegate(ERXEditingContextDelegate delegate)
Deprecated. see ERXEC


defaultECNoValidationDelegate

public static ERXECNoValidationDelegate defaultECNoValidationDelegate()
Deprecated. see ERXEC


setDefaultECNoValidationDelegate

public static void setDefaultECNoValidationDelegate(ERXECNoValidationDelegate delegate)
Deprecated. see ERXEC


newEditingContext

public static EOEditingContext newEditingContext()
Deprecated. see ERXEC


newEditingContext

public static EOEditingContext newEditingContext(boolean validation)
Deprecated. see ERXEC


newEditingContext

public static EOEditingContext newEditingContext(EOObjectStore objectStore)
Deprecated. see ERXEC


newEditingContext

public static EOEditingContext newEditingContext(EOObjectStore objectStore,
                                                 boolean validation)
Deprecated. see ERXEC


evaluateSQLWithEntityNamed

public static void evaluateSQLWithEntityNamed(String entityName,
                                              String exp,
                                              EOEditingContext ec)
Deprecated. see { @link ERXEOAccessUtilities#evaluateSQLWithEntityNamed}


sessionDidTimeOut

public static void sessionDidTimeOut(String sessionID)
This method is called when a session times out. Calling this method will release references to all editing contexts that were created when this session was active. This method is only called in pre-WO 5.2 versions of WebObjects.

Parameters:
sessionID - of the session that timed out

retainEditingContextForCurrentSession

public static void retainEditingContextForCurrentSession(EOEditingContext ec)
Retains an editing context for the current session. This is only needed or used for versions of WO pre-5.2. If you use ERXEC to create your editing contexts then you never need to call this method yourself.

Parameters:
ec - to be retained.

setDefaultDelegate

public static void setDefaultDelegate(EOEditingContext ec)
Deprecated. see ERXEC


setDefaultDelegate

public static void setDefaultDelegate(EOEditingContext ec,
                                      boolean validation)
Deprecated. see ERXEC


dataSourceForArray

public static EOArrayDataSource dataSourceForArray(NSArray array)
Deprecated. see ERXEOControlUtilities.dataSourceForArray(NSArray)


arrayFromDataSource

public static NSArray arrayFromDataSource(EODataSource dataSource)
Deprecated. see ERXEOControlUtilities#arrayFromDataSource(NSArray)


dataSourceForObjectAndKey

public static EODetailDataSource dataSourceForObjectAndKey(EOEnterpriseObject eo,
                                                           String key)
Deprecated. see ERXEOControlUtilities#arrayFromDataSource(NSArray)


friendlyEOArrayDisplayForKey

public static String friendlyEOArrayDisplayForKey(NSArray list,
                                                  String attribute,
                                                  String nullArrayDisplay)
Deprecated. use {@link ERXArrayUtilities#friendlyDisplayForKeyPath(NSArray, String, String, String, String)


replaceStringByStringInString

public static String replaceStringByStringInString(String old,
                                                   String newString,
                                                   String s)
Deprecated. use {@link ERXStringUtilities#replaceStringByStringInString(String, String, String)


emptyStringForNull

public static String emptyStringForNull(String s)
Deprecated. use {@link ERXStringUtilities#emptyStringForNull(String)


nullForEmptyString

public static String nullForEmptyString(String s)
Deprecated. use {@link ERXStringUtilities#nullForEmptyString(String)


stringIsNullOrEmpty

public static boolean stringIsNullOrEmpty(String s)
Deprecated. use {@link ERXStringUtilities#stringIsNullOrEmpty(String)


numberOfOccurrencesOfCharInString

public static int numberOfOccurrencesOfCharInString(char c,
                                                    String s)
Deprecated. use {@link ERXStringUtilities#numberOfOccurrencesOfCharInString(char,String)


stringWithNtimesString

public static String stringWithNtimesString(int n,
                                            String s)
Deprecated. use {@link ERXStringUtilities#numberOfOccurrencesOfCharInString(int,String)


removeHTMLTagsFromString

public static String removeHTMLTagsFromString(String s)
Removes all of the HTML tags from a given string. Note: that this is a very simplistic implementation and will most likely not work with complex HTML. Note: for actual conversion of HTML tags into regular strings have a look at ERXSimpleHTMLFormatter

Parameters:
s - html string
Returns:
string with all of it's html tags removed

forceGC

public static void forceGC(int maxLoop)
Forces the garbage collector to run. The max loop parameter determines the maximum number of times to run the garbage collector if the memory footprint is still going down. In normal cases you would just need to call this method with the parameter 1. If called with the parameter 0 the garbage collector will continue to run until no more free memory is available to collect.

Note: This can be a very costly operation and should only be used in extreme circumstances.

Parameters:
maxLoop - maximum times to run the garbage collector. Passing in 0 will cause the collector to run until all free objects have been collected.

isNewObject

public static boolean isNewObject(EOEnterpriseObject eo)
Deprecated. use ERXEOControlUtilities.isNewObject(EOEnterpriseObject)


primaryKeyForObject

public static String primaryKeyForObject(EOEnterpriseObject eo)
Deprecated. use ERXEOControlUtilities.primaryKeyStringForObject(EOEnterpriseObject)


rawPrimaryKeyFromPrimaryKeyAndEO

public static Object rawPrimaryKeyFromPrimaryKeyAndEO(NSDictionary primaryKey,
                                                      EOEnterpriseObject eo)
Deprecated. use just about anything else, like Random.nextInt() for example


primaryKeyArrayForObject

public static NSArray primaryKeyArrayForObject(EOEnterpriseObject obj)
Deprecated. use ERXEOControlUtilities.primaryKeyArrayForObject instead.

Gives the primary key array for a given enterprise object. This has the advantage of not firing the fault of the object, unlike the method in EOUtilities.

Parameters:
obj - enterprise object to get the primary key array from.
Returns:
array of all the primary key values for the object.

rawPrimaryKeyForObject

public static Object rawPrimaryKeyForObject(EOEnterpriseObject eo)
Returns the raw primary key of the object. Possible objects returned could be Integer, BigDecimal or NSData. Note: the object passed in should only have one primary key.

Parameters:
eo - enterprise object to get the primary key from

capitalize

public static String capitalize(String s)
Capitalizes the given string.

Parameters:
s - string to capitalize
Returns:
capitalized sting if the first char is a lowercase character.

plurify

public static String plurify(String s,
                             int howMany,
                             String language)
Plurifies a given string for a given language. See ERXLocalizer for more information.

Parameters:
s - string to plurify
howMany - number of its
language - target language
Returns:
plurified string

safeEquals

public static boolean safeEquals(Object v1,
                                 Object v2)
A safe comparison method that first checks to see if either of the objects are null before comparing them with the equals method.

Note that if both objects are null then they will be considered equal.

Parameters:
v1 - first object
v2 - second object
Returns:
true if they are equal, false if not

safeDifferent

public static boolean safeDifferent(Object v1,
                                    Object v2)
A safe different comparison method that first checks to see if either of the objects are null before comparing them with the equals method.

Note that if both objects are null then they will be considered equal.

Parameters:
v1 - first object
v2 - second object
Returns:
treu if they are not equal, false if they are

stringIsParseableInteger

public static boolean stringIsParseableInteger(String s)
Tests if a given string object can be parsed into an integer.

Parameters:
s - string to be parsed
Returns:
if the string can be parsed into an int

intFromParseableIntegerString

public static int intFromParseableIntegerString(String s)
Returns an integer from a parsable string. If the string can not be parsed then 0 is returned.

Parameters:
s - string to be parsed.
Returns:
int from the string or 0 if un-parsable.

substituteStringByStringInString

public static String substituteStringByStringInString(String s1,
                                                      String s2,
                                                      String s)

htmlFormatter

public static ERXSimpleHTMLFormatter htmlFormatter()

addObjectToBothSidesOfPotentialRelationshipFromObjectWithKeyPath

public static void addObjectToBothSidesOfPotentialRelationshipFromObjectWithKeyPath(EOEnterpriseObject to,
                                                                                    EOEnterpriseObject from,
                                                                                    String keyPath)
This method handles 3 different cases 1. keyPath is a single key and represents a relationship --> addObjectToBothSidesOfRelationshipWithKey 2. keyPath is a single key and does NOT represents a relationship 3. keyPath is a real key path: break it up, navigate to the last atom --> back to 1. or 2.

Parameters:
to - enterprise object that is having objects added to it
from - enterprise object that is providing the objects
keyPath - that specifies the relationship on the to object to add the objects to.

flatten

public static NSArray flatten(NSArray array)
Deprecated. use ERXArrayUtilities.flatten

Recursively flattens an array of arrays into a single array of elements.


eosInArrayGroupedByKeyPath

public static NSDictionary eosInArrayGroupedByKeyPath(NSArray eos,
                                                      String keyPath)
Deprecated. use ERXArrayUtilities.arrayGroupedByKeyPath

Groups an array of objects by a given key path.


eosInArrayGroupedByKeyPath

public static NSDictionary eosInArrayGroupedByKeyPath(NSArray eos,
                                                      String keyPath,
                                                      boolean includeNulls,
                                                      String extraKeyPathForValues)
Deprecated. use ERXArrayUtilities.arrayGroupedByKeyPath

Groups an array of objects by a given key path.


arraysAreIdenticalSets

public static boolean arraysAreIdenticalSets(NSArray a1,
                                             NSArray a2)
Deprecated. use ERXArrayUtilities.arraysAreIdenticalSets(NSArray, NSArray)

Simple comparision method to see if two array objects are identical sets.


filteredArrayWithQualifierEvaluation

public static NSArray filteredArrayWithQualifierEvaluation(NSArray a,
                                                           EOQualifierEvaluation q)
Deprecated. use ERXArrayUtilities.filteredArrayWithQualifierEvaluation

Filters an array using the EOQualifierEvaluation interface.


byteArrayToHexString

public static String byteArrayToHexString(byte[] data)
Deprecated. use ERXStringUtilities.byteArrayToHexString instead

Converts an array of bytes to a hex string

Parameters:
data - array of bytes
Returns:
hex representation of the byte array

hexStringToByteArray

public static byte[] hexStringToByteArray(String s)
Deprecated. ERXStringUtilities.hexStringToByteArray instead

Converts a hex string into an array of bytes

Parameters:
s - string
Returns:
byte array

bytesFromFile

public static byte[] bytesFromFile(File f)
                            throws IOException
Returns the byte array for a given file.

Parameters:
f - file to get the bytes from
Returns:
byte array of the file.
Throws:
IOException - if things go wrong

stringFromFile

public static String stringFromFile(File f)
                             throws IOException
Returns a string from the file using the default encoding.

Parameters:
f - file to read
Returns:
string representation of that file.
Throws:
IOException

stringFromFile

public static String stringFromFile(File f,
                                    String encoding)
                             throws IOException
Returns a string from the file using the specified encoding.

Parameters:
f - file to read
encoding - to be used, null will use the default
Returns:
string representation of the file.
Throws:
IOException

lastModifiedDateForFileInFramework

public static long lastModifiedDateForFileInFramework(String fileName,
                                                      String frameworkName)
Determines the last modification date for a given file in a framework. Note that this method will only test for the global resource not the localized resources.

Parameters:
fileName - name of the file
frameworkName - name of the framework, null or "app" for the application bundle
Returns:
the lastModified method off of the file object

readPropertyListFromFileinFramework

public static Object readPropertyListFromFileinFramework(String fileName,
                                                         String aFrameWorkName)
Reads a file in from the file system and then parses it as if it were a property list.

Parameters:
fileName - name of the file
aFrameWorkName - name of the framework, null or 'app' for the application bundle.
Returns:
de-serialized object from the plist formatted file specified.

readPropertyListFromFileInFramework

public static Object readPropertyListFromFileInFramework(String fileName,
                                                         String aFrameWorkName,
                                                         NSArray languageList)
Reads a file in from the file system for the given set of languages and then parses the file as if it were a property list.

Parameters:
fileName - name of the file
aFrameWorkName - name of the framework, null or 'app' for the application bundle.
languageList - language list search order
Returns:
de-serialized object from the plist formatted file specified.

userInfoUnit

public static String userInfoUnit(EOEnterpriseObject object,
                                  String key)
For a given enterprise object and key path, will return what the key 'unit' returns from the userInfo dictionary of the last property of the key path's EOAttribute or EORelationship. The userInfo dictionary can be edited via EOModeler, it is that open book looking icon when looking at either an attribute or relationship.

For example if the userInfo dictionary or the attribute 'speed' on the entity Car contained the key-value pair unit=mph, then this method would be able to resolve that unit given either of these keypaths:
userInfoUnit(aCar, "speed");
userInfoUnit(aDrive, "toCar.speed");

Units can be very useful for adding meta information to particular attributes and relationships in models. The ERDirectToWeb framework adds support for displaying units.

Parameters:
object - to resolve the key-path from
key - path off of the object
Returns:
unit information stored in the userInfo dictionary

resolveUnit

public static String resolveUnit(String userInfoUnitString,
                                 EOEnterpriseObject object,
                                 String prefixKeyPath)
Resolves a given user info unit string for a given object. User info values are stored in an EOAttibute or EORelationship's userInfo dictionary. See the method userInfoUnit for a better description of getting values out of the userInfo dictionary. This method deals with resolving dynamic userInfo keys. These keys need to start with the '@@' symbol. For instance if you have the user info value '@unit' off of an attribute for the entity Movie, then you can either pass in a Movie object or a different object with a prefix key path to a movie object.

Parameters:
userInfoUnitString - string to be resolved, needs to start with '@@' this keypath will be evaluated against either the object if no prefixKeyPath is specified or the object returned by the prefixKeyPath being evaluated against the object passed in.
object - to resolve either the user info unit or the prefixKeyPath.
prefixKeyPath - used as a prefix for the unit resolution.
Returns:
the resolved unit from the object.

arrayWithoutDuplicates

public static NSArray arrayWithoutDuplicates(NSArray anArray)
Deprecated. use ERXArrayUtilities.arrayWithoutDuplicates

Filters out all of the duplicate objects in a given array.


arrayWithoutDuplicateKeyValue

public static NSArray arrayWithoutDuplicateKeyValue(NSArray eos,
                                                    String key)
Deprecated. use ERXArrayUtilities.arrayWithoutDuplicateKeyValue

Filters out duplicates of an array of enterprise objects based on the value of the given key off of those objects.


arrayMinusArray

public static NSArray arrayMinusArray(NSArray main,
                                      NSArray minus)
Deprecated. use ERXArrayUtilities.arrayMinusArray

Subtracts the contents of one array from another.


arrayByAddingObjectsFromArrayWithoutDuplicates

public static NSArray arrayByAddingObjectsFromArrayWithoutDuplicates(NSArray a1,
                                                                     NSArray a2)
Deprecated. use ERXArrayUtilities.arrayByAddingObjectsFromArrayWithoutDuplicates

Creates an array preserving order by adding all of the non-duplicate values from the second array to the first.


addObjectsFromArrayWithoutDuplicates

public static void addObjectsFromArrayWithoutDuplicates(NSMutableArray a1,
                                                        NSArray a2)
Deprecated. use ERXArrayUtilities.addObjectsFromArrayWithoutDuplicates

Adds all of the non-duplicate elements from the second array to the mutable array.


userPresentableEOArray

public static String userPresentableEOArray(NSArray array,
                                            String attribute)
Deprecated. use ERXArrayUtilities.friendlyDisplayForKeyPath


refreshSharedObjectsWithNames

public static void refreshSharedObjectsWithNames(NSArray names)
Refreshes all of the objects for an array of entity names.

Parameters:
names - array of shared entity names

refreshSharedObjectsWithName

public static void refreshSharedObjectsWithName(String entityName)
Useful method to refresh all of the shared enterprise objects for a given shared entity. The current implementation depends on the shared entity to have a fetch specification named 'FetchAll' which will be created for you if you check the box that says 'share all objects'.

Parameters:
entityName - name of the shared entity

randomizeDirectActionURL

public static String randomizeDirectActionURL(String daURL)
This method can be used with Direct Action URLs to make sure that the browser will reload the page. This is done by adding the parameter [? | &]r=random_number to the end of the url.

Parameters:
daURL - a url to add the randomization to.
Returns:
url with the addition of the randomization key

addRandomizeDirectActionURL

public static void addRandomizeDirectActionURL(StringBuffer daURL)
This method can be used with Direct Action URLs to make sure that the browser will reload the page. This is done by adding the parameter [? | &]r=random_number to the end of the url.

Parameters:
daURL - a url to add the randomization to.

addWosidFormValue

public static String addWosidFormValue(String url,
                                       WOSession s)
Adds the wosid for a given session to a given url.

Parameters:
url - to add wosid form value to.
Returns:
url with the addition of wosid form value

cleanString

public static String cleanString(String newString,
                                 NSArray toBeCleaneds)
Removes any occurances of any strings in the array passed in from the string passed in. Used in conjunction with fuzzy matching.

Parameters:
newString - string to have other strings removed from it
toBeCleaneds - array of strings to check to see if the other string contains
Returns:
cleaned string.

setBooleanFlagOnSessionForKey

public static void setBooleanFlagOnSessionForKey(WOSession s,
                                                 String key,
                                                 boolean newValue)
Uses the setObjectForKey off of the WOSession class to push a Boolean object onto the session for a given key. Note this is not using key value coding, meaning you don't need to have a boolean instance variable corresponding to the given key on your session object. This flag can be retrieved using the method booleanFlagOnSessionForKeyWithDefault.

Parameters:
s - session object to have the boolean flag set on
key - to be used in the session's dictionary
newValue - boolean value to be set on the session

booleanFlagOnSessionForKeyWithDefault

public static boolean booleanFlagOnSessionForKeyWithDefault(WOSession s,
                                                            String key,
                                                            boolean defaultValue)
Retrieves a value from the session's dictionary and evaulates that object using the method booleanValue off of ERXUtilities. If there is not an object corresponding to the key passed in, then the default value is returned. The usual way in which boolean values are set on the session object is by using the method setBooleanFlagOnSessionForKey in this class.

Parameters:
s - session object to retrieve the boolean flag from
key - that the boolean is stored under
defaultValue - value to be returned if the object in the dictionary is null
Returns:
boolean value of the object stored in the session's dictionary for the given key.

setSession

public static void setSession(ERXSession session)
Sets the current session for this thread. This is called from ERXSession's awake and sleep methods.

Parameters:
session - that is currently active for this thread.

session

public static ERXSession session()
Returns the current session object for this thread.

Returns:
current session object for this thread

userPreferencesKeyFromContext

public static String userPreferencesKeyFromContext(String key,
                                                   NSKeyValueCoding context)
method used by the preferences mechanism from ERDirectToWeb needs to be in here because shared by ERDirectToWeb and ERCoreBusinessLogic The basic idea of this method is to construct a unique key based on a context.

Parameters:
key - preference key
context - most likely a d2wContext object
Returns:
a unique preference key for storing and retriving preferences

freeProcessResources

public static void freeProcessResources(Process p)
Frees all of a resources associated with a given process and then destroys it.

Parameters:
p - process to destroy

objectImplementsMethod

public static boolean objectImplementsMethod(Object object,
                                             String methodName,
                                             Class[] parameters)
Determines if a given object implements a method given the name and the array of input parameters.

Parameters:
object - to determine if it implements a method
methodName - name of the method
parameters - array of parameters
Returns:
if the object implements a method with the given name and class parameters

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

Copyright © 2002 – 2004 Project Wonder.