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();
 }
示例#2
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();
 }
  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;
  }
示例#4
0
 /** Converts the RRSIG/SIG Record to a String */
 public String rdataToString() {
   StringBuffer sb = new StringBuffer();
   if (signature != null) {
     sb.append(Type.string(covered));
     sb.append(" ");
     sb.append(alg);
     sb.append(" ");
     sb.append(labels);
     sb.append(" ");
     sb.append(origttl);
     sb.append(" ");
     if (Options.check("multiline")) sb.append("(\n\t");
     sb.append(FormattedTime.format(expire));
     sb.append(" ");
     sb.append(FormattedTime.format(timeSigned));
     sb.append(" ");
     sb.append(footprint);
     sb.append(" ");
     sb.append(signer);
     if (Options.check("multiline")) {
       sb.append("\n");
       sb.append(base64.formatString(signature, 64, "\t", true));
     } else {
       sb.append(" ");
       sb.append(base64.toString(signature));
     }
   }
   return sb.toString();
 }
    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;
      }
    }
示例#6
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);
  }
示例#7
0
文件: Notify.java 项目: fin-nick/fj
 public static void changeSoundMode(boolean showPopup) {
   boolean newValue = !Options.getBoolean(Options.OPTION_SILENT_MODE);
   if (showPopup) {
     PopupWindow.showShadowPopup(
         "Jimm", ResourceBundle.getString(newValue ? "#sound_is_off" : "#sound_is_on"));
   }
   getSound().vibrate(newValue ? 0 : 100);
   getSound().closePlayer();
   Options.setBoolean(Options.OPTION_SILENT_MODE, newValue);
   Options.safeSave();
 }
示例#8
0
 public static void checkUpdates() {
   if (Options.getBoolean(Options.OPTION_CHECK_UPDATES) && !hasNewVersion()) {
     final int today = (int) (System.currentTimeMillis() / (24L * 60 * 60 * 1000));
     final int nextCheck = Options.getInt(Options.OPTION_UPDATE_CHECK_TIME);
     if (nextCheck <= today) {
       new GetVersion(TYPE_DATE).get();
       final int nextDay = today + CHECK_UPDATES_INTERVAL;
       Options.setInt(Options.OPTION_UPDATE_CHECK_TIME, nextDay);
       Options.safeSave();
     }
   }
 }
示例#9
0
 public static boolean showUpdates() {
   if (Options.getBoolean(Options.OPTION_CHECK_UPDATES) && hasNewVersion()) {
     final int today = (int) (System.currentTimeMillis() / (24L * 60 * 60 * 1000));
     final int nextCheck = Options.getInt(Options.OPTION_UPDATE_CHECK_TIME);
     if (nextCheck <= today) {
       final int nextDay = today + SHOW_NEW_VERSION_INTERVAL;
       Options.setInt(Options.OPTION_UPDATE_CHECK_TIME, nextDay);
       Options.safeSave();
       return true;
     }
   }
   return false;
 }
  private CharSequence hashContext(Object context, Options options) throws IOException {
    StringBuilder buffer = new StringBuilder();

    Context parent = options.context;
    Iterator<Map.Entry<String, Object>> iterator = reverse(options.propertySet(context));
    while (iterator.hasNext()) {
      Map.Entry<String, Object> entry = iterator.next();
      Context current = Context.newContext(parent, entry.getValue()).data("key", entry.getKey());
      buffer.append(options.fn(current));
    }

    return buffer;
  }
