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());
 }
Example #2
0
 /** Try to convert a string value into a numerical value. */
 private static Number createNumberFromStringValue(String value) throws NumberFormatException {
   final String suffix = value.substring(value.length() - 1);
   if ("L".equalsIgnoreCase(suffix)) {
     return Long.valueOf(value.substring(0, value.length() - 1));
   }
   if ("F".equalsIgnoreCase(suffix)) {
     return Float.valueOf(value.substring(0, value.length() - 1));
   }
   if ("D".equalsIgnoreCase(suffix)) {
     return Double.valueOf(value.substring(0, value.length() - 1));
   }
   try {
     return Integer.valueOf(value);
   } catch (NumberFormatException e) {
     // OK: Ignore exception...
   }
   try {
     return Long.valueOf(value);
   } catch (NumberFormatException e1) {
     // OK: Ignore exception...
   }
   try {
     return Double.valueOf(value);
   } catch (NumberFormatException e2) {
     // OK: Ignore exception...
   }
   throw new NumberFormatException(
       "Cannot convert string value '" + value + "' into a numerical value");
 }
  public String getCompUniqueID() {
    UUID tempID = null;
    long longID = 0L;
    StringBuffer result = new StringBuffer();

    tempID = getId();

    result.append(Long.toHexString(tempID.getMostSignificantBits()));
    result.append(Long.toHexString(tempID.getLeastSignificantBits()));
    return result.toString();
  }
 /**
  * Create a channel with the given capacity and semaphore implementations instantiated from the
  * supplied class
  *
  * @exception IllegalArgumentException if capacity less or equal to zero.
  * @exception NoSuchMethodException If class does not have constructor that intializes permits
  * @exception SecurityException if constructor information not accessible
  * @exception InstantiationException if semaphore class is abstract
  * @exception IllegalAccessException if constructor cannot be called
  * @exception InvocationTargetException if semaphore constructor throws an exception
  */
 public SemaphoreControlledChannel(int capacity, Class semaphoreClass)
     throws IllegalArgumentException, NoSuchMethodException, SecurityException,
         InstantiationException, IllegalAccessException, InvocationTargetException {
   if (capacity <= 0) throw new IllegalArgumentException();
   capacity_ = capacity;
   Class[] longarg = {Long.TYPE};
   Constructor ctor = semaphoreClass.getDeclaredConstructor(longarg);
   Object[] cap = {Long.valueOf(capacity)};
   putGuard_ = (Semaphore) (ctor.newInstance(/*(Object[]) GemStoneAddition*/ cap));
   Object[] zero = {Long.valueOf(0)};
   takeGuard_ = (Semaphore) (ctor.newInstance(/*(Object[]) GemStoneAddition*/ zero));
 }
  public String getCompUniqueID() {
    UUID tempID = null;
    long longID = 0L;
    StringBuffer result = new StringBuffer();

    tempID = getArg_id();

    if (IdAssigner.NULL_UUID.equals(tempID)) tempID = getArg_idCachedValue();
    result.append(Long.toHexString(tempID.getMostSignificantBits()));
    result.append(Long.toHexString(tempID.getLeastSignificantBits()));
    return result.toString();
  }
