Example #1
0
  /** {@inheritDoc} */
  @Override
  public CoordinateReferenceSystem getResponseCRS() throws FactoryException {
    if (output == null
        || output.getGridCRS() == null
        || output.getGridCRS().getSrsName() == null
        || output.getGridCRS().getSrsName().getValue() == null) {
      return null;
    }
    final CoordinateReferenceSystem objCrs =
        CRS.forCode(output.getGridCRS().getSrsName().getValue());
    final BoundingBoxType boundingBox = domainSubset.getBoundingBox().getValue();

    /*
     * If the bounding box contains at least 3 dimensions and the CRS specified is just
     * a 2D one, then we have to add a VerticalCRS to the one gotten by the crs decoding step.
     * Otherwise the CRS decoded is already fine, and we just return it.
     */
    if (boundingBox.getDimensions().intValue() > 2
        && objCrs.getCoordinateSystem().getDimension() < 3) {
      final VerticalCRS verticalCRS = CommonCRS.Vertical.ELLIPSOIDAL.crs();
      return new GeodeticObjectBuilder()
          .addName(objCrs.getName().getCode() + " (3D)")
          .createCompoundCRS(objCrs, verticalCRS);
    } else {
      return objCrs;
    }
  }
 private ResultFormatter getFormatter() {
   if (outputType.toString().equals("xmi")) {
     return new XMIResultFormatter();
   } else {
     return new TimeMLResultFormatter();
   }
 }
Example #3
0
 /** {@inheritDoc} */
 @Override
 public String getFormat() {
   if (output == null) {
     return null;
   }
   return output.getFormat();
 }
Example #4
0
  public static void main(String... args) throws IOException {
    if (args == null || args.length < 5) {
      System.out.printf(
          "usage: java %s fichier.dgs outputPrefix imageType res policy%n",
          FileSinkImages.class.getName());
      System.exit(0);
    }

    FileSourceDGS dgs = new FileSourceDGS();
    FileSinkImages fsi =
        new FileSinkImages(
            args[1],
            OutputType.valueOf(args[2]),
            Resolutions.valueOf(args[3]),
            OutputPolicy.valueOf(args[4]));

    dgs.addSink(fsi);

    if (args.length > 5) fsi.addLogo(args[5], 0, 0);

    fsi.setHighQuality();
    fsi.setStyleSheet(
        "graph { padding: 50px; fill-color: black; }"
            + "node { stroke-mode: plain; stroke-color: #3d5689,#639330,#8d4180,#97872f,#9c4432; stroke-width: 2px; fill-mode: dyn-plain; fill-color: #5782db,#90dd3e,#e069cb,#e0ce69,#e07c69; }"
            + "edge { fill-color: white; }");

    boolean next = true;

    dgs.begin(args[0]);

    while (next) next = dgs.nextStep();

    dgs.end();
  }
Example #5
0
 public JsonWriter name(String name) throws IOException {
   if (current == null || current.array)
     throw new IllegalStateException("Current item must be an object.");
   if (!current.needsComma) current.needsComma = true;
   else writer.write(',');
   writer.write(outputType.quoteName(name));
   writer.write(':');
   named = true;
   return this;
 }
Example #6
0
  public synchronized void outputNewImage(String filename) {
    switch (layoutPolicy) {
      case COMPUTED_IN_LAYOUT_RUNNER:
        layoutPipeIn.pump();
        break;
      case COMPUTED_ONCE_AT_NEW_IMAGE:
        if (layout != null) layout.compute();
        break;
      case COMPUTED_FULLY_AT_NEW_IMAGE:
        stabilizeLayout(layout.getStabilizationLimit());
        break;
      default:
        break;
    }

    if (resolution.getWidth() != image.getWidth() || resolution.getHeight() != image.getHeight())
      initImage();

    if (clearImageBeforeOutput) {
      for (int x = 0; x < resolution.getWidth(); x++)
        for (int y = 0; y < resolution.getHeight(); y++) image.setRGB(x, y, 0x00000000);
    }

    if (gg.getNodeCount() > 0) {
      if (autofit) {
        gg.computeBounds();

        Point3 lo = gg.getMinPos();
        Point3 hi = gg.getMaxPos();

        renderer.getCamera().setBounds(lo.x, lo.y, lo.z, hi.x, hi.y, hi.z);
      }

      renderer.render(g2d, 0, 0, resolution.getWidth(), resolution.getHeight());
    }

    for (PostRenderer action : postRenderers) action.render(g2d);

    image.flush();

    try {
      File out = new File(filename);

      if (out.getParent() != null && !out.getParentFile().exists()) out.getParentFile().mkdirs();

      ImageIO.write(image, outputType.name(), out);

      printProgress();
    } catch (IOException e) {
      // ?
    }
  }