示例#11
0
  /**
   * Traverse the statements in the given body, looking for aggregation possibilities; that is,
   * given a def d and a use u, d has no other uses, u has no other defs, collapse d and u.
   *
   * <p>option: only-stack-locals; if this is true, only aggregate variables starting with $
   */
  protected void internalTransform(Body b, String phaseName, Map<String, String> options) {
    StmtBody body = (StmtBody) b;
    boolean onlyStackVars = PhaseOptions.getBoolean(options, "only-stack-locals");

    int aggregateCount = 1;

    if (Options.v().time()) Timers.v().aggregationTimer.start();
    boolean changed = false;

    Map<ValueBox, Zone> boxToZone =
        new HashMap<ValueBox, Zone>(body.getUnits().size() * 2 + 1, 0.7f);

    // Determine the zone of every box
    {
      Zonation zonation = new Zonation(body);

      for (Unit u : body.getUnits()) {
        Zone zone = zonation.getZoneOf(u);

        for (ValueBox box : u.getUseBoxes()) {
          boxToZone.put(box, zone);
        }

        for (ValueBox box : u.getDefBoxes()) {
          boxToZone.put(box, zone);
        }
      }
    }

    do {
      if (Options.v().verbose())
        G.v()
            .out
            .println(
                "["
                    + body.getMethod().getName()
                    + "] Aggregating iteration "
                    + aggregateCount
                    + "...");

      // body.printTo(new java.io.PrintWriter(G.v().out, true));

      changed = internalAggregate(body, boxToZone, onlyStackVars);

      aggregateCount++;
    } while (changed);

    if (Options.v().time()) Timers.v().aggregationTimer.end();
  }
  public static void main(String[] args) throws Exception {

    String propertyFile = null;

    // create the command line parser
    CommandLineParser parser = new PosixParser();
    Options options = new Options();
    options.addOption("f", "file", true, "The properties file");
    options.addOption("v", "verbose", false, "Verbose logging output");
    options.addOption("h", "help", false, "Help output");

    try {
      CommandLine line = parser.parse(options, args);

      if (line.hasOption('v')) {
        org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.DEBUG);
      }

      if (line.hasOption('h')) {
        usage(options);
      }

      if (line.hasOption('f')) {
        propertyFile = line.getOptionValue('f');
      } else {
        throw new Exception("Please supply -f");
      }

    } catch (Exception e) {
      log.error("Invalid command line: " + e, e);
      usage(options);
    }

    Properties props = new Properties();
    props.load(new FileReader(propertyFile));
    startFromProperties(props);

    Runtime.getRuntime()
        .addShutdownHook(
            new Thread(
                new Runnable() {
                  @Override
                  public void run() {
                    log.info("Received shutdown signal. Shutting down...");
                    server.stop(3);
                  }
                }));
  }
示例#13
0
  // This method starts a newGame by initializing everything that is necessary before calling the
  // game() method
  public void newGame() {
    // Calls the loadMap method to load the map for the game
    loadMap();

    // Calls the createPlayers method to create the players needed for the game
    createPlayers();

    // Starts the powerup manager to make powerups
    pum.startPowerUps();

    // Makes the gamePanel the only visible panel
    gamePanel.setVisible(true);
    optionsPanel.setVisible(false);
    rulesPanel.setVisible(false);
    controlsPanel.setVisible(false);
    creditsPanel.setVisible(false);
    titlePanel.setVisible(false);

    // Resets some variables needed to play the game
    winPlayer = 5;
    deadPlayers = 0;

    // Calls the game() method to play the game
    game();
  }
示例#14
0
  // This method is deprecated. Use soot.util.JasminOutputStream instead.
  public void writeXXXDeprecated(SootClass cl, String outputDir) {
    String outputDirWithSep = "";

    if (!outputDir.equals("")) outputDirWithSep = outputDir + fileSeparator;

    try {
      File tempFile = new File(outputDirWithSep + cl.getName() + ".jasmin");

      FileOutputStream streamOut = new FileOutputStream(tempFile);

      PrintWriter writerOut = new PrintWriter(new EscapedWriter(new OutputStreamWriter(streamOut)));

      if (cl.containsBafBody()) new soot.baf.JasminClass(cl).print(writerOut);
      else new soot.jimple.JasminClass(cl).print(writerOut);

      writerOut.close();

      if (Options.v().time()) Timers.v().assembleJasminTimer.start();

      // Invoke jasmin
      {
        String[] args;

        if (outputDir.equals("")) {
          args = new String[1];

          args[0] = cl.getName() + ".jasmin";
        } else {
          args = new String[3];

          args[0] = "-d";
          args[1] = outputDir;
          args[2] = outputDirWithSep + cl.getName() + ".jasmin";
        }

        jasmin.Main.main(args);
      }

      tempFile.delete();

      if (Options.v().time()) Timers.v().assembleJasminTimer.end();

    } catch (IOException e) {
      throw new RuntimeException("Could not produce new classfile! (" + e + ")");
    }
  }
