Esempio n. 1
1
  public void test13666() {
    Options options = new Options();
    Option dir = OptionBuilder.withDescription("dir").hasArg().create('d');
    options.addOption(dir);

    final PrintStream oldSystemOut = System.out;
    try {
      final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
      final PrintStream print = new PrintStream(bytes);

      // capture this platform's eol symbol
      print.println();
      final String eol = bytes.toString();
      bytes.reset();

      System.setOut(new PrintStream(bytes));
      try {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("dir", options);
      } catch (Exception exp) {
        fail("Unexpected Exception: " + exp.getMessage());
      }
      assertEquals("usage: dir" + eol + " -d <arg>   dir" + eol, bytes.toString());
    } finally {
      System.setOut(oldSystemOut);
    }
  }
 /** Print classes that were parts of relationships, but not parsed by javadoc */
 public void printExtraClasses(RootDoc root) {
   Set<String> names = new HashSet<String>(classnames.keySet());
   for (String className : names) {
     ClassInfo info = getClassInfo(className);
     if (!info.nodePrinted) {
       ClassDoc c = root.classNamed(className);
       if (c != null) {
         printClass(c, false);
       } else {
         Options opt = optionProvider.getOptionsFor(className);
         if (opt.matchesHideExpression(className)) continue;
         w.println("\t// " + className);
         w.print("\t" + info.name + "[label=");
         externalTableStart(opt, className, classToUrl(className));
         innerTableStart();
         int idx = className.lastIndexOf(".");
         if (opt.postfixPackage && idx > 0 && idx < (className.length() - 1)) {
           String packageName = className.substring(0, idx);
           String cn = className.substring(idx + 1);
           tableLine(Align.CENTER, escape(cn), opt, Font.CLASS);
           tableLine(Align.CENTER, packageName, opt, Font.PACKAGE);
         } else {
           tableLine(Align.CENTER, escape(className), opt, Font.CLASS);
         }
         innerTableEnd();
         externalTableEnd();
         if (className == null || className.length() == 0)
           w.print(", URL=\"" + classToUrl(className) + "\"");
         nodeProperties(opt);
       }
     }
   }
 }
 @Override
 public Options getOptions(AnnotatedPluginDocument... documents)
     throws DocumentOperationException {
   Options options = new Options(this.getClass());
   options.addStringOption("query", "query", "PROJECT_NAME = \"BARCODE\"");
   return options;
 }
Esempio n. 4
0
  public void run(String[] args)
      throws ParseException, TransformationException, IOException, AnalysisException {
    Options options = new Options();
    options.addOption("input", true, "input path");
    options.addOption("output", true, "output path");
    options.addOption("ext", true, "extension");
    CommandLineParser parser = new DefaultParser();
    CommandLine line = parser.parse(options, args);
    String inDir = line.getOptionValue("input");
    String outDir = line.getOptionValue("output");
    String extension = line.getOptionValue("ext");

    File dir = new File(inDir);

    for (File f : FileUtils.listFiles(dir, new String[] {extension}, true)) {
      TrueVizToBxDocumentReader tvReader = new TrueVizToBxDocumentReader();
      List<BxPage> pages = tvReader.read(new FileReader(f));
      BxDocument doc = new BxDocument().setPages(pages);
      doc.setFilename(f.getName());

      BxDocument rewritten = transform(doc);

      File f2 = new File(outDir + doc.getFilename());
      BxDocumentToTrueVizWriter wrt = new BxDocumentToTrueVizWriter();
      boolean created = f2.createNewFile();
      if (!created) {
        throw new IOException("Cannot create file: ");
      }
      FileWriter fw = new FileWriter(f2);
      wrt.write(fw, Lists.newArrayList(rewritten));
      fw.flush();
      fw.close();
    }
  }
