public void handle()

in api-reference-examples/java/te-tag-query/com/facebook/threatexchange/TETagQuery.java [295:372]


    public void handle(
      String[] args,
      int numIDsPerQuery,
      boolean verbose,
      boolean showURLs,
      DescriptorFormatter descriptorFormatter
    ) {
      int pageSize = 10;
      boolean includeIndicatorInOutput = true;
      String taggedSince = null;
      String taggedUntil = null;

      while (args.length > 0 && args[0].startsWith("-")) {
        String option = args[0];
        args = Arrays.copyOfRange(args, 1, args.length);

        if (option.equals("-h") || option.equals("--help")) {
          usage(0);

        } else if (option.equals("--tagged-since")) {
          if (args.length < 1) {
            usage(1);
          }
          taggedSince = args[0];
          args = Arrays.copyOfRange(args, 1, args.length);

        } else if (option.equals("--tagged-until")) {
          if (args.length < 1) {
            usage(1);
          }
          taggedUntil = args[0];
          args = Arrays.copyOfRange(args, 1, args.length);

        } else if (option.equals("--page-size")) {
          if (args.length < 1) {
            usage(1);
          }
          pageSize = Integer.valueOf(args[0]);
          args = Arrays.copyOfRange(args, 1, args.length);

        } else if (option.equals("--no-print-indicator")) {
          includeIndicatorInOutput = false;

        } else {
          System.err.printf("%s %s: unrecognized option \"%s\".\n",
            PROGNAME, _verb, option);
          usage(1);
        }
      }

      if (args.length != 1) {
        usage(1);
      }
      String tagName = args[0];

      String tagID = Net.getTagIDFromName(tagName, showURLs);
      if (tagID == null) {
        System.err.printf("%s: could not find tag by name \"%s\".\n",
          PROGNAME, tagName);
        System.exit(1);
      }

      if (verbose) {
        SimpleJSONWriter w = new SimpleJSONWriter();
        w.add("tag_name", tagName);
        w.add("tag_id", tagID);
        System.out.println(w.format());
        System.out.flush();
      }

      // Returns IDs for all descriptors. The return from this bulk-query call
      // gives back only ID code, indicator text, and the uninformative label
      // "THREAT_DESCRIPTOR". From this we can dive in on each item, though,
      // and query for its details one ID at a time.
      Net.getDescriptorIDsByTagID(tagID, verbose, showURLs,
        taggedSince, taggedUntil, pageSize, includeIndicatorInOutput,
        new IDPrinterProcessor(verbose));
    }