function getClosure()
{
    $cl = java_closure(new c());
    $res = java_cast($cl, "S");
    if ($res != "class c") {
        throw new JavaException("java.lang.Exception", "test failed");
    }
    return $cl;
}
Esempio n. 2
0
 /**
  * @param $cell
  * @param $xml
  * @throws Exception
  */
 function __construct($cell, $xml)
 {
     $sdtCell = java_cast($cell, 'org.apache.poi.xwpf.usermodel.XWPFSDTCell');
     $this->sdtCell = $sdtCell;
     $this->rowXml = $xml;
     if (!is_object($this->sdtCell)) {
         throw new Exception("[XWPFSDTCell::new XWPFSDTCell(Java cell)] Fail on create STDCell");
     }
 }
Esempio n. 3
0
 function __sleep()
 {
     $buf = new java("java.io.ByteArrayOutputStream");
     $out = new java("java.io.ObjectOutputStream", $buf);
     $out->writeObject($this->java);
     $out->close();
     $this->serialID = base64_encode(java_cast($buf->toByteArray(), "S"));
     return array("serialID");
 }
Esempio n. 4
0
 /**
  * @param $element
  */
 function __construct($element)
 {
     if (java_instanceof($element, java('org.apache.poi.xwpf.usermodel.XWPFSDT'))) {
         $toc = java_cast($element, 'org.apache.poi.xwpf.usermodel.XWPFSDT');
         $this->toc = $toc;
         $this->idList = array();
         $this->tableContents = array();
     }
 }
Esempio n. 5
0
 function __construct($paragraph, $stylesheet)
 {
     $this->listLevelState = 0;
     $this->listNumId = 1;
     $this->paragraph = $paragraph;
     $this->listItemIterator = null;
     $numberingObject = java_values($this->paragraph->getDocument()->getNumbering());
     $this->mainStyleSheet = $stylesheet;
     //Cast to XWPFNumbering
     $this->numbering = java_cast($numberingObject, 'org.apache.poi.xwpf.usermodel.XWPFNumbering');
 }
Esempio n. 6
0
 /**
  * @param $element
  * @param $key
  * @param $mainStyleSheet
  * @throws Exception
  */
 function __construct($element, $key, $mainStyleSheet)
 {
     try {
         $table = java_cast($element, 'org.apache.poi.xwpf.usermodel.XWPFTable');
     } catch (Exception $ex) {
         $ex->getMessage();
         return null;
     }
     $this->javaTable = $table;
     $this->tableKey = $key;
     $this->element = $element;
     $this->mainStyleSheet = $mainStyleSheet;
 }
function toString()
{
    global $count;
    $s = new java("java.lang.String", "hello");
    $v = new java("java.lang.String", "hello");
    $t = new java("java.lang.String", "hello");
    $s = $v = $t = null;
    if ($count < 10) {
        $c = $count++;
        return java_cast(java_closure(), "String") . "{$c}";
    }
    return "leaf";
}
function toString()
{
    global $count;
    $s = new java("java.lang.String", "hello");
    $v = new java("java.lang.String", "hello");
    $t = new java("java.lang.String", "hello");
    $s = $v = $t = null;
    if ($count < 2) {
        $count++;
        return java_cast(java_closure(), "string");
    }
    echo 'check the server log, it should contain a php.java.bridge.Request$AbortException';
    exit(0);
    return "leaf";
}
Esempio n. 9
0
 /**
  * Parses a section element of HWPF document
  * @return  HTMLElement
  */
 private function parseSection()
 {
     // Create new style for HTML element
     $container = new HTMLElement(HTMLElement::DIV);
     $this->mainStyleSheet = new StyleSheet();
     // Set class name
     $styleClass = new StyleClass();
     $className = $this->mainStyleSheet->getClassName($styleClass);
     $container->setClass($className);
     //Initialize headers and footers
     $this->collectHeaderFooterInformation();
     // Get document body elements
     $elements = java_values($this->document->getBodyElements());
     //Set current processed part
     $this->currentProcessedPart = "BODY";
     $tocNumber = 0;
     // Every Word document section consists of paragraphs, so we iterate through them, and parse them one by one
     foreach ($elements as $key => $element) {
         // Check if element is a table
         if (java_instanceof($element, java('org.apache.poi.xwpf.usermodel.XWPFTable'))) {
             $table = new XWPFTable($element, $key, $this->mainStyleSheet);
             $tableElement = $table->parseTable();
             $container->addInnerElement($tableElement);
         }
         // Check if element is a paragraph
         if (java_instanceof($element, java('org.apache.poi.xwpf.usermodel.XWPFParagraph'))) {
             // Get paragraph out of element
             $paragraph = java_cast($element, 'org.apache.poi.xwpf.usermodel.XWPFParagraph');
             //$beforeProcess = $this->inspectParagraph($paragraph, $container ,$key);
             if ($this->checkLastRenderedPage($paragraph)) {
                 //echo "page:".$this->pageCounter."<br/>";
                 //  $container->addInnerElement($this->auxContainer[0]);
                 //  $container->addInnerElement($this->auxContainer[1]);
             }
             //Check if the element is a list
             $numberingInfo = $this->paragraphExtractNumbering($paragraph);
             if ($numberingInfo) {
                 $this->processList($numberingInfo, $container, $paragraph, $key);
             } else {
                 // Parse paragraph
                 $paragraphHTMLElement = $this->parseParagraph($paragraph, $key);
                 $container = $this->processContainer($paragraphHTMLElement, $container, $key);
             }
         }
         // Adjust progress step
         //$this->_progress->incrementStep();
         $elementType = java_values($element->getElementType()->toString());
         if ($elementType == "CONTENTCONTROL") {
             $tableOfContents = new TableOfContents($element);
             $tocContainer = $tableOfContents->processToc($tocNumber);
             $container->addInnerElement($tocContainer);
             $tocNumber++;
         }
     }
     // Add container to inner body
     $this->htmlDocument->setBody($container);
 }
