Example usage for java.lang Long longValue

List of usage examples for java.lang Long longValue

Introduction

In this page you can find the example usage for java.lang Long longValue.

Prototype

@HotSpotIntrinsicCandidate
public long longValue() 

Source Link

Document

Returns the value of this Long as a long value.

Usage

From source file:com.tc.server.UpdateCheckAction.java

private static long checkPeriodMillis(int days) {
    Long minutes = Long.getLong("terracotta.update-checker.next-check-minutes");
    long nextCheckTime;

    if (minutes != null) {
        nextCheckTime = minutes.longValue() * 60 * 1000;
    } else {//w  ww .  ja v  a2 s.  c om
        nextCheckTime = 1000L * 60 * 60 * 24 * days;
    }

    return nextCheckTime;
}

From source file:org.spc.ofp.observer.domain.TripIdRepository.java

private static String buildGearAndYearQuery(final Long limit, String... years) {
    final StringBuilder sb = new StringBuilder(GEAR_AND_YEAR_QUERY);
    if (null != years && years.length > 0) {
        final Joiner joiner = Joiner.on(" OR ").skipNulls();
        sb.append(" AND (").append(joiner.join(years)).append(")");
    }//from   w ww  .  j  a v a  2 s  . co m
    if (null != limit && limit.longValue() > 0L) {
        sb.append(" LIMIT ").append(limit.intValue());
    }
    return sb.toString();
}

From source file:com.morty.podcast.writer.PodCastUtils.java

/**
 * Gets the duration of an audio file.// w  w  w . j ava2  s. c o  m
 * @param file
 * @return the number of milliseconds in the file
 * @throws UnsupportedAudioFileException
 * @throws IOException
 */
public static long getDurationWithMp3Spi(File file) throws UnsupportedAudioFileException, IOException {
    m_logger.info("Determining length of MP3 file");

    AudioFileFormat audioFile = AudioSystem.getAudioFileFormat(file);
    if (audioFile instanceof TAudioFileFormat) {
        m_logger.debug("TAudioFileFormat file found");
        Map<?, ?> properties = ((TAudioFileFormat) audioFile).properties();
        String key = "duration";
        Long numberOfMicroseconds = (Long) properties.get(key);
        m_logger.info("Duration of [" + numberOfMicroseconds + "] microseconds");
        return (numberOfMicroseconds.longValue() / 1000);
    } else {
        m_logger.info("Unsupported Mp3 fileformat.");
        throw new UnsupportedAudioFileException();
    }

}

From source file:com.tesora.dve.sql.parser.TimestampVariableUtils.java

/**
 * The value of 'timestamp' session variable. Can be overriden by DVE
 * 'dve_repl_slave_timestamp' variable if set to a non-zero value.
 * //ww  w.  j a  v  a2  s.co m
 * @return The current time in seconds.
 */
public static long getCurrentUnixTime(ConnectionContext cc) {
    final Long replicationSlaveTimestamp = KnownVariables.REPL_TIMESTAMP.getValue(cc.getVariableSource());
    if ((replicationSlaveTimestamp != null) && (replicationSlaveTimestamp.longValue() != 0L)) {
        return replicationSlaveTimestamp;
    }

    return KnownVariables.TIMESTAMP.getValue(cc.getVariableSource());
}

From source file:com.liangc.hq.base.utils.AlertDefUtil.java

/**
 * <p>/*from ww w . j av  a  2  s.  c  om*/
 * Return the duration and units for the passed-in number of seconds. The
 * first element of the returned array will be the duration. The second
 * element in the returned array will be one of
 * <code>org.hyperic.hq.ui.Constants.ALERT_ACTION_ENABLE_UNITS_SECONDS,
 * org.hyperic.hq.ui.Constants.ALERT_ACTION_ENABLE_UNITS_MINUTES,
 * org.hyperic.hq.ui.Constants.ALERT_ACTION_ENABLE_UNITS_HOURS,
 * org.hyperic.hq.ui.Constants.ALERT_ACTION_ENABLE_UNITS_DAYS,
 * org.hyperic.hq.ui.Constants.ALERT_ACTION_ENABLE_UNITS_WEEKS</code>.
 * </p>
 * 
 * @param seconds number of seconds <b>(will be updated)</b>
 * @return two-element Long array
 */
