Example #1
0
 /**
  * @param $run
  * @param $mainStyleSheet
  */
 function __construct($run, $mainStyleSheet)
 {
     if (java_instanceof($run, java('org.apache.poi.xwpf.usermodel.XWPFRun'))) {
         $this->run = $run;
     }
     $this->mainStyleSheet = $mainStyleSheet;
 }
Example #2
0
 /**
  * @param $paragraph
  * @param $mainStyleSheet
  */
 function __construct($paragraph, $mainStyleSheet)
 {
     if (java_instanceof($paragraph, java('org.apache.poi.xwpf.usermodel.XWPFParagraph'))) {
         $this->paragraph = $paragraph;
     }
     $this->mainStyleSheet = $mainStyleSheet;
 }
Example #3
0
 /**
  * @param $picture
  * @param $mainStyleSheet
  * @param $path
  */
 function __construct($picture, $mainStyleSheet, $path)
 {
     if (java_instanceof($picture, java('org.apache.poi.xwpf.usermodel.XWPFPicture'))) {
         $this->picture = $picture;
     }
     $this->mainStyleSheet = $mainStyleSheet;
     $this->_tmp_path = $path;
 }
Example #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();
     }
 }
Example #5
0
 function __construct($style)
 {
     if (java_instanceof($style, java('org.apache.poi.xwpf.usermodel.XWPFStyle'))) {
         $this->style = $style;
     } else {
         echo "This is not  Style Class";
         die;
     }
 }
Example #6
0
 function __construct($cell, $mainStyleSheet)
 {
     if (java_instanceof($cell, java('org.apache.poi.xwpf.usermodel.XWPFTableCell'))) {
         $this->cell = $cell;
     } else {
         throw new Exception("[XWPFTableCell::new XWPFTableCell] Cell cannot be null");
     }
     $this->mainStyleSheet = $mainStyleSheet;
     $this->xmlCell = $this->getXMLCellObject();
 }
Example #7
0
<th>Value</th>
<th WIDTH="60%">Description</th>
</tr>
<tr>
<td>servlet_log_level</td>
<td><?php 
echo java_values($bridge->getlogLevel());
?>
</td>
<td>The request log level.</td>
</tr>
</table>
</p>
<p>
<?php 
if (java_instanceof($servlet, java('php.java.servlet.fastcgi.FastCGIServlet'))) {
    ?>
<H2>PhpCGIServlet</H2>
<p>
The <code>PhpCGIServlet</code> runs PHP scripts within the J2EE/Servlet engine.
</p>
<blockquote>
<code>
internet browser &lt;--&gt; PhpCGIServlet &lt;--&gt; php-cgi &lt;--&gt; PhpJavaServlet
</code>
</blockquote>
<p>
It starts a PHP FastCGI server, if possible and necessary. Requests for PHP scripts are delegated to the FastCGI server. If the PHP code contains Java calls, the PHP/Java Bridge protocol requests are delegated back to the current VM, to an instance of the <code>PhpJavaServlet</code>.
</p>
<table BORDER=1 CELLSPACING=5 WIDTH="85%" >
<tr VALIGN=TOP>
Example #8
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";
    }
}
<?php

include_once "java/Java.inc";
$s = new java("java.lang.String", 12);
$c1 = java_context();
$c2 = java_session();
$c3 = java_session();
$c4 = java_context();
echo "{$c1}\n{$c2}\n{$c3}\n{$c4}\n";
$instance = java_instanceof($s, new java("java.lang.String"));
if (!$c1 || !$c2 || !$c3 || !$c4 || !$instance) {
    echo "ERROR\n";
    exit(1);
}
echo "test okay\n";
exit(0);
Example #10
0
#!/bin/env php
<?php 
/**
 * This example uses the PHP/Java Bridge to connect to a SOAP service.
 */
