Packageorg.restfulx.utils
Classpublic class RxUtils

Various Utilities.



Public Methods
 MethodDefined by
  
addModelToCache(model:Object, fqn:String):void
[static] Add a give model to cache.
RxUtils
  
addObjectIdToResourceURL(url:String, object:Object, suffix:String = "fxml"):String
[static] Reformats the URL to be suitable for update/destroy requests where model id is embedded in the URL.
RxUtils
  
canDeleteModel(model:RxModel):Boolean
[static] Check to see if the model can be deleted
RxUtils
  
cast(targetType:String, value:Object):*
[static] Casts a variable to specific type from a string, while trying to do the right thing based on targetType description.
RxUtils
  
cleanupModelAssociations(model:Object, fqn:String):void
[static] Clean up all HasOne,HasMany associations that this model refers to recursively
RxUtils
  
cleanupModelReferences(model:Object, fqn:String, singleReference:String = ""):void
[static] Clean up references to specified model.
RxUtils
  
clone(object:Object, recursive:Boolean = false):Object
[static] If the object cloned is a RxModel do clone based on reflection, else default to binary ObjectUtil clone.
RxUtils
  
daysFromNow(numDays:int):Date
[static] Calculate days from now
RxUtils
  
describeResource(object:Object):XMLList
[static] Gets Resource metadata.
RxUtils
  
fireUndoRedoActionEvent(undoRedoFlag:int = 0):void
[static] Dispatches appropriate Undo/Redo event depending on the flag.
RxUtils
  
getAttributeAnnotation(attribute:XML, annotationName:String):XMLList
[static] Get specific annotation from XML node.
RxUtils
  
getResourceName(object:Object):String
[static] Get Rx Model resource name annotation
RxUtils
  
getResourcePathPrefix(object:Object):String
[static] Get Rx Model resource pathPrefix annotation
RxUtils
  
getWithDefault(str:String, defaultStr:String):String
[static] Get default string is str is empty or null
RxUtils
  
isAnyEmpty(... args):Boolean
[static] Checks to see if any of the arguments is empty or null
RxUtils
  
isBelongsTo(attribute:XML):Boolean
[static] Checks if the node is annotated with [BelongsTo]
RxUtils
  
isDateTime(attribute:XML):Boolean
[static] Checks if the node is annotated with [DateTime]
RxUtils
  
isEmpty(str:String):Boolean
[static] Check if the string is null or empty
RxUtils
  
isHasMany(attribute:XML):Boolean
[static] Checks if the node is annotated with [HasMany]
RxUtils
  
isHasOne(attribute:XML):Boolean
[static] Checks if the node is annotated with [HasOne]
RxUtils
  
isIgnored(attribute:XML):Boolean
[static] Checks if the node is annotated with [Ignored]
RxUtils
  
isInSamePackage(fqn1:String, fqn2:String):Boolean
[static] Checks if given FQNs are in the same package
RxUtils
  
isInTheFuture(date:Date):Boolean
[static] Check if a date is in the future
RxUtils
  
isInvalidPropertyName(name:String):Boolean
[static] Checks to see if a property should be ignored during serialization based on name.
RxUtils
  
isInvalidPropertyType(type:String):Boolean
[static] Checks to see if a property should be ignored during serialization based on type.
RxUtils
  
isLazy(attribute:XML):Boolean
[static] Checks if the node is annotated with [Lazy]
RxUtils
  
isNested(attribute:XML):Boolean
[static] Checks if the node is annotated with [Nested]
RxUtils
  
isoToDate(value:String):Date
[static] Convert from ISO date representation to an actual AS3 Date object
RxUtils
  
isPolymorphicBelongsTo(attribute:XML):Boolean
[static] Checks if the node is annotated with [BelongsTo(polymorphic="true")]
RxUtils
  
itemMatches(text:String, item:Object, properties:Array):Boolean
[static] Checks to see if any of the specified properties contain given text
RxUtils
  
lowerCaseFirst(string:String):String
[static] Lower cases first letter in a string leaving the rest of it alone
RxUtils
  
mergeArrays(items:Array, toAdd:Array, after:Boolean = false):RxCollection
[static] Merges two arrays and returns a new RxCollection of the result
RxUtils
  
navToURL(url:Object, target:String = "_top"):Boolean
[static] Wrapper around navigateToURL that does URLRequest formatting and error handling
RxUtils
  
nestResource(object:Object, nestedBy:Array = null, suffix:String = "fxml"):String
[static] Figures out the URL that this model resource represents including any other resources that it should be nested under.
RxUtils
  
removeFirstMatch(o:Object, ac:ArrayCollection):Object
[static] Shifts first match of the object from target ArrayCollection
RxUtils
  
shallowCopy(source:Object, target:Object, fqn:String):void
[static] Do a shallow copy on two RxModel instances.
RxUtils
  