public static Long[] getDurationAndUnits(Long seconds) {
    Long[] retVal = new Long[2];
    long secs = seconds.longValue();
    if (secs % Constants.SECS_IN_WEEK == 0) {
        retVal[0] = new Long(secs / Constants.SECS_IN_WEEK);
        retVal[1] = new Long(Constants.ALERT_ACTION_ENABLE_UNITS_WEEKS);
    } else if (secs % Constants.SECS_IN_DAY == 0) {
        retVal[0] = new Long(secs / Constants.SECS_IN_DAY);
        retVal[1] = new Long(Constants.ALERT_ACTION_ENABLE_UNITS_DAYS);
    } else if (secs % Constants.SECS_IN_HOUR == 0) {
        retVal[0] = new Long(secs / Constants.SECS_IN_HOUR);
        retVal[1] = new Long(Constants.ALERT_ACTION_ENABLE_UNITS_HOURS);
    } else if (secs % Constants.SECS_IN_MINUTE == 0) {
        retVal[0] = new Long(secs / Constants.SECS_IN_MINUTE);
        retVal[1] = new Long(Constants.ALERT_ACTION_ENABLE_UNITS_MINUTES);
    } else {
        retVal[0] = seconds;
        retVal[1] = new Long(Constants.ALERT_ACTION_ENABLE_UNITS_SECONDS);
    }
    return retVal;
}

From source file:com.emc.ecs.EcsBufferedWriter.java

protected static WriterTask createTask(CommandLine line) throws Exception {

    WriterTask task;// w  w w  .j a v a  2 s  .co m

    // Special check for version
    if (line.hasOption(VERSION_OPTION)) {
        //System.out.println(versionLine());
        System.out.println("JMC 1.0");
        System.exit(0);
    }

    //LogManager.getRootLogger().setLevel(Level.INFO);
    //this.l4j.
    //LogManager.getRootLogger().addAppender(new FileAppender());
    // check required options
    boolean status = true;
    if (line.hasOption(ENDPOINT_OPTION) == false) {
        status = false;
        System.out.println("Missing endpoint option");
    }
    if (line.hasOption(ACCESS_KEY_OPTION) == false) {
        status = false;
        System.out.println("Missing access key option");
    }
    if (line.hasOption(SECRET_KEY_OPTION) == false) {
        status = false;
        System.out.println("Missing secret key option");
    }
    if (line.hasOption(BUCKET_OPTION) == false) {
        status = false;
        System.out.println("Missing bucket option");
    }
    if (line.hasOption(KEY_OPTION) == false) {
        status = false;
        System.out.println("Missing key/file option");
    }
    if (line.getArgs().length == 0) {
        status = false;
        //JMC tailbuf is undocumented because that last partially filled buffer doesn't
        //flush if it's just hanging around waiting
        System.out.println("Missing initial command option (write|append|tail)");
    }
    if (status == false) {
        help();
        System.exit(1);
    }

    String command = line.getArgs()[0];

    // parse endpoint string
    String[] endpointStrings = line.getOptionValues(ENDPOINT_OPTION);
    ////////////////////////////////////
    /*
    Protocol protocol = Protocol.HTTPS;
    int port = -1;
    List<Vdc> vdcList = new ArrayList<Vdc>();
    for (String endpointString : endpointStrings) {
    URI endpoint = new URI(endpointString);
            
    // check for just a host
    if (endpointString.matches("^[a-zA-Z0-9.-]*$"))
        endpoint = new URI(null, endpointString, null, null);
            
    // get protocol
    if (endpoint.getScheme() != null) protocol = Protocol.valueOf(endpoint.getScheme().toUpperCase());
            
    // get port
    port = endpoint.getPort();
            
    vdcList.add(new Vdc(endpoint.getHost()));
    }
            
    // create S3 config
    S3Config s3Config = new S3Config(protocol, vdcList.toArray(new Vdc[vdcList.size()])).withPort(port);
    s3Config.withIdentity(line.getOptionValue(ACCESS_KEY_OPTION)).withSecretKey(line.getOptionValue(SECRET_KEY_OPTION));
    //s3Config.setProperty(S3Config.PROPERTY_DISABLE_HEALTH_CHECK, true);
    */
    ///////
    S3Config s3Config = new S3Config(new URI(endpointStrings[0]));
    s3Config.withIdentity(line.getOptionValue(ACCESS_KEY_OPTION))
            .withSecretKey(line.getOptionValue(SECRET_KEY_OPTION));
    if (line.hasOption(NAMESPACE_OPTION) == true) {
        String ns = new String(line.getOptionValue(NAMESPACE_OPTION));
        System.err.println("Creating s3Config with namespace: " + ns);
        s3Config.withNamespace(ns);
    }
    l4j.debug(s3Config);

    S3Client s3Client = new S3JerseyClient(s3Config);
    String bucket = line.getOptionValue(BUCKET_OPTION);
    // figure out file/key name
    String key = line.getOptionValue(KEY_OPTION);

    System.err.println("executing command: " + command);
    //if stream to ecs
    if (WRITE_COMMAND.equals(command)) {
        System.err.println("Found matching write command");
        StreamToEcs ste = new StreamToEcs(s3Client, bucket, key, StreamToEcs.DOWRITE);
        task = new WriterTask(ste);
    } else if (APPEND_COMMAND.equals(command)) {
        System.err.println("Found matching append command");
        StreamToEcs ste = new StreamToEcs(s3Client, bucket, key, StreamToEcs.DOAPPEND);
        task = new WriterTask(ste);
    }
    //else if tail from ecs
    else if (TAILBYTE_COMMAND.equals(command)) {
        System.err.println("Found matching tail command");
        TailFromEcs tfe = new TailFromEcs(s3Client, bucket, key, TailFromEcs.TAILBYTE);
        task = new WriterTask(tfe);
    } else if (TAIL_COMMAND.equals(command)) {
        System.err.println("Found matching tailbuf command");
        TailFromEcs tfe = new TailFromEcs(s3Client, bucket, key, TailFromEcs.TAIL);
        if (line.hasOption(BYTES_FROM_END_OPTION) == true) {
            Long bytesFromEnd = new Long(line.getOptionValue(BYTES_FROM_END_OPTION));
            tfe.bytesFromEnd = bytesFromEnd.longValue();
            System.err.println("tailing " + bytesFromEnd + " bytes from EOF");

        }
        task = new WriterTask(tfe);
    }
    //else... not sure
    else {
        throw new RuntimeException("unrecognized command word");
    }

    return (task);
}

