WebObjects 5.2

com.webobjects.directtoweb
Class DefaultAssignment

java.lang.Object
  |
  +--com.webobjects.directtoweb.Assignment
        |
        +--com.webobjects.directtoweb.DefaultAssignment
All Implemented Interfaces:
EOKeyValueArchiving, Serializable
Direct Known Subclasses:
EOAssignment

public class DefaultAssignment
extends Assignment

The DefaultAssignment class methods provide default values for the right-hand sides of rules. Many of these default values depend on the current entity or property in the Direct to Web context that is active when the rule fires.

This is a good class to extend if you want to add your own assignment methods. Any rule that uses the method must have its right-hand side value set to the name of the method. Use the _context variable to access the Direct to Web context that is active when the rule fires.

For more information about subclassing DefaultAssignment, see the "Customizing a Direct to Web Application" chapter of Developing WebObjects Applications with Direct to Web.

See Also:
Serialized Form

Inner classes inherited from class com.webobjects.eocontrol.EOKeyValueArchiving
EOKeyValueArchiving.Awaking, EOKeyValueArchiving.FinishInitialization, EOKeyValueArchiving.Support
 
Fields inherited from class com.webobjects.directtoweb.Assignment
KeyPathKey, ValueKey
 
Constructor Summary
DefaultAssignment(EOKeyValueUnarchiver unarchiver)
          Constructs a new DefaultAssignment based on an EOKeyValueUnarchiver.
DefaultAssignment(String keyPath, String value)
          Constructs a new DefaultAssignment with the specified key path and value.
 
Method Summary
 int attributeWidth()
          Returns the attribute width.
 D2WContext d2wContext()
           
static Object decodeWithKeyValueUnarchiver(EOKeyValueUnarchiver unarchiver)
          This method is intentionally undocumented.
 String defaultDisplayNameForProperty()
          Returns a String containing a user-presentable version of the current property key in the Direct to Web context in which the receiver's rule fires.
 String defaultEntityName()
          Returns the first entity name in the NSArray returned by the smartDefaultEntityNames method.
 NSArray defaultPropertyKeysFromEntity()
          Returns a sorted NSArray containing the property keys for the current entity excluding primary and foreign keys.
 NSArray defaultPropertyKeysFromEntityWithoutRelationships()
          Returns a sorted NSArray containing the property keys for the current entity excluding relationships, primary keys, and foreign keys.
 Object fire(D2WContext context)
          This method is invoked when a rule fires.
 Integer isEntityReadOnly()
          Returns whether the current entity in the Direct to Web context in which the receiver's rule fires cannot be modified.
 String smartDefaultAttributeWidth()
          Returns the result of smartDefaultAttributeWidthAsInt as a String.
 int smartDefaultAttributeWidthAsInt()
          Returns the width of the current attribute in the Direct to Web context in which the receiver's rule fires.
 NSArray smartDefaultEntityNames()
          Returns a sorted NSArray of the names of the entities in the application.
 String smartDefaultKey()
          Returns the key for the default property of the current entity in the Direct to Web context in which the receiver's rule fires.
 String smartDefaultKeyWhenRelationship()
          Returns a key for the default property of the current relationship's destination object.
 String smartDefaultRows()
          Returns a String containing an estimate of the number of rows that a WOText element would need to display the current attribute.
 String valueString()
           
 
Methods inherited from class com.webobjects.directtoweb.Assignment
encodeWithKeyValueArchiver, keyPath, toString, value, value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultAssignment

public DefaultAssignment(String keyPath,
                         String value)
Constructs a new DefaultAssignment with the specified key path and value.
Parameters:
keyPath - - the key path.
value - - the value.

DefaultAssignment

public DefaultAssignment(EOKeyValueUnarchiver unarchiver)
Constructs a new DefaultAssignment based on an EOKeyValueUnarchiver. This is used to read the assignment information from a rule file.
Parameters:
unarchiver - - the unarchiver.
Method Detail