示例#15
0
 // This method makes only the credits panel visible
 public void credits() {
   // Makes only the creditsPanel visible
   gamePanel.setVisible(false);
   optionsPanel.setVisible(false);
   rulesPanel.setVisible(false);
   controlsPanel.setVisible(false);
   creditsPanel.setVisible(true);
   titlePanel.setVisible(false);
 }
示例#16
0
 private Message parseMessage(byte[] b) throws WireParseException {
   try {
     return (new Message(b));
   } catch (IOException e) {
     if (Options.check("verbose")) e.printStackTrace();
     if (!(e instanceof WireParseException)) e = new WireParseException("Error parsing message");
     throw (WireParseException) e;
   }
 }
示例#17
0
  public static void main(String[] args) {
    Options options = new Options();
    options.addOption("v", true, "Input Vector folder"); // yearly vector data
    options.addOption("p", true, "Points folder"); // yearly mds (rotate) output
    options.addOption("d", true, "Destination folder");
    options.addOption("o", true, "Original stock file"); // global 10 year stock file
    options.addOption(
        "s",
        true,
        "Sector file"); // If Histogram true then set this as the folder to histogram output
    options.addOption("h", false, "Gen from histogram");
    options.addOption("e", true, "Extra classes file"); // a file containing fixed classes
    options.addOption("ci", true, "Cluster input file");
    options.addOption("co", true, "Cluster output file");

    CommandLineParser commandLineParser = new BasicParser();
    try {
      CommandLine cmd = commandLineParser.parse(options, args);
      String vectorFile = cmd.getOptionValue("v");
      String pointsFolder = cmd.getOptionValue("p");
      String distFolder = cmd.getOptionValue("d");
      String originalStocks = cmd.getOptionValue("o");
      String sectorFile = cmd.getOptionValue("s");
      boolean histogram = cmd.hasOption("h");
      String fixedClasses = cmd.getOptionValue("e");
      String clusterInputFile = cmd.getOptionValue("ci");
      String clusterOutputFile = cmd.getOptionValue("co");

      LabelApply program =
          new LabelApply(
              vectorFile,
              pointsFolder,
              distFolder,
              originalStocks,
              sectorFile,
              histogram,
              fixedClasses,
              clusterInputFile,
              clusterOutputFile);
      program.process();
    } catch (ParseException e) {
      e.printStackTrace();
    }
  }
示例#18
0
文件: Traffic.java 项目: fin-nick/fj
  // Generates int of money amount spent on connection
  protected int generateCostSum(int in, int out, boolean thisSession) {
    int cost = 0;
    int costOf1M = Options.getInt(Options.OPTION_COST_OF_1M) * 100;
    int costPacketLength = Math.max(Options.getInt(Options.OPTION_COST_PACKET_LENGTH), 1);

    long packets = 0;
    if (0 != in) {
      packets += (in + costPacketLength - 1) / costPacketLength;
    }
    if (0 != out) {
      packets += (out + costPacketLength - 1) / costPacketLength;
    }
    cost += (int) (packets * costPacketLength * costOf1M / (1024 * 1024));
    if (!usedToday() && (0 != sessionInTraffic) && (0 == costPerDaySum)) {
      costPerDaySum = costPerDaySum + Options.getInt(Options.OPTION_COST_PER_DAY);
      lastTimeUsed.setTime(new Date().getTime());
    }
    return cost + costPerDaySum;
  }
