package components.tree { /** * NameLabel is a 'default' (suitable for most situations) class responsible for * determining a label for an XML element. The possible label attributes are used in the following * order: labelFunction, labelField and label. */ public class NameLabel implements LabelRule { /** * The name of the XML element this rule applies to. */ public var name:Object = null; /** * Contant label. */ public var label:String = ""; /** * A field as label. */ public var labelField:Object = null; /** * A reference to a function that produces a label. */ public var labelFunction:Function = null; /** * Determine label. */ public function getLabel(node:XML):String { if(node.name() == name) { if(labelFunction != null) { return labelFunction(node); } if(labelField != null) { return node.child(labelField).toString(); } return label; } // Rule doesn't match therefore no label is returned. return null; } } }