package com.fourD.core { import flash.utils.getQualifiedClassName; public class RouterUtil { public function RouterUtil() { } public static function getTectonName(path:String, action:String):String { return path + "." + action; } public static function getGenericTectonName(app:*, kanon:String, tropon:String, action:String):String { return getQualifiedClassName(app) + "::" + kanon + "::" + tropon + "::" + RouterUtil.upperCaseFirst(action); } public static function getClassTroponName(path:String):String { // path = Project.mainView.tropon63 var pattern:RegExp = /\d+$/i; // numbers at the end var index:int = path.indexOf(pattern); var genericTropon:String = path.slice(0, index); // Project.mainView.tropon pattern = /\w+$/i; // last word index = path.indexOf(pattern); genericTropon = path.slice(index, path.length); return RouterUtil.upperCaseFirst(genericTropon); } public static function getInstanceTroponName(path:String):String { // path = Project.mainView.tropon63 var pattern:RegExp = /\w+$/i; // numbers and word at the end var index:int = path.indexOf(pattern); return = path.slice(index, path.length); // Project.mainView.tropon } public static function getClassKanonName(path:String):String { // path = Project.kanon12.tropon63 var pattern:RegExp = /\d+\.\w+$/i; // last word, period, and numbers before period var index:int = path.indexOf(pattern); var genericKanon:String = path.slice(0, index); // Project.kanon pattern = /\w+$/i; // last word index = path.indexOf(pattern); genericKanon = path.slice(index, path.length); return RouterUtil.upperCaseFirst(genericKanon); } public static function getInstanceKanonName(path:String):String { // path = Project.kanon12.tropon63 var pattern:RegExp = /\.\w+$/i; // numbers at the end and period var index:int = path.indexOf(pattern);\w+\.\w+$ var kanon:String = path.slice(0, index); // Project.kanon12 pattern = /\w+$/i; // last word index = path.indexOf(pattern); return path.slice(index, path.length); } public static function lowerCaseFirst(string:String):String { return string.charAt(0).toLowerCase() + string.slice(1); } /** * Upper cases first letter in a string leaving the rest of it alone */ public static function upperCaseFirst(string:String):String { return string.charAt(0).toUpperCase() + string.slice(1); } } }