home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / OpenStepConversion / 3.3Headers / eoaccess / EOExpressionArray.h < prev    next >
Encoding:
Text File  |  1994-09-15  |  3.1 KB  |  99 lines

  1. // EOExpressionArray.h
  2. // Copyright (c) 1994, NeXT Computer, Inc. All rights reserved.
  3.  
  4. #import <foundation/NSArray.h>
  5. #import <foundation/NSData.h>
  6. #import <foundation/NSDictionary.h>
  7. #import <foundation/NSObject.h>
  8. #import <foundation/NSString.h>
  9.  
  10. #import <objc/Object.h>
  11.  
  12. @class EOAttribute;
  13. @class EOExpressionArray;
  14.  
  15.  
  16. @protocol EOExpressionContext <NSObject>
  17.  
  18. - (NSString *)expressionValueForAttribute:(EOAttribute *)anAttribute;
  19.     // Does the appropriate aliasing and name generation for an attribute in
  20.     // the context of this particular query.
  21.  
  22. - (NSString *)expressionValueForAttributePath:(EOExpressionArray *)path;
  23.     // Returns an attribute name complete with alias for an attribute path.
  24.     // An attribute path is an array that consists of any number of
  25.     // relationships followed by an attribute.
  26.  
  27. @end
  28.  
  29. // An EOExpressionArray is an array that composes query expressions from
  30. // the expression values of its elements, prepending its prefix, inserting
  31. // its infix between values and appending its suffix.  For example, if an
  32. // array contains the string objects "toAuthor", "toPublisher", "address",
  33. // and has "(", ".", and ")" as its prefix, infix, and suffix, its
  34. // expression value would be "(toAuthor.toPublisher.address)".
  35. //
  36. // This class is used internally by the Framework; you should never need to
  37. // create or use one yourself.
  38.  
  39. @interface EOExpressionArray:NSMutableArray <NSCopying>
  40. {
  41.     NSString *_prefix;
  42.     NSString *_infix;
  43.     NSString *_suffix;
  44.     NSMutableArray *_array;
  45. }
  46.  
  47. - initWithPrefix:(NSString *)prefix 
  48.     infix:(NSString *)infix
  49.     suffix:(NSString *)suffix;
  50.     // Initializes a newly allocated EOExpressionArray to contain no objects and to use the given prefix, infix, and suffix.
  51.  
  52. - (void)setPrefix:(NSString *)prefix;
  53. - (NSString *)prefix;
  54. - (void)setInfix:(NSString *)infix;
  55. - (NSString *)infix;
  56. - (void)setSuffix:(NSString *)suffix;
  57. - (NSString *)suffix;
  58.     // These methods set/return the prefix, infix, or suffix string.
  59.  
  60. - (BOOL)referencesObject:object;
  61.     // Returns YES if the receiver contains object or if any EOExpressionArray
  62.     // contained by the receiver contains object.  Pointer equality, NOT
  63.     // -isEqual: is used to compare objects.
  64.  
  65. @end
  66.  
  67.  
  68. // This category defaults expressionValue to -stringValue for all objects.
  69. // This allows the use of many standard Application Kit objects with
  70. // EOExpressionArray.
  71. @interface Object (EOExpression)
  72.  
  73. - (NSString *)expressionValueForContext:(id <EOExpressionContext>)context;
  74.     // If the receiver responds to -stringValue, returns that as an NSString;
  75.     // otherwise returns nil.
  76.  
  77. @end
  78.  
  79.  
  80. // This category provides the same defaulting for foundation objects.
  81.  
  82. @interface NSObject(EOExpression)
  83.  
  84. - (NSString *)expressionValueForContext:(id <EOExpressionContext>)context;
  85.     // If the receiver responds to -stringValue, returns that as an NSString;
  86.     // otherwise returns nil.
  87.  
  88. @end
  89.  
  90.  
  91. // This category allows strings to conform to the EOExpression protocol
  92.  
  93. @interface NSString(EOExpression)
  94.  
  95. - (NSString *)expressionValueForContext:(id <EOExpressionContext>)context;
  96.     // Returns an immutable version of the receiver.
  97.  
  98. @end
  99.