From source file:com.kcs.core.utilities.Utility.java

public static String getXmlLongString(Long o) {
    if (Utility.isNull(o) || o.longValue() == 0) {
        return StringUtil.BLANK;
    } else {//from  w  w  w  .  jav a  2s .  c  o m
        return o.toString();
    }
}

From source file:Main.java

/**
 * <p>Converts an array of object Long to primitives handling {@code null}.</p>
 *
 * <p>This method returns {@code null} for a {@code null} input array.</p>
 *
 * @param array  a {@code Long} array, may be {@code null}
 * @param valueForNull  the value to insert if {@code null} found
 * @return a {@code long} array, {@code null} if null array input
 *//*from   www  .jav  a2  s. c  o  m*/
public static long[] toPrimitive(Long[] array, long valueForNull) {
    if (array == null) {
        return null;
    } else if (array.length == 0) {
        return EMPTY_LONG_ARRAY;
    }
    final long[] result = new long[array.length];
    for (int i = 0; i < array.length; i++) {
        Long b = array[i];
        result[i] = (b == null ? valueForNull : b.longValue());
    }
    return result;
}

From source file:Main.java

/**
 * <p>Converts an array of object Long to primitives handling {@code null}.</p>
 *
 * <p>This method returns {@code null} for a {@code null} input array.</p>
 *
 * @param array  a {@code Long} array, may be {@code null}
 * @param valueForNull  the value to insert if {@code null} found
 * @return a {@code long} array, {@code null} if null array input
 *//*  w  w  w. j av  a 2s . com*/
public static long[] toPrimitive(final Long[] array, final long valueForNull) {
    if (array == null) {
        return null;
    } else if (array.length == 0) {
        return EMPTY_LONG_ARRAY;
    }
    final long[] result = new long[array.length];
    for (int i = 0; i < array.length; i++) {
        final Long b = array[i];
        result[i] = (b == null ? valueForNull : b.longValue());
    }
    return result;
}

From source file:com.meetup.memcached.NativeHandler.java

protected static Double decodeDouble(byte[] b) throws Exception {
    Long l = decodeLong(b);
    return Double.valueOf(Double.longBitsToDouble(l.longValue()));
}