Example #1
1
 private String getDate(String timeStampStr, String format) {
   DateFormat formatter = new SimpleDateFormat(format);
   long timeStamp = Long.parseLong(timeStampStr);
   Calendar calendar = Calendar.getInstance();
   calendar.setTimeInMillis(timeStamp);
   return formatter.format(calendar.getTime());
 }
 /**
  * Parses a textual representation of an object ID as dotted string (e.g. "1.3.6.1.2.1.1") and
  * returns its raw value.
  *
  * @param text a textual representation of an OID.
  * @return the raw OID value.
  * @throws ParseException if the OID cannot be parsed successfully.
  */
 public int[] parse(String text) throws ParseException {
   StringTokenizer st = new StringTokenizer(text, ".", true);
   int size = st.countTokens();
   int[] value = new int[size];
   size = 0;
   StringBuffer buf = null;
   while (st.hasMoreTokens()) {
     String t = st.nextToken();
     if ((buf == null) && t.startsWith("'")) {
       buf = new StringBuffer();
       t = t.substring(1);
     }
     if ((buf != null) && (t.endsWith("'"))) {
       buf.append(t.substring(0, t.length() - 1));
       OID o = new OctetString(buf.toString()).toSubIndex(true);
       int[] h = value;
       value = new int[st.countTokens() + h.length + o.size()];
       System.arraycopy(h, 0, value, 0, size);
       System.arraycopy(o.getValue(), 0, value, size, o.size());
       size += o.size();
       buf = null;
     } else if (buf != null) {
       buf.append(t);
     } else if (!".".equals(t)) {
       value[size++] = (int) Long.parseLong(t.trim());
     }
   }
   if (size < value.length) {
     int[] h = value;
     value = new int[size];
     System.arraycopy(h, 0, value, 0, size);
   }
   return value;
 }
 public String toString() {
   String ret =
       "<CFDbTestBoolTypeBySchemaIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredSchemaDefId="
           + "\""
           + Long.toString(getRequiredSchemaDefId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFCrmContactURLPKey"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredContactURLId="
           + "\""
           + Long.toString(getRequiredContactURLId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFBamScopePKey"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredId="
           + "\""
           + Long.toString(getRequiredId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFCrmMemoTagByTagIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredTagId="
           + "\""
           + Long.toString(getRequiredTagId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFBamPopDepByRelationIdx"
           + " RequiredRelationTenantId="
           + "\""
           + Long.toString(getRequiredRelationTenantId())
           + "\""
           + " RequiredRelationId="
           + "\""
           + Long.toString(getRequiredRelationId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFBamClearTopDepByContTblIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredContTableId="
           + "\""
           + Long.toString(getRequiredContTableId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFFreeSwitchPbxIvrMenuEntryByMenuIdIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredMenuId="
           + "\""
           + Long.toString(getRequiredMenuId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFDbTestValueByScopeIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredScopeId="
           + "\""
           + Long.toString(getRequiredScopeId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFBamTimeColByTableIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredTableId="
           + "\""
           + Long.toString(getRequiredTableId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFAsteriskClusterId64Gen"
           + " RequiredId="
           + "\""
           + Long.toString(getRequiredId())
           + "\""
           + ", SliceId=\""
           + Short.toString(getRequiredSliceId())
           + "\""
           + ", NextId=\""
           + Long.toString(nextId)
           + "\"/>";
   return (ret);
 }
Example #13
0
    @Override
    public Object stringToValue(String text) throws ParseException {
      if (text != null) text = text.trim();

      if ((text == null) || text.isEmpty()) {
        if (nullable) {
          return null;
        } else {
          throw new ParseException("Empty/null value is not allowed.", 0);
        }
      }

      long value;
      try {
        value = Long.parseLong(text);
      } catch (Exception e) {
        throw new ParseException("Parsing \"" + text + "\" to an integer value failed.", 0);
      }

      if ((value < minValue) || (value > maxValue)) {
        throw new ParseException(
            "Parsing \""
                + text
                + "\" to an integer value in the range ["
                + minValue
                + ", "
                + maxValue
                + "] failed.",
            0);
      }

      return value;
    }
Example #14
0
 private void getPositions(HttpServletRequest request, Role item) {
   String[] pos = request.getParameterValues("positions");
   item.clearPositions();
   for (int i = 0; i < pos.length; i++) {
     item.addPosition(Long.parseLong(pos[i]));
   }
 }
Example #15
0
 private long[] parse(String[] as) {
   long ans[] = new long[as.length];
   int index = 0;
   for (String cur : as) ans[index++] = Long.parseLong(cur, 2);
   Arrays.sort(ans);
   return ans;
 }
Example #16
0
  public static void main(String[] args) {
    if (args.length < 5) {
      System.out.println(
          "\n  Usage: java prob.mdp.MDPSim prob_file " + "spudd_vfun trials steps rand_seed\n");
      System.exit(1);
    }

    MDPSim mdpsim = new MDPSim(args[0], args[1]);

    ArrayList vals = null;
    int trials = -1, steps = -1;
    long seed = -1;
    try {
      trials = Integer.parseInt(args[2]);
      steps = Integer.parseInt(args[3]);
      seed = Long.parseLong(args[4]);
      vals = mdpsim.simulate(trials, steps, seed);
    } catch (NumberFormatException nfe) {
      System.out.println(nfe);
      System.exit(1);
    }

    System.out.println("\n Problem:  " + args[0]);
    System.out.println(" VFun:     " + args[1]);
    System.out.println(" Trials:   " + trials);
    System.out.println(" Steps:    " + steps);
    System.out.println(" Seed:     " + seed);
    System.out.println(" Data:     " + PrintList(vals));
    System.out.println(" Average:  " + MDP._df.format(Average(vals)) + "\n");
  }
Example #17
0
  public Chart(String filename) {
    try {
      // Get Stock Symbol
      this.stockSymbol = filename.substring(0, filename.indexOf('.'));

      // Create time series
      TimeSeries open = new TimeSeries("Open Price", Day.class);
      TimeSeries close = new TimeSeries("Close Price", Day.class);
      TimeSeries high = new TimeSeries("High", Day.class);
      TimeSeries low = new TimeSeries("Low", Day.class);
      TimeSeries volume = new TimeSeries("Volume", Day.class);

      BufferedReader br = new BufferedReader(new FileReader(filename));
      String key = br.readLine();
      String line = br.readLine();
      while (line != null && !line.startsWith("<!--")) {
        StringTokenizer st = new StringTokenizer(line, ",", false);
        Day day = getDay(st.nextToken());
        double openValue = Double.parseDouble(st.nextToken());
        double highValue = Double.parseDouble(st.nextToken());
        double lowValue = Double.parseDouble(st.nextToken());
        double closeValue = Double.parseDouble(st.nextToken());
        long volumeValue = Long.parseLong(st.nextToken());

        // Add this value to our series'
        open.add(day, openValue);
        close.add(day, closeValue);
        high.add(day, highValue);
        low.add(day, lowValue);

        // Read the next day
        line = br.readLine();
      }

      // Build the datasets
      dataset.addSeries(open);
      dataset.addSeries(close);
      dataset.addSeries(low);
      dataset.addSeries(high);
      datasetOpenClose.addSeries(open);
      datasetOpenClose.addSeries(close);
      datasetHighLow.addSeries(high);
      datasetHighLow.addSeries(low);

      JFreeChart summaryChart = buildChart(dataset, "Summary", true);
      JFreeChart openCloseChart = buildChart(datasetOpenClose, "Open/Close Data", false);
      JFreeChart highLowChart = buildChart(datasetHighLow, "High/Low Data", true);
      JFreeChart highLowDifChart =
          buildDifferenceChart(datasetHighLow, "High/Low Difference Chart");

      // Create this panel
      this.setLayout(new GridLayout(2, 2));
      this.add(new ChartPanel(summaryChart));
      this.add(new ChartPanel(openCloseChart));
      this.add(new ChartPanel(highLowChart));
      this.add(new ChartPanel(highLowDifChart));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Example #18
0
 private void getPermissions(HttpServletRequest request, Role item) {
   String[] per = request.getParameterValues("permissions");
   item.clearPermissions();
   for (int i = 0; i < per.length; i++) {
     item.addPermission(Long.parseLong(per[i]));
   }
 }
Example #19
0
 public static String getTimestamp(String timestamp, String format) {
   if (timestamp == null || timestamp.isEmpty() || timestamp.equals("null")) {
     return null;
   }
   if (format == null || format.isEmpty()) format = "yyyy-MM-dd";
   SimpleDateFormat sdf = new SimpleDateFormat(format);
   return sdf.format(new Date(Long.valueOf(timestamp + "000")));
 }
 public String toString() {
   String ret =
       "<CFBamValueHPKey"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredId="
           + "\""
           + Long.toString(getRequiredId())
           + "\""
           + " RequiredRevision=\""
           + Integer.toString(getRequiredRevision())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFFreeSwitchFSSFDialerHPKey"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredFSSFDialerId="
           + "\""
           + Long.toString(getRequiredFSSFDialerId())
           + "\""
           + " RequiredRevision=\""
           + Integer.toString(getRequiredRevision())
           + "\""
           + "/>";
   return (ret);
 }
Example #22
0
File: Macro.java Project: bramk/bnd
 public String _long2date(String args[]) {
   try {
     return new Date(Long.parseLong(args[1])).toString();
   } catch (Exception e) {
     e.printStackTrace();
   }
   return "not a valid long";
 }
 public String toString() {
   String ret =
       "<CFInternetMajorVersionByNameIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredParentProjectId="
           + "\""
           + Long.toString(getRequiredParentProjectId())
           + "\""
           + " RequiredName="
           + "\""
           + CFInternetSchema.xmlEncodeString(getRequiredName())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFDbTestTableByUNameIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredSchemaDefId="
           + "\""
           + Long.toString(getRequiredSchemaDefId())
           + "\""
           + " RequiredName="
           + "\""
           + CFDbTestSchema.xmlEncodeString(getRequiredName())
           + "\""
           + "/>";
   return (ret);
 }
 public CFSecurityCursor openMemoDataCursorByMemoDataCtcIdx(
     CFSecurityAuthorization Authorization, long TenantId, long ContactId) {
   String sql =
       getSqlSelectMemoDataBuff()
           + " WHERE "
           + "mmod.tenantid = "
           + Long.toString(TenantId)
           + " "
           + "AND "
           + "mmod.contactid = "
           + Long.toString(ContactId)
           + " "
           + "ORDER BY "
           + "mmod.TenantId ASC"
           + ", "
           + "mmod.MemoId ASC";
   CFCrmCursor cursor = new CFCrmMSSqlCursor(Authorization, schema, sql);
   return (cursor);
 }
 public String toString() {
   String ret =
       "<CFSecurityHostNodeByClusterIdx"
           + " RequiredClusterId="
           + "\""
           + Long.toString(getRequiredClusterId())
           + "\""
           + "/>";
   return (ret);
 }
 public CFSecurityCursor openFeeDetailCursorByFeeIdx(
     CFSecurityAuthorization Authorization, long TenantId, long FeeId) {
   String sql =
       getSqlSelectFeeDetailBuff()
           + "WHERE "
           + "fedt.tenantid = "
           + Long.toString(TenantId)
           + " "
           + "AND "
           + "fedt.feeid = "
           + Long.toString(FeeId)
           + " "
           + "ORDER BY "
           + "fedt.TenantId ASC"
           + ", "
           + "fedt.FeeDetailId ASC";
   CFAccCursor cursor = new CFAccSybaseCursor(Authorization, schema, sql);
   return (cursor);
 }
 public String toString() {
   String ret =
       "<CFAccAccountContactByTenantIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + "/>";
   return (ret);
 }
 /** Find the data for a given id */
 public SOAPMonitorData findData(Long id) {
   SOAPMonitorData soap = null;
   for (int row = data.size(); (row > 0) && (soap == null); row--) {
     soap = (SOAPMonitorData) data.elementAt(row - 1);
     if (soap.getId().longValue() != id.longValue()) {
       soap = null;
     }
   }
   return soap;
 }
Example #30
0
  /** Sets up configuration based on params */
  private static boolean setup(Hashtable<String, String> curConf, Configuration argConf) {

    if (argConf.get("file") == null) {
      logger.fatal("Missing file parameter");
      System.exit(1);
    }

    if (argConf.get("hdfs_base_path") == null) {
      logger.fatal("Missing HDFS base path, check gestore-conf.xml");
      System.exit(1);
    }

    if (argConf.get("hdfs_temp_path") == null) {
      logger.fatal("Missing HDFS temp path, check gestore-conf.xml");
      System.exit(1);
    }

    if (argConf.get("local_temp_path") == null) {
      logger.fatal("Missing local temp path, check gestore-conf.xml");
      System.exit(1);
    }

    // Input paramaters
    curConf.put("run_id", argConf.get("run", ""));
    curConf.put("task_id", argConf.get("task", ""));
    curConf.put("file_id", argConf.get("file"));
    curConf.put("local_path", argConf.get("path", ""));
    curConf.put("type", argConf.get("type", "l2r"));
    curConf.put("timestamp_start", argConf.get("timestamp_start", "1"));
    curConf.put(
        "timestamp_stop", argConf.get("timestamp_stop", Integer.toString(Integer.MAX_VALUE)));
    curConf.put("delimiter", argConf.get("regex", "ID=.*"));
    curConf.put("taxon", argConf.get("taxon", "all"));
    curConf.put("intermediate", argConf.get("full_run", "false"));
    curConf.put("quick_add", argConf.get("quick_add", "false"));
    Boolean full_run = curConf.get("intermediate").matches("(?i).*true.*");
    curConf.put("format", argConf.get("format", "unknown"));
    curConf.put("split", argConf.get("split", "1"));
    curConf.put("copy", argConf.get("copy", "true"));

    // Constants
    curConf.put("base_path", argConf.get("hdfs_base_path"));
    curConf.put("temp_path", argConf.get("hdfs_temp_path"));
    curConf.put("local_temp_path", argConf.get("local_temp_path"));
    curConf.put("db_name_files", argConf.get("hbase_file_table"));
    curConf.put("db_name_runs", argConf.get("hbase_run_table"));
    curConf.put("db_name_updates", argConf.get("hbase_db_update_table"));

    // Timestamps
    Date currentTime = new Date();
    Date endDate = new Date(new Long(curConf.get("timestamp_stop")));
    curConf.put("timestamp_real", Long.toString(currentTime.getTime()));

    return true;
  }