Example #7
0
 public JsonWriter value(Object value) throws IOException {
   if (current != null) {
     if (current.array) {
       if (!current.needsComma) current.needsComma = true;
       else writer.write(',');
     } else {
       if (!named) throw new IllegalStateException("Name must be set.");
       named = false;
     }
   }
   if (value == null || value instanceof Number || value instanceof Boolean) {
     writer.write(String.valueOf(value));
   } else {
     writer.write(outputType.quoteValue(value.toString()));
   }
   return this;
 }
Example #8
0
 com.mongodb.MapReduceCommand build(JacksonDBCollection<?, ?> collection) {
   DBObject query = null;
   if (this.query != null) {
     query = collection.serializeQuery(this.query);
   }
   com.mongodb.MapReduceCommand command =
       new com.mongodb.MapReduceCommand(
           collection.getDbCollection(),
           map,
           reduce,
           this.collection,
           outputType.getDriverType(),
           query);
   if (finalize != null) {
     command.setFinalize(finalize);
   }
   if (readPreference != null) {
     command.setReadPreference(readPreference);
   }
   if (outputDB != null) {
     command.setOutputDB(outputDB);
   }
   if (sort != null) {
     command.setSort(sort);
   }
   command.setLimit(limit);
   if (scope != null) {
     command.setScope(scope);
   }
   command.setVerbose(verbose);
   if (extra != null) {
     for (String key : extra.keySet()) {
       command.addExtraOption(key, extra.get(key));
     }
   }
   return command;
 }