toCamelCase(string:String):String
[static] Converts a string to CamelCase from snake_case
RxUtils
  
toSnakeCase(string:String):String
[static] Converts a string to snake_case from CamelCase
RxUtils
  
uncast(object:Object, property:String):*
[static] Convert a specific object to its string representation
RxUtils
  
updateExistingParentReferenceIfExists(model:Object, fqn:String):void
[static] Updates a parent references with this item if their ids match.
RxUtils
  
upperCaseFirst(string:String):String
[static] Upper cases first letter in a string leaving the rest of it alone
RxUtils
Method detail
addModelToCache()method
public static function addModelToCache(model:Object, fqn:String):void

Add a give model to cache.

Parameters
model:Object — model instance to clean-up references for
 
fqn:String — FullyQualifiedName of the model
addObjectIdToResourceURL()method 
public static function addObjectIdToResourceURL(url:String, object:Object, suffix:String = "fxml"):String

Reformats the URL to be suitable for update/destroy requests where model id is embedded in the URL.

Parameters
url:String — url to reformat
 
object:Object — object to append id of
 
suffix:String (default = "fxml")

Returns
String — url suitable for being used with update/destroy requests on models
canDeleteModel()method 
public static function canDeleteModel(model:RxModel):Boolean

Check to see if the model can be deleted

Parameters
model:RxModel — RxModel instance to check

Returns
Boolean
cast()method 
public static function cast(targetType:String, value:Object):*

Casts a variable to specific type from a string, while trying to do the right thing based on targetType description.

Parameters
targetType:String
 
value:Object

Returns
*
cleanupModelAssociations()method 
public static function cleanupModelAssociations(model:Object, fqn:String):void

Clean up all HasOne,HasMany associations that this model refers to recursively

Parameters
model:Object — model instance to clean-up references for
 
fqn:String — FullyQualifiedName of the model
cleanupModelReferences()method 
public static function cleanupModelReferences(model:Object, fqn:String, singleReference:String = ""):void

Clean up references to specified model.

Parameters
model:Object — model instance to clean-up references for
 
fqn:String — FullyQualifiedName of the model
 
singleReference:String (default = "") — indicates if this reference is single
clone()method 
public static function clone(object:Object, recursive:Boolean = false):Object

If the object cloned is a RxModel do clone based on reflection, else default to binary ObjectUtil clone. Recursive cloning can be very slow and should be avoided for large trees.

Parameters
object:Object — object to clone
 
recursive:Boolean (default = false) — indicates if references RxModels should be cloned too

Returns
Object — cloned RxModel instance
daysFromNow()method 
public static function daysFromNow(numDays:int):Date

Calculate days from now

Parameters
numDays:int

Returns
Date
describeResource()method 
public static function describeResource(object:Object):XMLList

Gets Resource metadata.

Parameters
object:Object — object to instrospect

Returns
XMLList
fireUndoRedoActionEvent()method 
public static function fireUndoRedoActionEvent(undoRedoFlag:int = 0):void

Dispatches appropriate Undo/Redo event depending on the flag.

Parameters
undoRedoFlag:int (default = 0) — flag indicating what action is being performed
getAttributeAnnotation()method 
public static function getAttributeAnnotation(attribute:XML, annotationName:String):XMLList

Get specific annotation from XML node.

Parameters
attribute:XML
 
annotationName:String

Returns
XMLList
getResourceName()method 
public static function getResourceName(object:Object):String

Get Rx Model resource name annotation

Parameters
object:Object — restfulx model

Returns
String
getResourcePathPrefix()method 
public static function getResourcePathPrefix(object:Object):String

Get Rx Model resource pathPrefix annotation

Parameters
object:Object — restfulx model

Returns
String
getWithDefault()method 
public static function getWithDefault(str:String, defaultStr:String):String

Get default string is str is empty or null

Parameters
str:String
 
defaultStr:String

Returns
String
isAnyEmpty()method 
public static function isAnyEmpty(... args):Boolean

Checks to see if any of the arguments is empty or null

Parameters
... args

Returns
Boolean
isBelongsTo()method 
public static function isBelongsTo(attribute:XML):Boolean

Checks if the node is annotated with [BelongsTo]

Parameters
attribute:XML

Returns
Boolean
isDateTime()method 
public static function isDateTime(attribute:XML):Boolean

Checks if the node is annotated with [DateTime]

Parameters
attribute:XML

Returns
Boolean
isEmpty()method 
public static function isEmpty(str:String):Boolean

Check if the string is null or empty

Parameters
str:String — String to check

Returns
Boolean
isHasMany()method 
public static function isHasMany(attribute:XML):Boolean

Checks if the node is annotated with [HasMany]

Parameters
attribute:XML