Esempio n. 5
0
  public void test11456() {
    // Posix
    Options options = new Options();
    options.addOption(OptionBuilder.hasOptionalArg().create('a'));
    options.addOption(OptionBuilder.hasArg().create('b'));
    String[] args = new String[] {"-a", "-bvalue"};

    CommandLineParser parser = new PosixParser();

    try {
      CommandLine cmd = parser.parse(options, args);
      assertEquals(cmd.getOptionValue('b'), "value");
    } catch (ParseException exp) {
      fail("Unexpected Exception: " + exp.getMessage());
    }

    // GNU
    options = new Options();
    options.addOption(OptionBuilder.hasOptionalArg().create('a'));
    options.addOption(OptionBuilder.hasArg().create('b'));
    args = new String[] {"-a", "-b", "value"};

    parser = new GnuParser();

    try {
      CommandLine cmd = parser.parse(options, args);
      assertEquals(cmd.getOptionValue('b'), "value");
    } catch (ParseException exp) {
      fail("Unexpected Exception: " + exp.getMessage());
    }
  }
 /**
  * Create a "Compiler" object based on some init param data. This is not done yet. Right now we're
  * just hardcoding the actual compilers that are created.
  */
 public Compiler createCompiler() {
   if (jspCompiler != null) {
     return jspCompiler;
   }
   jspCompiler = null;
   if (options.getCompilerClassName() != null) {
     jspCompiler = createCompiler(options.getCompilerClassName());
   } else {
     if (options.getCompiler() == null) {
       jspCompiler = createCompiler("org.apache.jasper.compiler.JDTCompiler");
       if (jspCompiler == null) {
         jspCompiler = createCompiler("org.apache.jasper.compiler.AntCompiler");
       }
     } else {
       jspCompiler = createCompiler("org.apache.jasper.compiler.AntCompiler");
       if (jspCompiler == null) {
         jspCompiler = createCompiler("org.apache.jasper.compiler.JDTCompiler");
       }
     }
   }
   if (jspCompiler == null) {
     throw new IllegalStateException(Localizer.getMessage("jsp.error.compiler"));
   }
   jspCompiler.init(this, jsw);
   return jspCompiler;
 }
Esempio n. 7
0
  /**
   * Parse the arguments according to the specified options and properties.
   *
   * @param options the specified Options
   * @param arguments the command line arguments
   * @param properties command line option name-value pairs
   * @param stopAtNonOption if <tt>true</tt> an unrecognized argument stops the parsing and the
   *     remaining arguments are added to the {@link CommandLine}s args list. If <tt>false</tt> an
   *     unrecognized argument triggers a ParseException.
   * @return the list of atomic option and value tokens
   * @throws ParseException if there are any problems encountered while parsing the command line
   *     tokens.
   */
  public CommandLine parse(
      Options options, String[] arguments, Properties properties, boolean stopAtNonOption)
      throws ParseException {
    this.options = options;
    this.stopAtNonOption = stopAtNonOption;
    skipParsing = false;
    currentOption = null;
    expectedOpts = new ArrayList(options.getRequiredOptions());

    // clear the data from the groups
    for (OptionGroup group : options.getOptionGroups()) {
      group.setSelected(null);
    }

    cmd = new CommandLine();

    if (arguments != null) {
      for (String argument : arguments) {
        handleToken(argument);
      }
    }

    // check the arguments of the last option
    checkRequiredArgs();

    // add the default options
    handleProperties(properties);

    checkRequiredOptions();

    return cmd;
  }
  public void setImage(BufferedImage image, String format) {
    ImageDocument document = imageComponent.getDocument();
    BufferedImage previousImage = document.getValue();
    document.setValue(image);
    if (image == null) return;
    document.setFormat(format);
    ImageZoomModel zoomModel = getZoomModel();
    if (previousImage == null || !zoomModel.isZoomLevelChanged()) {
      // Set smart zooming behaviour on open
      Options options = OptionsManager.getInstance().getOptions();
      ZoomOptions zoomOptions = options.getEditorOptions().getZoomOptions();
      // Open as actual size
      zoomModel.setZoomFactor(1.0d);

      if (zoomOptions.isSmartZooming()) {
        Dimension prefferedSize = zoomOptions.getPrefferedSize();
        if (prefferedSize.width > image.getWidth() && prefferedSize.height > image.getHeight()) {
          // Resize to preffered size
          // Calculate zoom factor

          double factor =
              (prefferedSize.getWidth() / (double) image.getWidth()
                      + prefferedSize.getHeight() / (double) image.getHeight())
                  / 2.0d;
          zoomModel.setZoomFactor(Math.ceil(factor));
        }
      }
    }
  }
