Project Wonder 5.0

er.extensions.foundation
Class ERXUtilities

java.lang.Object
  extended by er.extensions.foundation.ERXUtilities

public class ERXUtilities
extends java.lang.Object

Diverse collection of utility methods for handling everything from EOF to foundation. In the future this class will most likely be split into more meaning full groups of utility methods.


Nested Class Summary
static interface ERXUtilities.BooleanCallback
          Generic boolean callback interface with a context object.
static interface ERXUtilities.BooleanOperation
          Useful interface for binding objects to WOComponent bindings where you want to delay the evaluation of the boolean operation until valueForBinding is actually called.
static interface ERXUtilities.Callback
          Generic callback interface with a context object.
static interface ERXUtilities.Operation
          Useful interface for binding objects to WOComponent bindings where you want to delay the evaluation of the operation until valueForBinding is actually called.
 
Field Summary
static com.webobjects.foundation.NSTimestamp DISTANT_FUTURE
           
static com.webobjects.foundation.NSTimestamp DISTANT_PAST
           
static org.apache.log4j.Logger log
          logging support
 
Constructor Summary
ERXUtilities()
           
 
Method Summary
static void addObjectToObjectOnBothSidesOfRelationshipWithKey(com.webobjects.eocontrol.EOEnterpriseObject addedObject, com.webobjects.eocontrol.EOEnterpriseObject referenceObject, java.lang.String key)
          Deprecated. use ERXEOControlUtilities.addObjectToObjectOnBothSidesOfRelationshipWithKey(EOEnterpriseObject,EOEnterpriseObject,String)
static com.webobjects.foundation.NSArray allFrameworkNames()
          Utility method to get all of the framework names that have been loaded into the application.
static com.webobjects.foundation.NSArray allSubEntitiesForEntity(com.webobjects.eoaccess.EOEntity entity, boolean includeAbstracts)
          Utility method used to find all of the sub entities for a given entity.
static com.webobjects.eoaccess.EOEntity caseInsensitiveEntityNamed(java.lang.String entityName)
          Finds an entity given a case insensitive search of all the entity names.
Note: The current implementation caches the entity-entity name pair in an insensitive manner.
static com.webobjects.eocontrol.EOEnterpriseObject createEO(java.lang.String entityName, com.webobjects.eocontrol.EOEditingContext editingContext)
          Deprecated. use ERXEOControlUtilities.createAndInsertObject(EOEditingContext,String)
static com.webobjects.eocontrol.EOEnterpriseObject createEO(java.lang.String entityName, com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.foundation.NSDictionary objectInfo)
          Deprecated. use createAndInsertObject(EOEditingContext,String, NSDictionary)
static com.webobjects.eocontrol.EOEnterpriseObject createEOLinkedToEO(java.lang.String entityName, com.webobjects.eocontrol.EOEditingContext editingContext, java.lang.String relationshipName, com.webobjects.eocontrol.EOEnterpriseObject eo)
          Deprecated. use ERXEOControlUtilities.createAndAddObjectToRelationship(EOEditingContext,EOEnterpriseObject,String,String,NSDictionary);
static com.webobjects.eocontrol.EOEnterpriseObject createEOLinkedToEO(java.lang.String entityName, com.webobjects.eocontrol.EOEditingContext editingContext, java.lang.String relationshipName, com.webobjects.eocontrol.EOEnterpriseObject eo, com.webobjects.foundation.NSDictionary objectInfo)
          Deprecated. use ERXEOControlUtilities.createAndAddObjectToRelationship(EOEditingContext,EOEnterpriseObject,String,String,NSDictionary);
static com.webobjects.eocontrol.EOArrayDataSource dataSourceForArray(com.webobjects.foundation.NSArray array)
          Deprecated. see ERXEOControlUtilities.dataSourceForArray(NSArray)
static
<T> T
deepClone(T obj, boolean onlyCollections)
          Returns a deep clone of the given object.
