function loadFromFile() { $configname = new StringBuffer(); $buffers = new StringBuffer(); $key = ''; $value = ''; $conf = ''; $skipline = 0; $c = ''; if ($this->reader->ready()) { while (($c = $this->reader->read()) != '') { if ($c == CONFIG_END_KEY) { if ($buffers->length() > 0) { $buffers = $buffers->trimAll(); if (!$buffers->startsWith(CONFIG_COMMENT)) { $key_separator_pos = $buffers->indexOf(CONFIG_SEPARATOR); if ($key_separator_pos > 0) { $key = $buffers->substring(0, $key_separator_pos); $key = $key->trimAll(); $value = $buffers->substring($key_separator_pos + 1); $value = $value->trimAll(); if ($key->length() > 0 && $value->length() > 0) { $str = $this->get($key->toString()) . $value->toString(); $this->put($key->toString(), $str); } } } } $buffers = new StringBuffer(); } else { $buffers->append($c); } } if ($buffers->length() > 0) { $key_separator_pos = $buffers->indexOf(CONFIG_SEPARATOR); if ($key_separator_pos > 0) { $key = $buffers->substring(0, $key_separator_pos); $key = $key->trimAll(); $value = $buffers->substring($key_separator_pos + 1); $value = $value->trimAll(); if ($key->length() > 0 && $value->length() > 0 && $this->acceptableKey($key)) { $str = $this->get($key->toString()) . $value->toString(); $this->put($key->toString(), $str); } } } } }
private function readJSONString($peek = false, $start = 0) { if (!\hacklib_cast_as_boolean($peek)) { $start = 0; } $this->expectChar("\"", $peek, $start); $count = \hacklib_cast_as_boolean($peek) ? 1 : 0; $sb = new StringBuffer(); $reading = true; while (\hacklib_cast_as_boolean($reading)) { $c = $this->bufTrans->peek(1, $start + $count); switch ($c) { case "\"": $reading = false; break; case "\\": $count++; $c = $this->bufTrans->peek(1, $start + $count); switch ($c) { case "\\": $count++; $sb->append("\\"); break; case "\"": $count++; $sb->append("\""); break; case "b": $count++; $sb->append(chr(0x8)); break; case "/": $count++; $sb->append("/"); break; case "f": $count++; $sb->append("\f"); break; case "n": $count++; $sb->append("\n"); break; case "r": $count++; $sb->append("\r"); break; case "t": $count++; $sb->append("\t"); break; case "u": $count++; $this->expectChar("0", true, $start + $count); $this->expectChar("0", true, $start + $count + 1); $count += 2; $sb->append(hex2bin($this->bufTrans->peek(2, $start + $count))); $count += 2; break; default: throw new TProtocolException("TSimpleJSONProtocol: Expected Control Character, found 0x" . bin2hex($c)); } break; default: $count++; $sb->append($c); break; } } if (!\hacklib_cast_as_boolean($peek)) { $this->trans_->readAll($count); } $this->expectChar("\"", $peek, $start + $count); return \HH\Pair::hacklib_new($sb->detach(), $count + 1); }
function loadFromStream($filename) { $buffers = new StringBuffer(); $file = NULL; if (File::validClass($filename)) { $file = $filename; } else { $file = new File($filename); } $filereader = new FileReader($file); while ($c = $filereader->read()) { $buffers->append($c); } $this->str = $buffers->toString(); }
public function toString() { $sb = new StringBuffer("package "); $sb->append($this->name . " "); if ($this->specTitle) { $sb->append($this->specTitle . " "); } if ($this->specVersion) { $sb->append($this->specVersion . " "); } return $sb->toString(); }
function performMax($fields, $from, $where = NULL) { $query = new StringBuffer('SELECT '); if (isset($fields)) { $query->append('Max(' . $fields . ') AS total'); } if (isset($from)) { if (is_array($from)) { if (count($from) > 0) { $query->append(implode(',', $from)); } } else { $query->append(' FROM ' . $from); } } $where = StringBuffer::toStringBuffer($where); if (isset($where) && $where->length() > 0) { $query->append(' WHERE ' . $where->toString()); } $result = $this->query($query); if (isset($result) && is_array($result) && count($result) > 0) { $result = $result[0]; return $result['total']; } else { return 0; } }
function loadFromFile() { $configname = new StringBuffer(); $buffers = new StringBuffer(); $conf = NULL; $key = ''; $value = ''; $skipline = 0; $c = ''; if ($this->reader->ready()) { while (($c = $this->reader->read()) != '') { if ($c == CONFIG_END_KEY) { if (isset($conf) && $buffers->length() > 0) { $buffers = $buffers->trimAll(); if (!$buffers->startsWith(CONFIG_COMMENT)) { $key_separator_pos = $buffers->indexOf('='); if ($buffers->startsWith(MULTICONFIG_START) && $buffers->endsWith(MULTICONFIG_END)) { if ($conf->size() > 0) { $this->put($configname->toString(), $conf); } $i = $buffers->indexOf(':') + 1; $configname = $buffers->substring($i, $buffers->length() - 1); $conf = new Hashtable(); } else { if ($key_separator_pos > 0) { $key = $buffers->substring(0, $key_separator_pos); $key = $key->trimAll(); $value = $buffers->substring($key_separator_pos + 1); $value = $value->trimAll(); if ($key->length() > 0 && $value->length() > 0) { $str = $conf->get($key->toString()) . $value->toString(); $conf->put($key->toString(), $str); } } } } } else { $buffers = $buffers->trimAll(); if ($buffers->startsWith(MULTICONFIG_START) && $buffers->endsWith(MULTICONFIG_END)) { $i = $buffers->indexOf(':') + 1; $configname = $buffers->substring($i, $buffers->length() - 1); $conf = new Hashtable(); } } $buffers = new StringBuffer(); } else { $buffers->append($c); } } if ($buffers->length() > 0) { $key_separator_pos = $buffers->indexOf('='); if ($key_separator_pos > 0) { $key = $buffers->substring(0, $key_separator_pos); $key = $key->trimAll(); $value = $buffers->substring($key_separator_pos + 1); $value = $value->trimAll(); if ($key->length() > 0 && $value->length() > 0) { $conf->put($key->toString(), $value->toString()); } } } if (isset($conf) && $conf->size() > 0) { $this->put($configname, $conf); } } }