/** * {@inheritdoc} */ public function next() { $this->valid = false; $style = null; $type = null; $columnIndex = null; $rowBuilder = null; $currentKey = 0; while ($this->xml->read()) { if (\XMLReader::ELEMENT === $this->xml->nodeType) { switch ($this->xml->name) { case 'row': $currentKey = (int) $this->xml->getAttribute('r'); $rowBuilder = $this->rowBuilderFactory->create(); break; case 'c': $columnIndex = $this->columnIndexTransformer->transform($this->xml->getAttribute('r')); $style = $this->getValue($this->xml->getAttribute('s')); $type = $this->getValue($this->xml->getAttribute('t')); break; case 'v': $rowBuilder->addValue($columnIndex, $this->valueTransformer->transform($this->xml->readString(), $type, $style)); break; case 'is': $rowBuilder->addValue($columnIndex, $this->xml->readString()); break; } } elseif (\XMLReader::END_ELEMENT === $this->xml->nodeType) { switch ($this->xml->name) { case 'row': $currentValue = $rowBuilder->getData(); if (count($currentValue)) { $this->currentKey = $currentKey; $this->currentValue = $currentValue; $this->valid = true; return; } break; case 'sheetData': break 2; } } } }
/** * @param mixed $value * * @return mixed */ public function getReadableFormat($value) { $transformedValue = $this->valueTransformer->translateObjectsAndResourceToString($value); $result = $this->valueFormatterHelper->getReadableFormatFromSimpleValue($transformedValue); return $result; }
/** * @param selectedFields array */ public function getOutput($selectedFields = array()) { // Split the original code on the opening curly-brace for the class $splitCode = explode('{', $this->mInput, 2); // Add Parcelable interface to class declaration if (strpos($splitCode[0], 'implements') == false) { $code = trim($splitCode[0]) . " implements Parcelable {" . $splitCode[1]; } else { $code = trim($splitCode[0]) . ", Parcelable {" . $splitCode[1]; } // Remove the last curly-brace to allow for the new code $code = rtrim($code, '}'); $code .= "\n protected " . $this->mClass . "(Parcel in) {\n"; $reads = array(); $writes = array(); foreach ($this->getFields() as $field) { if (in_array($field->getName(), $selectedFields)) { $level = $this->getSupportLevel($field); if ($level == SupportLevel::SpecificTransformer) { $transformer = $this->mParcelableTypes[$field->getType()]; $reads[] = $this->padCodeLeft($transformer->getReadCode($field)); $writes[] = $this->padCodeLeft($transformer->getWriteCode($field)); } else { if ($level == SupportLevel::GeneralTransformer) { $transformer = new ValueTransformer(); $reads[] = $this->padCodeLeft($transformer->getReadCode($field)); $writes[] = $this->padCodeLeft($transformer->getWriteCode($field)); } } } } if (count($reads) > 0) { $code .= implode("\n", $reads); } $code .= "\n }\n\n @Override\n public int describeContents() {\n return 0;\n }\n\n @Override\n public void writeToParcel(Parcel dest, int flags) {\n"; if (count($writes) > 0) { $code .= implode("\n", $writes); } $code .= "\n }\n\n @SuppressWarnings(\"unused\")\n public static final Parcelable.Creator<" . $this->mClass . "> CREATOR = new Parcelable.Creator<" . $this->mClass . ">() {\n @Override\n public " . $this->mClass . " createFromParcel(Parcel in) {\n return new " . $this->mClass . "(in);\n }\n\n @Override\n public " . $this->mClass . "[] newArray(int size) {\n return new " . $this->mClass . "[size];\n }\n };"; $code .= "\n" . '}'; return $code; }