示例#19
0
 private static void addSearch(String search, List list) {
   Name name;
   if (Options.check("verbose")) System.out.println("adding search " + search);
   try {
     name = Name.fromString(search, Name.root);
   } catch (TextParseException e) {
     return;
   }
   if (list.contains(name)) return;
   list.add(name);
 }
示例#20
0
 /** Converts a Record into a String representation */
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append(name);
   if (sb.length() < 8) sb.append("\t");
   if (sb.length() < 16) sb.append("\t");
   sb.append("\t");
   if (Options.check("BINDTTL")) sb.append(TTL.format(ttl));
   else sb.append(ttl);
   sb.append("\t");
   if (dclass != DClass.IN || !Options.check("noPrintIN")) {
     sb.append(DClass.string(dclass));
     sb.append("\t");
   }
   sb.append(Type.string(type));
   String rdata = rrToString();
   if (!rdata.equals("")) {
     sb.append("\t");
     sb.append(rdata);
   }
   return sb.toString();
 }
 /*
  * Receive an exception.  If the resolution has been completed,
  * do nothing.  Otherwise make progress.
  */
 public void handleException(Object id, Exception e) {
   if (Options.check("verbose")) System.err.println("ExtendedResolver: got " + e);
   synchronized (this) {
     outstanding--;
     if (done) return;
     int n;
     for (n = 0; n < inprogress.length; n++) if (inprogress[n] == id) break;
     /* If we don't know what this is, do nothing. */
     if (n == inprogress.length) return;
     boolean startnext = false;
     boolean waiting = false;
     /*
      * If this is the first response from server n,
      * we should start sending queries to server n + 1.
      */
     if (sent[n] == 1 && n < resolvers.length - 1) startnext = true;
     if (e instanceof InterruptedIOException) {
       /* Got a timeout; resend */
       if (sent[n] < retries) send(n);
       if (thrown == null) thrown = e;
     } else if (e instanceof SocketException) {
       /*
        * Problem with the socket; don't resend
        * on it
        */
       if (thrown == null || thrown instanceof InterruptedIOException) thrown = e;
     } else {
       /*
        * Problem with the response; don't resend
        * on the same socket.
        */
       thrown = e;
     }
     if (done) return;
     if (startnext) send(n + 1);
     if (done) return;
     if (outstanding == 0) {
       /*
        * If we're done and this is synchronous,
        * wake up the blocking thread.
        */
       done = true;
       if (listener == null) {
         notifyAll();
         return;
       }
     }
     if (!done) return;
   }
   /* If we're done and this is asynchronous, call the callback. */
   if (!(thrown instanceof Exception)) thrown = new RuntimeException(thrown.getMessage());
   listener.handleException(this, (Exception) thrown);
 }
示例#22
0
  public static Options constructGnuOptions() {
    final Options gnuOptions = new Options();
    Option aminoDefaultConfigurationOption =
        new Option(
            "d", "amino_default_config_path", true, "The path where the amino default file lives.");
    aminoDefaultConfigurationOption.setRequired(true);
    gnuOptions.addOption(aminoDefaultConfigurationOption);
    gnuOptions.addOption("b", "base_dir", true, "The base directory of the running job");
    gnuOptions.addOption(
        "c",
        "amino_config_file_path",
        true,
        "A CSV of filenames or paths which will be acted like a classpath setting up configurations!");
    gnuOptions.addOption(
        "stop",
        "stop_on_first_phase",
        false,
        "Stop after the first phase of an AminoEnrichmentJob");

    Option propertyOverride =
        new Option(
            "D",
            "property_override",
            true,
            "A map of key/value configuration properties to override (ie: 'key=value')");
    propertyOverride.setValueSeparator('=');
    propertyOverride.setArgs(2);
    gnuOptions.addOption(propertyOverride);

    return gnuOptions;
  }