Esempio n. 10
0
#!/usr/bin/php

<?php 
include_once "java/Java.inc";
$here = realpath(dirname($_SERVER["SCRIPT_FILENAME"]));
if (!$here) {
    $here = getcwd();
}
$Array = new java_class("ArrayArray");
$arrayArray = $Array->create(10);
$String = new java_class("java.lang.String");
for ($i = 0; $i < 10; $i++) {
    $ar = $arrayArray[$i]->array;
    echo java_cast($ar, "S") . " " . java_cast($ar[0], "S") . "\n";
}
echo "\n";
foreach ($arrayArray as $value) {
    $ar = $value->array;
    echo java_cast($ar, "S") . " " . java_cast($ar[0], "S") . "\n";
}
Esempio n. 11
0
#!/usr/bin/php

<?php 
include_once "java/Java.inc";
$ListClass = new java_class("java.util.ArrayList");
$list = new java("java.util.ArrayList");
$list->add(0);
$list->add("one");
$list->add(null);
$list->add(new java("java.lang.Object"));
$list->add(new java("java.lang.Long", 4));
$list->add($list);
// the list now contains itself
$list->add(new java("java.lang.String", "last entry"));
foreach ($list as $key => $value) {
    echo "{$key} => ";
    if ($value instanceof java) {
        if (java_instanceof($value, $ListClass)) {
            // second argument may also be an instance of a class
            if (!java_instanceof($value, $list)) {
                exit(1);
            }
            echo "[I have found myself!] \n";
        } else {
            echo "[found java object: " . java_cast($value, "S") . "] \n";
        }
    } else {
        echo "{$value}\n";
    }
}
Esempio n. 12
0
  Welcome to the Number Guess game.<p>

  I'm thinking of a number between 1 and 100.<p>

  <form method=post>
  What's your guess? <input type=text name=guess>
  <input type=submit value="Submit">
  </form>