attributeWidth

public int attributeWidth()
Returns the attribute width.
Returns:
the attribute width.

d2wContext

public D2WContext d2wContext()

decodeWithKeyValueUnarchiver

public static Object decodeWithKeyValueUnarchiver(EOKeyValueUnarchiver unarchiver)
Description copied from class: Assignment
This method is intentionally undocumented. You should never have to invoke or customize it.

defaultDisplayNameForProperty

public String defaultDisplayNameForProperty()
Returns a String containing a user-presentable version of the current property key in the Direct to Web context in which the receiver's rule fires. This string is formed by capitalizing the key and inserting spaces between words with mixed case.
Returns:
the default display name for the current property.

defaultEntityName

public String defaultEntityName()
Returns the first entity name in the NSArray returned by the smartDefaultEntityNames method.
Returns:
the first of the smart default entity names.
See Also:
smartDefaultEntityNames()

defaultPropertyKeysFromEntity

public NSArray defaultPropertyKeysFromEntity()
Returns a sorted NSArray containing the property keys for the current entity excluding primary and foreign keys.
Returns:
the default property keys.

defaultPropertyKeysFromEntityWithoutRelationships

public NSArray defaultPropertyKeysFromEntityWithoutRelationships()
Returns a sorted NSArray containing the property keys for the current entity excluding relationships, primary keys, and foreign keys.
Returns:
the default property keys excluding relationships.

fire

public Object fire(D2WContext context)
Description copied from class: Assignment
This method is invoked when a rule fires. It returns the right-hand side value (an Object) for a right-hand side key in the Direct to Web context. You can override this method to provide your own assignments.
Overrides:
fire in class Assignment
Following copied from class: com.webobjects.directtoweb.Assignment
Parameters:
context - - the Direct to Web context.
Returns:
the value.

isEntityReadOnly

public Integer isEntityReadOnly()
Returns whether the current entity in the Direct to Web context in which the receiver's rule fires cannot be modified. You can specify whether an entity can be modified using the Web Assistant.

You can override this method to provide your own criteria for whether or not a entity can be modified.

Returns:
true if the current entity cannot be modified; false otherwise.

smartDefaultAttributeWidth

public final String smartDefaultAttributeWidth()
Returns the result of smartDefaultAttributeWidthAsInt as a String.
Returns:
the smart default attribute width as a String.
See Also:
smartDefaultAttributeWidthAsInt()

smartDefaultAttributeWidthAsInt

public int smartDefaultAttributeWidthAsInt()
Returns the width of the current attribute in the Direct to Web context in which the receiver's rule fires. Returns 50 if the width of the current attribute is less than 50. Returns 20 if the current property is not an attribute.
Returns:
the smart default attribute width as an int.

smartDefaultEntityNames

public final NSArray smartDefaultEntityNames()
Returns a sorted NSArray of the names of the entities in the application. Entities having fewer than three relationships and no attributes are assumed to be join tables and are excluded.
Returns:
the entity names excluding join tables.

smartDefaultKey

public String smartDefaultKey()
Returns the key for the default property of the current entity in the Direct to Web context in which the receiver's rule fires. This method guesses the most likely property with which the user will query for the entity and returns its key.
Returns:
the smart default key.

smartDefaultKeyWhenRelationship

public String smartDefaultKeyWhenRelationship()
Returns a key for the default property of the current relationship's destination object. If the current property in the Direct to Web context in which the receiver's rule fires is not a relationship, returns null. This method guesses the most likely property with which the user will query for the relationship's destination entity and returns its key.
Returns:
the smart default key of current relationship's destination; null if the current property is not a relationship.

smartDefaultRows

public final String smartDefaultRows()
Returns a String containing an estimate of the number of rows that a WOText element would need to display the current attribute.
Returns:
the smart default rows as a String.

valueString

public String valueString()

Last updated Fri Feb 21 13:15:00 PST 2003.

Copyright © 2003 Apple Computer, Inc.