示例#23
0
  @Override
  public Item item(final QueryContext qc, final InputInfo ii) throws QueryException {
    checkCreate(qc);
    // URL to relational database
    final String url = string(toToken(exprs[0], qc));
    final JDBCConnections jdbc = jdbc(qc);
    try {
      if (exprs.length > 2) {
        // credentials
        final String user = string(toToken(exprs[1], qc));
        final String pass = string(toToken(exprs[2], qc));
        if (exprs.length == 4) {
          // connection options
          final Options opts = toOptions(3, Q_OPTIONS, new Options(), qc);
          // extract auto-commit mode from options
          boolean ac = true;
          final HashMap<String, String> options = opts.free();
          final String commit = options.get(AUTO_COMM);
          if (commit != null) {
            ac = Strings.yes(commit);
            options.remove(AUTO_COMM);
          }
          // connection properties
          final Properties props = connProps(options);
          props.setProperty(USER, user);
          props.setProperty(PASS, pass);

          // open connection
          final Connection conn = getConnection(url, props);
          // set auto/commit mode
          conn.setAutoCommit(ac);
          return Int.get(jdbc.add(conn));
        }
        return Int.get(jdbc.add(getConnection(url, user, pass)));
      }
      return Int.get(jdbc.add(getConnection(url)));
    } catch (final SQLException ex) {
      throw BXSQ_ERROR_X.get(info, ex);
    }
  }
    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 == 0) {
          System.err.println("No sstables to split");
          printUsage(options);
          System.exit(1);
        }
        Options opts = new Options(Arrays.asList(args));
        opts.debug = cmd.hasOption(DEBUG_OPTION);
        opts.verbose = cmd.hasOption(VERBOSE_OPTION);
        opts.snapshot = !cmd.hasOption(NO_SNAPSHOT_OPTION);
        opts.sizeInMB = DEFAULT_SSTABLE_SIZE;

        if (cmd.hasOption(SIZE_OPTION))
          opts.sizeInMB = Integer.valueOf(cmd.getOptionValue(SIZE_OPTION));

        return opts;
      } catch (ParseException e) {
        errorMsg(e.getMessage(), options);
        return null;
      }
    }
 /*
  * Receive a response.  If the resolution hasn't been completed,
  * either wake up the blocking thread or call the callback.
  */
 public void receiveMessage(Object id, Message m) {
   if (Options.check("verbose")) System.err.println("ExtendedResolver: " + "received message");
   synchronized (this) {
     if (done) return;
     response = m;
     done = true;
     if (listener == null) {
       notifyAll();
       return;
     }
   }
   listener.receiveMessage(this, response);
 }
示例#26
0
文件: Q2.java 项目: rlishtaba/jPOS
  private void parseCmdLine(String[] args) {
    CommandLineParser parser = new PosixParser();

    Options options = new Options();
    options.addOption("v", "version", false, "Q2's version");
    options.addOption("d", "deploydir", true, "Deployment directory");
    options.addOption("r", "recursive", false, "Deploy subdirectories recursively");
    options.addOption("h", "help", false, "Usage information");
    options.addOption("C", "config", true, "Configuration bundle");
    options.addOption("e", "encrypt", true, "Encrypt configuration bundle");
    options.addOption("i", "cli", false, "Command Line Interface");
    options.addOption("c", "command", true, "Command to execute");

    try {
      CommandLine line = parser.parse(options, args);
      if (line.hasOption("v")) {
        displayVersion();
        System.exit(0);
      }
      if (line.hasOption("h")) {
        HelpFormatter helpFormatter = new HelpFormatter();
        helpFormatter.printHelp("Q2", options);
        System.exit(0);
      }
      if (line.hasOption("c")) {
        cli = new CLI(this, line.getOptionValue("c"), line.hasOption("i"));
      } else if (line.hasOption("i")) cli = new CLI(this, null, true);

      String dir = DEFAULT_DEPLOY_DIR;
      if (line.hasOption("d")) {
        dir = line.getOptionValue("d");
      }
      recursive = line.hasOption("r");
      this.deployDir = new File(dir);
      if (line.hasOption("C")) deployBundle(new File(line.getOptionValue("C")), false);
      if (line.hasOption("e")) deployBundle(new File(line.getOptionValue("e")), true);
    } catch (MissingArgumentException e) {
      System.out.println("ERROR: " + e.getMessage());
      System.exit(1);
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }
  }