Esempio n. 9
0
 private static void setLastVersion(String version) {
   Options.setString(Options.OPTION_LAST_VERSION, version);
   if (hasNewVersion()) {
     Options.setInt(Options.OPTION_UPDATE_CHECK_TIME, 0);
   }
   Options.safeSave();
 }
Esempio n. 10
0
File: Main.java Progetto: Hdzi/emacs
  private void script(Options options) {
    if (options.getRestArgs().isEmpty()) {
      runScript(in, options, false);
    } else {
      try {
        for (String filename : options.getRestArgs()) {
          File file;
          if (currentDir == null || !(file = new File(currentDir, filename)).exists()) {
            // Load from current directory if possible
            file = new File(filename);
          }

          File oldCurrentDir = currentDir;
          currentDir = file.getParentFile();
          InputStream in = new FileInputStream(file);
          try {
            runScript(in, options, true);
          } finally {
            in.close();
            currentDir = oldCurrentDir;
          }
        }
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
  }
Esempio n. 11
0
File: Main.java Progetto: Hdzi/emacs
 private void test(Options options, Collection<String> data) {
   if (options.isShouldBeGiven()) {
     Set<String> shouldBe = options.getShouldBe();
     if (shouldBe.equals(data)) {
       testSuccess(options);
     } else {
       String expected = shouldBe.isEmpty() ? "empty" : shouldBe.toString();
       testFailure(options, "%s should be %s", data, expected);
     }
   } else {
     Set<String> shouldContain = options.getShouldContain();
     Set<String> shouldNotContain = options.getShouldNotContain();
     for (String str : shouldContain) {
       if (!data.contains(str)) {
         testFailure(options, "%s should be in %s", str, shouldContain);
         return;
       }
     }
     for (String str : shouldNotContain) {
       if (data.contains(str)) {
         testFailure(options, "%s should not be in %s", str, shouldNotContain);
         return;
       }
     }
     testSuccess(options);
   }
 }
Esempio n. 12
0
File: Main.java Progetto: Hdzi/emacs
  public void run(String[] args) throws Exception {
    in = System.in;
    out = System.out;
    inReader = new InputStreamReader(in);

    properties = new Properties();
    properties.load(this.getClass().getResourceAsStream("rsense.properties"));

    if (args.length == 0 || args[0].equals("help")) {
      usage();
      return;
    } else if (args[0].equals("version")) {
      version();
      return;
    }

    String command = args[0];
    Options options = parseOptions(args, 1);

    Logger.getInstance().setLevel(options.getLogLevel());
    init(options);
    if (options.getLog() != null) {
      PrintStream log = new PrintStream(new FileOutputStream(options.getLog(), true));
      try {
        Logger.getInstance().setOut(log);
        start(command, options);
      } finally {
        log.close();
      }
    } else {
      start(command, options);
    }
    testResult(options);
  }
  /**
   * Starts the code server with the given command line options. To shut it down, see {@link
   * WebServer#stop}.
   *
   * <p>Only one code server should be started at a time because the GWT compiler uses a lot of
   * static variables.
   */
  public static WebServer start(Options options) throws IOException, UnableToCompleteException {
    if (options.getModuleNames().isEmpty()) {
      throw new IllegalArgumentException("Usage: at least one module must be supplied");
    }

    PrintWriterTreeLogger logger = new PrintWriterTreeLogger();
    logger.setMaxDetail(TreeLogger.Type.INFO);
    Modules modules = new Modules();

    File workDir = ensureWorkDir(options);
    System.out.println("workDir: " + workDir);

    for (String moduleName : options.getModuleNames()) {
      AppSpace appSpace = AppSpace.create(new File(workDir, moduleName));

      Recompiler recompiler = new Recompiler(appSpace, moduleName, options.getSourcePath(), logger);
      modules.addModuleState(new ModuleState(recompiler, logger));
    }

    SourceHandler sourceHandler = new SourceHandler(modules, logger);

    WebServer webServer =
        new WebServer(sourceHandler, modules, options.getBindAddress(), options.getPort(), logger);
    webServer.start();

    return webServer;
  }
Esempio n. 14
0
    public static Options parseArgs(String cmdArgs[]) {
      CommandLineParser parser = new GnuParser();
      CmdLineOptions options = getCmdLineOptions();
      try {
        CommandLine cmd = parser.parse(options, cmdArgs, false);

        if (cmd.hasOption(HELP_OPTION)) {
          printUsage(options);
          System.exit(0);
        }

        String[] args = cmd.getArgs();
        if (args.length >= 4 || args.length < 2) {
          String msg = args.length < 2 ? "Missing arguments" : "Too many arguments";
          errorMsg(msg, options);
          System.exit(1);
        }

        String keyspace = args[0];
        String cf = args[1];
        String snapshot = null;
        if (args.length == 3) snapshot = args[2];

        Options opts = new Options(keyspace, cf, snapshot);

        opts.debug = cmd.hasOption(DEBUG_OPTION);
        opts.keepSource = cmd.hasOption(KEEP_SOURCE);

        return opts;
      } catch (ParseException e) {
        errorMsg(e.getMessage(), options);
        return null;
      }
    }
 private void initCharacters() {
   opponentCharacter = Art.HERR_VON_SPECK;
   if (!Options.isCharacterIDset()) {
     addMenu(new CharacterSelectionMenu());
   }
   playerCharacter = Options.getCharacterID();
 }
Esempio n. 16
0
 public Manager(URI uri, Options opts) {
   if (opts == null) {
     opts = new Options();
   }
   if (opts.path == null) {
     opts.path = "/socket.io";
   }
   if (opts.sslContext == null) {
     opts.sslContext = defaultSSLContext;
   }
   if (opts.hostnameVerifier == null) {
     opts.hostnameVerifier = defaultHostnameVerifier;
   }
   this.opts = opts;
   this.nsps = new ConcurrentHashMap<String, Socket>();
   this.subs = new LinkedList<On.Handle>();
   this.reconnection(opts.reconnection);
   this.reconnectionAttempts(
       opts.reconnectionAttempts != 0 ? opts.reconnectionAttempts : Integer.MAX_VALUE);
   this.reconnectionDelay(opts.reconnectionDelay != 0 ? opts.reconnectionDelay : 1000);
   this.reconnectionDelayMax(opts.reconnectionDelayMax != 0 ? opts.reconnectionDelayMax : 5000);
   this.randomizationFactor(opts.randomizationFactor != 0.0 ? opts.randomizationFactor : 0.5);
   this.backoff =
       new Backoff()
           .setMin(this.reconnectionDelay())
           .setMax(this.reconnectionDelayMax())
           .setJitter(this.randomizationFactor());
   this.timeout(opts.timeout);
   this.readyState = ReadyState.CLOSED;
   this.uri = uri;
   this.encoding = false;
   this.packetBuffer = new ArrayList<Packet>();
   this.encoder = new Parser.Encoder();
   this.decoder = new Parser.Decoder();
 }
Esempio n. 17
0
  private static boolean setOptions(String[] lcommand) {

    Options loptions = new Options();
    loptions.addOption(new Option("d", "debug", false, "print debug information (highly verbose)"));
    loptions.addOption(new Option("o", "stdout", false, "print output files to standard output"));
    loptions.addOption(new Option("w", "warning", false, "print warning messages"));

    CommandLineParser clparser = new PosixParser();
    try {
      cmd = clparser.parse(loptions, lcommand);
    } catch (org.apache.commons.cli.ParseException e) {
      String mytoolcmd = "java -jar stave.jar";
      String myoptlist = " <options> <source files>";
      String myheader = "Convert JavaParser's AST to OpenJDK's AST";
      String myfooter = "More info: https://github.com/pcgomes/javaparser2jctree";

      HelpFormatter formatter = new HelpFormatter();
      // formatter.printUsage( new PrintWriter(System.out,true), 100, "java -jar synctask.jar",
      // loptions );
      // formatter.printHelp( mytoolcmd + myoptlist, myheader, loptions, myfooter, false);
      formatter.printHelp(mytoolcmd + myoptlist, loptions, false);
      return (false);
    }

    return (true);
  }
  /** Creates the notification. */
  @SuppressLint("NewApi")
  private Builder buildNotification() {
    Bitmap icon = BitmapFactory.decodeResource(context.getResources(), options.getIcon());
    Uri sound = options.getSound();

    Builder notification =
        new Notification.Builder(context)
            .setContentTitle(options.getTitle())
            .setContentText(options.getMessage())
            .setNumber(options.getBadge())
            .setTicker(options.getMessage())
            .setSmallIcon(options.getSmallIcon())
            .setLargeIcon(icon)
            .setAutoCancel(options.getAutoCancel())
            .setOngoing(options.getOngoing());

    if (sound != null) {
      notification.setSound(sound);
    }

    if (Build.VERSION.SDK_INT > 16) {
      notification.setStyle(new Notification.BigTextStyle().bigText(options.getMessage()));
    }

    setClickEvent(notification);

    return notification;
  }
 public void compile() throws JasperException, FileNotFoundException {
   createCompiler();
   if (jspCompiler.isOutDated()) {
     if (isRemoved()) {
       throw new FileNotFoundException(jspUri);
     }
     try {
       jspCompiler.removeGeneratedFiles();
       jspLoader = null;
       jspCompiler.compile();
       jsw.setReload(true);
       jsw.setCompilationException(null);
     } catch (JasperException ex) {
       // Cache compilation exception
       jsw.setCompilationException(ex);
       if (options.getDevelopment() && options.getRecompileOnFail()) {
         // Force a recompilation attempt on next access
         jsw.setLastModificationTest(-1);
       }
       throw ex;
     } catch (FileNotFoundException fnfe) {
       // Re-throw to let caller handle this - will result in a 404
       throw fnfe;
     } catch (Exception ex) {
       JasperException je =
           new JasperException(Localizer.getMessage("jsp.error.unable.compile"), ex);
       // Cache compilation exception
       jsw.setCompilationException(je);
       throw je;
     }
   }
 }
  @Override
  public void onReceive(Context context, Intent intent) {
    Options options = null;
    Bundle bundle = intent.getExtras();
    JSONObject args;

    try {
      args = new JSONObject(bundle.getString(OPTIONS));
      options = new Options(context).parse(args);
    } catch (JSONException e) {
      return;
    }

    this.context = context;
    this.options = options;

    // The context may got lost if the app was not running before
    LocalNotification.setContext(context);

    fireTriggerEvent();

    if (options.getInterval() == 0) {
      LocalNotification.unpersist(options.getId());
    } else if (isFirstAlarmInFuture()) {
      return;
    } else {
      LocalNotification.add(options.moveDate(), false);
    }

    Builder notification = buildNotification();

    showNotification(notification);
  }
  private CharSequence iterableContext(Iterable<?> context, Options options) throws IOException {
    if (options.isFalsy(context)) {
      return options.inverse();
    }

    StringBuilder buffer = new StringBuilder();

    Iterator<?> iterator = reverse(context);
    int index = 0;
    Context parent = options.context;
    while (iterator.hasNext()) {
      Object element = iterator.next();

      boolean first = index == 0;
      boolean even = index % 2 == 0;
      boolean last = !iterator.hasNext();

      Context current =
          Context.newContext(parent, element)
              .data("index", index)
              .data("first", first ? "first" : "")
              .data("last", last ? "last" : "")
              .data("odd", even ? "" : "odd")
              .data("even", even ? "even" : "");
      buffer.append(options.fn(current));

      index++;
    }

    return buffer;
  }
Esempio n. 22
0
 // #sijapp cond.if modules_TOUCH is "true"#
 protected void stylusXMoved(TouchState state) {
   if (getWidth() / 2 < Math.abs(state.fromX - state.x)) {
     boolean isTrue = state.fromX < state.x;
     int currentModel = 0;
     if (Options.getBoolean(Options.OPTION_CL_HIDE_OFFLINE)) currentModel = 1;
     if (((RosterContent) content).getModel() == getUpdater().getChatModel()) currentModel = 2;
     currentModel = (currentModel + 3 + (isTrue ? -1 : +1)) % 3;
     switch (currentModel) {
       case 0:
         Options.setBoolean(Options.OPTION_CL_HIDE_OFFLINE, false);
         updateOfflineStatus();
         Options.safeSave();
         break;
       case 1:
         Options.setBoolean(Options.OPTION_CL_HIDE_OFFLINE, true);
         updateOfflineStatus();
         Options.safeSave();
         break;
       case 2:
         ((RosterContent) content).setModel(getUpdater().getChatModel());
         break;
     }
     updateTitle();
     Jimm.getJimm().getCL().activate();
   }
 }
Esempio n. 23
0
  public void test13425() {
    Options options = new Options();
    Option oldpass =
        OptionBuilder.withLongOpt("old-password")
            .withDescription("Use this option to specify the old password")
            .hasArg()
            .create('o');
    Option newpass =
        OptionBuilder.withLongOpt("new-password")
            .withDescription("Use this option to specify the new password")
            .hasArg()
            .create('n');

    String[] args = {"-o", "-n", "newpassword"};

    options.addOption(oldpass);
    options.addOption(newpass);

    Parser parser = new PosixParser();

    try {
      CommandLine line = parser.parse(options, args);
    }
    // catch the exception and leave the method
    catch (Exception exp) {
      assertTrue(exp != null);
      return;
    }
    fail("MissingArgumentException not caught.");
  }
 @Test
 public void blockBasedTableWithoutFilter() {
   try (final Options options =
       new Options().setTableFormatConfig(new BlockBasedTableConfig().setFilter(null))) {
     assertThat(options.tableFactoryName()).isEqualTo("BlockBasedTable");
   }
 }
Esempio n. 25
0
  public static void main(String args[]) throws IOException, ParseException {
    Options options = new Options();
    options.addOption("u", "uniquehits", false, "only output hits with a single mapping");
    options.addOption(
        "s",
        "nosuboptimal",
        false,
        "do not include hits whose score is not equal to the best score for the read");
    CommandLineParser parser = new GnuParser();
    CommandLine cl = parser.parse(options, args, false);
    boolean uniqueOnly = cl.hasOption("uniquehits");
    boolean filterSubOpt = cl.hasOption("nosuboptimal");

    ArrayList<String[]> lines = new ArrayList<String[]>();

    String line;
    String lastRead = "";
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    while ((line = reader.readLine()) != null) {
      String pieces[] = line.split("\t");
      if (!pieces[0].equals(lastRead)) {
        printLines(lines, uniqueOnly, filterSubOpt);
        lines.clear();
      }
      lines.add(pieces);
      lastRead = pieces[0];
    }
    printLines(lines, uniqueOnly, filterSubOpt);
  }
Esempio n. 26
0
  /** Creates the notification with all its options passed through JS. */
  public Notification build() {
    Uri sound = options.getSoundUri();
    NotificationCompat.BigTextStyle style;
    NotificationCompat.Builder builder;

    style = new NotificationCompat.BigTextStyle().bigText(options.getText());

    builder =
        new NotificationCompat.Builder(context)
            .setDefaults(0)
            .setContentTitle(options.getTitle())
            .setContentText(options.getText())
            .setNumber(options.getBadgeNumber())
            .setTicker(options.getText())
            .setSmallIcon(options.getSmallIcon())
            .setLargeIcon(options.getIconBitmap())
            .setAutoCancel(true)
            .setOngoing(options.isOngoing())
            .setStyle(style)
            .setLights(options.getLedColor(), 500, 500);

    if (sound != null) {
      builder.setSound(sound);
    }

    applyDeleteReceiver(builder);
    applyContentReceiver(builder);

    return new Notification(context, options, builder, triggerReceiver);
  }
Esempio n. 27
0
 public Command parse(Options opt, String args) {
   Command cc = new Command();
   String[] tokens = args.split("\\s");
   for (int i = 0; i < tokens.length; i++) {
     // long option
     if (tokens[i].startsWith("--")) {
       String s = stripDash(tokens[i]);
       if (opt.hasLongOption(s)) {
         cc.addOption(opt.matchLongOption(s));
       }
     } else {
       // short option
       String s = stripDash(tokens[i]);
       int max = s.length();
       for (int j = 0; j < max; j++) {
         if (opt.hasShortOption(s)) {
           Option cmd = opt.matchShortOption(s);
           if (cmd.getValue() != null) {
             int op_len = cmd.getValue().length();
             s = s.substring(op_len);
             j = j + op_len;
           }
           cc.addOption(cmd);
         }
         s = s.substring(1);
       }
     }
   }
   return cc;
 }
Esempio n. 28
0
 @Override
 public void actionPerformed(ActionEvent e) {
   for (Options option : Options.values())
     if (e.getActionCommand().equals(option.getCaption())) this.option = option;
   for (Tool tool : Tool.values())
     if (e.getActionCommand().equals(tool.name())) {
       try {
         Method m = BusLaneAdderWindow.class.getMethod(tool.function, new Class[] {});
         m.invoke(this, new Object[] {});
       } catch (SecurityException e1) {
         e1.printStackTrace();
       } catch (NoSuchMethodException e1) {
         e1.printStackTrace();
       } catch (IllegalArgumentException e1) {
         e1.printStackTrace();
       } catch (IllegalAccessException e1) {
         e1.printStackTrace();
       } catch (InvocationTargetException e1) {
         e1.printStackTrace();
       }
       setVisible(true);
       repaint();
     }
   if (e.getActionCommand().equals(READY_TO_EXIT)) {
     setVisible(false);
     readyToExit = true;
   }
 }
Esempio n. 29
0
  @Override
  public org.apache.hadoop.hive.ql.exec.FileSinkOperator.RecordWriter getRawRecordWriter(
      Path path, Options options) throws IOException {
    final Path filename = AcidUtils.createFilename(path, options);
    final OrcFile.WriterOptions opts = OrcFile.writerOptions(options.getConfiguration());
    if (!options.isWritingBase()) {
      opts.bufferSize(OrcRecordUpdater.DELTA_BUFFER_SIZE)
          .stripeSize(OrcRecordUpdater.DELTA_STRIPE_SIZE)
          .blockPadding(false)
          .compress(CompressionKind.NONE)
          .rowIndexStride(0);
    }
    final OrcRecordUpdater.KeyIndexBuilder watcher = new OrcRecordUpdater.KeyIndexBuilder();
    opts.inspector(options.getInspector()).callback(watcher);
    final Writer writer = OrcFile.createWriter(filename, opts);
    return new org.apache.hadoop.hive.ql.exec.FileSinkOperator.RecordWriter() {
      @Override
      public void write(Writable w) throws IOException {
        OrcStruct orc = (OrcStruct) w;
        watcher.addKey(
            ((IntWritable) orc.getFieldValue(OrcRecordUpdater.OPERATION)).get(),
            ((LongWritable) orc.getFieldValue(OrcRecordUpdater.ORIGINAL_TRANSACTION)).get(),
            ((IntWritable) orc.getFieldValue(OrcRecordUpdater.BUCKET)).get(),
            ((LongWritable) orc.getFieldValue(OrcRecordUpdater.ROW_ID)).get());
        writer.addRow(w);
      }

      @Override
      public void close(boolean abort) throws IOException {
        writer.close();
      }
    };
  }
 public void resetOptionsTimeToLive(long timeToLive) {
   if (null == options) {
     options = Options.newBuilder().setTimeToLive(timeToLive).build();
   } else {
     options.setTimeToLive(timeToLive);
   }
 }