Package net.sf.jpluck.plucker

Examples of net.sf.jpluck.plucker.Document$URIIndexRecord


        String name = jxlDocument.getName();
        if (jxlDocument.isRemoveAccents()) {
          name = Database.convertToDatabaseName(name);
        }
        Document document = new Document(name, ClientConfiguration.getDefault().getCompression());

        Date date = jxlDocument.getDate();
        if (date != null) {
          document.setCreationDate(date);
          document.setModificationDate(date);
        }
        spider = new Spider(document, jxlDocument, httpCache, cookieStore, maxConnections,
                  Spider.DEFAULT_MAX_PARSE_THREADS, httpTimeout);
        try {
          for (Iterator iterator = spiderListenerList.iterator(); iterator.hasNext();) {
            SpiderListener spiderListener = (SpiderListener) iterator.next();
            spider.addSpiderListener(spiderListener);
          }
          if (!running) {
            break;
          }
          spider.run();
        } finally {
          for (Iterator iterator = spiderListenerList.iterator(); iterator.hasNext();) {
            SpiderListener spiderListener = (SpiderListener) iterator.next();
            spider.removeSpiderListener(spiderListener);
          }
        }

        boolean success = false;
        if (!running) {
          break;
        }

        String uri = jxlDocument.getStartingURI().toString();
        if (document.contains(uri)) {
          try {
            document.setHome(uri);
            document.setOutputEncoding(jxlDocument.getOutputEncoding());
            document.setIncludeImageAltText(jxlDocument.isIncludeAltText());
            document.setCategories(jxlDocument.getCategories());
            document.setDefaultLinkColor(jxlDocument.getLinkColor());
            document.setUnresolvedLinkColor(jxlDocument.getUnresolvedLinkColor());
            document.setRemoveUnresolvedLinks(jxlDocument.isRemoveUnresolvedLinks());
            document.setIncludeURIInfo(jxlDocument.isIncludeURIInfo());
            document.setBackup(jxlDocument.isSetBackupBit());
            document.setEncoding(jxlDocument.getOutputEncoding());
            // Sort bookmarks for sites
            if (jxlDocument instanceof Site) {
              Site site = (Site) jxlDocument;
              if (site.isSortBookmarks()) {
                document.sortBookmarks();
              }
            }

            fireGenerationStarted(jxlDocument);
            for (Iterator it = recordListenerList.iterator(); it.hasNext();) {
              document.addRecordListener((RecordListener) it.next());
            }
            document.setFilename(jxlDocument.getFilename());
            long size = destination.write(document);
            jxlDocument.converted(size);
            fireGenerationCompleted(jxlDocument);
            logger.info("Completed conversion: " + jxlDocument.getName());
            success = true;
          } catch (Exception e) {
            logger.severe("Could not generate document: " + e.getClass() + " " + e.getMessage());
            e.printStackTrace();
          } finally {
            for (Iterator it = recordListenerList.iterator(); it.hasNext();) {
              document.removeRecordListener((RecordListener) it.next());
            }
          }
        } else {
          logger.severe(jxlDocument.getName() + ": could not load starting URI " + jxlDocument.getUri() +
                  ". Document cannot be generated.");
View Full Code Here


        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        for (int bytesRead; (bytesRead = System.in.read(buf)) != -1; ) {
          baos.write(buf, 0, bytesRead);
        }
        byte[] data = baos.toByteArray();
        Document document = new Document();
        if (mimeType.equals("text/html")) {
      Resource resource = new Resource("http://127.0.0.1/", null, new ContentType(mimeType), data, 0, false);
      org.w3c.dom.Document dom = resource.parseHTML();
      TextRecord textRecord = new TextRecord("http://127.0.0.1/");
      Transformer transformer = TransformerFactory.newInstance().newTransformer();
      TextRecordResult result = new TextRecordResult(textRecord, new URIRewriter(), 100, false, document);
      transformer.transform(new DOMSource(dom), result);
      document.addRecord(textRecord);
        } else if (mimeType.startsWith("image/")) {
      BufferedImage image = ImageIO.read(new ByteArrayInputStream(data));
      CompositeBitmap compositeBitmap = CompositeBitmap.create(image, bpp);
      String[] uris = new String[compositeBitmap.getRows()];
      for (int j = 0, n = compositeBitmap.getRows(); j < n; j++) {
        uris[j] = "http://127.0.0.1/-" + j;
        document.addRecord(new ImageRecord(uris[j], compositeBitmap.getBitmapAt(j, 0)));
      }
      document.addRecord(new CompositeImageRecord("http://127.0.0.1/", uris, 1));
        }

        if (name.length() > 31) {
            name = name.substring(0, 31).trim();
        }
        LogUtil logUtil = new LogUtil(LogUtil.DEFAULT_LOGGER_NAMES);
        logUtil.setLevel(Level.OFF);
        document.setName(name);
        document.setHome("http://127.0.0.1/");
        document.setCompression(Document.ZLIB_COMPRESSION);
        document.setIncludeURIInfo(false);
        document.write(System.out);
    }
