| 
<?php
 /**
 * JAVA Autoboxing (part of Lotos Framework)
 *
 * Copyright (c) 2005-2010 Artur Graniszewski ([email protected])
 * All rights reserved.
 *
 * @category   Example
 * @package    Lotos
 * @subpackage Examples
 * @copyright  Copyright (c) 2005-2010 Artur Graniszewski ([email protected])
 * @license    GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007
 * @version    $Id$
 */
 
 
 /**
 * Example class.
 *
 * Note: in order to use AutoBoxing, your class need to extend "AutoBoxedObject" class.
 */
 class String extends AutoBoxedObject
 {
 public $value;
 
 public function __construct($value) {
 $this->value = $value;
 }
 
 public function __toString() {
 // NOTE: this must be a string, PHP forbids returning different type of variables in __toString() methods.
 return "$this->value";
 }
 
 public function toUpperCase() {
 return strtoupper($this->value);
 }
 }
 
 /**
 * Initializes a newly created String object.
 * @return String created String object
 */
 function & string($value = null) {
 $x = & VariablesManager::getNewPointer(new String($value));
 return $x;
 }
 
 /**
 * Example class.
 *
 * Note: in order to use AutoBoxing, your class need to extend "AutoBoxedObject" class.
 */
 class CachedString extends AutoBoxedObject
 {
 public $value;
 
 public function __construct($value) {
 parent::__construct();
 $this->value = & VariablesManager::getIntern($value, $this->internId);
 }
 
 public function __destruct() {
 VariablesManager::unsetIntern($this->internId);
 parent::__destruct();
 }
 
 public function __toString() {
 // NOTE: this must be a string, PHP forbids returning different type of variables in __toString() methods.
 return "$this->value";
 }
 
 public function toUpperCase() {
 return strtoupper($this->value);
 }
 }
 
 /**
 * Initializes a newly created String object.
 * @return String created String object
 */
 function & cachedString($value = null) {
 $x = & VariablesManager::getNewPointer(new CachedString($value));
 return $x;
 }
 
 /**
 * Example class.
 *
 * Note: in order to use AutoBoxing, your class need to extend "AutoBoxedObject" class.
 */
 class Integer extends AutoBoxedObject
 {
 public $value = 0;
 
 public function __construct($value) {
 $this->value = $value;
 }
 
 public function __toString() {
 // NOTE: this must be a string, PHP forbids returning different type of variables in __toString() methods.
 return "{$this->value}";
 }
 
 public function imStillAnObject() {
 return true;
 }
 }
 
 /**
 * Initializes a newly created Integer object.
 * @return Integer created Integer object
 */
 function & integer($value = null) {
 $x = & VariablesManager::getNewPointer(new Integer($value));
 return $x;
 }
 
 
 
 
 |