Package nz.govt.natlib.fx

Examples of nz.govt.natlib.fx.FileDataSource


  public boolean acceptsFile(File file) {
    String name = file.getName().toLowerCase();
    if (WordUtils.isDocFile(file) == true) {
      DataSource ftk = null;
      try {
        ftk = new FileDataSource(file);
        long signature = FXUtil.getNumericalValue(ftk,
            IntegerElement.LONG_SIZE, false);
        if (signature == OLE_TYPE_SIGNATURE) {
          return true;
        }
View Full Code Here


  }

  public static boolean isWord2(File file) throws java.io.IOException {
    DataSource ftk = null;
    try {
      ftk = new FileDataSource(file);
      ftk.setPosition(Offset_To_NFib);
      int iNFib = (int) FXUtil.getNumericalValue(ftk,
          IntegerElement.SHORT_SIZE, false);
      // System.out.println("iNFib " + Integer.toHexString(iNFib));
      // NFib >= 101 => Word6 or greater
View Full Code Here

  public boolean acceptsFile(File file) {
    boolean wp = false;
    DataSource ftk = null;
    try {
      ftk = new FileDataSource(file);
      // Header and default information
      String head = FXUtil.getFixedStringValue(ftk, 4);
      if ((head.equals("�WPC"))) {
        wp = true;
      }
View Full Code Here

      AdapterUtils.close(ftk);
    }
  }

  public static boolean isOLEWord(File file) throws java.io.IOException {
    DataSource ftk = new FileDataSource(file);
    ftk.setPosition(Offset_To_NFib);
    int iNFib = (int) FXUtil.getNumericalValue(ftk,
        IntegerElement.SHORT_SIZE, false);
    // NFib >= 101 => Word6 or greater
    if (iNFib >= 0x101) {
      return true;
View Full Code Here

    return "Adapts all Corel WordPerfect files from version 5.1 to 12.0";
  }

  public void adapt(File file, ParserContext ctx) throws IOException {
    // Add the MetaData to the tree!
    DataSource ftk = new FileDataSource(file);
    ctx.fireStartParseEvent("wordperfect");
    writeFileInfo(file, ctx);
    // ctx.fireParseEvent("Version", "");
    try {
      ctx.fireStartParseEvent("header");
      wpHeaderElement.read(ftk, ctx);
      ctx.fireEndParseEvent("header");
      boolean fivePointOnePlus = ctx
          .getIntAttribute("wordperfect.header.minor-version") >= 1;
      boolean sixPlus = Double.parseDouble(ctx
          .getAttribute("wordperfect.header.major-version")
          + "") >= 6;

      if (sixPlus) {
        // next version should encompass WordPerfect 6.0+
      } else {

        IndexHeaderElement indexReader = new IndexHeaderElement();
        PacketHeaderElement blockHead = new PacketHeaderElement();
        boolean readingBlocks = true;
        boolean summary = false;
        while (readingBlocks) {
          indexReader.read(ftk, ctx);
          // System.out.println(indexReader);
          for (int i = 0; i < indexReader.count - 1; i++) {
            blockHead.read(ftk, ctx);
            // arrange to retrive the data from the appropriate
            // place
            long pos = ftk.getPosition();
            ftk.setPosition(blockHead.dataOffset);

            // System.out.println(" >"+blockHead);
            switch (blockHead.getType()) {
            case 0xc:
              ctx.fireStartParseEvent("printer");
              printerElement.read(ftk, ctx);
              ctx.fireEndParseEvent("printer");
              break;
            case 0x8:
              ctx.fireStartParseEvent("graphics");
              graphicElement.read(ftk, ctx);
              ctx.fireEndParseEvent("graphics");
              break;
            case 0x6:
              ctx.fireStartParseEvent("document");
              documentElement.read(ftk, ctx);
              ctx.fireEndParseEvent("document");
              break;
            case 0x1:
              ctx.fireStartParseEvent("summary");
              summary = true;
              System.out.println("Found Sumary at :"
                  + ftk.getPosition());
              summaryElement.read(ftk, ctx);
              if (fivePointOnePlus) {
                summary2Element.read(ftk, ctx);
              }
              ctx.fireEndParseEvent("summary");
              break;
            }

            // move back to the next block...
            ftk.setPosition(pos);
          }

          // now move to the next block...
          if (indexReader.getNextBlockOffset() == 0) {
            readingBlocks = false;
            break;
          }
          ftk.setPosition(indexReader.getNextBlockOffset());
        }

        if (!summary) {
          ctx.fireParseEvent("summary", "");
        }
View Full Code Here

    HashMap results = new HashMap();
    // add the MetaData to the tree!
    DataSource ftk = null;
   
    try {
      ftk = new FileDataSource(file);
      ctx.fireStartParseEvent("tiff");
      writeFileInfo(file, ctx);
 
      // work out the endian...
      long endianIndicator = FXUtil.getNumericalValue(ftk,
View Full Code Here

TOP

Related Classes of nz.govt.natlib.fx.FileDataSource

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.