/**
  * @see parent::parse
  */
 function parse($data)
 {
     parent::parse($data);
     $message = $this->getMessage();
     $fields = CHL7v2::split($message->fieldSeparator, $data);
     $this->name = array_shift($fields);
     $specs = $this->getSpecs();
     $this->description = $specs->queryTextNode("description");
     if ($this->name === $message->getHeaderSegmentName()) {
         array_unshift($fields, $message->fieldSeparator);
     }
     // Don't count empty fields on the right
     $count_fields = count($fields);
     for ($i = $count_fields - 1; $i >= 0; $i--) {
         if ($fields[$i] === "") {
             $count_fields--;
         } else {
             break;
         }
     }
     $_segment_specs = $specs->getItems();
     // Check the number of fields
     if ($count_fields > count($_segment_specs)) {
         $this->error(CHL7v2Exception::TOO_MANY_FIELDS, $data, $this, CHL7v2Error::E_WARNING);
     }
     foreach ($_segment_specs as $i => $_spec) {
         if (array_key_exists($i, $fields)) {
             $field = new CHL7v2Field($this, $_spec);
             $field->parse($fields[$i]);
             $this->fields[] = $field;
         } elseif ($_spec->isRequired()) {
             $field = new CHL7v2Field($this, $_spec);
             $this->error(CHL7v2Exception::FIELD_EMPTY, $field->getPathString(), $field);
         }
     }
 }