<?php 
    } else {
        ?>

  Good guess, but nope.  Try <b><?php 
        echo java_cast($numguess->getHint(), "S");
        ?>
</b>.

  You have made <?php 
        echo java_values($numguess->getNumGuesses());
        ?>
 guesses.<p>

  I'm thinking of a number between 1 and 100.<p>

  <form method=post>
  What's your guess? <input type=text name=guess>
  <input type=submit value="Submit">
  </form>
Esempio n. 13
0
<?php

include_once "java/Java.inc";
is_string(java_cast(1, "string")) || die("string");
is_long(java_cast("1", "long")) || die("long");
is_double(java_cast(1, "double")) || die("double");
is_bool(java_cast(1, "boolean")) || die("boolean");
is_object(java_cast(1, "object")) || die("object");
is_array(java_cast(1, "array")) || die("array");
echo "test okay\n";
 /**
  * {@inheritDoc}
  */
 public function getHtmlScriptSource()
 {
     if (function_exists("java_get_base") && java_server_name() && is_object($this->value) && $this->value instanceof java_JavaType) {
         return highlight_string(java_cast($this->value, "S"), true);
     } else {
         return highlight_string($this->value, true);
     }
 }
Esempio n. 15
0
 private static function _get_dirs($path, $left, $level, $parent, $recursive, &$tree)
 {
     $right = $left + 1;
     $subfolders = 0;
     if ($recursive and sys_is_folderstate_open($path, "cifs", $parent)) {
         try {
             $ntlm = self::_get_ntlm($parent);
             $w = new Java("jcifs.smb.SmbFile", "smb://" . $path, $ntlm);
             if ($files = $w->listFiles()) {
                 $dirs = array();
                 foreach ($files as $file) {
                     $type = $file->getType();
                     if ($file->isDirectory() and $type != 32 and (!in_array($type, array(8, 16)) or !$file->isHidden())) {
                         $dirs[] = $path . str_replace(chr(0), "", $file->getName());
                         $subfolders = 1;
                     }
                 }
                 natcasesort($dirs);
                 foreach ($dirs as $dir) {
                     $right = self::_get_dirs($dir, $right, $level + 1, $parent, true, $tree);
                 }
             }
         } catch (Exception $e) {
             if (DEBUG_JAVA) {
                 $msg = java_cast($e, "string");
             } else {
                 $msg = $e->getMessage();
             }
             sys_warning("{t}Access denied.{/t} [get_dirs] " . $msg . " " . $path);
         }
     } else {
         $right = $right + 2;
         $subfolders = 1;
         if ($level > 1) {
             $subfolders = (int) self::_has_subfolder($path, self::_get_ntlm($parent));
         }
     }
     $icon = "";
     if ($level == 0) {
         $icon = "sys_nodb_cifs.png";
     }
     $tree[$left] = array("id" => $path, "lft" => $left, "rgt" => $right, "flevel" => $level, "ftitle" => basename($path), "ftype" => "sys_nodb_cifs", "icon" => $icon, "ffcount" => $subfolders);
     return $right + 1;
 }
Esempio n. 16
0
#!/usr/bin/php

<?php 
include_once "java/Java.inc";
try {
    $here = realpath(dirname($_SERVER["SCRIPT_FILENAME"]));
    if (!$here) {
        $here = getcwd();
    }
    $e = new java("Exception");
    // trigger ID=42
    $i = $e->inner;
    $i->o = new java("java.lang.Integer", 42);
    // should return 33
    $e->inner->meth(33);
    try {
        // should throw exception "Exception$Ex"
        $e->inner->meth(42);
        return 2;
    } catch (java_exception $exception) {
        echo "An exception occured: " . java_cast($exception, "S") . "\n";
        $cause = $exception->getCause();
        echo "exception " . java_cast($cause, "S") . " --> " . $cause->getID() . "\n";
        return java_values($cause->getID()) == 42 ? 0 : 3;
    }
} catch (exception $err) {
    print "unexpected: " . java_cast($err, "S") . " \n";
    return 4;
}
#!/usr/bin/php

<?php 
include_once "java/Java.inc";
$conversion = new java("java.util.Properties");
$conversion->put("long", "java.lang.Byte java.lang.Short java.lang.Integer");
$conversion->put("boolean", "java.lang.Boolean");
$conversion->put("double", "java.lang.Double");
$conversion->put("null", "null");
$conversion->put("object", "depends");
$conversion->put("array of longs", "int[]");
$conversion->put("array of doubles", "double[]");
$conversion->put("array of boolean", "boolean[]");
$conversion->put("mixed array", "");
foreach ($conversion as $key => $value) {
    echo "{$key} => " . java_cast($value, "S") . "\n";
}
#!/usr/bin/php

<?php 
include_once "java/Java.inc";
$file_encoding = "ASCII";
java_set_file_encoding($file_encoding);
$out = new java("java.io.ByteArrayOutputStream");
$stream = new java("java.io.PrintStream", $out);
$str = new java("java.lang.String", "Cześć! -- שלום -- Grüß Gott", "UTF-8");
$stream->print($str);
echo "Stream: " . $out->__toString() . "\n";
echo "Stream as {$file_encoding} string: " . java_values($out->toString()) . "\n";
echo "Stream as binary data: " . java_cast($out->toByteArray(), "S") . "\n";
Esempio n. 19
0
#!/usr/bin/php

<?php 
include_once "java/Java.inc";
$h = array("k" => "v", "k2" => "v2");
$m = new java("java.util.Properties", $h);
echo $m->size() . " " . java_cast($m->getProperty("k", "ERROR"), "S") . " \n";
if (java_values($m->getProperty("k2", "ERROR")) != "v2") {
    echo "ERROR\n";
    exit(1);
}
echo "test okay\n";
exit(0);
Esempio n. 20
0
            $code=java_values($rep->getRetCode()); //得到交易返回码
            $msg=java_values($rep->getErrorMessage());

            if (!java_is_null($msg)) {
            //为正确显示中文对返回java变量进行转换,如果用java_set_file_encoding进行过转换则不用再次转换
                $msg=java_values($msg->getBytes("GBK")); }

            print "交易返回码:" . $code . "<br>";
            print "交易错误信息:" . $msg . "<br>";

            if ($code == "0") //交易成功
                {
                $oprSet=$rep->getOpResultSet();

                $iNum=java_cast($oprSet->getOpresultNum(), "integer"); //转换为整数类型

                print "总交易记录数:";

                print java_values($iNum);

                print "<br>------------------------<br>";

                for ($index=0; $index <= $iNum - 1; $index=$index + 1)
                    {
                    $order=$oprSet->getResultValueByName($index, "order");                     //订单号

                    $orderDate=$oprSet->getResultValueByName($index, "orderDate");             //订单日期

                    $orderTime=$oprSet->getResultValueByName($index, "orderTime");             //订单时间
Esempio n. 21
0
<?php

define("JAVA_PREFER_VALUES", true);
require_once "java/Java.inc";
$system = new java("java.lang.System");
$t1 = $system->currentTimeMillis();
$here = getcwd();
// load scheme interpreter
// try to load local ~/lib/kawa.jar, otherwise load it from sf.net
try {
    java_require("kawa.jar");
} catch (JavaException $e) {
    java_require("http://php-java-bridge.sourceforge.net/kawa.jar");
}
$s = new java("kawa.standard.Scheme");
for ($i = 0; $i < 100; $i++) {
    $res = java_cast($s->eval("\n\n(letrec\n ((f (lambda(v)\n       (if \n\t   (= v 0)\n\t   1\n\t (*\n\t  (f\n\t   (- v 1))\n\t  v)))))\n (f {$i}))\n\n"), "D");
    if ($ex = java_last_exception_get()) {
        $res = $ex->toString();
    }
    java_last_exception_clear();
    echo "fact({$i}) ==> {$res}\n";
}
$t2 = $system->currentTimeMillis();
$delta = ($t2 - $t1) / 1000.0;
$now = new java("java.sql.Timestamp", $system->currentTimeMillis());
echo "Evaluation took {$delta} s -- at: {$now}\n";
Esempio n. 22
0
#!/usr/bin/php

<?php 
include_once "java/Java.inc";
$ar = array(1, 2, 3, 5, 7, 11, -13, -17.01, 19);
unset($ar[1]);
$v = new java("java.util.Vector", $ar);
$Arrays = new java_class("java.util.Arrays");
$l = $Arrays->asList($ar);
$v->add(1, null);
$l2 = $v->sublist(0, $v->size());
echo java_cast($l, "S") . "\n" . java_cast($l2, "S") . "\n";
$res1 = java_values($l);
$res2 = java_values($l2);
$res3 = array();
$res4 = array();
$i = 0;
foreach ($v as $key => $val) {
    $res3[$i++] = java_values($val);
}
for ($i = 0; $i < java_values($l2->size()); $i++) {
    $res4[$i] = java_values($l2[$i]);
}
if (!$l->equals($l2)) {
    echo "ERROR\n";
    exit(1);
}
if (java_values($l[1]) != null || (string) $res3 != (string) $res1 || (string) $res4 != (string) $res1) {
    echo "ERROR\n";
    exit(2);
}
#!/usr/bin/php

<?php 
include_once "java/Java.inc";
$ar = array(1, 2, 3, "X" => 5, "X" => 99, 7, 11, -13, -17.01, 19);
$ar2 = array(1, 2, 3, 5, 7, 1000 => 23, 6 => 11, 7 => -13, 8 => -17.01, 9 => 19);
echo "Set       : " . java_cast(new java("java.util.Vector", $ar), "S") . "\n";
echo "Ordered   : " . java_cast(new java("java.util.Vector", $ar2), "S") . "\n";
echo "Dictionary: " . java_cast(new java("java.util.HashMap", $ar), "S") . "\n";
echo "Dictionary: " . java_cast(new java("java.util.HashMap", $ar2), "S") . "\n";