Boolean
PHPJava\Kernel\Types\_Boolean
Introduction
_Boolean class is provided APIs for emulating Java's boolean on PHPJava.
How to use
The class can be pass boolean type into Java if you want.
For an example as follows:
- Write Java:
class Test { public static void echoEnabled(boolean isEnabled) { if (isEnabled) { System.out.println("Excellent, This method is enabled."); return; } System.out.println("OMG, This method is disabled."); } }
- Compile Java:
$ javac -UTF8 /path/to/Test.java
- Call the
echoEnabledmethod as follows:
<?php use PHPJava\Core\JavaClass; use PHPJava\Core\Stream\Reader\FileReader; use PHPJava\Kernel\Types\\_Boolean; (new JavaClass(new FileReader('/path/to/Test.class'))) ->getInvoker() ->getStatic() ->getMethods() ->call( 'echoEnabled', new _Boolean(true) );
- Get the result
$ php /path/to/Test.php
Excellent, This method is enabled.
- In pass parameter is
falsethen result is here:
$ php /path/to/Test.php
OMG, This method is disabled.
Provided methods
Name
public function __construct($value)
Introduction
Initiate a boolean type for Java.
Parameters
| Name | Type | Description |
|---|---|---|
| $value | mixed | Specify boolean 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.