Beispiel #1
0
 /**
  * This method converts a collection to use collections.
  *
  * @access private
  * @static
  * @param mixed $data                                       the data to be converted
  * @param boolean $case_sensitive                           whether keys are to be case sensitive
  * @return mixed                                            the converted data
  */
 private static function useCollections($data, $case_sensitive)
 {
     if (is_object($data)) {
         if ($data instanceof Common\IList || $data instanceof Common\ISet) {
             $buffer = new OrderCalc\Engine\Model\Dynamic\ArrayList(null, $case_sensitive);
             foreach ($data as $value) {
                 $buffer->addValue(static::useCollections($value, $case_sensitive));
             }
             return $buffer;
         } else {
             if ($data instanceof Common\IMap) {
                 $buffer = new OrderCalc\Engine\Model\Dynamic\HashMap(null, $case_sensitive);
                 foreach ($data as $key => $value) {
                     $buffer->putEntry($key, static::useCollections($value, $case_sensitive));
                 }
                 return $buffer;
             } else {
                 if ($data instanceof \stdClass) {
                     $data = get_object_vars($data);
                     $buffer = new OrderCalc\Engine\Model\Dynamic\HashMap(null, $case_sensitive);
                     foreach ($data as $key => $value) {
                         $buffer->putEntry($key, static::useCollections($value, $case_sensitive));
                     }
                     return $buffer;
                 }
             }
         }
     }
     if (is_array($data)) {
         if (Common\Collection::isDictionary($data)) {
             $buffer = new OrderCalc\Engine\Model\Dynamic\HashMap(null, $case_sensitive);
             foreach ($data as $key => $value) {
                 $buffer->putEntry($key, static::useCollections($value, $case_sensitive));
             }
             return $buffer;
         } else {
             $buffer = new OrderCalc\Engine\Model\Dynamic\ArrayList(null, $case_sensitive);
             foreach ($data as $value) {
                 $buffer->addValue(static::useCollections($value, $case_sensitive));
             }
             return $buffer;
         }
     }
     return $data;
 }
Beispiel #2
0
 /**
  * This constructor initializes the class with the specified data.
  *
  * @access public
  * @param mixed $data                                       the data to be written
  */
 public function __construct($data)
 {
     $this->data = Common\Collection::useArrays($data);
     $this->metadata = array('credentials' => array(), 'encoding' => array(Core\Data\Charset::UTF_8_ENCODING, Core\Data\Charset::UTF_8_ENCODING), 'ext' => '.xml', 'mime' => 'text/xml', 'xmlns' => '');
 }
Beispiel #3
0
 /**
  * This constructor initializes the class with the specified data.
  *
  * @access public
  * @param mixed $data                                       the data to be written
  */
 public function __construct($data)
 {
     $this->data = Common\Collection::useArrays($data);
     $this->metadata = array('builder' => '', 'command' => 'insert', 'data_source' => 'default', 'encoding' => array(Core\Data\Charset::UTF_8_ENCODING, Core\Data\Charset::UTF_8_ENCODING), 'eol' => "\n", 'ext' => '.sql', 'mime' => 'text/x-sql', 'schema' => array(), 'url' => null);
 }
Beispiel #4
0
 /**
  * This constructor initializes the class with the specified data.
  *
  * @access public
  * @param mixed $data                                       the data to be written
  */
 public function __construct($data)
 {
     $this->data = Common\Collection::useObjects($data);
     $this->metadata = array('encoding' => array(Core\Data\Charset::UTF_8_ENCODING, Core\Data\Charset::UTF_8_ENCODING), 'ext' => '.xml', 'mime' => 'text/xml', 'minify' => array(), 'prototype' => true, 'url' => null);
 }
Beispiel #5
0
 /**
  * This method returns the data as an XML string.
  *
  * @access protected
  * @param \DOMDocument $document                            the XML DOM document
  * @param \DOMElement $element                              the XML DOM element
  * @param mixed $data                                       the data as an XML string
  */
 protected function toXML($document, $element, $data)
 {
     if (is_array($data)) {
         if (Common\Collection::isDictionary($data)) {
             foreach ($data as $node => $value) {
                 $child = $document->createElement($node);
                 $element->appendChild($child);
                 $this->toXML($document, $child, $value);
             }
         } else {
             foreach ($data as $value) {
                 $this->toXML($document, $element, $value);
             }
         }
     } else {
         if (is_string($data) && preg_match('/^<!CDATA\\[.*\\]\\]>$/', $data)) {
             $data = substr($data, 8, strlen($data) - 11);
             $child = $document->createCDATASection($data);
             $element->appendChild($child);
         } else {
             if ($data !== null) {
                 $child = $document->createTextNode(Core\Convert::toString($data));
                 $element->appendChild($child);
             }
         }
     }
 }
Beispiel #6
0
 /**
  * This constructor initializes the class with the specified data.
  *
  * @access public
  * @param mixed $data                                       the data to be written
  */
 public function __construct($data)
 {
     $this->data = Common\Collection::useArrays($data);
     $this->metadata = array('builder' => null, 'encoding' => array(Core\Data\Charset::UTF_8_ENCODING, Core\Data\Charset::UTF_8_ENCODING), 'ext' => '.txt', 'mime' => 'text/plain', 'schema' => array(), 'url' => null);
 }