Beispiel #1
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();
 }
 @Override
 public Options getOptions(AnnotatedPluginDocument... documents)
     throws DocumentOperationException {
   Options options = new Options(this.getClass());
   options.addStringOption("query", "query", "PROJECT_NAME = \"BARCODE\"");
   return options;
 }
Beispiel #3
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);
  }
Beispiel #4
0
  /** Construct a log with given I/O redirections. */
  protected Log(
      Context context, PrintWriter errWriter, PrintWriter warnWriter, PrintWriter noticeWriter) {
    super(JCDiagnostic.Factory.instance(context));
    context.put(logKey, this);
    this.errWriter = errWriter;
    this.warnWriter = warnWriter;
    this.noticeWriter = noticeWriter;

    @SuppressWarnings("unchecked") // FIXME
    DiagnosticListener<? super JavaFileObject> dl = context.get(DiagnosticListener.class);
    this.diagListener = dl;

    diagnosticHandler = new DefaultDiagnosticHandler();

    messages = JavacMessages.instance(context);
    messages.add(Main.javacBundleName);

    final Options options = Options.instance(context);
    initOptions(options);
    options.addListener(
        new Runnable() {
          public void run() {
            initOptions(options);
          }
        });
  }
Beispiel #5
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;
  }
  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);
  }
Beispiel #8
0
  private static void parseOptions(Options options, String[] args) {
    ParserProperties properties = ParserProperties.defaults().withUsageWidth(128);
    CmdLineParser parser = new CmdLineParser(options, properties);
    try {
      parser.parseArgument(args);
    } catch (CmdLineException e) {
      System.err.println(e.getMessage());
      System.err.println(getUsageString(parser, false));
      System.exit(1);
    }
    if (options.showVersion) {
      System.out.println(getVersionString());
      System.exit(0);
    }
    if (options.showHelp) {
      System.out.println(getUsageString(parser, false));
      System.exit(0);
    }
    if (options.showExtendedHelp) {
      System.out.println(getUsageString(parser, true));
      System.exit(0);
    }
    if (options.debug || options.fullDebug || options.debugInfo) {
      // Disable interpreter when bytecode is requested
      options.noInterpreter = true;
    }
    if (options.fileName != null) {
      // Execute as last script
      if (options.fileName.toString().equals("-")) {
        // "-" is a short-hand to request reading from System.in
        if (System.console() == null) {
          // System.in is not interactive
          options.evalScripts.add(new EvalString(read(System.in)));
        } else {
          options.interactive = true;
        }
      } else {
        options.evalScripts.add(new EvalPath(options.fileName));
      }
    }
    if (options.evalScripts.isEmpty()) {
      // Default to interactive mode when no files or expressions were set
      options.interactive = true;

      // Warn if --module is used without input files.
      if (options.module) {
        System.err.println(formatMessage("module_no_files"));
      }
    }
    if (options.ecmascript7) {
      System.err.println(formatMessage("deprecated.es7"));
    }
  }
Beispiel #9
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();
     }
   }
 }
  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;
  }
Beispiel #11
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;
 }
Beispiel #12
0
 /** Convert to a String */
 String rrToString() {
   StringBuffer sb = new StringBuffer();
   sb.append(host);
   sb.append(" ");
   sb.append(admin);
   if (Options.check("multiline")) {
     sb.append(" (\n\t\t\t\t\t");
     sb.append(serial);
     sb.append("\t; serial\n\t\t\t\t\t");
     sb.append(refresh);
     sb.append("\t; refresh\n\t\t\t\t\t");
     sb.append(retry);
     sb.append("\t; retry\n\t\t\t\t\t");
     sb.append(expire);
     sb.append("\t; expire\n\t\t\t\t\t");
     sb.append(minimum);
     sb.append(" )\t; minimum");
   } else {
     sb.append(" ");
     sb.append(serial);
     sb.append(" ");
     sb.append(refresh);
     sb.append(" ");
     sb.append(retry);
     sb.append(" ");
     sb.append(expire);
     sb.append(" ");
     sb.append(minimum);
   }
   return sb.toString();
 }
Beispiel #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();
  }
Beispiel #14
0
/*	public static String optarg; //TODO import gnu.getopt.Getopt; in ginit()
	public static int optind; //TODO import gnu.getopt.Getopt; in ginit();
	//TODO make long_options(struct)
	private static String[] long_options = { "verbose", "verbose:gc", "verbose:sugar", 
								"verbose:code", "interactive", "typecheck", 
								"start-with", "test", "test-with", "builtin-test", "NULL" };
*/	
	static {
		longOptions = new Options();
		longOptions.addOption(null, "verbose", false, null);
		longOptions.addOption(null, "verbose:gc", false, null);
		longOptions.addOption(null, "verbose:sugar", false, null);
		longOptions.addOption(null, "verbose:code", false, null);
		longOptions.addOption("i", "interactive", false, null);
		longOptions.addOption("c", "typecheck", false, null);
		longOptions.addOption("S", "start-with", true, null);
		longOptions.addOption("T", "test", true, null);
		longOptions.addOption("T", "test-with", true, null);
		longOptions.addOption("B", "builtin-test", true, null);
	}
