Package org.archive.wayback.resourceindex.cdx.format

Examples of org.archive.wayback.resourceindex.cdx.format.CDXFormat


   * @param args
   */
  public static void main(String[] args) {
//    String cdxSpec = CDXFormatIndex.CDX_HEADER_MAGIC;
    String cdxSpec = " CDX N b a m s k r V g";
    CDXFormat format = null;
    BlockLoader blockLoader = new GenericBlockLoader();
    try {
      format = new CDXFormat(cdxSpec);
    } catch (CDXFormatException e1) {
      e1.printStackTrace();
      System.exit(1);
    }
    ZiplinesSearchResultSource zl = new ZiplinesSearchResultSource(format);
    PrintWriter pw = new PrintWriter(System.out);
    int idx;
    boolean blockDump = false;
    for(idx = 0; idx < args.length; idx++) {
      if(args[idx].equals("-format")) {
        idx++;
        if(idx >= args.length) {
          USAGE();
        }
        try {
          zl.setFormat(new CDXFormat(args[idx]));
        } catch (CDXFormatException e1) {
          e1.printStackTrace();
          System.exit(1);
        }
      } else if(args[idx].equals("-flexFormat")) {
View Full Code Here


 
  protected CloseableIterator<CaptureSearchResult> adaptIterator(Iterator<String> itr)
  throws IOException {
   
    long nowMod = file.lastModified();
    CDXFormat cdx = format;
    if(cdx == null) {
      if(nowMod > lastMod) {
        try {
          // BUGBUG: I don't think java will let us do much better than
          // this... No way to stat() a filehandle, right?
          FileInputStream fis = new FileInputStream(file);
          InputStreamReader isr = new InputStreamReader(fis,ByteOp.UTF8);
          BufferedReader fr = new BufferedReader(isr);
          cdx = new CDXFormat(fr.readLine());
          lastMod = nowMod;
          fr.close();
        } catch (CDXFormatException e) {
          lastMod = -1;
          try {
            cdx = new CDXFormat(CDX_HEADER_MAGIC);
          } catch (CDXFormatException e1) {
            throw new IOException(e1.getMessage());
          }
        }
      }
View Full Code Here

    worker.canonicalizer = canonicalizer;
    worker.interval = 0;
    worker.init();
    try {
      CloseableIterator<CaptureSearchResult> itr = worker.indexFile(path);
      CDXFormat cdxFormat = new CDXFormat(cdxSpec);
      Iterator<String> lines =
        SearchResultToCDXFormatAdapter.adapt(itr, cdxFormat);
      pw.println(cdxSpec);
      while(lines.hasNext()) {
        pw.println(lines.next());
View Full Code Here

import junit.framework.TestCase;

public class CDXFormatTest extends TestCase {
  public void testParseSpec() {
    CaptureSearchResult c;
    CDXFormat f = OKFormat(" CDX a V");
    c = OKParse(f,"http://foo.com 12");
    assertEquals("http://foo.com",c.getOriginalUrl());
    assertEquals(c.getOffset(), 12);

   
View Full Code Here

      fail(e.getLocalizedMessage());
    }
    return r;
  }
  private CDXFormat OKFormat(String format) {
    CDXFormat f = null;
    try {
      f = new CDXFormat(format);
    } catch (CDXFormatException e) {
      fail("Format '" + format + "' should NOT have thrown exception");
    }
    return f;
  }
View Full Code Here

    }
    return f;
  }
  private void exceptionFormat(String format) {
    try {
      new CDXFormat(format);
      fail("Format '" + format + "' should have thrown exception");
    } catch (CDXFormatException e) {
    }
   
  }
View Full Code Here

TOP

Related Classes of org.archive.wayback.resourceindex.cdx.format.CDXFormat

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.