Source for file Meta.class.php

Documentation is available at Meta.class.php

  1. <?php
  2. /**
  3. * XOAD Meta file.
  4. *
  5. * <p>This file defines the {@link XOAD_Meta} Class.</p>
  6. * <p>This class is used internally only.</p>
  7. *
  8. * @author Stanimir Angeloff
  9. *
  10. * @package XOAD
  11. *
  12. * @version 0.6.0.0
  13. *
  14. */
  15.  
  16. /**
  17. * XOAD Meta Class.
  18. *
  19. * <p>This class is used to extend classes with meta
  20. * data, such as private methods and/or variables.</p>
  21. * <p>You should never use this class directly.
  22. * Rather, use the {@link XOAD_Utilities} class.</p>
  23. *
  24. * @access public
  25. *
  26. * @author Stanimir Angeloff
  27. *
  28. * @package XOAD
  29. *
  30. * @version 0.6.0.0
  31. *
  32. */
  33. class XOAD_Meta extends XOAD_Observable
  34. {
  35. /**
  36. *
  37. * @access private
  38. *
  39. * @var array
  40. *
  41. */
  42. var $publicMethods;
  43.  
  44. /**
  45. *
  46. * @access private
  47. *
  48. * @var array
  49. *
  50. */
  51. var $privateMethods;
  52.  
  53. /**
  54. *
  55. * @access private
  56. *
  57. * @var array
  58. *
  59. */
  60. var $publicVariables;
  61.  
  62. /**
  63. *
  64. * @access private
  65. *
  66. * @var array
  67. *
  68. */
  69. var $privateVariables;
  70.  
  71. /**
  72. *
  73. * @access private
  74. *
  75. * @var array
  76. *
  77. */
  78. var $methodsMap;
  79.  
  80. /**
  81. *
  82. * @access public
  83. *
  84. * @return void
  85. *
  86. */
  87. function setPublicMethods($methods)
  88. {
  89. $methodsType = XOAD_Utilities::getType($methods);
  90.  
  91. if ($methodsType == 'string') {
  92.  
  93. $this->publicMethods = array(XOAD_Utilities::caseConvert($methods));
  94.  
  95. } else if (($methodsType == 's_array') || ($methodsType == 'a_array')) {
  96.  
  97. $this->publicMethods = array_map(array('XOAD_Utilities', 'caseConvert'), $methods);
  98.  
  99. } else {
  100.  
  101. $this->publicMethods = null;
  102. }
  103. }
  104.  
  105. /**
  106. *
  107. * @access public
  108. *
  109. * @return void
  110. *
  111. */
  112. function setPrivateMethods($methods)
  113. {
  114. $methodsType = XOAD_Utilities::getType($methods);
  115.  
  116. if ($methodsType == 'string') {
  117.  
  118. $this->privateMethods = array(XOAD_Utilities::caseConvert($methods));
  119.  
  120. } else if (($methodsType == 's_array') || ($methodsType == 'a_array')) {
  121.  
  122. $this->privateMethods = array_map(array('XOAD_Utilities', 'caseConvert'), $methods);
  123.  
  124. } else {
  125.  
  126. $this->privateMethods = null;
  127. }
  128. }
  129.  
  130. /**
  131. *
  132. * @access public
  133. *
  134. * @return void
  135. *
  136. */
  137. function setPublicVariables($variables)
  138. {
  139. $variablesType = XOAD_Utilities::getType($variables);
  140.  
  141. if ($variablesType == 'string') {
  142.  
  143. $this->publicVariables = array(XOAD_Utilities::caseConvert($variables));
  144.  
  145. } else if (($variablesType == 's_array') || ($variablesType == 'a_array')) {
  146.  
  147. $this->publicVariables = array_map(array('XOAD_Utilities', 'caseConvert'), $variables);
  148.  
  149. } else {
  150.  
  151. $this->publicVariables = null;
  152. }
  153. }
  154.  
  155. /**
  156. *
  157. * @access public
  158. *
  159. * @return void
  160. *
  161. */
  162. function setPrivateVariables($variables)
  163. {
  164. $variablesType = XOAD_Utilities::getType($variables);
  165.  
  166. if ($variablesType == 'string') {
  167.  
  168. $this->privateVariables = array(XOAD_Utilities::caseConvert($variables));
  169.  
  170. } else if (($variablesType == 's_array') || ($variablesType == 'a_array')) {
  171.  
  172. $this->privateVariables = array_map(array('XOAD_Utilities', 'caseConvert'), $variables);
  173.  
  174. } else {
  175.  
  176. $this->privateVariables = null;
  177. }
  178. }
  179.  
  180. /**
  181. *
  182. * @access public
  183. *
  184. * @return void
  185. *
  186. */
  187. function setMethodsMap($methodsMap)
  188. {
  189. $methodsMapType = XOAD_Utilities::getType($methodsMap);
  190.  
  191. if ($methodsMapType == 'string') {
  192.  
  193. $this->methodsMap = array(XOAD_Utilities::caseConvert($methodsMap) => $methodsMap);
  194.  
  195. } else if (($methodsMapType == 's_array') || ($methodsMapType == 'a_array')) {
  196.  
  197. $map = array();
  198.  
  199. foreach ($methodsMap as $method) {
  200.  
  201. $map[XOAD_Utilities::caseConvert($method)] = $method;
  202. }
  203.  
  204. $this->methodsMap = $map;
  205.  
  206. } else {
  207.  
  208. $this->methodsMap = null;
  209. }
  210. }
  211.  
  212. /**
  213. *
  214. * @access public
  215. *
  216. * @return bool
  217. *
  218. */
  219. function isPublicMethod($methodName)
  220. {
  221. if ( ! empty($this->privateMethods)) {
  222.  
  223. if (in_array(XOAD_Utilities::caseConvert($methodName), $this->privateMethods)) {
  224.  
  225. return false;
  226. }
  227. }
  228.  
  229. if ( ! empty($this->publicMethods)) {
  230.  
  231. if ( ! in_array(XOAD_Utilities::caseConvert($methodName), $this->publicMethods)) {
  232.  
  233. return false;
  234. }
  235. }
  236.  
  237. return true;
  238. }
  239.  
  240. /**
  241. *
  242. * @access public
  243. *
  244. * @return bool
  245. *
  246. */
  247. function isPublicVariable($variableName)
  248. {
  249. if ( ! empty($this->privateVariables)) {
  250.  
  251. if (in_array(XOAD_Utilities::caseConvert($variableName), $this->privateVariables)) {
  252.  
  253. return false;
  254. }
  255. }
  256.  
  257. if ( ! empty($this->publicVariables)) {
  258.  
  259. if ( ! in_array(XOAD_Utilities::caseConvert($variableName), $this->publicVariables)) {
  260.  
  261. return false;
  262. }
  263. }
  264.  
  265. return true;
  266. }
  267.  
  268. /**
  269. *
  270. * @access public
  271. *
  272. * @return string
  273. *
  274. */
  275. function findMethodName($methodName)
  276. {
  277. if ( ! empty($this->methodsMap)) {
  278.  
  279. $name = XOAD_Utilities::caseConvert($methodName);
  280.  
  281. if (isset($this->methodsMap[$name])) {
  282.  
  283. return $this->methodsMap[$name];
  284. }
  285. }
  286.  
  287. return $methodName;
  288. }
  289.  
  290. /**
  291. * Adds a {@link XOAD_Meta} events observer.
  292. *
  293. * @access public
  294. *
  295. * @param mixed $observer The observer object to add (must extend {@link XOAD_Observer}).
  296. *
  297. * @return string true on success, false otherwise.
  298. *
  299. * @static
  300. *
  301. */
  302. function addObserver(&$observer)
  303. {
  304. return parent::addObserver($observer, 'XOAD_Meta');
  305. }
  306.  
  307. /**
  308. *
  309. * @access public
  310. *
  311. * @return bool
  312. *
  313. */
  314. function notifyObservers($event = 'default', $arg = null)
  315. {
  316. return parent::notifyObservers($event, $arg, 'XOAD_Meta');
  317. }
  318. }
  319. ?>

Documentation generated on Sat, 12 Nov 2005 20:24:20 +0200 by phpDocumentor 1.3.0RC3