Example usage for java.lang Long getLong

List of usage examples for java.lang Long getLong

Introduction

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

Prototype

public static Long getLong(String nm) 

Source Link

Document

Determines the long value of the system property with the specified name.

Usage

From source file:Main.java

public static void main(String[] args) {

    System.setProperty("Java2s.com", "12345");
    String str = "Java2s.com";
    System.out.println(Long.getLong(str));

}

From source file:org.LexGrid.LexBIG.caCore.utils.LexEVSCaCoreUtils.java

public static Object setFieldValue(Object input, Object value, String fieldName) throws Exception {
    Class searchClass = input.getClass();

    while (searchClass != null) {
        Field[] fields = searchClass.getDeclaredFields();
        for (Field field : fields) {
            if (field.getName().equals(fieldName)) {
                field.setAccessible(true);
                //Check to see if we're trying to set a int, long, etc with a String
                if (field.getType().getName().equals("java.lang.Long")) {
                    if (value instanceof String) {
                        field.set(input, Long.getLong((String) value));
                    } else {
                        field.set(input, value);
                    }/*w ww . ja  va 2s.c o  m*/
                } else if (field.getType().getName().equals("java.lang.Integer")) {
                    if (value instanceof String) {
                        field.set(input, Integer.getInteger((String) value));
                    } else {
                        field.set(input, value);
                    }
                } else {
                    field.set(input, value);
                }
            }
        }
        searchClass = searchClass.getSuperclass();
    }
    return input;
}

From source file:org.apache.stratos.cartridge.agent.statistics.publisher.HealthStatisticsNotifier.java

public HealthStatisticsNotifier() {
    this.statsPublisher = new HealthStatisticsPublisher();

    String interval = System.getProperty("stats.notifier.interval");
    if (interval != null) {
        statsPublisherInterval = Long.getLong(interval);
    }/*w ww  .j a  va  2 s  .  c o  m*/
}

From source file:org.apache.stratos.load.balancer.common.statistics.notifier.LoadBalancerStatisticsNotifier.java

public LoadBalancerStatisticsNotifier(LoadBalancerStatisticsReader statsReader) {
    this.statsReader = statsReader;
    this.inFlightRequestPublisher = new WSO2CEPInFlightRequestPublisher();

    String interval = System.getProperty("stats.notifier.interval");
    if (interval != null) {
        statsPublisherInterval = Long.getLong(interval);
    }//from w w w . j  a  va2 s .  c  o m
    if (log.isDebugEnabled()) {
        log.debug(String.format("stats.notifier.interval: %dms", statsPublisherInterval));
    }

    networkPartitionId = System.getProperty("network.partition.id");
    if (StringUtils.isBlank(networkPartitionId)) {
        throw new RuntimeException("network.partition.id system property was not found.");
    }
}

From source file:uk.ac.sanger.cgp.wwdocker.beans.WorkerResources.java

private void base_init(OperatingSystemMXBean osmxb) {
    String[] bits = ManagementFactory.getRuntimeMXBean().getName().split("@");
    pid = Long.getLong(bits[0]);
    totalMemBytes = osmxb.getTotalPhysicalMemorySize();
    availableProcessors = Runtime.getRuntime().availableProcessors();
    hostName = System.getenv("HOSTNAME");
    if (hostName == null) {
        try {//www .ja  va2  s  . c  o m
            hostName = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e) {
            throw new RuntimeException("Unable to determine hostname", e);
        }
    }
}

From source file:com.spectralogic.ds3cli.command.ModifyDataPolicy.java

@Override
public GetDataPoliciesResult call() throws IOException, CommandException {
    // get the target policy
    final GetDataPolicySpectraS3Response response = getClient()
            .getDataPolicySpectraS3(new GetDataPolicySpectraS3Request(this.policyId));
    final DataPolicy policy = response.getDataPolicyResult();

    // update this.policyId to the UUID in case we used name to select it and change the name
    this.policyId = policy.getId().toString();

    // apply changes from metadata
    final ModifyDataPolicySpectraS3Request modifyRequest = new ModifyDataPolicySpectraS3Request(this.policyId);
    for (final String paramChange : this.policyParams.keySet()) {
        final String paramNewValue = this.policyParams.get(paramChange);
        if ("blobbing_enabled".equalsIgnoreCase(paramChange)) {
            modifyRequest.withBlobbingEnabled(Boolean.parseBoolean(paramNewValue));
        } else if ("name".equalsIgnoreCase(paramChange)) {
            modifyRequest.withName(paramNewValue);
        } else if ("checksum_type".equalsIgnoreCase(paramChange)) {
            modifyRequest.withChecksumType(ChecksumType.Type.valueOf(paramNewValue));
        } else if ("default_blob_size".equalsIgnoreCase(paramChange)) {
            modifyRequest.withDefaultBlobSize(Long.getLong(paramNewValue));
        } else if ("default_get_job_priority".equalsIgnoreCase(paramChange)) {
            modifyRequest.withDefaultGetJobPriority(Priority.valueOf(paramNewValue));
        } else if ("default_put_job_priority".equalsIgnoreCase(paramChange)) {
            modifyRequest.withDefaultPutJobPriority(Priority.valueOf(paramNewValue));
        } else if ("default_verify_job_priority".equalsIgnoreCase(paramChange)) {
            modifyRequest.withDefaultVerifyJobPriority(Priority.valueOf(paramNewValue));
        } else if ("rebuild_priority".equalsIgnoreCase(paramChange)) {
            modifyRequest.withRebuildPriority(Priority.valueOf(paramNewValue));
        } else if ("end_to_end_crc_required".equalsIgnoreCase(paramChange)) {
            modifyRequest.withEndToEndCrcRequired(Boolean.parseBoolean(paramNewValue));
        } else if ("versioning".equalsIgnoreCase(paramChange)) {
            modifyRequest.withVersioning(VersioningLevel.valueOf(paramNewValue));
        } else {//from w  w  w  .  ja  v  a  2s  .  co  m
            throw new CommandException("Unrecognized Data Policy parameter: " + paramChange);
        }
    } // for

    // Apply changes
    final ModifyDataPolicySpectraS3Response modifyResponse = getClient()
            .modifyDataPolicySpectraS3(modifyRequest);
    return new GetDataPoliciesResult(modifyResponse.getDataPolicyResult());
}