Example #9
0
  /** Produce a new image. */
  protected synchronized void outputNewImage() {
    switch (layoutPolicy) {
      case ComputedAtNewImage:
        if (layout != null) layout.compute();
        break;
    }

    if (resolution.getWidth() != image.getWidth() || resolution.getHeight() != image.getHeight())
      initImage();

    if (gg.getNodeCount() > 0) {
      gg.computeBounds();

      Point3 lo = gg.getMinPos();
      Point3 hi = gg.getMaxPos();

      renderer.setBounds(lo.x, lo.y, lo.z, hi.x, hi.y, hi.z);
      renderer.render(g2d, resolution.getWidth(), resolution.getHeight());
    }

    for (PostRenderer action : postRenderers) action.render(g2d);

    image.flush();

    try {
      File out = new File(String.format("%s%06d.png", filePrefix, counter++));

      if (!out.getParentFile().exists()) out.getParentFile().mkdirs();

      ImageIO.write(image, outputType.name(), out);

      printProgress();
    } catch (IOException e) {
      // ?
    }
  }
  /** @param args */
  public static void main(String[] args) {
    String docPath = null;
    for (int i = 0; i < args.length; i++) { // iterate over cli parameter tokens
      if (args[i].startsWith("-")) { // assume we found a switch
        // get the relevant enum
        CLISwitch sw = CLISwitch.getEnumFromSwitch(args[i]);
        if (sw == null) { // unsupported CLI switch
          logger.log(Level.WARNING, "Unsupported switch: " + args[i] + ". Quitting.");
          System.exit(-1);
        }

        if (sw.getHasFollowingValue()) { // handle values for switches
          if (args.length > i + 1
              && !args[i + 1].startsWith(
                  "-")) { // we still have an array index after this one and it's not a switch
            sw.setValue(args[++i]);
          } else { // value is missing or malformed
            logger.log(
                Level.WARNING, "Invalid or missing parameter after " + args[i] + ". Quitting.");
            System.exit(-1);
          }
        } else { // activate the value-less switches
          sw.setValue(null);
        }
      } else { // assume we found the document's path/name
        docPath = args[i];
      }
    }

    // display help dialog if HELP-switch is given
    if (CLISwitch.HELP.getIsActive()) {
      printHelp();
      System.exit(0);
    }

    // start off with the verbosity recognition -- lots of the other
    // stuff can be skipped if this is set too high
    if (CLISwitch.VERBOSITY2.getIsActive()) {
      logger.setLevel(Level.ALL);
      logger.log(Level.INFO, "Verbosity: '-vv'; Logging level set to ALL.");

      // output the found language resource folders
      String languagesList = "";
      for (String language : ResourceScanner.getInstance().getDetectedResourceFolders()) {
        languagesList += System.getProperty("line.separator") + "- " + language;
      }
      logger.log(Level.INFO, "Listing detected language folders:" + languagesList);
    } else if (CLISwitch.VERBOSITY.getIsActive()) {
      logger.setLevel(Level.INFO);
      logger.log(Level.INFO, "Verbosity: '-v'; Logging level set to INFO and above.");
    } else {
      logger.setLevel(Level.WARNING);
      logger.log(
          Level.INFO,
          "Verbosity -v/-vv NOT FOUND OR RECOGNIZED; Logging level set to WARNING and above.");
    }

    // Check input encoding
    String encodingType = null;
    if (CLISwitch.ENCODING.getIsActive()) {
      encodingType = CLISwitch.ENCODING.getValue().toString();
      logger.log(Level.INFO, "Encoding '-e': " + encodingType);
    } else {
      // Encoding type not found
      encodingType = CLISwitch.ENCODING.getValue().toString();
      logger.log(Level.INFO, "Encoding '-e': NOT FOUND OR RECOGNIZED; set to 'UTF-8'");
    }

    // Check output format
    OutputType outputType = null;
    if (CLISwitch.OUTPUTTYPE.getIsActive()) {
      outputType = OutputType.valueOf(CLISwitch.OUTPUTTYPE.getValue().toString().toUpperCase());
      logger.log(Level.INFO, "Output '-o': " + outputType.toString().toUpperCase());
    } else {
      // Output type not found
      outputType = (OutputType) CLISwitch.OUTPUTTYPE.getValue();
      logger.log(
          Level.INFO,
          "Output '-o': NOT FOUND OR RECOGNIZED; set to " + outputType.toString().toUpperCase());
    }

    // Check language
    Language language = null;
    if (CLISwitch.LANGUAGE.getIsActive()) {
      language = Language.getLanguageFromString((String) CLISwitch.LANGUAGE.getValue());

      if (language == Language.WILDCARD
          && !ResourceScanner.getInstance()
              .getDetectedResourceFolders()
              .contains(language.getName())) {
        logger.log(
            Level.SEVERE,
            "Language '-l': " + CLISwitch.LANGUAGE.getValue() + " NOT RECOGNIZED; aborting.");
        printHelp();
        System.exit(-1);
      } else {
        logger.log(Level.INFO, "Language '-l': " + language.getName());
      }
    } else {
      // Language not found
      language = Language.getLanguageFromString((String) CLISwitch.LANGUAGE.getValue());
      logger.log(
          Level.INFO, "Language '-l': NOT FOUND; set to " + language.toString().toUpperCase());
    }

    // Check type
    DocumentType type = null;
    if (CLISwitch.DOCTYPE.getIsActive()) {
      try {
        if (CLISwitch.DOCTYPE
            .getValue()
            .equals("narrative")) { // redirect "narrative" to "narratives"
          CLISwitch.DOCTYPE.setValue("narratives");
        }
        type = DocumentType.valueOf(CLISwitch.DOCTYPE.getValue().toString().toUpperCase());
      } catch (IllegalArgumentException e) {
        logger.log(
            Level.WARNING,
            "Type '-t': NOT RECOGNIZED. These are the available options: "
                + Arrays.asList(DocumentType.values()));
        System.exit(-1);
      }
      logger.log(Level.INFO, "Type '-t': " + type.toString().toUpperCase());
    } else {
      // Type not found
      type = (DocumentType) CLISwitch.DOCTYPE.getValue();
      logger.log(Level.INFO, "Type '-t': NOT FOUND; set to " + type.toString().toUpperCase());
    }

    // Check document creation time
    Date dct = null;
    if (CLISwitch.DCT.getIsActive()) {
      try {
        DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        dct = formatter.parse(CLISwitch.DCT.getValue().toString());
        logger.log(Level.INFO, "Document Creation Time '-dct': " + dct.toString());
      } catch (Exception e) {
        // DCT was not parseable
        logger.log(Level.WARNING, "Document Creation Time '-dct': NOT RECOGNIZED. Quitting.");
        printHelp();
        System.exit(-1);
      }
    } else {
      if ((type == DocumentType.NEWS) || (type == DocumentType.COLLOQUIAL)) {
        // Dct needed
        dct = (Date) CLISwitch.DCT.getValue();
        logger.log(
            Level.INFO,
            "Document Creation Time '-dct': NOT FOUND; set to local date ("
                + dct.toString()
                + ").");
      } else {
        logger.log(Level.INFO, "Document Creation Time '-dct': NOT FOUND; skipping.");
      }
    }

    // Handle locale switch
    String locale = (String) CLISwitch.LOCALE.getValue();
    Locale myLocale = null;
    if (CLISwitch.LOCALE.getIsActive()) {
      // check if the requested locale is available
      for (Locale l : Locale.getAvailableLocales()) {
        if (l.toString().toLowerCase().equals(locale.toLowerCase())) myLocale = l;
      }

      try {
        Locale.setDefault(myLocale); // try to set the locale
        logger.log(Level.INFO, "Locale '-locale': " + myLocale.toString());
      } catch (Exception e) { // if the above fails, spit out error message and available locales
        logger.log(
            Level.WARNING,
            "Supplied locale parameter couldn't be resolved to a working locale. Try one of these:");
        logger.log(
            Level.WARNING,
            Arrays.asList(Locale.getAvailableLocales()).toString()); // list available locales
        printHelp();
        System.exit(-1);
      }
    } else {
      // no -locale parameter supplied: just show default locale
      logger.log(
          Level.INFO,
          "Locale '-locale': NOT FOUND, set to environment locale: "
              + Locale.getDefault().toString());
    }

    // Read configuration from file
    String configPath = CLISwitch.CONFIGFILE.getValue().toString();
    try {
      logger.log(Level.INFO, "Configuration path '-c': " + configPath);

      readConfigFile(configPath);

      logger.log(Level.FINE, "Config initialized");
    } catch (Exception e) {
      e.printStackTrace();
      logger.log(
          Level.WARNING,
          "Config could not be initialized! Please supply the -c switch or "
              + "put a config.props into this directory.");
      printHelp();
      System.exit(-1);
    }

    // Set the preprocessing POS tagger
    POSTagger posTagger = null;
    if (CLISwitch.POSTAGGER.getIsActive()) {
      try {
        posTagger = POSTagger.valueOf(CLISwitch.POSTAGGER.getValue().toString().toUpperCase());
      } catch (IllegalArgumentException e) {
        logger.log(
            Level.WARNING,
            "Given POS Tagger doesn't exist. Please specify a valid one as listed in the help.");
        printHelp();
        System.exit(-1);
      }
      logger.log(Level.INFO, "POS Tagger '-pos': " + posTagger.toString().toUpperCase());
    } else {
      // Type not found
      posTagger = (POSTagger) CLISwitch.POSTAGGER.getValue();
      logger.log(
          Level.INFO,
          "POS Tagger '-pos': NOT FOUND OR RECOGNIZED; set to "
              + posTagger.toString().toUpperCase());
    }

    // Set whether or not to use the Interval Tagger
    Boolean doIntervalTagging = false;
    if (CLISwitch.INTERVALS.getIsActive()) {
      doIntervalTagging = CLISwitch.INTERVALS.getIsActive();
      logger.log(Level.INFO, "Interval Tagger '-it': " + doIntervalTagging.toString());
    } else {
      logger.log(
          Level.INFO,
          "Interval Tagger '-it': NOT FOUND OR RECOGNIZED; set to " + doIntervalTagging.toString());
    }

    // make sure we have a document path
    if (docPath == null) {
      logger.log(Level.WARNING, "No input file given; aborting.");
      printHelp();
      System.exit(-1);
    }

    // Run HeidelTime
    RandomAccessFile aFile = null;
    MappedByteBuffer buffer = null;
    FileChannel inChannel = null;
    PrintWriter pwOut = null;
    try {
      logger.log(Level.INFO, "Reading document using charset: " + encodingType);

      aFile = new RandomAccessFile(docPath, "r");
      inChannel = aFile.getChannel();
      buffer = inChannel.map(FileChannel.MapMode.READ_ONLY, 0, inChannel.size());
      buffer.load();
      byte[] inArr = new byte[(int) inChannel.size()];

      for (int i = 0; i < buffer.limit(); i++) {
        inArr[i] = buffer.get();
      }

      // double-newstring should not be necessary, but without this, it's not running on Windows (?)
      String input = new String(new String(inArr, encodingType).getBytes("UTF-8"), "UTF-8");

      HeidelTimeStandalone standalone =
          new HeidelTimeStandalone(language, type, outputType, null, posTagger, doIntervalTagging);
      String out = standalone.process(input, dct);

      // Print output always as UTF-8
      pwOut = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8"));
      pwOut.println(out);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (pwOut != null) {
        pwOut.close();
      }
      if (buffer != null) {
        buffer.clear();
      }
      if (inChannel != null) {
        try {
          inChannel.close();
        } catch (IOException e) {
        }
      }
      if (aFile != null) {
        try {
          aFile.close();
        } catch (IOException e) {
        }
      }
    }
  }