require_once "java/Java.inc";
include "wsimport.php";
try {
    $addNumbersService = new java("org.duke.AddNumbersService");
    $port = $addNumbersService->getAddNumbersPort();
    $number1 = 10;
    $number2 = 20;
    echo "Invoking one-way operation. Nothing is returned from service.\n";
    $port->oneWayInt($number1);
    echo "Invoking addNumbers({$number1}, {$number2})\n";
    $result = $port->addNumbers($number1, $number2);
    echo "The result of adding {$number1} and {$number2} is {$result}\n\n";
    $number1 = -10;
    echo "Invoking addNumbers({$number1}, {$number2})\n";
    $result = $port->addNumbers($number1, $number2);
    echo "The result of adding {$number1} and {$number2} is {$result}\n\n";
} catch (JavaException $ex) {
    $ex = $ex->getCause();
    if (java_instanceof($ex, new JavaClass("org.duke.AddNumbersFault_Exception"))) {
        $info = $ex->getFaultInfo()->getFaultInfo();
        echo "Caught AddNumbersFault_Exception: {$ex}, INFO: {$info}.\n";
    } else {
        echo "Exception occured: {$ex}\n";
    }
}
Example #11
0
 /**
  * @param $charRuns
  * @param $container
  */
 private function parseRuns($charRuns, $container)
 {
     $prevCharRunHTMLElement = null;
     // for ($j = 0; $j < count($charRuns); $j++) {
     foreach ($charRuns as $charRun) {
         if (java_instanceof($charRun, java('org.apache.poi.xwpf.usermodel.XWPFRun'))) {
             $characterRun = $charRun;
             $pictures = java_values($characterRun->getEmbeddedPictures());
             //$charRunHTMLElement = $this->parseCharacterRun($characterRun);
             $run = new XWPFRun($characterRun, $this->mainStyleSheet);
             $charRunHTMLElement = $run->parseRun();
             // Check if this is a picture
             if (count($pictures) > 0) {
                 $container->addInnerElement($charRunHTMLElement);
                 $prevCharRunHTMLElement = clone $charRunHTMLElement;
                 // This part is needed in order to merge similar SPAN tags in one, if they have same
                 // style (this will also prevent unneeded spaces)
             } else {
                 if (@isset($prevCharRunHTMLElement) && $charRunHTMLElement->getClass() == $prevCharRunHTMLElement->getClass()) {
                     $container->getLastElement()->addInnerText($charRunHTMLElement->getInnerText());
                     // The rest of elements
                 } else {
                     $container->addInnerElement($charRunHTMLElement);
                     $prevCharRunHTMLElement = clone $charRunHTMLElement;
                 }
             }
         } else {
             var_dump($charRun);
         }
     }
 }
#!/usr/bin/php