View Full Code Here

import net.sf.jpluck.plucker.TextRecord;

public class BookmarkTest {

  public static void main(String[] args) throws Exception {
    Document document = new Document("Bookmark Test");
    for (int i = 1; i <= 10; i++) {
      String uri = "page" + i;
      TextRecord page = new TextRecord(uri);
      String name = "Page " + i;
      page.addParagraph().addFontH1().addText(name).addAnchor("anchor");
     
      document.addBookmark(name, uri + "#anchor");
      document.addRecord(page);
    }
    document.setIncludeURIInfo(true);
    document.setHome("page1");
    document.write(new File(args[0]));   
  }
View Full Code Here

    cell = row.addCell();
        cell.addText("sw");
        cell = row.addCell();
        cell.addText("se");

        Document document = new Document("Table test");
        document.setCompression(Document.NO_COMPRESSION);
        document.addRecord(home);
        document.setHome(home);
        document.addRecord(table);
        document.write(new File(args[0]));

    }
View Full Code Here

      maxHeight = Integer.parseInt(cl.getOptionValue("maxheight"));
    }
   
    boolean noBookmarks = cl.hasOption("nobookmarks");

    Document document = new Document(name, Document.ZLIB_COMPRESSION);
    String category = null;
    if (cl.hasOption("category")) {
      category = cl.getOptionValue("category");
      if (category.length() > 15) {
        category = category.substring(0, 15).trim();
      }
      document.setCategories(new String[] { category });
    }
   
    TextRecord home=new TextRecord("home");
    home.addParagraph().addFontH1().addText(name).addFontRegular();    

    for (int i = 1; i < arguments.length; i++) {
      System.out.println(arguments[i] + " (" + i + "/" + (arguments.length-1) + ")");
      File file = new File(arguments[i]);
      if (!file.isFile()) {
        throw new IOException("Not a file: " + file.getAbsolutePath());
      }
      BufferedImage image = ImageIO.read(file);

      int width = image.getWidth();
      int height = image.getHeight();
      image = ImageConverter.rescale(image, ((maxWidth > 0) ? maxWidth : width),
                   ((maxHeight > 0) ? maxHeight : height));

      CompositeBitmap compositeBitmap = CompositeBitmap.create(image, bpp);
      String uri = file.toURI().toString();     
      home.addParagraph(2).addText(i + " ").addLinkStart(uri).addText(file.getName()).addLinkEnd();
     
      String[] uris = new String[compositeBitmap.getRows()];
      for (int j = 0, n = compositeBitmap.getRows(); j < n; j++) {
        uris[j] = uri + "-" + j;
        document.addRecord(new ImageRecord(uris[j], compositeBitmap.getBitmapAt(j, 0)));
      }
      document.addRecord(new CompositeImageRecord(uri, uris, 1));
      if (!noBookmarks) {
        document.addBookmark(file.getName(), uri);
      }
    }

    document.addRecord(home);
    document.setHome(home);

    System.out.println("Writing " + pdbFile.getAbsolutePath());
    document.write(pdbFile);
    System.out.println("Done!");
  }
View Full Code Here

TOP

Related Classes of net.sf.jpluck.plucker.Document$URIIndexRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.