Mutan API

A.Introduction
B.Variable type
 1.void
 2.bool
 3.int
 4.string
 5.array
 6.function
 7.object
 8.hash
 9.enum
C.core
 1.DomUtils
 2.HttpRequestUtils
 3.mConfig
 4.mController
 5.mUtils
D.utility
 1.mFilter
 2.mLanguage
 3.mLogger
 4.mValidator
E.render
 1.mRender
 2.domRender
 3.dummyRender
 4.easyTemplateRender
 5.formRender
 6.hashRender
 7.htmlRender
 8.queryRender
F.request
 1.mRequest
 2.formRequest
 3.hashRequest
 4.queryRequest
G.action
 1.mAction
H.model
 1.mModel






A.Introduction
 This document for public member and public method of each object.
 Object tree of Mutan is as follows.

 + root
    + DomUtils
    + HttpRequestUtils
    + mController
    |  + mRender
    |  + mRequest
    |  + mAction
    |     + mModel
    + mUtils
       + mConfig
       + array
       |  + mFilter
       + mLanguage
       + mLogger
       + array
       |  + mValidator
       + context

---- 8< ---- Tear off along dotted line ---- 8< ----

B.Variable type
 This is explanation of the variable type.
 Special type for the explanation is included in this.

 1.void
  This type is non value.

 2.bool
  This type is true or false.
  It is called the boolean.

 3.int
  This type is only numerical.

 4.string
  This type is character string.

 5.array
  This type is array.

 6.function
  This type is function.

 7.object
  This type can any value.

 8.hash
  This type is subset of object.
  It is association array like
   {'key' : 'value'}

 9.enum
  This type is subset of string.
  It is allowed only special value.
  For instance
   ["strawberry",'apple','orange','pear']
  at this time,"melon" is not allowed though "strawberry" and "pear".
  The value defined by double quart(") is default value.
  If list of values when all are single quart('),it is allowed other value.

---- >8 ---- Tear off along dotted line ---- >8 ----

C.core
 This objects are core of Mutan.

 1.DomUtils (/mutan/lib/core/domUtils.js > /mutan/core.js)
  This object is DOM control object.
  You can access to this object by DomUtils.

  void appendEvent(object obj,string eveName,function fnc,enum priority)
   obj         : target object
   eveName     : event name (without "on" before event name)
   fnc         : callback function
   priority    : priority of this callback function ['first',"normal",'last']
   return      : none return value
   see         : DomUtils::raiseEvent
   description : This method is add callback function to target object.
                 Event name is allowed any value.

  void clearCache(string targetId)
   targetId    : ID of target object
   return      : none return value
   see         : DomUtils::createObject,DomUtils::getObject
   description : Cache of target object is cleared by this method.
                 If targetID isn't defined,all cache is cleared.

  object createObject(string targetId,string type,hash params,hash styles)
   targetId    : ID of target object
   type        : object type of target object
   params      : special parameter list of target object
   styles      : special style list of target object
   return      : created object
   see         : DomUtils::clearCache,DomUtils::getObject
   description : This method is wrapper of createElement.
                 This create new object.

  object getObject(targetId)
   targetId    : ID of target object
   return      : target object
   see         : DomUtils::clearCache,DomUtils::createObject
   description : This method is wrapper of getElementById.
                 This method result is cached.

  void init(void)
   arguments   : none arguments value
   return      : none return value
   see         : window::onload
   description : This method is initialize this object.
                 You will not call this method.

  void raiseEvent(object obj,string eveName,object args)
   obj         : target object
   eveName     : event name (without "on" before event name)
   args        : arguments of callback function
   return      : none return value
   see         : DomUtils::appendEvent
   description : This method executes callback functions added by appendEvent.
                 Order is decided by priority.
                 This method is wrapper of onXXX,but you can call original event too.


 2.HttpRequestUtils (/mutan/lib/core/httpRequestUtils.js > /mutan/core.js)
  This object is XMLHttpRequest contol object.
  You can access to this object by HttpRequestUtils.

  string encodeString(hash val)
   val         : list of encode target data
   return      : val data that is URL encoded and is joined
   see         : XMLHttpRequest::send
   description : This method is wrapper of encodeURIComponent.

  object getClient(enum mod,string adr)
   mod         : sending method name ['get','post','head']
   adr         : target URI
   return      : XMLHttpRequest object
   see         : XMLHttpRequest
   description : This method is created XMLHttpRequest object with charset header and callback function.
                 Callback function is execute object.callbacks['response code'] function.
                 object.callbacks['unknown'] is fallback function.
                 Arguments of callback function is {'txt' : responseText,'xml' : responseXML}.

  void init(void)
   arguments   : none arguments value
   return      : none return value
   see         : window::onload
   description : This method is initialize this object.
                 You will not call this method.

  void isUnknown(hash res)
   res         : {'txt','xml'}
   return      : none return value
   see         : HttpRequestUtils::getClient
   description : This method is fallback function.
                 You will not call this method.

  object parseJson(string txt)
   txt         : target JSON string
   return      : created object
   see         : XMLHttpRequest
   description : This method is parsed from JSON text to object.


 3.mConfig (/mutan/lib/core/mUtils.js > /mutan/core.js)
  This object is configure management object.
  You can access to this object by mUtils.config.

  string getConfig(string keyName)
   keyName     : target config name
   return      : setting value
   see         : mConfig::loadCustomConfig,mConfig::init,mConfig::setConfig
   description : This method is getting config value.
                 If same config name is setting,priority is 
                  action config & setting by setConfig > directory config > default value
                 action config & setting by setConfig is temporary setting.

  void init(void)
   arguments   : none arguments value
   return      : none return value
   see         : mUtils::init
   description : This method is initialize this object.
                 You will not call this method.

  void loadCustomConfig(string actionName,function func,object,args)
   actionName  : target action name
   func        : callback function for load completed
   args        : arguments of callback function
   return      : none return value
   see         : mController::doAction
   description : This method load action config.
                 You will not call this method.

  void loadDirConfig(function func,object args)
   func        : callback function for loading completed
   args        : arguments of callback function
   return      : none return value
   see         : mUtils::init,mConfig::getConfig
   description : This method is load config file for directory.

  void resetConfig(void)
   arguments   : none arguments value
   return      : none return value
   see         : mController::doAction,mConfig::getConfig,mConfig::setConfig
   description : action config and setting by setConfig is cleared by this method.

  void setConfig(string keyName,string value)
   keyName     : target config name
   value       : config value
   return      : none return value
   see         : mConfig::getConfig,mConfig::resetConfig
   description : This method is setting to config value.
                 This config value is high priority,but you can use only this action.


 4.mController (/mutan/lib/core/mController.js > /mutan/core.js)
  This object is main controller of Mutan.
  You can access to this object by mController.

  void appendActionChain(array actionChain)
   actionChain : array of target action name
   return      : none return value
   see         : mAction,mController::doAction
   description : action is added to action chain array by this method.

  void doAction(string actionName,object args)
   actionName  : action name
   args        : arguments of this action
   return      : none return value
   see         : mAction,mModel
   description : This method is execute action.

  void init(void)
   arguments   : none arguments value
   return      : none return value
   see         : window::load
   description : This method is initialize this object.
                 You will not call this method.


 5.mUtils (/mutan/lib/core/mUtils.js > /mutan/core.js)
  This object is utility of Mutan.
  You can access to this object by mUtils

  config : mConfig
   configure management object

  filter : hash {'key' : mFilter}
   output filter function hash

  language : mLanguage
   language management object

  logger : mLogger
   log management object

  validator : hash {'key' : mValidator}
   validation function hash

  context : hash {'key' : object}
   global variable space


  void appendFilter(hash filters)
   filters     : hash of filter functions
   return      : none return value
   see         : mFilter,mUtils::doFilter
   description : filter function is added to filter hash by this method.

  void appendValidator(hash validators)
   validators  : hash of validate functions
   return      : none return value
   see         : mValidator,mUtils::doValidate
   description : validate function is added to validator hash by this method.

  void dest(void)
   arguments   : none arguments value
   return      : none return value
   see         : window::unload
   description : This method is destructor of mutan core object.
                 You will not call this method.

  object doFilter(string value,array filter,hash params)
   value       : string of filtering target
   filter      : array of filter name strings
   params      : hash of filtering parameters
   return      : filtered value
   see         : mModel::show,mFilter,mUtils.appendFilter
   description : This method is execute filtering.

  object doTypeSafe(enum type,string value)
   type        : target type ['bool','int','float','string',"text"]
   value       : string of type safe target
   return      : type argument value
   see         : mModel::set
   description : This method is execute type safe.
                 string type in not allowed new line,but text type is allowed any character.

  object doValidate(string value,array validator,hash params)
   value       : string of validate target
   validator   : array of validator name strings
   params      : hash of validation parameters
   return      : validated value
   see         : mModel::set,mValidator,mUtils::appendValidator
   description : This method is execute validation.

  void init(void)
   arguments   : none arguments value
   return      : none return value
   see         : window::load
   description : This method is initialize this object.
                 You will not call this method.

  void loadFile(string file,bool mode)
   file        : string of target file name
   mode        : input mode (true : string mode,false : object mode)
   return      : none return value
   see         : HttpRequestUtils,mUtils::waitResponse
   description : Target file is loaded by this method.
                 This method result is cached.

  void preloadActionFile(array actions)
   actions     : array of action name strings
   return      : none return value
   see         : mUtils::loadFile,mController::doAction
   description : This method preload action files.

  void renderLog(enum level,bool flag)
   level       : message filtering level ['memo','notice','warning','critical']
   flag        : message filtering flag
   return      : none return value
   see         : mLogger
   description : Output log message to mutanLogBox by this method.
                 If flag is true,message of high level or more is matched and output.
                 You can output original level.

  void waitResponse(object pObj,hash list,function fnc,object args)
   pObj        : parent object for mapping
   list        : list of mapping {'key' : 'file name'}
   fnc         : callback function for mapping completed
   args        : arguments of callback function
   return      : none return value
   see         : mUtils::loadFile
   description : This method is wait for request response.
                 When loading completed,object is mapped to pObj.

---- 8< ---- Tear off along dotted line ---- 8< ----

D.utility
 This object is replaceable utility.

 1.mFilter (/mutan/lib/abstract/abstractFilter.js > /mutan/lib/filter.js)
  This object work is do filtering.
  You can access to this object by mUtils::filter.

  mHtmlFilter
   escape html character entity

  mUnHtmlFilter
   unescape html character entity

  mNewLineFilter
   convert from new line to br tag

  mUnNewLineFilter
   convert from br tag to new line


 2.mLanguage (/mutan/lib/interface/interfaceLanguage.js > /mutan/lib/language.js)
  This object is language management object.
  You can access to this object by mUtils::language.

  string getLanguage(string keyName,hash opts)
   keyName     : tartget language name
   opts        : replacement option
   return      : setting value
   see         : mLanguage::init,mLanguage::loadDirLanguage
   description : This method is getting language value.
                 When there is {"option key"},{"option key"} replace to {"option value"}.

  void init(void)
   arguments   : none arguments value
   return      : none return value
   see         : mUtils::init
   description : This method is initialize this object.
                 You will not call this method.

  void loadCustomLanguage(string actionName,function func,object args)
   actionName  : target action name
   fnc         : callback function for loading completed
   args        : arguments of callback function
   return      : none return value
   see         : mController::doAction,mLanguage::getLanguage
   description : This method is load language file for action.

  void loadDirLanguage(function func,object args)
   func        : callback function for loading completed
   args        : arguments of callback function
   return      : none return value
   see         : mUtils::init,mLanguage::getLanguage
   description : This method is load language file for directory.


 3.mLogger (/mutan/lib/interface/interfaceLogger.js > /mutan/lib/logger.js)
  This object is log management object.
  You can access to this object by mUtils::logger

  array getMessage(enum level,bool flag)
   level       : message filtering level ['memo','notice','warning','critical']
   flag        : message filtering flag
   return      : message object array
   see         : mLogger::setMessage,mLogger::setTime
   description : This method is getting message object array.
                 If flag is true,message of high level or more is matched and get.
                 You can get original level.

  string getMessageString(enum level,bool flag)
   level       : message filtering level ['memo','notice','warning','critical']
   flag        : message filtering flag
   return      : message object array
   see         : mLogger::getMessage,mLogger::setMessage,mLogger::setTimer
   description : This method is getting message string.
                 If flag is true,message of high level or more is matched and get.
                 You can get original level.

  int getTimer(string timerName)
   timerName   : target timer name
   return      : elapsed time from started
   see         : mLogger::setTimer
   description : Get elapsed time from started by this method.

  void init(void)
   arguments   : none arguments value
   return      : none return value
   see         : mUtils::init
   description : This method is initialize this object.
                 You will not call this method.

  void setMessage(enum level,string path,string section,string message)
   level       : message level
   path        : object name where message is raised
   section     : point name where message is raised
   message     : string of message
   return      : none return value
   see         : mLogger::getMessage
   description : This method is register message.
                 You can set original level.

  void setTimer(string timerName)
   timerName   : target timer name
   return      : none return value
   see         : mLogger::getTimer
   description : Timer is started by this method.
                 If timer is start,timer is reset.


 4.mValidator (/mutan/lib/abstract/abstractValidator.js > /mutan/lib/validator.js)
  This object work is validation.
  You can access to this object by mUtils::validator


  mAlphabetValidator
   allowed only alphabet

  mEnumValidator
   enumArray : allowed list array
   If value in enumArray, it allowed

  mFilterValidator
   filter     : filtering pattern
   filterFlag : filtering option flag
   If filtering pattern is not included,it allowed

  mLengthRangeValidator
   minLength : minimum length
   maxLength : maximum length
   allowed string length is between minLength and maxLength

  mMaskValidator
   mask     : mask pattern
   maskFlag : mask option flag
   

  mMaxLengthValidator
   maxLength : maximum length
   allowed string length is or less maxLength

  mMaxValueValidator
   max : maximum value
   allowed value is or less max

  mMinLengthValidator
   minLength : minimum length
   allowed string length is more than minLength

  mMinValueValidator
   min : minimum value
   allowed value is more than min

  mNumberValidator
   allowed only numeric

  mRequireValidator
   allowed not null

  mValueRengeValidator
   min : minimum value
   max : maximum value
   allowed value is between min and max

---- >8 ---- Tear off along dotted line ---- >8 ----

E.render
 This object work is do view process.

 1.mRender (/mutan/lib/interface/interfaceRender.js)
  This object is interface of render object.
  If you create original render, it should have this interface.

  void display(void)
   arguments   : none arguments value
   return      : none return value
   see         : mAction::executeViewXXXX,mRender::setRenderTarget,mRender::setRenderValue
   description : This method is display at result.

  void init(void)
   arguments   : none arguments value
   return      : none return value
   see         : mController::doAction
   description : This method is initialize this object.
                 You will not call this method.

  void setRenderTarget(object targetObject)
   targetObject : target object
   return       : none return value
   see          : mAction,mRender::display
   description  : This method is setting object for render.

 2.domRender (/mutan/render/domRender.js)
  This object work is appendChild to target object.
  This hasn't speciality method.

 3.dummyRender (/mutan/render/dummyRender.js)
  This object don't work, because this object is dummy.
  This hasn't speciality method.

 4.easyTemplateRender (/mutan/render/easyTemplateRender.js)
  This object have easy template function.
  This has special config at "template" and "templatePath".

  void setDelimiter(string leftDelemiter,string rightDelimiter)
   leftDelimiter  : string of left delimiter for split to variable
   rightDelimiter : string of right delimiter for split to variable
   return         : none return value
   see            : mRender::display,mRender::setRenderValue
   description    : This method is setting to delimiter.
                    Default setting is <{ and }>.

  void setTemplate(string file)
   file        : string of template file name
   return      : none return value
   see         : easyTemplateRender::setTemplatePath,mRender::display
   description : This method is setting to template.
                 Execute easyTemplateRender::setTemplatePath before executing this.
                 This method result is cached.

  void setTemplatePath(string path)
   path        : string of template path
   return      : none return value
   see         : easyTemplateRender::setTemplate
   description : This method is setting to template path.
                 This method executing before easyTemplateRender::setTemplate.

 5.formRender (/mutan/render/formRender.js)
  This object work is set to form node.
  This hasn't speciality method.

 6.hashRender (/mutan/render/hashRender.js)
  This object work is set to location.hash.
  This hasn't speciality method.

 7.htmlRender (/mutan/render/htmlRender.js)
  This object work is set to innerHTML of target object.
  This hasn't speciality method.

 8.queryRender (/mutan/render/queryRender.js)
  This object work is set to location.search.
  This hasn't speciality method.

---- 8< ---- Tear off along dotted line ---- 8< ----

F.request
 This object work is get input data from anywhere.

 1.mRequest (/mutan/lib/interface/interfaceRequest.js)
  This object is interface of request object.
  If you create original request, it should have this interface.

  void init(void)
   arguments   : none arguments value
   return      : none return value
   see         : mController::doAction
   description : This method is initialize this object.
                 You will not call this method.

  object get(string keyName)
   keyName     : string of target name
   return      : getting object
   see         : mAction,mModel
   description : This method work is get data of target.

 2.formRequest (/mutan/request/formRequest.js)
  This object is get input data from form object.
  This hasn't speciality method.

 3.hashRequest (/mutan/request/hashRequest.js)
  This object is get input data from location.hash.
  This hasn't speciality method.

 4.queryRequest (/mutan/request/queryRequest.js)
  This object is get input data from location.search.
  This hasn't speciality method.

---- >8 ---- Tear off along dotted line ---- >8 ----

G.action
 This object is executing action.

 1.mAction (/mutan/lib/abstractAction.js)
  This object is abstract of action object.
  executeViewXXX method mounts necessary number.

  string execute(mRequest request,object args)
   request     : request object
   args        : arguments from mController::doAction
   return      : view method name
   see         : mController::doAction,mRequest,mModel,mAction::executeXXX
   description : This method is main process of action.

  void executeViewError(mRender render)
   render      : render object
   return      : none return value
   see         : mAction::execute,mRender
   desctiption : This method is error process view.

  void executeViewIndex(mRender render)
   render      : render object
   return      : none return value
   see         : mAction::execute,mRender
   desctiption : This method is index process view.

  void executeViewInput(mRender render)
   render      : render object
   return      : none return value
   see         : mAction::execute,mRender
   desctiption : This method is input process view.

  void executeViewNone(mRender render)
   render      : render object
   return      : none return value
   see         : mAction::execute,mRender
   desctiption : This method is dummy process view.

  void executeViewSuccess(mRender render)
   render      : render object
   return      : none return value
   see         : mAction::execute,mRender
   desctiption : This method is success process view.

  void init(mModel model)
   model       : model object
   return      : none return value
   see         : mController::doAction,mModel
   description : This method is initialize this object.
                 You will not call this method.

---- 8< ---- Tear off along dotted line ---- 8< ----

H.model
 This object work is to define data property.

 1.mModel (/mutan/lib/abstract/acstractModel.js)
  This object is abstract of model object

  object get(string keyName)
   keyName     : string of target name
   return      : getting object
   see         : mAction,mModel::set
   description : This method work is get raw data.
                 If you used this data for display,mModel::show is more better.

  void init(mRequest request)
   model       : request object
   return      : none return value
   see         : mAction,mRequest
   description : This method is initialize this object.
                 You will not call this method.

  void initVar(enum type,string keyName,object value,array validator,hash vParams,array filter,hash fParams)
   type        : string of value type name ['bool','int','float',,'string','text']
   keyName     : string of data name
   value       : default value
   validator   : array of validator name
   vParams     : parameter for validate functions
   filter      : array of filter name
   fParams     : parameter for filtring functions
   return      : none return value
   see         : mModel::set,mModel::show
   description : This method is to defined data format.

  void set(string keyName,object value)
   keyName     : string of data name
   value       : data value
   return      : none return value
   see         : mModel::get,mModel::initVar,mModel::show
   description : This method is setting to data value with validation.
                 If data is not valide,data value is null.

  object show(string keyName)
   keyName     : string of target name
   return      : getting object
   see         : mAction,mModel::set,mModel::initVar
   description : This method is get data with filter.
                 If you used this data for display,this method is more better than mModel::get.