Example #6
0
 public void dispatchEvent(XEvent ev) {
   super.dispatchEvent(ev);
   switch (ev.get_type()) {
     case XConstants.CreateNotify:
       XCreateWindowEvent cr = ev.get_xcreatewindow();
       if (xembedLog.isLoggable(PlatformLogger.FINEST)) {
         xembedLog.finest("Message on embedder: " + cr);
       }
       if (xembedLog.isLoggable(PlatformLogger.FINER)) {
         xembedLog.finer(
             "Create notify for parent "
                 + Long.toHexString(cr.get_parent())
                 + ", window "
                 + Long.toHexString(cr.get_window()));
       }
       embedChild(cr.get_window());
       break;
     case XConstants.DestroyNotify:
       XDestroyWindowEvent dn = ev.get_xdestroywindow();
       if (xembedLog.isLoggable(PlatformLogger.FINEST)) {
         xembedLog.finest("Message on embedder: " + dn);
       }
       if (xembedLog.isLoggable(PlatformLogger.FINER)) {
         xembedLog.finer("Destroy notify for parent: " + dn);
       }
       childDestroyed();
       break;
     case XConstants.ReparentNotify:
       XReparentEvent rep = ev.get_xreparent();
       if (xembedLog.isLoggable(PlatformLogger.FINEST)) {
         xembedLog.finest("Message on embedder: " + rep);
       }
       if (xembedLog.isLoggable(PlatformLogger.FINER)) {
         xembedLog.finer(
             "Reparent notify for parent "
                 + Long.toHexString(rep.get_parent())
                 + ", window "
                 + Long.toHexString(rep.get_window())
                 + ", event "
                 + Long.toHexString(rep.get_event()));
       }
       if (rep.get_parent() == getWindow()) {
         // Reparented into us - embed it
         embedChild(rep.get_window());
       } else {
         // Reparented out of us - detach it
         childDestroyed();
       }
       break;
   }
 }
 public String toString() {
   String ret =
       "<CFBamScopePKey"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredId="
           + "\""
           + Long.toString(getRequiredId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFBamPopDepByRelationIdx"
           + " RequiredRelationTenantId="
           + "\""
           + Long.toString(getRequiredRelationTenantId())
           + "\""
           + " RequiredRelationId="
           + "\""
           + Long.toString(getRequiredRelationId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFFreeSwitchPbxIvrMenuEntryByMenuIdIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredMenuId="
           + "\""
           + Long.toString(getRequiredMenuId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFCrmMemoTagByTagIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredTagId="
           + "\""
           + Long.toString(getRequiredTagId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFBamTimeColByTableIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredTableId="
           + "\""
           + Long.toString(getRequiredTableId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFDbTestValueByScopeIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredScopeId="
           + "\""
           + Long.toString(getRequiredScopeId())
           + "\""
           + "/>";
   return (ret);
 }
 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 =
       "<CFBamClearTopDepByContTblIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredContTableId="
           + "\""
           + Long.toString(getRequiredContTableId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFAsteriskClusterId64Gen"
           + " RequiredId="
           + "\""
           + Long.toString(getRequiredId())
           + "\""
           + ", SliceId=\""
           + Short.toString(getRequiredSliceId())
           + "\""
           + ", NextId=\""
           + Long.toString(nextId)
           + "\"/>";
   return (ret);
 }
Example #17
0
 private static Object parseValue(String value, Prop p, Class type) {
   Object v = value;
   if (type.isArray()) {
     StringTokenizer st = new StringTokenizer(value, ",");
     Class ctype = type.getComponentType();
     v = Array.newInstance(ctype, st.countTokens());
     for (int i = 0; st.hasMoreTokens(); i++)
       Array.set(v, i, parseValue(st.nextToken(), p, ctype));
   } else if (type == boolean.class) {
     v = Boolean.valueOf(value);
   } else if (type == double.class) {
     v = Double.valueOf(value);
   } else if (type == int.class) {
     v = Integer.valueOf(value);
   } else if (p.field.isAnnotationPresent(TimeIntervalProp.class)) {
     if (value.endsWith("s")) {
       v = (long) (Double.parseDouble(value.substring(0, value.length() - 1)) * SEC);
     } else if (value.endsWith("m")) {
       v = (long) (Double.parseDouble(value.substring(0, value.length() - 1)) * MIN);
     } else {
       v = Long.valueOf(value);
     }
   }
   return v;
 }
Example #18
0
 /**
  * Helper method used to get default value for wrappers used for primitive types (0 for Integer
  * etc)
  *
  * @since 1.6.1
  */
 public static Object defaultValue(Class<?> cls) {
   if (cls == Integer.TYPE) {
     return Integer.valueOf(0);
   }
   if (cls == Long.TYPE) {
     return Long.valueOf(0L);
   }
   if (cls == Boolean.TYPE) {
     return Boolean.FALSE;
   }
   if (cls == Double.TYPE) {
     return Double.valueOf(0.0);
   }
   if (cls == Float.TYPE) {
     return Float.valueOf(0.0f);
   }
   if (cls == Byte.TYPE) {
     return Byte.valueOf((byte) 0);
   }
   if (cls == Short.TYPE) {
     return Short.valueOf((short) 0);
   }
   if (cls == Character.TYPE) {
     return '\0';
   }
   throw new IllegalArgumentException("Class " + cls.getName() + " is not a primitive type");
 }
    /** Return the next possible capacity, counting from the current buffers' size. */
    protected int nextCapacity(int current) {
      assert current > 0 && Long.bitCount(current) == 1 : "Capacity must be a power of two.";
      assert ((current << 1) > 0) : "Maximum capacity exceeded (" + (0x80000000 >>> 1) + ").";

      if (current < MIN_CAPACITY / 2) current = MIN_CAPACITY / 2;
      return current << 1;
    }
  public static Object[] stringToObject(String[] str, Type[] type) {

    Object[] oArr = new Object[str.length];

    for (int i = 0; i < oArr.length; i++) {
      // 基本データ型の場合
      System.out.println("type: " + type[i].toString());
      if (type[i].equals(String.class) || type[i].equals(String.class.getSuperclass())) {
        oArr[i] = str[i];
      } else if (type[i].equals(Boolean.TYPE)) {
        oArr[i] = Boolean.parseBoolean(str[i]);
      } else if (type[i].equals(Integer.TYPE)) {
        oArr[i] = Integer.parseInt(str[i]);
      } else if (type[i].equals(Double.TYPE)) {
        oArr[i] = Double.parseDouble(str[i]);
      } else if (type[i].equals(Long.TYPE)) {
        oArr[i] = Long.parseLong(str[i]);
      } else if (type[i].equals(Short.TYPE)) {
        oArr[i] = Short.parseShort(str[i]);
      } else if (type[i].equals(Character.TYPE)) {
        oArr[i] = str[i].charAt(0);
      } else if (type[i].equals(Byte.TYPE)) {
        oArr[i] = Byte.parseByte(str[i]);
      } else if (type[i].equals(Float.TYPE)) {
        oArr[i] = Float.parseFloat(str[i]);
      }
      // 基本データ型以外の場合:forName()でクラスオブジェクトを取得
      else {
        //				return Class.forName(strip(o.getClass().toString(), "class "));
        System.out.println("基本データ型");
      }
    }
    return oArr;
  }
 public String toString() {
   String ret =
       "<CFFreeSwitchFSSFDialerHPKey"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredFSSFDialerId="
           + "\""
           + Long.toString(getRequiredFSSFDialerId())
           + "\""
           + " RequiredRevision=\""
           + Integer.toString(getRequiredRevision())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFBamValueHPKey"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + " RequiredId="
           + "\""
           + Long.toString(getRequiredId())
           + "\""
           + " RequiredRevision=\""
           + Integer.toString(getRequiredRevision())
           + "\""
           + "/>";
   return (ret);
 }
Example #23
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 String toString() {
   String ret =
       "<CFSecurityHostNodeByClusterIdx"
           + " RequiredClusterId="
           + "\""
           + Long.toString(getRequiredClusterId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFAccAccountContactByTenantIdx"
           + " RequiredTenantId="
           + "\""
           + Long.toString(getRequiredTenantId())
           + "\""
           + "/>";
   return (ret);
 }
Example #28
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;
  }
Example #29
0
 public void genSeed(ActionEvent e) {
   long seed = 0;
   boolean redo = false;
   do {
     redo = false;
     String seedString =
         JOptionPane.showInputDialog(
             this, "Enter a number:", Long.toString(rand.nextLong(), 36)
             // "Random Seed", JOptionPane.QUESTION_MESSAGE
             );
     if (seedString == null) return;
     try {
       seed = Long.parseLong(seedString, 36);
     } catch (NumberFormatException ex) {
       JOptionPane.showMessageDialog(this, "Use only letters and numbers, max 12 characters.");
       redo = true;
     }
   } while (redo);
   genSeed(seed);
 }
Example #30
0
 void endDispatching() {
   xembedLog.fine("End dispatching for " + Long.toHexString(xembed.handle));
   XToolkit.awtLock();
   try {
     XDropTargetRegistry.getRegistry().unregisterXEmbedClient(getWindow(), xembed.handle);
     // We can't deselect input since someone else might be interested in it
     XToolkit.removeEventDispatcher(xembed.handle, xembed);
   } finally {
     XToolkit.awtUnlock();
   }
 }