Example #11
0
  public static void main(String... args) throws IOException {

    HashMap<Option, String> options = new HashMap<Option, String>();
    LinkedList<String> others = new LinkedList<String>();

    for (Option option : Option.values())
      if (option.defaultValue != null) options.put(option, option.defaultValue);

    if (args != null && args.length > 0) {
      Pattern valueGetter = Pattern.compile("^--\\w[\\w-]*\\w?(?:=(?:\"([^\"]*)\"|([^\\s]*)))$");

      for (int i = 0; i < args.length; i++) {

        if (args[i].matches("^--\\w[\\w-]*\\w?(=(\"[^\"]*\"|[^\\s]*))?$")) {
          boolean found = false;
          for (Option option : Option.values()) {
            if (args[i].startsWith("--" + option.fullopts + "=")) {
              Matcher m = valueGetter.matcher(args[i]);

              if (m.matches()) {
                options.put(option, m.group(1) == null ? m.group(2) : m.group(1));
              }

              found = true;
              break;
            }
          }

          if (!found) {
            System.err.printf("unknown option: %s%n", args[i].substring(0, args[i].indexOf('=')));
            System.exit(1);
          }
        } else if (args[i].matches("^-\\w$")) {
          boolean found = false;

          for (Option option : Option.values()) {
            if (args[i].equals("-" + option.shortopts)) {
              options.put(option, args[++i]);
              break;
            }
          }

          if (!found) {
            System.err.printf("unknown option: %s%n", args[i]);
            System.exit(1);
          }
        } else {
          others.addLast(args[i]);
        }
      }
    } else {
      usage();
      System.exit(0);
    }

    LinkedList<String> errors = new LinkedList<String>();

    if (others.size() == 0) {
      errors.add("dgs file name missing.");
    }

    String imagePrefix;
    OutputType outputType = null;
    OutputPolicy outputPolicy = null;
    Resolution resolution = null;
    Quality quality = null;
    String logo;
    String stylesheet;

    imagePrefix = options.get(Option.IMAGE_PREFIX);

    try {
      outputType = OutputType.valueOf(options.get(Option.IMAGE_TYPE));
    } catch (IllegalArgumentException e) {
      errors.add("bad image type: " + options.get(Option.IMAGE_TYPE));
    }

    try {
      outputPolicy = OutputPolicy.valueOf(options.get(Option.OUTPUT_POLICY));
    } catch (IllegalArgumentException e) {
      errors.add("bad output policy: " + options.get(Option.OUTPUT_POLICY));
    }

    try {
      quality = Quality.valueOf(options.get(Option.QUALITY));
    } catch (IllegalArgumentException e) {
      errors.add("bad quality: " + options.get(Option.QUALITY));
    }

    logo = options.get(Option.LOGO);
    stylesheet = options.get(Option.STYLESHEET);

    try {
      resolution = Resolutions.valueOf(options.get(Option.IMAGE_RESOLUTION));
    } catch (IllegalArgumentException e) {
      Pattern p = Pattern.compile("^\\s*(\\d+)\\s*x\\s*(\\d+)\\s*$");
      Matcher m = p.matcher(options.get(Option.IMAGE_RESOLUTION));

      if (m.matches()) {
        resolution =
            new CustomResolution(Integer.parseInt(m.group(1)), Integer.parseInt(m.group(2)));
      } else {
        errors.add("bad resolution: " + options.get(Option.IMAGE_RESOLUTION));
      }
    }

    if (stylesheet != null && stylesheet.length() < 1024) {
      File test = new File(stylesheet);

      if (test.exists()) {
        FileReader in = new FileReader(test);
        char[] buffer = new char[128];
        String content = "";

        while (in.ready()) {
          int c = in.read(buffer, 0, 128);
          content += new String(buffer, 0, c);
        }

        stylesheet = content;
        in.close();
      }
    }

    {
      File test = new File(others.peek());
      if (!test.exists()) errors.add(String.format("file \"%s\" does not exist", others.peek()));
    }

    if (errors.size() > 0) {
      System.err.printf("error:%n");

      for (String error : errors) System.err.printf("- %s%n", error);

      System.exit(1);
    }

    FileSourceDGS dgs = new FileSourceDGS();
    FileSinkImages fsi = new FileSinkImages(imagePrefix, outputType, resolution, outputPolicy);

    dgs.addSink(fsi);

    if (logo != null) fsi.addLogo(logo, 0, 0);

    fsi.setQuality(quality);
    if (stylesheet != null) fsi.setStyleSheet(stylesheet);

    boolean next = true;

    dgs.begin(others.get(0));

    while (next) next = dgs.nextStep();

    dgs.end();
  }
