# Primitive.class.php

Go to the documentation of this file.

    00001 <?php
    00002 /****************************************************************************
    00003  *   Copyright (C) 2004-2009 by Konstantin V. Arkhipov, Anton E. Lebedevich *
    00004  *                                                                          *
    00005  *   This program is free software; you can redistribute it and/or modify   *
    00006  *   it under the terms of the GNU Lesser General Public License as         *
    00007  *   published by the Free Software Foundation; either version 3 of the     *
    00008  *   License, or (at your option) any later version.                        *
    00009  *                                                                          *
    00010  ****************************************************************************/
    00011
    00017     final class Primitive extends StaticFactory
    00018     {
    00022         public static function spawn($primitive, $name)
    00023         {
    00024             Assert::classExists($primitive);
    00025
    00026             return new $primitive($name);
    00027         }
    00028
    00032         public static function alias($name, BasePrimitive $prm)
    00033         {
    00034             return new PrimitiveAlias($name, $prm);
    00035         }
    00036
    00040         public static function anyType($name)
    00041         {
    00042             return new PrimitiveAnyType($name);
    00043         }
    00044
    00048         public static function integer($name)
    00049         {
    00050             return new PrimitiveInteger($name);
    00051         }
    00052
    00056         public static function float($name)
    00057         {
    00058             return new PrimitiveFloat($name);
    00059         }
    00060
    00065         public static function identifier($name)
    00066         {
    00067             return new PrimitiveIdentifier($name);
    00068         }
    00069
    00073         public static function integerIdentifier($name)
    00074         {
    00075             return new PrimitiveIntegerIdentifier($name);
    00076         }
    00077
    00081         public static function scalarIdentifier($name)
    00082         {
    00083             return new PrimitiveScalarIdentifier($name);
    00084         }
    00085
    00089         public static function polymorphicIdentifier($name)
    00090         {
    00091             return new PrimitivePolymorphicIdentifier($name);
    00092         }
    00093
    00097         public static function identifierlist($name)
    00098         {
    00099             return new PrimitiveIdentifierList($name);
    00100         }
    00101
    00105         public static function clazz($name)
    00106         {
    00107             return new PrimitiveClass($name);
    00108         }
    00109
    00113         public static function enumeration($name)
    00114         {
    00115             return new PrimitiveEnumeration($name);
    00116         }
    00117
    00121         public static function enumerationByValue($name)
    00122         {
    00123             return new PrimitiveEnumerationByValue($name);
    00124         }
    00125
    00129         public static function enumerationList($name)
    00130         {
    00131             return new PrimitiveEnumerationList($name);
    00132         }
    00133
    00137         public static function date($name)
    00138         {
    00139             return new PrimitiveDate($name);
    00140         }
    00141
    00145         public static function timestamp($name)
    00146         {
    00147             return new PrimitiveTimestamp($name);
    00148         }
    00149
    00153         public static function time($name)
    00154         {
    00155             return new PrimitiveTime($name);
    00156         }
    00157
    00161         public static function string($name)
    00162         {
    00163             return new PrimitiveString($name);
    00164         }
    00165
    00169         public static function binary($name)
    00170         {
    00171             return new PrimitiveBinary($name);
    00172         }
    00173
    00177         public static function range($name)
    00178         {
    00179             return new PrimitiveRange($name);
    00180         }
    00181
    00185         public static function dateRange($name)
    00186         {
    00187             return new PrimitiveDateRange($name);
    00188         }
    00189
    00193         public static function timestampRange($name)
    00194         {
    00195             return new PrimitiveTimestampRange($name);
    00196         }
    00197
    00201         public static function choice($name)
    00202         {
    00203             return new PrimitiveList($name);
    00204         }
    00205
    00209         public static function set($name)
    00210         {
    00211             return new PrimitiveArray($name);
    00212         }
    00213
    00217         public static function hstore($name)
    00218         {
    00219             return new PrimitiveHstore($name);
    00220         }
    00221
    00225         public static function multiChoice($name)
    00226         {
    00227             return new PrimitiveMultiList($name);
    00228         }
    00229
    00233         public static function plainChoice($name)
    00234         {
    00235             return new PrimitivePlainList($name);
    00236         }
    00237
    00241         public static function boolean($name)
    00242         {
    00243             return new PrimitiveBoolean($name);
    00244         }
    00245
    00249         public static function ternary($name)
    00250         {
    00251             return new PrimitiveTernary($name);
    00252         }
    00253
    00257         public static function file($name)
    00258         {
    00259             return new PrimitiveFile($name);
    00260         }
    00261
    00265         public static function image($name)
    00266         {
    00267             return new PrimitiveImage($name);
    00268         }
    00269
    00273         public static function exploded($name)
    00274         {
    00275             return new ExplodedPrimitive($name);
    00276         }
    00277
    00281         public static function inet($name)
    00282         {
    00283             return new PrimitiveInet($name);
    00284         }
    00285
    00289         public static function form($name)
    00290         {
    00291             return new PrimitiveForm($name);
    00292         }
    00293
    00297         public static function formsList($name)
    00298         {
    00299             return new PrimitiveFormsList($name);
    00300         }
    00301
    00305         public static function noValue($name)
    00306         {
    00307             return new PrimitiveNoValue($name);
    00308         }
    00309
    00313         public static function httpUrl($name)
    00314         {
    00315             return new PrimitiveHttpUrl($name);
    00316         }
    00317
    00321         public static function prototyped($class, $propertyName, $name = null)
    00322         {
    00323             Assert::isInstance($class, 'Prototyped');
    00324
    00325             $proto = is_string($class)
    00326                 ? call_user_func(array($class, 'proto'))
    00327                 : $class->proto();
    00328
    00329             if (!$name)
    00330                 $name = $propertyName;
    00331
    00332             return $proto->getPropertyByName($propertyName)->
    00333                 makePrimitive($name);
    00334         }
    00335
    00339         public static function prototypedIdentifier($class, $name = null)
    00340         {
    00341             Assert::isInstance($class, 'DAOConnected');
    00342
    00343             $dao = is_string($class)
    00344                 ? call_user_func(array($class, 'dao'))
    00345                 : $class->dao();
    00346
    00347             return self::prototyped($class, $dao->getIdName(), $name);
    00348         }
    00349     }
    00350 ?>