public function generate(\blaze\lang\StringBuffer $buffer)
 {
     if ($this->package != null) {
         $packageName = $this->package;
         $className = $this->name;
     } else {
         $idx = $this->name->lastIndexOf('\\');
         $packageName = $this->name->substring(0, $idx)->toNative();
         $className = $this->name->substring($idx + 1)->toNative();
     }
     $buffer->append('<?php ' . PHP_EOL . PHP_EOL);
     $buffer->append('namespace ');
     $buffer->append($packageName);
     $buffer->append(';' . PHP_EOL . PHP_EOL);
     $buffer->append('class ');
     $buffer->append($className);
     $buffer->append(' extends \\blaze\\lang\\Object {' . PHP_EOL . PHP_EOL);
     foreach ($this->identifiers as $member) {
         $member->generate($buffer);
     }
     foreach ($this->singleFields as $member) {
         $member->generate($buffer);
     }
     foreach ($this->collectionFields as $member) {
         $member->generate($buffer);
     }
     $buffer->append('}');
 }
Exemple #2
0
 /**
  *
  * @param blaze\lang\String|string $value
  * @return string
  */
 public static function asNative($value)
 {
     if ($value instanceof String) {
         return $value->toNative();
     } else {
         if (is_string($value)) {
             return $value;
         } else {
             return (string) $value;
         }
     }
 }
Exemple #3
0
 public function equals(\blaze\lang\Reflectable $obj)
 {
     if ($obj === $this) {
         return true;
     }
     if ($obj == null || !$obj instanceof URI) {
         return false;
     }
     if ($this->url != null && $obj->url != null) {
         return $this->url->equals($obj);
     }
     $fragmetOk = true;
     if ($this->fragment != null xor $obj->fragment != null) {
         $fragmetOk = false;
     }
     if ($fragmetOk && $this->fragment != null && $obj->fragment != null) {
         $fragmetOk = $this->fragment->equals($obj->fragment);
     }
     return $this->scheme->equalsIgnoreCase($obj->scheme) && $this->schemeSpecificPart->equals($obj->schemeSpecificPart) && $fragmetOk;
 }
 public function generate(\blaze\lang\StringBuffer $buffer)
 {
     $buffer->append("\t" . '/**' . PHP_EOL);
     $buffer->append("\t" . ' * @var ' . $this->type . PHP_EOL);
     $buffer->append("\t" . ' */' . PHP_EOL);
     $buffer->append("\t" . 'private $');
     $buffer->append($this->name);
     $buffer->append(';' . PHP_EOL . PHP_EOL);
     $buffer->append("\t" . '/**' . PHP_EOL);
     $buffer->append("\t" . ' * @return ' . $this->type . PHP_EOL);
     $buffer->append("\t" . ' */' . PHP_EOL);
     $buffer->append("\t" . 'public function get' . $this->name->toUpperCase(true)->toNative() . '(){' . PHP_EOL);
     $buffer->append("\t" . "\t" . ' return $this->' . $this->name . ';' . PHP_EOL);
     $buffer->append("\t" . '}' . PHP_EOL . PHP_EOL);
     $buffer->append("\t" . '/**' . PHP_EOL);
     $buffer->append("\t" . ' * @param ' . $this->type . ' $' . $this->name . PHP_EOL);
     $buffer->append("\t" . ' */' . PHP_EOL);
     $buffer->append("\t" . 'public function set' . $this->name->toUpperCase(true)->toNative() . '($' . $this->name . '){' . PHP_EOL);
     $buffer->append("\t" . "\t" . ' $this->' . $this->name . ' = $' . $this->name . ';' . PHP_EOL);
     $buffer->append("\t" . '}' . PHP_EOL . PHP_EOL);
 }
Exemple #5
0
 /**
  *
  * @param string|blaze\lang\String $value
  */
 public static function toBoolean($value)
 {
     if ($value instanceof String) {
         return $value != null && $value->equalsIgnoreCase("true");
     } else {
         return $value != null && $value === "true";
     }
 }
Exemple #6
0
 /**
  * Handle <code>beforePhase</code> <code>PhaseListener</code> events.
  * @param blaze\web\application\BlazeContext $context the FacesContext for the current request
  * @param array[blaze\web\event\PhaseListener] $listenersIterator a ListIterator for the PhaseListeners that need
  *  to be invoked
  * @param blaze\web\event\PhaseEvent $event the event to pass to each of the invoked listeners
  */
 protected function handleBeforePhase(BlazeContext $context, \blaze\collections\Map $listeners, PhaseEvent $event)
 {
     //try {
     //Flash flash = context.getExternalContext().getFlash();
     //flash.doPrePhaseActions(context);
     //} catch (UnsupportedOperationException uoe) {
     //if (LOGGER.isLoggable(Level.FINE)) {
     //LOGGER.fine("ExternalContext.getFlash() throw UnsupportedOperationException -> Flash unavailable");
     //}
     //}
     //RequestStateManager.clearAttributesForPhase(context,
     // context.getCurrentPhaseId());
     $requestUri = $context->getRequest()->getRequestURI()->getPath();
     // remove the prefix of the url e.g. BlazeFrameworkServer/
     if (!$requestUri->endsWith('/')) {
         $requestUri = $requestUri->concat('/');
     }
     $requestUri = $requestUri->substring($context->getApplication()->getUrlPrefix()->replace('*', '')->length());
     // Requesturl has always to start with a '/'
     if ($requestUri->length() == 0 || $requestUri->charAt(0) != '/') {
         $requestUri = new \blaze\lang\String('/' . $requestUri->toNative());
     }
     foreach ($listeners as $pattern => $listener) {
         if (($this->getId() == $listener->getPhaseId() || \blaze\web\event\PhaseId::ANY_PHASE == $listener->getPhaseId()) && $this->matchesPattern($requestUri, $pattern)) {
             try {
                 $listener->beforePhase($event);
             } catch (Exception $e) {
                 $this->queueException($context, $e);
                 //, ExceptionQueuedEventContext.IN_BEFORE_PHASE_KEY);
                 // move the iterator pointer back one
                 //if (listenersIterator.hasPrevious()) {
                 //listenersIterator.previous();
                 //}
                 return;
             }
         }
     }
 }