Byte
PHPJava\Kernel\Types\_Byte
Introduction
_Byte class is provided APIs for emulating Java's byte on PHPJava.
This class not been determined of features.
How to use
The class can be pass byte type into Java if you want.
For an example as follows:
- Write Java:
class Test { public static void echo(byte[] text) { System.out.println(new String(text)); } }
- Compile Java:
$ javac -UTF8 /path/to/Test.java
- Call the
echomethod as follows:
<?php use PHPJava\Core\JavaClass; use PHPJava\Core\Stream\Reader\FileReader; use PHPJava\Kernel\Types\\_Byte; (new JavaClass(new FileReader('/path/to/Test.class'))) ->getInvoker() ->getStatic() ->getMethods() ->call( 'echo', array_map( function ($char) { return new _Byte(ord($char)); }, preg_split( '//', "HelloWorld!", -1, PREG_SPLIT_NO_EMPTY ) ) );
- Get the result
$ php /path/to/Test.php
HelloWorld!
Provided methods
Name
public function __construct($value)
Introduction
Initiate a boolean type for Java.
Parameters
| Name | Type | Description |
|---|---|---|
| $value | mixed | Specify byte value |
Name
public function getValue()
Introduction
Return real value.
Parameters
No parameter.
Name
public function getTypeNameInJava()
Introduction
Return type name in Java.
Parameters
No parameter.
Name
public function getTypeNameInPHP()
Introduction
Return type name in PHP.
Parameters
No parameter.
Name
public function __toString()
Introduction
Return stringified real value.
Parameters
No parameter.