From source file:org.kuali.mobility.shared.controllers.FileControllerTest.java

@Test
public void testRemoveFile() {
    MockHttpServletRequest request = new MockHttpServletRequest(servletContext);
    Model uiModel = new ExtendedModelMap();

    Long fileHash = Long.getLong("42");
    File file = new File();
    file.setId(fileHash);//from w w  w  . java  2s  .c o m

    when(getFileService().findFileById(fileHash)).thenReturn(file);
    when(getFileService().removeFile(file)).thenReturn(true);

    String viewName;
    try {
        viewName = getController().removeFile(uiModel, request, fileHash);
    } catch (Exception e) {
        LOG.error(e.getLocalizedMessage(), e);
        viewName = null;
    }
    assertTrue("Failed to remove file.", INDEX.equals(viewName));
}

From source file:nz.net.orcon.kanban.tools.CardConverter.java

@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
    Card card = new Card();

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    if ("id".equalsIgnoreCase(reader.getNodeName())) {
        card.setId(Long.getLong(reader.getValue()));
    }/*  w w w.  ja  va 2  s  .  c  om*/
    if ("template".equalsIgnoreCase(reader.getNodeName())) {
        card.setTemplate(reader.getValue());
    }
    if ("creator".equalsIgnoreCase(reader.getNodeName())) {
        card.setCreator(reader.getValue());
    }
    if ("created".equalsIgnoreCase(reader.getNodeName())) {
        Date createdDate = null;
        try {
            createdDate = simpleDateFormat.parse(reader.getValue());
        } catch (ParseException e) {
            e.printStackTrace();
        }
        card.setCreated(createdDate);
    }

    if ("modifiedby".equalsIgnoreCase(reader.getNodeName())) {
        card.setModifiedby(reader.getValue());
    }
    if ("modified".equalsIgnoreCase(reader.getNodeName())) {
        Date modifiedDate = null;
        try {
            modifiedDate = simpleDateFormat.parse(reader.getValue());
        } catch (ParseException e) {
            e.printStackTrace();
        }
        card.setModified(modifiedDate);
    }
    if ("color".equalsIgnoreCase(reader.getNodeName())) {
        card.setColor(reader.getValue());
    }

    Map<String, Object> map = new HashMap<String, Object>();
    while (reader.hasMoreChildren()) {
        reader.moveDown();
        map.put(reader.getNodeName(), reader.getValue());
        reader.moveUp();
    }
    card.setFields(map);
    if ("tasks".equalsIgnoreCase(reader.getNodeName())) {
        card.setTasks(new Long(reader.getValue()));
    }
    if ("history".equalsIgnoreCase(reader.getNodeName())) {
        card.setHistory(new Long(reader.getValue()));
    }
    if ("comments".equalsIgnoreCase(reader.getNodeName())) {
        card.setComments(new Long(reader.getValue()));
    }
    if ("alerts".equalsIgnoreCase(reader.getNodeName())) {
        card.setAlerts(new Long(reader.getValue()));
    }
    return card;
}

From source file:org.kuali.mobility.shared.controllers.FileControllerTest.java

@Test
public void testRemoveFileNullFile() {
    MockHttpServletRequest request = new MockHttpServletRequest(servletContext);
    Model uiModel = new ExtendedModelMap();

    Long fileHash = Long.getLong("42");

    when(getFileService().findFileById(fileHash)).thenReturn(null);

    String viewName;//from   www . j  a  va2s  . com
    try {
        viewName = getController().removeFile(uiModel, request, fileHash);
    } catch (Exception e) {
        LOG.error(e.getLocalizedMessage(), e);
        viewName = null;
    }
    assertTrue("Failed to remove file.", INDEX.equals(viewName));
}

From source file:org.apache.stratos.cloud.controller.iaases.kubernetes.KubernetesIaas.java

public KubernetesIaas(IaasProvider iaasProvider) {
    super(iaasProvider);
    partitionValidator = new KubernetesPartitionValidator();
    payload = new ArrayList<>();

    podActivationTimeout = Long.getLong("stratos.pod.activation.timeout");
    if (podActivationTimeout == null) {
        podActivationTimeout = DEFAULT_POD_ACTIVATION_TIMEOUT;
        if (log.isInfoEnabled()) {
            log.info("Pod activation timeout was set: " + podActivationTimeout);
        }/*from w  w w .  j  a v a  2s  .co m*/
    }
}