<?php 
include_once "java/Java.inc";
$Thread = new JavaClass("java.lang.Thread");
$current = $Thread->currentThread();
try {
    $thread = new java("java.lang.Thread", $current->getThreadGroup(), "simple");
    echo "Test failed or no javabridge.policy installed\n";
    exit(1);
} catch (JavaException $e) {
    $cause = $e->getCause();
    if (!java_instanceof($cause, new JavaClass("java.lang.SecurityException"))) {
        echo "test failed\n";
        exit(2);
    }
}
try {
    $thread = new java("java.lang.Thread");
    echo "Test failed or no javabridge.policy installed\n";
    exit(3);
} catch (JavaException $e) {
    $cause = $e->getCause();
    if (!java_instanceof($cause, new JavaClass("java.lang.SecurityException"))) {
        echo "test failed\n";
        exit(4);
    }
}
echo "test okay\n";
exit(0);
 /**
  * Get the information about an annotation object. The information retreived is: the predicate URI which is the
  * annotation property, the value, the datatype of the value and possibly the language if it is a literal and that
  * the language is defined for it.
  * 
  * @param mixed $annotation OWLAnnotation object to get information about
  * @param boolean $getReifications This tells the getAnnotationInfo method if it should check for possible
  *                                 reification statements. This should always be TRUE. This is mainly
  *                                 used to stop possible infinite loops between getAnnotationInfo and
  *                                 getPrefLabel.
  * @return mixed Array("property" => "", "value" => "", "type" => "", "lang" => "")
  *  
  * @author Frederick Giasson, Structured Dynamics LLC.
  */
 private function getAnnotationInfo($annotation, $getReifications = TRUE)
 {
     $property = "";
     $value = "";
     $type = "";
     $lang = "";
     $rei = array();
     if (!java_instanceof($annotation, java("org.semanticweb.owlapi.model.OWLAnnotation"))) {
         return array("property" => "", "uri" => "", "value" => "", "type" => "", "lang" => "", "reify" => "");
     }
     // Check if the value is an OWLLiteral
     if (java_instanceof($annotation->getValue(), java("org.semanticweb.owlapi.model.OWLLiteral"))) {
         $property = (string) java_values($annotation->getProperty()->toStringID());
         $value = (string) java_values($annotation->getValue()->getLiteral());
         $lang = (string) java_values($annotation->getValue()->getLang());
         $type = (string) java_values($annotation->getValue()->getDatatype()->toStringID());
     }
     // Check if the value is a IRI
     if (java_instanceof($annotation->getValue(), java("org.semanticweb.owlapi.model.IRI"))) {
         $property = (string) java_values($annotation->getProperty()->toStringID());
         $value = (string) java_values($annotation->getValue()->toURI());
         $entities = $this->ontology->getEntitiesInSignature($annotation->getValue());
         if ($getReifications) {
             foreach ($entities as $entity) {
                 $rei = array("wsf:objectLabel" => array($this->getPrefLabel($entity)));
                 break;
             }
         }
         $type = "xsd:anyURI";
     }
     // Check if the value is a OWLAnonymousIndividual
     if (java_instanceof($annotation->getValue(), java("org.semanticweb.owlapi.model.OWLAnonymousIndividual"))) {
         $property = (string) java_values($annotation->getProperty()->toStringID());
         $value = (string) java_values($annotation->getValue()->toStringID());
         $type = "xsd:anyURI";
     }
     if ($type == "xsd:anyURI") {
         return array("property" => $property, "uri" => $value, "reify" => $rei);
     } else {
         return array("property" => $property, "value" => $value, "type" => $type, "lang" => $lang);
     }
 }
Example #14
0
 /**
  * @return HTMLElement|null
  * @throws Exception
  */
 public function parseTable()
 {
     if (is_object($this->javaTable)) {
         $container = new HTMLElement(HTMLElement::TABLE);
         $styleClass = $this->processTableStyles();
         $tableStyleClass = !empty($styleClass) ? $styleClass['table'] : $styleClass;
         if (is_a($tableStyleClass, 'StyleClass')) {
             $tableClassName = $this->mainStyleSheet->getClassName($tableStyleClass);
             $container->setClass($tableClassName);
         }
         $rows = $this->getRows();
         $numberOfRows = count($rows) - 1;
         foreach ($rows as $rowNumber => $row) {
             $conditionalTableRowStyleClass = $this->processConditionalFormat($rowNumber, $styleClass, $numberOfRows);
             $rowContainer = new HTMLElement(HTMLElement::TR);
             $xwpfRow = new XWPFTableRow($row);
             $cells = $xwpfRow->getTableICells();
             foreach ($cells as $cellNumber => $cell) {
                 if (java_instanceof($cell, java('org.apache.poi.xwpf.usermodel.XWPFTableCell'))) {
                     $cellContainer = $this->processXWPFTableCell($cell, $styleClass, $conditionalTableRowStyleClass);
                     $rowContainer->addInnerElement($cellContainer);
                 }
                 if (java_instanceof($cell, java('org.apache.poi.xwpf.usermodel.XWPFSDTCell'))) {
                     $rowXml = java_values($row->getCtRow()->ToString());
                     $xwpfSdtCell = new XWPFSDTCell($cell, $rowXml);
                     $xwpfSdtCell->setMainStyleSheet($this->mainStyleSheet);
                     $container = $xwpfSdtCell->parseSDTCell();
                 }
             }
             //Set default size
             $container->setAttribute('style', 'width : 100%');
             $container->addInnerElement($rowContainer);
         }
         return $container;
     } else {
         throw new Exception("[XWPFTable::parseTable] No Java Table instance");
     }
 }