static com.webobjects.foundation.NSArray deletedObjectsPKeys(com.webobjects.eocontrol.EOEditingContext ec)
          Utility method for returning all of the primary keys for all of the objects that are marked for deletion in the editing context.
static void deleteObjects(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.foundation.NSArray objects)
          Simple utility method for deleting an array of objects from an editing context.
static void deplicateRelationshipFromEO(com.webobjects.eocontrol.EOEnterpriseObject r1, java.lang.String relationshipName)
          Copies a relationship from one EO to another using the name of the relationship
static com.webobjects.foundation.NSTimestamp distantFuture()
           
static com.webobjects.foundation.NSTimestamp distantPast()
           
static com.webobjects.foundation.NSArray entitiesForModelGroup(com.webobjects.eoaccess.EOModelGroup group)
          Simple utility method for getting all of the entities for all of the models of a given model group.
static java.lang.String escapeApostrophe(java.lang.String aString)
          Gets rid of all ' from a String.
static com.webobjects.foundation.NSTimestampFormatter gregorianDateFormatterForJavaDate()
          Utility method to return a standard timestamp formatter for the default string representation of java dates.
static com.webobjects.foundation.NSArray intersectingElements(com.webobjects.foundation.NSArray array1, com.webobjects.foundation.NSArray array2)
          Performs a basic intersection between two arrays.
static com.webobjects.eocontrol.EOEnterpriseObject localInstanceOfObject(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.eocontrol.EOEnterpriseObject eo)
          Deprecated. use ERXEOControlUtilities.localInstanceOfObject(EOEditingContext,EOEnterpriseObject);
static com.webobjects.foundation.NSArray localInstancesOfObjects(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.foundation.NSArray eos)
          Deprecated. use ERXEOControlUtilities.localInstancesOfObjects(EOEditingContext,NSArray);
static void makeEditableSharedEntityNamed(java.lang.String entityName)
          Deprecated. see ERXEOAccessUtilities.makeEditableSharedEntityNamed(String)
static com.webobjects.foundation.NSDictionary primaryKeyDictionaryForEntity(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName)
          Deprecated. use ERXEOAccessUtilities.primaryKeyDictionaryForEntity(EOEditingContext, String)
static com.webobjects.foundation.NSDictionary relationshipEntityWithEntityAndKeyPath(com.webobjects.eoaccess.EOEntity srcentity, java.lang.String keyPath)
           
static com.webobjects.eocontrol.EOEnterpriseObject relationshipObjectWithObjectAndKeyPath(com.webobjects.eocontrol.EOEnterpriseObject object, java.lang.String keyPath)
           
static com.webobjects.eoaccess.EORelationship relationshipWithObjectAndKeyPath(com.webobjects.eocontrol.EOEnterpriseObject object, java.lang.String keyPath)
          Traverses a key path to return the last EORelationship object.
Note: that this method uses the object and not the model to traverse the key path, this has the added benefit of handling EOF inheritance
static void replicateDataFromEOToEO(com.webobjects.eocontrol.EOEnterpriseObject r1, com.webobjects.eocontrol.EOEnterpriseObject r2, com.webobjects.foundation.NSArray attributeNames)
          Copies values from one EO to another using an array of Attributes
static void replicateRelationshipFromEOToEO(com.webobjects.eocontrol.EOEnterpriseObject r1, com.webobjects.eocontrol.EOEnterpriseObject r2, java.lang.String relationshipName)
          Copies a relationship from one EO to another using the name of the relationship
static com.webobjects.eoaccess.EOEntity rootParentEntityForEntity(com.webobjects.eoaccess.EOEntity entity)
          Walks all of the parentEntity relationships to find the root entity.
static com.webobjects.foundation.NSSet setFromArray(com.webobjects.foundation.NSArray array)
          Deprecated. use ERXArrayUtilities.setFromArray(NSArray)