Example #12
0
  public static enum Option {
    IMAGE_PREFIX("image-prefix", 'p', "prefix of outputted images", true, true, "image_"),
    IMAGE_TYPE(
        "image-type",
        't',
        "image type. one of " + Arrays.toString(OutputType.values()),
        true,
        true,
        "PNG"),
    IMAGE_RESOLUTION(
        "image-resolution",
        'r',
        "defines images resolution. \"width x height\" or one of "
            + Arrays.toString(Resolutions.values()),
        true,
        true,
        "HD720"),
    OUTPUT_POLICY(
        "output-policy",
        'e',
        "defines when images are outputted. one of " + Arrays.toString(OutputPolicy.values()),
        true,
        true,
        "ByStepOutput"),
    LOGO("logo", 'l', "add a logo to images", true, true, null),
    STYLESHEET(
        "stylesheet",
        's',
        "defines stylesheet of graph. can be a file or a string.",
        true,
        true,
        null),
    QUALITY(
        "quality",
        'q',
        "defines quality of rendering. one of " + Arrays.toString(Quality.values()),
        true,
        true,
        "HIGH");
    String fullopts;
    char shortopts;
    String description;
    boolean optional;
    boolean valuable;
    String defaultValue;

    Option(
        String fullopts,
        char shortopts,
        String description,
        boolean optional,
        boolean valuable,
        String defaultValue) {
      this.fullopts = fullopts;
      this.shortopts = shortopts;
      this.description = description;
      this.optional = optional;
      this.valuable = valuable;
      this.defaultValue = defaultValue;
    }
  }
