public function getRenderer($rendererId) { if (!array_key_exists($rendererId, $this->renderer)) { $this->renderer[$rendererId] = \blaze\lang\ClassWrapper::forName('blaze\\web\\render\\html4\\' . $rendererId)->newInstance(); } return $this->renderer[$rendererId]; }
/** * Returns an instance of TypeChecker for the specified type. * * @param string|blaze\lang\String|blaze\lang\ClassWrapper $type * @return blaze\collections\TypeChecker */ public static function getInstance($type) { if ($type === null) { throw new blaze\lang\NullPointerException(); } $class = null; $type = null; $typeName = null; if ($type instanceof \blaze\lang\ClassWrapper) { $class = $type; $typeName = $type->getName(); } else { $type = \blaze\lang\String::asNative($type); if (in_array($type, self::$basicTypes)) { $type = $type; $typeName = new \blaze\lang\String($type); } else { $class = \blaze\lang\ClassWrapper::forName($type); $typeName = $class->getName(); } } if (!array_key_exists($typeName, self::$typeCheckers)) { self::$typeCheckers[$typeName] = new TypeChecker($type, $class, $typeName); } return self::$typeCheckers[$typeName]; }
public function __construct(\blaze\collections\map\Properties $properties, \blaze\collections\ListI $ressources) { $driverName = $properties->getProperty('persistence.connection.datasource.class'); $dsUsername = $properties->getProperty('persistence.connection.datasource.username'); $dsPassword = $properties->getProperty('persistence.connection.datasource.password'); $dsOptions = $properties->getProperty('persistence.connection.datasource.options'); if ($driverName != null) { $dsClass = \blaze\lang\ClassWrapper::forName($driverName); $dsHost = $properties->getProperty('persistence.connection.datasource.host'); $dsPort = $properties->getProperty('persistence.connection.datasource.port'); $dsDatabase = $properties->getProperty('persistence.connection.datasource.database'); $this->ds = $dsClass->getMethod('getDataSource')->invokeArgs(null, array($dsHost, $dsPort, $dsDatabase, $dsUsername, $dsPassword, $dsOptions)); } else { $dsn = $properties->getProperty('persistence.connection.datasource.url'); $this->ds = \blaze\ds\DataSourceManager::getInstance()->getDataSource($dsn, $dsUsername, $dsPassword, $dsOptions); } $this->dialect = \blaze\lang\ClassWrapper::forName($properties->getProperty('persistence.dialect'))->newInstance(); foreach ($ressources as $ressource) { $this->loadMapping($ressource); } $this->properties = $properties; $this->ressources = $ressources; $this->freeConnections = new \blaze\collections\queue\Stack(); $this->usedConnections = new \blaze\collections\map\HashMap(); }
/** * * @param string|blaze\lang\String|blaze\lang\ClassWrapper $resultClass */ public function __construct($resultClass, $isArray = false) { $this->columnAliasToPropertyPathMapping = array(); $this->collectionProxies = array(); if ($resultClass instanceof \blaze\lang\ClassWrapper) { $this->resultClass = $resultClass; } else { $this->resultClass = \blaze\lang\ClassWrapper::forName(\blaze\lang\String::asNative($resultClass)); } $this->isArray = $isArray; }
public function get(\blaze\web\application\BlazeContext $context, $key) { $val = $this->variables->get($key); if ($val === null) { $def = $this->nutDefinitions->get($key); if ($def !== null) { $val = \blaze\lang\ClassWrapper::forName($def)->newInstance(); $this->variables->put($key, $val); } } return $val; }
private static function lazyInit() { self::$numberClasses = array(); self::$numberClasses[0] = ClassWrapper::forName('blaze\\lang\\Byte'); self::$numberClasses[1] = ClassWrapper::forName('blaze\\lang\\Short'); self::$numberClasses[2] = ClassWrapper::forName('blaze\\lang\\Double'); self::$numberClasses[3] = ClassWrapper::forName('blaze\\lang\\Float'); self::$numberClasses[4] = ClassWrapper::forName('blaze\\lang\\Integer'); self::$numberClasses[5] = ClassWrapper::forName('blaze\\lang\\Long'); self::$numberClasses[6] = ClassWrapper::forName('blaze\\math\\BigInteger'); self::$numberClasses[7] = ClassWrapper::forName('blaze\\math\\BigDecimal'); }
public function get(\blaze\web\application\BlazeContext $context, $key) { $defVal = $this->nutDefinitions->get($key); if ($defVal === null) { return null; } $sess = $this->getSession($context); $val = $sess->getAttribute($key); if ($val == null) { $val = \blaze\lang\ClassWrapper::forName($defVal)->newInstance(); $this->getSession($context)->setAttribute($key, $val); } return $val; }
/** * Returns the <code>Class</code> object representing the class or interface * that declares the field represented by this <code>Field</code> object. * * @return blaze\lang\ClassWrapper */ public function getDeclaringClass() { return ClassWrapper::forName($this->property->getDeclaringClass()->getName()); }
private function handleTagDecorators($node) { foreach ($node->childNodes as $child) { if ($child->nodeType == XML_ELEMENT_NODE) { $name = $child->getAttribute('name'); $class = $child->getAttribute('class'); $this->decorators->put($name, ClassWrapper::forName($class)->newInstance()); } } }
private function initFilters($node) { foreach ($node->childNodes as $child) { if ($child->localName == 'filter') { $name = $child->getAttribute('name'); $class = $child->getAttribute('class'); $initParams = $this->getInitParams($child); $filterConfig = new FilterConfigImpl($name, $this->netletContext, $initParams); $filter = ClassWrapper::forName($class)->newInstance(); $filter->init($filterConfig); $this->netletContext->addFilter($name, $filter); $mappings = self::getMappings($child); foreach ($mappings as $mapping) { $this->netletContext->addFilterMapping($mapping, $name); } } } }
public function readObjectOverride() { $ser = $this->getNext(); if ($ser[0] != 'O') { throw new \blaze\lang\ClassCastException('The next token is not a object'); } $start = strpos($ser, '"') + 1; $end = strpos($ser, '"', $start); $class = \blaze\lang\ClassWrapper::forName(substr($ser, $start, $end - $start)); $object = $class->newInstance(); if (!$object instanceof \blaze\io\Serializable) { throw new \blaze\io\NotSerializableException(); } $method = $class->getMethod('readObject'); if ($method != null) { $this->current = substr($ser, strpos($ser, '{', $end) + 1, -1); $method->invoke($object, $this); $this->current = null; } else { $object = unserialize($ser); } return $object; }
/** * Reads the annotations of the class and adds it to the mappings of the configuration * @param string|blaze\lang\String|blaze\lang\ClassWrapper $class * @return blaze\persistence\cfg\Configuration */ public function addClass($class) { if (\blaze\lang\String::isType($class)) { $class = \blaze\lang\ClassWrapper::forName($class); } if (!$class instanceof \blaze\lang\ClassWrapper) { throw new \blaze\lang\IllegalArgumentException('The parameter class must be a ClassWrapper or the full class name as string.'); } $annotations = $class->getAnnotations(); //Add mapping from the annotations return $this; }
private function handleChildren(\blaze\web\component\UIComponent $parent, $children, $compositionChildren) { $prefixComponents = array('b' => 'blaze\\web\\component\\html\\', 'e' => 'blaze\\web\\component\\event\\'); foreach ($children as $node) { if ($node->nodeType == XML_ELEMENT_NODE) { if ($node->prefix == 'b' || $node->prefix == 'e') { $class = ClassWrapper::forName($prefixComponents[$node->prefix] . ucfirst($node->localName)); $component = $class->newInstance(); if ($node->hasAttributes()) { foreach ($node->attributes as $attribute) { if ($attribute->nodeType == XML_ATTRIBUTE_NODE) { $class->getMethod('set' . ucfirst($attribute->nodeName))->invoke($component, $attribute->nodeValue); } } } $parent->addChild($component); if ($node->hasChildNodes()) { $this->handleChildren($component, $node->childNodes, $compositionChildren); } } else { if ($node->prefix == 'ui') { if ($node->localName == 'insert') { if ($compositionChildren != null) { $foundElem = $this->findCompositionDefinition($compositionChildren, $node->getAttribute('name')); if ($foundElem == null) { $this->handleChildren($parent, $node->childNodes, $compositionChildren); } else { $this->handleChildren($parent, $foundElem->childNodes, $compositionChildren); } } else { $this->handleChildren($parent, $node->childNodes, $compositionChildren); } } else { if ($node->localName == 'composite') { $template = $node->getAttribute('template'); if ($template == '') { throw new Exception('No template view given'); } $f = new \blaze\io\File($this->viewDir, $template); if (!$f->exists()) { throw new \blaze\io\IOException('Template was not found'); } $root = $this->getRoot($parent); $newRoot = $this->parseAndCreateView($f, $node->childNodes); $newRoot->setViewId($root->getViewId()); $this->views->put($newRoot->getViewId(), $newRoot); } } } else { $tag = '<' . $node->nodeName; if ($node->hasAttributes()) { foreach ($node->attributes as $attribute) { if ($attribute->nodeType == XML_ATTRIBUTE_NODE) { $tag .= ' ' . $attribute->nodeName . '="' . $attribute->nodeValue . '"'; } } } $parent->addChild(\blaze\web\component\html\PlainText::create()->setValue($tag . '>')); if ($node->hasChildNodes()) { $this->handleChildren($parent, $node->childNodes, $compositionChildren); } $parent->addChild(\blaze\web\component\html\PlainText::create()->setValue('</' . $node->nodeName . '>')); } } } else { if ($node->nodeType == XML_TEXT_NODE) { $content = trim($node->textContent); if (strlen($content) != 0) { $parent->addChild(\blaze\web\component\html\PlainText::create()->setValue($content)); } } } } }