Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

Configurator.java 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package org.apache.poi.util;
  2. /* ====================================================================
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. ==================================================================== */
  16. import org.apache.logging.log4j.LogManager;
  17. import org.apache.logging.log4j.Logger;
  18. /**
  19. * Helper for fetching int values from system properties
  20. */
  21. public class Configurator {
  22. private static final Logger LOG = LogManager.getLogger(Configurator.class);
  23. public static int getIntValue(String systemProperty, int defaultValue) {
  24. String property = System.getProperty(systemProperty);
  25. if (property == null || "".equals(property) || "null".equals(property)) {
  26. return defaultValue;
  27. }
  28. try {
  29. return Integer.parseInt(property);
  30. } catch (Exception e) {
  31. LOG.atError().log("System property -D{} does not contains a valid integer: {}", systemProperty, property);
  32. return defaultValue;
  33. }
  34. }
  35. }