static com.webobjects.eocontrol.EOEnterpriseObject sharedObjectWithFetchSpec(java.lang.String fetchSpec, java.lang.String entityName)
          Deprecated. use ERXEOControlUtilities.sharedObjectWithFetchSpec(String, String)
static com.webobjects.eocontrol.EOEnterpriseObject sharedObjectWithPrimaryKey(java.lang.Object pk, java.lang.String entityName)
          Deprecated. use ERXEOControlUtilities.sharedObjectWithPrimaryKey(String, object)
static com.webobjects.foundation.NSSelector sortSelectorWithKey(java.lang.String key)
          Deprecated. use ERXArrayUtilities.sortSelectorWithKey(String)
static java.lang.String stackTrace()
          Generates a string representation of the current stacktrace.
static java.lang.String stackTrace(java.lang.Throwable t)
          Converts a throwable's stacktrace into a string representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final org.apache.log4j.Logger log
logging support


DISTANT_FUTURE

public static final com.webobjects.foundation.NSTimestamp DISTANT_FUTURE

DISTANT_PAST

public static final com.webobjects.foundation.NSTimestamp DISTANT_PAST
Constructor Detail

ERXUtilities

public ERXUtilities()
Method Detail

addObjectToObjectOnBothSidesOfRelationshipWithKey

public static void addObjectToObjectOnBothSidesOfRelationshipWithKey(com.webobjects.eocontrol.EOEnterpriseObject addedObject,
                                                                     com.webobjects.eocontrol.EOEnterpriseObject referenceObject,
                                                                     java.lang.String key)
Deprecated. use ERXEOControlUtilities.addObjectToObjectOnBothSidesOfRelationshipWithKey(EOEnterpriseObject,EOEnterpriseObject,String)


createEO

public static com.webobjects.eocontrol.EOEnterpriseObject createEO(java.lang.String entityName,
                                                                   com.webobjects.eocontrol.EOEditingContext editingContext)
Deprecated. use ERXEOControlUtilities.createAndInsertObject(EOEditingContext,String)


createEO

public static com.webobjects.eocontrol.EOEnterpriseObject createEO(java.lang.String entityName,
                                                                   com.webobjects.eocontrol.EOEditingContext editingContext,
                                                                   com.webobjects.foundation.NSDictionary objectInfo)
Deprecated. use createAndInsertObject(EOEditingContext,String, NSDictionary)


createEOLinkedToEO

public static com.webobjects.eocontrol.EOEnterpriseObject createEOLinkedToEO(java.lang.String entityName,
                                                                             com.webobjects.eocontrol.EOEditingContext editingContext,
                                                                             java.lang.String relationshipName,
                                                                             com.webobjects.eocontrol.EOEnterpriseObject eo)
Deprecated. use ERXEOControlUtilities.createAndAddObjectToRelationship(EOEditingContext,EOEnterpriseObject,String,String,NSDictionary);


createEOLinkedToEO

public static com.webobjects.eocontrol.EOEnterpriseObject createEOLinkedToEO(java.lang.String entityName,
                                                                             com.webobjects.eocontrol.EOEditingContext editingContext,
                                                                             java.lang.String relationshipName,
                                                                             com.webobjects.eocontrol.EOEnterpriseObject eo,
                                                                             com.webobjects.foundation.NSDictionary objectInfo)
Deprecated. use ERXEOControlUtilities.createAndAddObjectToRelationship(EOEditingContext,EOEnterpriseObject,String,String,NSDictionary);


localInstanceOfObject

public static com.webobjects.eocontrol.EOEnterpriseObject localInstanceOfObject(com.webobjects.eocontrol.EOEditingContext ec,
                                                                                com.webobjects.eocontrol.EOEnterpriseObject eo)
Deprecated. use ERXEOControlUtilities.localInstanceOfObject(EOEditingContext,EOEnterpriseObject);


localInstancesOfObjects

public static com.webobjects.foundation.NSArray localInstancesOfObjects(com.webobjects.eocontrol.EOEditingContext ec,
                                                                        com.webobjects.foundation.NSArray eos)