示例#27
0
文件: Notify.java 项目: fin-nick/fj
  // Play a sound notification
  private int getNotificationMode(int notType) {
    switch (notType) {
      case NOTIFY_MESSAGE:
        return Options.getInt(Options.OPTION_MESS_NOTIF_MODE);

      case NOTIFY_ONLINE:
        return Options.getInt(Options.OPTION_ONLINE_NOTIF_MODE);

      case NOTIFY_OFFLINE: // offline sound
        return Options.getInt(Options.OPTION_OFFLINE_NOTIF_MODE); // offline sound

      case NOTIFY_TYPING:
        return Options.getInt(Options.OPTION_TYPING_MODES); // typing

      case NOTIFY_MULTIMESSAGE:
        return 0;

      case NOTIFY_OTHER: // other sound
        return Options.getInt(Options.OPTION_OTHER_NOTIF_MODE); // other sound
    }
    return 0;
  }
示例#28
0
 /**
  * Converts the generate specification to a string containing the corresponding $GENERATE
  * statement.
  */
 public String toString() {
   StringBuffer sb = new StringBuffer();
   sb.append("$GENERATE ");
   sb.append(start + "-" + end);
   if (step > 1) sb.append("/" + step);
   sb.append(" ");
   sb.append(namePattern + " ");
   sb.append(ttl + " ");
   if (dclass != DClass.IN || !Options.check("noPrintIN")) sb.append(DClass.string(dclass) + " ");
   sb.append(Type.string(type) + " ");
   sb.append(rdataPattern + " ");
   return sb.toString();
 }
示例#29
0
  @Override
  public void action(final Object comp) {
    final String pth = path();
    final IOFile io = new IOFile(pth);
    String inf = io.isDir() && io.children().length > 0 ? DIR_NOT_EMPTY : null;
    ok = !pth.isEmpty();

    final SerialMethod mth = SerialMethod.valueOf(method.getSelectedItem());
    final OptionsOption<? extends Options> opts =
        mth == SerialMethod.JSON
            ? SerializerOptions.JSON
            : mth == SerialMethod.CSV ? SerializerOptions.CSV : null;
    final boolean showmparams = opts != null;
    mparams.setEnabled(showmparams);

    if (ok) {
      gui.gopts.set(GUIOptions.INPUTPATH, pth);
      try {
        if (comp == method) {
          if (showmparams) {
            final Options mopts = options(null).get(opts);
            mparams.setToolTipText(tooltip(mopts));
            mparams.setText(mopts.toString());
          } else {
            mparams.setToolTipText(null);
            mparams.setText("");
          }
        }
        Serializer.get(new ArrayOutput(), options(mth));
      } catch (final IOException ex) {
        ok = false;
        inf = ex.getMessage();
      }
    }

    info.setText(inf, ok ? Msg.WARN : Msg.ERROR);
    enableOK(buttons, B_OK, ok);
  }
示例#30
0
 private static boolean hasNewVersion() {
   final String lastSVersion = Options.getString(Options.OPTION_LAST_VERSION);
   if (0 == lastSVersion.length()) {
     return false;
   }
   final int[] curVersion = getVersionDate("###DATE###");
   final int[] lastVersion = getVersionDate(lastSVersion);
   if (curVersion[2] < lastVersion[2]) return true;
   if (curVersion[2] > lastVersion[2]) return false;
   if (curVersion[1] < lastVersion[1]) return true;
   if (curVersion[1] > lastVersion[1]) return false;
   if (curVersion[0] < lastVersion[0]) return true;
   return false;
 }