function formatClass() { $TypeKey = $this->getTypeKey(); $note = parent::getNoteFormat(); if (!is_array($this->value)) { throw new Exception("formatClass is_array error!"); } $format = $TypeKey[Element::TYPE_KEY_CLASS]; $format = parent::getFileContents($format); if (empty($format)) { throw new Exception("formatClass TYPE_KEY_CLASS null!"); } $format = str_replace(Element::FORMAT_CLASS, $this->divname, $format); $data = ""; foreach ($this->value as $key => $value) { if ($value != null) { $element = $this->getElement(); $element->initElement($key, $value, $this->getClassElement($key)); $data = $data . $element->format(); } } $format = str_replace(Element::FORMAT_DATA, $data, $format); $format = str_replace(DataElement::FORMAT_JSON_DATA, $this->parse(), $format); $format = str_replace(Element::FORMAT_NOTE, $note, $format); $format = str_replace(Element::FORMAT_VERSION, $this->version, $format); $result = JAVA_NATIVE_HEAD . $format; $fileurl = $this->getFileUrl($result, $this->divname . ".java"); return $result; }
function getJavaElement($datavalue) { foreach ($this->note as $key => $value) { if ($value != null && is_array($value)) { $data = new JavaElement($key); $data->setDictionary($value); break; } else { if ($value != null) { $data = new JavaElement(); $data->setDictionary($this->note); break; } } } $data->setType(Element::TYPE_KEY_CLASS); $data->setValue($datavalue); $data->setName($this->name); return $data; }
function formatStatic($key) { if (!is_array($this->dictionary)) { /**没有静态区间标注*/ return ""; } $StaticKey = $this->getStaticKey(); if (!array_key_exists($key, $StaticKey)) { throw new Exception("formatStatic StaticKey no found {$key} !"); } $static = $StaticKey[$key]; $static = parent::getFileContents($static); $result = ""; foreach ($this->dictionary as $value => $note) { $name = $value; if ($this->note_type == self::NOTE_TYPE_AUTO && $key != Element::TYPE_KEY_STRING && !empty($note)) { $az = language_new_az($note); if (!empty($az) && preg_match("/^[a-zA-Z\\s]+\$/", $az)) { $name = $az; } } $name = self::FORMAT_STATIC . strtoupper("_" . $this->name . "_{$name}"); $data = str_replace(Element::FORMAT_NOTE, $note, $static); $data = str_replace(Element::FORMAT_CLASS, $name, $data); $data = str_replace(Element::FORMAT_DATA_KEY, strval($value), $data); $result .= $data; } return $result; }