Deprecated. use ERXEOControlUtilities.localInstancesOfObjects(EOEditingContext,NSArray);


sharedObjectWithFetchSpec

public static com.webobjects.eocontrol.EOEnterpriseObject sharedObjectWithFetchSpec(java.lang.String fetchSpec,
                                                                                    java.lang.String entityName)
Deprecated. use ERXEOControlUtilities.sharedObjectWithFetchSpec(String, String)


sharedObjectWithPrimaryKey

public static com.webobjects.eocontrol.EOEnterpriseObject sharedObjectWithPrimaryKey(java.lang.Object pk,
                                                                                     java.lang.String entityName)
Deprecated. use ERXEOControlUtilities.sharedObjectWithPrimaryKey(String, object)


primaryKeyDictionaryForEntity

public static com.webobjects.foundation.NSDictionary primaryKeyDictionaryForEntity(com.webobjects.eocontrol.EOEditingContext ec,
                                                                                   java.lang.String entityName)
Deprecated. use ERXEOAccessUtilities.primaryKeyDictionaryForEntity(EOEditingContext, String)


deletedObjectsPKeys

public static com.webobjects.foundation.NSArray deletedObjectsPKeys(com.webobjects.eocontrol.EOEditingContext ec)
Utility method for returning all of the primary keys for all of the objects that are marked for deletion in the editing context.

Parameters:
ec - editing context
Returns:
an array containing all of the dictionaries of primary keys for all of the objects marked for deletion

makeEditableSharedEntityNamed

public static void makeEditableSharedEntityNamed(java.lang.String entityName)
Deprecated. see ERXEOAccessUtilities.makeEditableSharedEntityNamed(String)


dataSourceForArray

public static com.webobjects.eocontrol.EOArrayDataSource dataSourceForArray(com.webobjects.foundation.NSArray array)
Deprecated. see ERXEOControlUtilities.dataSourceForArray(NSArray)


relationshipWithObjectAndKeyPath

public static com.webobjects.eoaccess.EORelationship relationshipWithObjectAndKeyPath(com.webobjects.eocontrol.EOEnterpriseObject object,
                                                                                      java.lang.String keyPath)
Traverses a key path to return the last EORelationship object.
Note: that this method uses the object and not the model to traverse the key path, this has the added benefit of handling EOF inheritance

Parameters:
object - enterprise object to find the relationship off of
keyPath - key path used to find the relationship
Returns:
relationship object corresponding to the last property key of the key path.

relationshipEntityWithEntityAndKeyPath

public static com.webobjects.foundation.NSDictionary relationshipEntityWithEntityAndKeyPath(com.webobjects.eoaccess.EOEntity srcentity,
                                                                                            java.lang.String keyPath)

relationshipObjectWithObjectAndKeyPath

public static com.webobjects.eocontrol.EOEnterpriseObject relationshipObjectWithObjectAndKeyPath(com.webobjects.eocontrol.EOEnterpriseObject object,
                                                                                                 java.lang.String keyPath)

deleteObjects

public static void deleteObjects(com.webobjects.eocontrol.EOEditingContext ec,
                                 com.webobjects.foundation.NSArray objects)
Simple utility method for deleting an array of objects from an editing context.

Parameters:
ec - editing context to have objects deleted from
objects - objects to be deleted.

allFrameworkNames

public static com.webobjects.foundation.NSArray allFrameworkNames()
Utility method to get all of the framework names that have been loaded into the application.

Returns:
array containing all of the framework names

intersectingElements

public static com.webobjects.foundation.NSArray intersectingElements(com.webobjects.foundation.NSArray array1,
                                                                     com.webobjects.foundation.NSArray array2)
Performs a basic intersection between two arrays.

Parameters:
array1 - first array
array2 - second array
Returns:
array containing the intersecting elements of the two arrays.

entitiesForModelGroup

