function __wakeup() { $buf = new java("java.io.ByteArrayInputStream", base64_decode($this->serialID)); $in = new java("java.io.ObjectInputStream", $buf); $this->java = $in->readObject(); $in->close(); }
$master->addAll($bookmarks); } } $pageOffset += $n; echo "There are " . $n . " pages in " . $args[$f]; echo "\n"; if ($f == 1) { $document = new java("com.lowagie.text.Document", $reader->getPageSizeWithRotation(1)); $writer = new java("com.lowagie.text.pdf.PdfCopy", $document, new java("java.io.FileOutputStream", $outfile)); $document->open(); } for ($i = 0; $i < $n;) { ++$i; $page = $writer->getImportedPage($reader, $i); $writer->addPage($page); echo "Processed page: " . $i; echo "\n"; } $form = $reader->getAcroForm(); if (java_values($form) != null) { $writer->copyAcroForm($reader); } $f++; } if (java_values($master->size()) > 0) { $writer->setOutlines($master); } $document->close(); ?>
/* Create an index */ $cwd = getcwd(); /* create the index files in the tmp dir */ $tmp = create_index_dir(); $analyzer = new java("org.apache.lucene.analysis.standard.StandardAnalyzer"); $writer = new java("org.apache.lucene.index.IndexWriter", $tmp, $analyzer, true); $file = new java("java.io.File", $cwd); $files = $file->listFiles(); assert(!java_is_null($files)); foreach ($files as $f) { $doc = new java("org.apache.lucene.document.Document"); $doc->add(new java("org.apache.lucene.document.Field", "name", $f->getName(), java('org.apache.lucene.document.Field$Store')->YES, java('org.apache.lucene.document.Field$Index')->UN_TOKENIZED)); $writer->addDocument($doc); } $writer->optimize(); $writer->close(); echo "done\n"; echo "searching... "; /* Search */ $searcher = new java("org.apache.lucene.search.IndexSearcher", $tmp); $phrase = new java("org.apache.lucene.search.MatchAllDocsQuery"); $hits = $searcher->search($phrase); /* Print result */ $iter = $hits->iterator(); $n = java_values($hits->length()); echo "done\n"; echo "Hits: {$n}\n"; /* Instead of retrieving the values one-by-one, we store them into a * LinkedList on the server side and then retrieve the list in one * query using java_values(): */