Example #13
0
 public void process(String arg) throws Exception {
   if (arg.equals("-?") || arg.equals("--help")) {
     pipeMode = false;
     usage();
   } else if (arg.equals("-V") || arg.equals("--version")) {
     pipeMode = false;
     version();
   } else if (arg.equals("-v") || arg.equals("--verbose")) {
     //            Logger.getRootLogger().setLevel(Level.DEBUG);
   } else if (arg.equals("-g") || arg.equals("--gui")) {
     pipeMode = false;
     TikaGUI.main(new String[0]);
   } else if (arg.equals("--list-parser") || arg.equals("--list-parsers")) {
     pipeMode = false;
     displayParsers(false);
   } else if (arg.equals("--list-detector") || arg.equals("--list-detectors")) {
     pipeMode = false;
     displayDetectors();
   } else if (arg.equals("--list-parser-detail") || arg.equals("--list-parser-details")) {
     pipeMode = false;
     displayParsers(true);
   } else if (arg.equals("--list-met-models")) {
     pipeMode = false;
     displayMetModels();
   } else if (arg.equals("--list-supported-types")) {
     pipeMode = false;
     displaySupportedTypes();
   } else if (arg.equals("--container-aware") || arg.equals("--container-aware-detector")) {
     // ignore, as container-aware detectors are now always used
   } else if (arg.equals("-f") || arg.equals("--fork")) {
     fork = true;
   } else if (arg.startsWith("-e")) {
     encoding = arg.substring("-e".length());
   } else if (arg.startsWith("--encoding=")) {
     encoding = arg.substring("--encoding=".length());
   } else if (arg.startsWith("-p") && !arg.equals("-p")) {
     password = arg.substring("-p".length());
   } else if (arg.startsWith("--password="******"--password="******"-j") || arg.equals("--json")) {
     type = JSON;
   } else if (arg.equals("-y") || arg.equals("--xmp")) {
     type = XMP;
   } else if (arg.equals("-x") || arg.equals("--xml")) {
     type = XML;
   } else if (arg.equals("-h") || arg.equals("--html")) {
     type = HTML;
   } else if (arg.equals("-t") || arg.equals("--text")) {
     type = TEXT;
   } else if (arg.equals("-T") || arg.equals("--text-main")) {
     type = TEXT_MAIN;
   } else if (arg.equals("-m") || arg.equals("--metadata")) {
     type = METADATA;
   } else if (arg.equals("-l") || arg.equals("--language")) {
     type = LANGUAGE;
   } else if (arg.equals("-d") || arg.equals("--detect")) {
     type = DETECT;
   } else if (arg.startsWith("--extract-dir=")) {
     extractDir = new File(arg.substring("--extract-dir=".length()));
   } else if (arg.equals("-z") || arg.equals("--extract")) {
     type = NO_OUTPUT;
     context.set(EmbeddedDocumentExtractor.class, new FileEmbeddedDocumentExtractor());
   } else if (arg.equals("-r") || arg.equals("--pretty-print")) {
     prettyPrint = true;
   } else if (arg.equals("-p")
       || arg.equals("--port")
       || arg.equals("-s")
       || arg.equals("--server")) {
     serverMode = true;
     pipeMode = false;
   } else if (arg.startsWith("-c")) {
     URI uri = new URI(arg.substring("-c".length()));
     parser = new NetworkParser(uri);
   } else if (arg.startsWith("--client=")) {
     URI uri = new URI(arg.substring("--client=".length()));
     parser = new NetworkParser(uri);
   } else if (arg.startsWith("--create-profile=")) {
     profileName = arg.substring("--create-profile=".length());
     type = CREATE_PROFILE;
   } else {
     pipeMode = false;
     if (serverMode) {
       new TikaServer(Integer.parseInt(arg)).start();
     } else if (arg.equals("-")) {
       InputStream stream = TikaInputStream.get(new CloseShieldInputStream(System.in));
       try {
         type.process(stream, System.out, new Metadata());
       } finally {
         stream.close();
       }
     } else {
       URL url;
       File file = new File(arg);
       if (file.isFile()) {
         url = file.toURI().toURL();
       } else {
         url = new URL(arg);
       }
       Metadata metadata = new Metadata();
       InputStream input = TikaInputStream.get(url, metadata);
       try {
         type.process(input, System.out, metadata);
       } finally {
         input.close();
         System.out.flush();
       }
     }
   }
 }
Example #14
0
 public void setParserEvaluationTypes(final String string) throws EvalError, CorpusError {
   if (string.equals("")) {
     evalTypes.add(OutputType.CLUMP);
     evalTypes.add(OutputType.NPS);
   } else for (final String s : string.split(",")) evalTypes.add(OutputType.valueOf(s));
 }