Beispiel #15
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 + ")");
    }
  }
Beispiel #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;
   }
 }
Beispiel #17
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);
 }
  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();
    }
  }
Beispiel #19
0
  private static String createVirtex5(Options opts) {
    StringBuffer generate = new StringBuffer();
    boolean signed = opts.signed;
    int WR = opts.WR;
    int WA = opts.WA;
    int WB = opts.WB;

    String sign = signed ? "Signed" : "Unsigned";
    generate.append("SET addpads = False\n");
    generate.append("SET asysymbol = True\n");
    generate.append("SET busformat = BusFormatAngleBracketNotRipped\n");
    generate.append("SET createndf = False\n");
    generate.append("SET designentry = Verilog\n");
    generate.append("SET device = xc5vfx70t\n");
    generate.append("SET devicefamily = virtex5\n");
    generate.append("SET flowvendor = Other\n");
    generate.append("SET formalverification = False\n");
    generate.append("SET foundationsym = False\n");
    generate.append("SET implementationfiletype = Ngc\n");
    generate.append("SET package = ff1136\n");
    generate.append("SET removerpms = False\n");
    generate.append("SET simulationfiles = Behavioral\n");
    generate.append("SET speedgrade = -2\n");
    generate.append("SET verilogsim = True\n");
    generate.append("SET vhdlsim = False\n");
    generate.append("# END Project Options\n");
    generate.append("# BEGIN Select\n");
    generate.append("SELECT Multiplier family Xilinx,_Inc. 11.2\n");
    generate.append("# END Select\n");
    generate.append("# BEGIN Parameters\n");
    generate.append("CSET ccmimp=Distributed_Memory\n");
    generate.append("CSET clockenable=true\n");
    generate.append(
        String.format(
            "CSET component_name=mul_pipe_%s_%d_%d_%d\n", signed ? "s" : "u", WA, WB, WR));
    generate.append("CSET constvalue=129\n");
    generate.append("CSET internaluser=0\n");
    generate.append("CSET multiplier_construction=Use_Mults\n");
    generate.append("CSET multtype=Parallel_Multiplier\n");
    generate.append("CSET optgoal=Speed\n");
    generate.append(String.format("CSET outputwidthhigh=%d\n", WR - 1));
    generate.append("CSET outputwidthlow=0\n");
    generate.append(String.format("CSET pipestages=%d\n", opts.delay()));
    generate.append(String.format("CSET portatype=%s\n", sign));
    generate.append(String.format("CSET portawidth=%d\n", WA));
    generate.append(String.format("CSET portbtype=%s\n", sign));
    generate.append(String.format("CSET portbwidth=%d\n", WB));
    generate.append("CSET roundpoint=0\n");
    generate.append("CSET sclrcepriority=SCLR_Overrides_CE\n");
    generate.append("CSET syncclear=true\n");
    generate.append("CSET use_custom_output_width=true\n");
    generate.append("CSET userounding=false\n");
    generate.append("CSET zerodetect=false\n");
    generate.append("GENERATE\n");
    return generate.toString();
  }
Beispiel #20
0
  // 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;
  }
Beispiel #21
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);
 }
 /*
  * 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);
 }
Beispiel #23
0
 private int getIntOption(Options options, Option option, int defaultValue) {
   String s = options.get(option);
   try {
     if (s != null) {
       int n = Integer.parseInt(s);
       return (n <= 0 ? Integer.MAX_VALUE : n);
     }
   } catch (NumberFormatException e) {
     // silently ignore ill-formed numbers
   }
   return defaultValue;
 }
 /** 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();
 }
  /** Construct a new compiler from a shared context. */
  public AptJavaCompiler(Context context) {
    super(preRegister(context));

    context.put(compilerKey, this);
    apt = Apt.instance(context);

    ClassReader classReader = ClassReader.instance(context);
    classReader.preferSource = true;

    // TEMPORARY NOTE: bark==log, but while refactoring, we maintain their
    // original identities, to remember the original intent.
    log = Log.instance(context);
    bark = Bark.instance(context);

    Options options = Options.instance(context);
    classOutput = options.get("-retrofit") == null;
    nocompile = options.get("-nocompile") != null;
    print = options.get("-print") != null;
    classesAsDecls = options.get("-XclassesAsDecls") != null;

    genSourceFileNames = new java.util.LinkedHashSet<String>();
    genClassFileNames = new java.util.LinkedHashSet<String>();

    // this forces a copy of the line map to be kept in the tree,
    // for use by com.sun.mirror.util.SourcePosition.
    lineDebugInfo = true;
  }
 /*
  * 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);
 }
Beispiel #27
0
  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);
    }
  }
Beispiel #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();
 }
Beispiel #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);
  }
Beispiel #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;
 }