/** * Creates a new instance of a throwable object. * * @param blaze\lang\String|string $message The error message. * @param blaze\lang\Integer|int $code The error code. * @param blaze\lang\Throwable $previous The th */ public function __construct($message = null, $code = null, $previous = null) { parent::__construct(String::asNative($message), Integer::asNative($code), $previous); if ($previous != null && !$previous instanceof Throwable) { new IllegalArgumentException('Previous element must be a subtype of Throwable', 0, $this); } }
public static function getStringHash($value) { $value = String::asNative($value); if (!array_key_exists($value, self::$hashes)) { $h = 0; $off = 0; $val = $value; $len = strlen($value); for ($i = 0; $i < $len; $i++) { $h = 31 * $h + $val[$off++]; } self::$hashes[$value] = $h; } return self::$hashes[$value]; }
protected function get($identifier) { if (!is_array($this->actRow)) { throw new DataSourceException('No valid result.'); } if (is_int($identifier)) { if (!array_key_exists($identifier, $this->actRowIndex)) { throw new DataSourceException('Index ' . $identifier . ' was not found.'); } return $this->actRowIndex[$identifier]; } else { if (!array_key_exists(String::asNative($identifier), $this->actRow)) { throw new DataSourceException('Index ' . $identifier . ' was not found.'); } return $this->actRow[String::asNative($identifier)]; } }
/** * * @param mixed $value * @return char */ public static function asNative($value) { if ($value instanceof Character) { return $value->value; } $value = String::asNative($value); if (is_string($value) && strlen($value) != 0) { return $value[0]; } return ''; }
/** * * @param blaze\lang\Boolean|boolean $value * @return boolean */ public static function asNative($value) { if ($value instanceof Boolean) { return $value->value; } else { if (is_bool($value)) { return $value; } else { return (bool) String::asNative($value); } } }
/** * @access private * @return string */ public final function __toString() { return String::asNative($this->toString()); }
/** * Splits this string around matches of the given <a * href="../util/regex/Pattern.html#sum">regular expression</a>. * * <p> This method works as if by invoking the two-argument {@link * #split(String, int) split} method with the given expression and a limit * argument of zero. Trailing empty strings are therefore not included in * the resulting array. * * <p> The string <tt>"boo:and:foo"</tt>, for example, yields the following * results with these expressions: * * <blockquote><table cellpadding=1 cellspacing=0 summary="Split examples showing regex and result"> * <tr> * <th>Regex</th> * <th>Result</th> * </tr> * <tr><td align=center>:</td> * <td><tt>{ "boo", "and", "foo" }</tt></td></tr> * <tr><td align=center>o</td> * <td><tt>{ "b", "", ":and:f" }</tt></td></tr> * </table></blockquote> * * * @param regex * the delimiting regular expression * * @return array[blaze\lang\String] the array of strings computed by splitting this string * around matches of the given regular expression * * @throws PatternSyntaxException * if the regular expression's syntax is invalid * * @see java.util.regex.Pattern * * @since 1.4 * @spec JSR-51 */ public function splitRegex($regex, $limit = null, $wrapper = false) { $regex = String::asNative($regex); if (!$wrapper) { return preg_split($regex, $this->string, $limit); } $pieces = preg_split($regex, $this->string, $limit); $result = array(); foreach ($pieces as $piece) { $result[] = new String($piece); } return $result; }
public static function setProperty($key, $value) { $key = String::asNative($key); $oldValue = self::getProperty($key); self::$props->setProperty($key, $value); return $oldValue; }