-
Notifications
You must be signed in to change notification settings - Fork 36
Boolean
memory-agape edited this page Apr 18, 2019
·
4 revisions
_Boolean class is provided APIs for emulating Java's boolean on PHPJava.
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.
public function __construct($value)Initiate a boolean type for Java.
| Name | Type | Description |
|---|---|---|
| $value | mixed | Specify boolean value |
public function getValue()Return real value.
No parameter.
public function getTypeNameInJava()Return type name in Java.
No parameter.
public function getTypeNameInPHP()Return type name in PHP.
No parameter.
public function __toString()Return stringified real value.
No parameter.
- The Contribution Guide
- CHANGELOG
- How to run JavaClass
- How to run JavaArchive
- How to run Kotlin
-
Provided classes
- Core
- Types
- Utilities
- Provided options
- Operation Injector