Show
Ignore:
Timestamp:
11/09/07 18:21:05 (1 year ago)
Author:
mikey
Message:

added possibility to set the xml version and encoding of xml stream writers to be created by the factory

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/xml/stubXMLStreamWriterFactory.php

    r860 r1020  
    2626                                    'xmlwriter' => 'LibXml' 
    2727                              ); 
     28    /** 
     29     * default version of xml stream writers to create 
     30     * 
     31     * @var  string 
     32     */ 
     33    protected static $version  = '1.0'; 
     34    /** 
     35     * default encoding of xml stream writers to create 
     36     * 
     37     * @var  string 
     38     */ 
     39    protected static $encoding = 'UTF-8'; 
     40 
     41    /** 
     42     * sets the default version of xml stream writers to create 
     43     * 
     44     * @param  string  $version 
     45     */ 
     46    public static function setVersion($version) 
     47    { 
     48        self::$version = $version; 
     49    } 
     50 
     51    /** 
     52     * sets the default encoding of xml stream writers to create 
     53     * 
     54     * @param  string  $encoding 
     55     */ 
     56    public static function setEncoding($encoding) 
     57    { 
     58        self::$encoding = $encoding; 
     59    } 
    2860 
    2961    /** 
     
    3769        $fqClassName = self::getFqClassName($type); 
    3870        $nqClassName = stubClassLoader::getNonQualifiedClassName($fqClassName); 
    39         if (class_exists($nqClassName, false) == false) { 
     71        if (class_exists($nqClassName, false) === false) { 
    4072            stubClassLoader::load($fqClassName); 
    4173        } 
    4274 
    43         $xmlStreamWriter = new $nqClassName(); 
     75        $xmlStreamWriter = new $nqClassName(self::$version, self::$encoding); 
    4476        return $xmlStreamWriter; 
    4577    } 
     
    6193    public static function createAsAvailable(array $order = null, array $features = array()) 
    6294    { 
    63         if (null == $order) { 
     95        if (null === $order) { 
    6496            $order = array_keys(self::$types); 
    6597        } 
     
    107139    public static function getFqClassNameAsAvailable(array $order = null, array $features = array()) 
    108140    { 
    109         if (null == $order) { 
     141        if (null === $order) { 
    110142            $order = array_keys(self::$types); 
    111143        } 
     
    117149            } 
    118150             
    119             if (count($features) == 0) { 
     151            if (count($features) === 0) { 
    120152                return self::getFqClassName($name); 
    121153            }