public static com.webobjects.foundation.NSArray entitiesForModelGroup(com.webobjects.eoaccess.EOModelGroup group)
Simple utility method for getting all of the entities for all of the models of a given model group.

Parameters:
group - eo model group
Returns:
array of all entities for a given model group.

caseInsensitiveEntityNamed

public static com.webobjects.eoaccess.EOEntity caseInsensitiveEntityNamed(java.lang.String entityName)
Finds an entity given a case insensitive search of all the entity names.
Note: The current implementation caches the entity-entity name pair in an insensitive manner. This means that all of the models should be loaded before this method is called.


allSubEntitiesForEntity

public static com.webobjects.foundation.NSArray allSubEntitiesForEntity(com.webobjects.eoaccess.EOEntity entity,
                                                                        boolean includeAbstracts)
Utility method used to find all of the sub entities for a given entity.

Parameters:
entity - to walk all of the subEntities relationships
includeAbstracts - determines if abstract entities should be included in the returned array
Returns:
all of the sub-entities for a given entity.

rootParentEntityForEntity

public static com.webobjects.eoaccess.EOEntity rootParentEntityForEntity(com.webobjects.eoaccess.EOEntity entity)
Walks all of the parentEntity relationships to find the root entity.

Parameters:
entity - to find the root parent
Returns:
root parent entity

gregorianDateFormatterForJavaDate

public static com.webobjects.foundation.NSTimestampFormatter gregorianDateFormatterForJavaDate()
Utility method to return a standard timestamp formatter for the default string representation of java dates.

Returns:
timestamp formatter for java dates.

stackTrace

public static java.lang.String stackTrace()
Generates a string representation of the current stacktrace.

Returns:
current stacktrace.

stackTrace

public static java.lang.String stackTrace(java.lang.Throwable t)
Converts a throwable's stacktrace into a string representation.

Parameters:
t - throwable to print to a string
Returns:
string representation of stacktrace

distantFuture

public static com.webobjects.foundation.NSTimestamp distantFuture()

distantPast

public static com.webobjects.foundation.NSTimestamp distantPast()

escapeApostrophe

public static java.lang.String escapeApostrophe(java.lang.String aString)
Gets rid of all ' from a String.

Parameters:
aString - string to check
Returns:
string without '

setFromArray

public static com.webobjects.foundation.NSSet setFromArray(com.webobjects.foundation.NSArray array)
Deprecated. use ERXArrayUtilities.setFromArray(NSArray)


sortSelectorWithKey

public static com.webobjects.foundation.NSSelector sortSelectorWithKey(java.lang.String key)
Deprecated. use ERXArrayUtilities.sortSelectorWithKey(String)


replicateDataFromEOToEO

public static void replicateDataFromEOToEO(com.webobjects.eocontrol.EOEnterpriseObject r1,
                                           com.webobjects.eocontrol.EOEnterpriseObject r2,
                                           com.webobjects.foundation.NSArray attributeNames)
Copies values from one EO to another using an array of Attributes


replicateRelationshipFromEOToEO

public static void replicateRelationshipFromEOToEO(com.webobjects.eocontrol.EOEnterpriseObject r1,
                                                   com.webobjects.eocontrol.EOEnterpriseObject r2,
                                                   java.lang.String relationshipName)
Copies a relationship from one EO to another using the name of the relationship


deplicateRelationshipFromEO

public static void deplicateRelationshipFromEO(com.webobjects.eocontrol.EOEnterpriseObject r1,
                                               java.lang.String relationshipName)
Copies a relationship from one EO to another using the name of the relationship


deepClone

public static <T> T deepClone(T obj,
                              boolean onlyCollections)
Returns a deep clone of the given object. A deep clone will attempt to clone any contained values (in the case of an NSArray or NSDictionary) as well as the value itself.

Parameters:
obj - the object to clone
onlyCollections - if true, only collections will be cloned, not individual values
Returns:
a deep clone of obj

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.