Returns
Boolean
isHasOne()method 
public static function isHasOne(attribute:XML):Boolean

Checks if the node is annotated with [HasOne]

Parameters
attribute:XML

Returns
Boolean
isIgnored()method 
public static function isIgnored(attribute:XML):Boolean

Checks if the node is annotated with [Ignored]

Parameters
attribute:XML

Returns
Boolean
isInSamePackage()method 
public static function isInSamePackage(fqn1:String, fqn2:String):Boolean

Checks if given FQNs are in the same package

Parameters
fqn1:String — FQN1
 
fqn2:String — FQN2

Returns
Boolean
isInTheFuture()method 
public static function isInTheFuture(date:Date):Boolean

Check if a date is in the future

Parameters
date:Date

Returns
Boolean
isInvalidPropertyName()method 
public static function isInvalidPropertyName(name:String):Boolean

Checks to see if a property should be ignored during serialization based on name.

Parameters
name:String — property name

Returns
Boolean
isInvalidPropertyType()method 
public static function isInvalidPropertyType(type:String):Boolean

Checks to see if a property should be ignored during serialization based on type.

Parameters
type:String — property type

Returns
Boolean
isLazy()method 
public static function isLazy(attribute:XML):Boolean

Checks if the node is annotated with [Lazy]

Parameters
attribute:XML

Returns
Boolean
isNested()method 
public static function isNested(attribute:XML):Boolean

Checks if the node is annotated with [Nested]

Parameters
attribute:XML

Returns
Boolean
isoToDate()method 
public static function isoToDate(value:String):Date

Convert from ISO date representation to an actual AS3 Date object

Parameters
value:String

Returns
Date
isPolymorphicBelongsTo()method 
public static function isPolymorphicBelongsTo(attribute:XML):Boolean

Checks if the node is annotated with [BelongsTo(polymorphic="true")]

Parameters
attribute:XML

Returns
Boolean
itemMatches()method 
public static function itemMatches(text:String, item:Object, properties:Array):Boolean

Checks to see if any of the specified properties contain given text

Parameters
text:String — the text string to match
 
item:Object — object to check
 
properties:Array — an array of item properties to check against

Returns
Boolean — true if any of the properties match text, false otherwise
lowerCaseFirst()method 
public static function lowerCaseFirst(string:String):String

Lower cases first letter in a string leaving the rest of it alone

Parameters
string:String

Returns
String
mergeArrays()method 
public static function mergeArrays(items:Array, toAdd:Array, after:Boolean = false):RxCollection

Merges two arrays and returns a new RxCollection of the result

Parameters
items:Array
 
toAdd:Array
 
after:Boolean (default = false)

Returns
RxCollection
navToURL()method 
public static function navToURL(url:Object, target:String = "_top"):Boolean

Wrapper around navigateToURL that does URLRequest formatting and error handling

Parameters
url:Object — either a String URL or a URLRequest
 
target:String (default = "_top") — the target for the URL

Returns
Boolean — true if the navigateToURL call succeeded, false if it did not (or if it wasn't attempted)
nestResource()method 
public static function nestResource(object:Object, nestedBy:Array = null, suffix:String = "fxml"):String

Figures out the URL that this model resource represents including any other resources that it should be nested under.

Parameters
object:Object — the model resource
 
nestedBy:Array (default = null) — an array of model instances that should be used to nest this resource
 
suffix:String (default = "fxml")

Returns
String — string representation of the URL for this model resource
removeFirstMatch()method 
public static function removeFirstMatch(o:Object, ac:ArrayCollection):Object

Shifts first match of the object from target ArrayCollection

Parameters
o:Object
 
ac:ArrayCollection

Returns
Object
shallowCopy()method 
public static function shallowCopy(source:Object, target:Object, fqn:String):void

Do a shallow copy on two RxModel instances. Must of the same type.

Parameters
source:Object — source object
 
target:Object — target object
 
fqn:String
toCamelCase()method 
public static function toCamelCase(string:String):String

Converts a string to CamelCase from snake_case

Parameters
string:String

Returns
String
toSnakeCase()method 
public static function toSnakeCase(string:String):String

Converts a string to snake_case from CamelCase

Parameters
string:String

Returns
String
uncast()method 
public static function uncast(object:Object, property:String):*

Convert a specific object to its string representation

Parameters
object:Object
 
property:String

Returns
*
updateExistingParentReferenceIfExists()method 
public static function updateExistingParentReferenceIfExists(model:Object, fqn:String):void

Updates a parent references with this item if their ids match.

Parameters
model:Object — model instance to clean-up references for
 
fqn:String — FullyQualifiedName of the model
upperCaseFirst()method 
public static function upperCaseFirst(string:String):String

Upper cases first letter in a string leaving the rest of it alone

Parameters
string:String

Returns
String