Example usage for java.lang Integer decode

List of usage examples for java.lang Integer decode

Introduction

In this page you can find the example usage for java.lang Integer decode.

Prototype

public static Integer decode(String nm) throws NumberFormatException 

Source Link

Document

Decodes a String into an Integer .

Usage

From source file:org.apache.tajo.validation.MinValidator.java

@Override
protected <T> boolean validateInternal(T object) {
    boolean result = false;

    if (object != null) {
        if ((object instanceof Byte) || (object instanceof Short) || (object instanceof Integer)) {
            Integer objInteger = Integer.decode(object.toString());
            Integer minInteger = Integer.decode(minValue);
            result = objInteger.compareTo(minInteger) >= 0;
        } else if (object instanceof Long) {
            Long objLong = Long.decode(object.toString());
            Long minLong = Long.decode(minValue);
            result = objLong.compareTo(minLong) >= 0;
        } else if ((object instanceof Float) || (object instanceof Double)) {
            Double objDouble = Double.valueOf(object.toString());
            Double minDouble = Double.valueOf(minValue);
            result = objDouble.compareTo(minDouble) >= 0;
        } else if (object instanceof BigInteger) {
            BigInteger objInteger = (BigInteger) object;
            BigInteger minInteger = new BigInteger(minValue);
            result = objInteger.compareTo(minInteger) >= 0;
        } else if (object instanceof BigDecimal) {
            BigDecimal objDecimal = (BigDecimal) object;
            BigDecimal minDecimal = new BigDecimal(minValue);
            result = objDecimal.compareTo(minDecimal) >= 0;
        } else if (object instanceof String) {
            BigDecimal objDecimal = new BigDecimal((String) object);
            BigDecimal minDecimal = new BigDecimal(minValue);
            result = objDecimal.compareTo(minDecimal) >= 0;
        }/*from  w  w  w  . ja v a  2  s .c  o m*/
    } else {
        result = true;
    }

    return result;
}

From source file:org.dcm4che2.tool.chess3d.Chess3D.java

public static void main(String[] args) throws ParserConfigurationException, SAXException {
    try {/*from w w w  . ja v  a  2s  .  c om*/
        CommandLine cl = parse(args);
        Chess3D extruder = new Chess3D();
        if (cl.hasOption("d")) {
            extruder.setDest(cl.getOptionValue("d"));
        }
        if (cl.hasOption("t")) {
            extruder.setThickness(Float.parseFloat(cl.getOptionValue("thickness")));
        }
        if (cl.hasOption("l")) {
            extruder.setLocation(cl.getOptionValue("l"));
        }
        if (cl.hasOption("x")) {
            extruder.setRectWidth(Integer.parseInt(cl.getOptionValue("x")));
        }
        if (cl.hasOption("y")) {
            extruder.setRectHeight(Integer.parseInt(cl.getOptionValue("y")));
        }
        if (cl.hasOption("X")) {
            extruder.setXRect(Integer.parseInt(cl.getOptionValue("X")));
        }
        if (cl.hasOption("Y")) {
            extruder.setYRect(Integer.parseInt(cl.getOptionValue("Y")));
        }
        if (cl.hasOption("Z")) {
            extruder.setZRect(Integer.parseInt(cl.getOptionValue("Z")));
        }
        if (cl.hasOption("w")) {
            extruder.setWhite((byte) Integer.decode(cl.getOptionValue("w")).intValue());
        }
        if (cl.hasOption("b")) {
            extruder.setBlack((byte) Integer.decode(cl.getOptionValue("b")).intValue());
        }
        if (cl.hasOption("win")) {
            extruder.setWindow(cl.getOptionValue("win"));
        }
        if (cl.hasOption("uid")) {
            UIDUtils.setRoot(cl.getOptionValue("uid"));
        }
        if (cl.hasOption("S")) {
            extruder.setStudyUID(UIDUtils.createUID());
        }
        if (cl.hasOption("s")) {
            extruder.setSeriesUID(UIDUtils.createUID());
        }
        List argList = cl.getArgList();
        int idx = 0;
        File dcmFile = argList.size() > 1 ? new File((String) argList.get(idx++)) : null;
        int slices = Integer.parseInt((String) argList.get(idx));
        long start = System.currentTimeMillis();
        extruder.extrude(dcmFile, slices);
        long fin = System.currentTimeMillis();
        System.out.println("\n3D chess object created in " + (fin - start) + "ms. Chess cuboid: ("
                + extruder.xRect + "," + extruder.yRect + "," + extruder.zRect + "):\n" + "width:"
                + extruder.rectWidth + " height:" + extruder.rectHeight + " slices/field:" + slices + "\n"
                + "Files (all slices):" + (slices * extruder.zRect) + " slices (" + extruder.thickness
                + " mm).\nBlack:" + (extruder.black & 0x0ff) + " White:" + (extruder.white & 0x0ff));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:org.kchine.rpf.ServerDefaults.java

public static void init() {

    _namingMode = System.getProperty("naming.mode") != null && !System.getProperty("naming.mode").equals("")
            ? System.getProperty("naming.mode")
            : DEFAULT_NAMING_MODE;//from   w  w w  .j  a  v a  2  s  . co m

    System.out.println("----> naming mode :" + _namingMode);

    _servantPoolPrefix = System.getProperty("prefix") != null && !System.getProperty("prefix").equals("")
            ? System.getProperty("prefix")
            : DEFAULT_PREFIX;

    _registryHost = System.getProperty("registry.host") != null
            && !System.getProperty("registry.host").equals("") ? System.getProperty("registry.host")
                    : DEFAULT_REGISTRY_HOST;
    _registryPort = System.getProperty("registry.port") != null
            && !System.getProperty("registry.port").equals("")
                    ? Integer.decode(System.getProperty("registry.port"))
                    : DEFAULT_REGISTRY_PORT;
    _memoryMin = System.getProperty("memorymin") != null && !System.getProperty("memorymin").equals("")
            ? Integer.decode(System.getProperty("memorymin"))
            : DEFAULT_MEMORY_MIN;
    _memoryMax = System.getProperty("memorymax") != null && !System.getProperty("memorymax").equals("")
            ? Integer.decode(System.getProperty("memorymax"))
            : DEFAULT_MEMORY_MAX;

    String _DB_TYPE = System.getProperty("db.type") != null && !System.getProperty("db.type").equals("")
            ? System.getProperty("db.type")
            : DEFAULT_DB_TYPE;
    String _DB_HOST = System.getProperty("db.host") != null && !System.getProperty("db.host").equals("")
            ? System.getProperty("db.host")
            : DEFAULT_DB_HOST;
    int _DB_PORT = System.getProperty("db.port") != null && !System.getProperty("db.port").equals("")
            ? Integer.decode(System.getProperty("db.port"))
            : DEFAULT_DB_PORT;
    String _DB_NAME = System.getProperty("db.name") != null && !System.getProperty("db.name").equals("")
            ? System.getProperty("db.name")
            : DEFAULT_DB_NAME;
    String _DB_DIR = System.getProperty("db.dir") != null && !System.getProperty("db.dir").equals("")
            ? System.getProperty("db.dir")
            : DEFAULT_DB_DIR;
    _DB_DIR = _DB_DIR.replace('\\', '/');
    if (!_DB_DIR.equals("") && !_DB_DIR.endsWith("/"))
        _DB_DIR = _DB_DIR + "/";

    if (_DB_TYPE.equals("derby")) {
        _dbUrl = "jdbc:derby://" + _DB_HOST + ":" + _DB_PORT + "/" + _DB_DIR + _DB_NAME + ";create=true";
        _dbDriver = "org.apache.derby.jdbc.ClientDriver";
    } else if (_DB_TYPE.equals("mysql")) {
        _dbUrl = "jdbc:mysql://" + _DB_HOST + ":" + _DB_PORT + "/" + _DB_NAME;
        _dbDriver = "org.gjt.mm.mysql.Driver";

    } else if (_DB_TYPE.equals("oracle")) {
        _dbUrl = "jdbc:oracle:thin:@" + _DB_HOST + ":" + _DB_PORT + ":" + _DB_NAME;
        _dbDriver = "oracle.jdbc.driver.OracleDriver";
    }

    _dbUser = System.getProperty("db.user") != null && !System.getProperty("db.user").equals("")
            ? System.getProperty("db.user")
            : DEFAULT_DB_USER;
    _dbPassword = System.getProperty("db.password") != null && !System.getProperty("db.password").equals("")
            ? System.getProperty("db.password")
            : DEFAULT_DB_PASSWORD;

}

From source file:org.jboss.dashboard.ui.components.chart.GaugeMeterChartViewer.java

public CommandResponse actionApplyLink(CommandRequest request) {
    try {// w  w w .  j  ava2  s. c o m
        AbstractChartDisplayer abstractChartDisplayer = (AbstractChartDisplayer) getDataDisplayer();
        DataProperty property = abstractChartDisplayer.getDomainProperty();
        Integer series = Integer.decode(request.getRequestObject().getParameter(PARAM_NSERIE));
        DataSet dataSet = abstractChartDisplayer.buildXYDataSet();
        Interval interval = (Interval) dataSet.getValueAt(series, 0);
        Dashboard dashboard = DashboardHandler.lookup().getCurrentDashboard();
        if (dashboard.filter(property.getPropertyId(), interval, FilterByCriteria.ALLOW_ANY)) {
            return new ShowCurrentScreenResponse();
        }
    } catch (Exception e) {
        log.error("Cannot apply filter.", e);
    }
    return null;
}

From source file:ch.admin.suis.msghandler.common.MessageType.java

/**
 * Creates a list of message types from the provided string value. If the value
 * is null or empty, an empty list is returned.
 *
 * @param typesValue the types in the form <code>type1 type2</code>, i.e. the types are
 *                   numerical values separated by whitespaces
 * @return List of message types from a message
 *//* w  ww . j a v  a  2 s .  c om*/
public static List<MessageType> from(String typesValue) {
    // read the message types
    final ArrayList<MessageType> messageTypes = new ArrayList<>();

    if (null != typesValue) {
        final StringTokenizer types = new StringTokenizer(typesValue);

        while (types.hasMoreTokens()) {
            String type = types.nextToken();
            messageTypes.add(new MessageType(Integer.decode(type)));
        }
    }

    return messageTypes;
}

From source file:org.emonocot.portal.http.StaticUsernameAndPasswordHttpClientFactory.java

/**
 * @param newProxyPort the proxyPort to set
 *//*from   ww w  .jav  a 2s .  com*/
public final void setProxyPort(final String newProxyPort) {
    try {
        this.proxyPort = Integer.decode(newProxyPort);
    } catch (NumberFormatException nfe) {
        logger.warn(nfe.getMessage());
    }
}

From source file:com.mirth.connect.connectors.mllp.protocols.LlpProtocol.java

public void setTcpConnector(MllpConnector mllpConnector) {
    try {/*  w  w w . j  av a 2  s .  c  om*/
        _mllpConnector = mllpConnector;
        if (_mllpConnector.getCharEncoding().equals("hex")) {
            START_MESSAGE = (char) Integer.decode(_mllpConnector.getMessageStart()).intValue();
            END_MESSAGE = (char) Integer.decode(_mllpConnector.getMessageEnd()).intValue();
            END_OF_RECORD = (char) Integer.decode(_mllpConnector.getRecordSeparator()).intValue();
            END_OF_SEGMENT = (char) Integer.decode(_mllpConnector.getSegmentEnd()).intValue();

        } else {
            START_MESSAGE = _mllpConnector.getMessageStart().charAt(0);
            END_MESSAGE = _mllpConnector.getMessageEnd().charAt(0);
            END_OF_RECORD = _mllpConnector.getRecordSeparator().charAt(0);
            END_OF_SEGMENT = _mllpConnector.getSegmentEnd().charAt(0);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.boxcharts.SimpleBox.java

public JFreeChart createChart(DatasetMap datasetMap) {

    BoxAndWhiskerCategoryDataset dataset = (BoxAndWhiskerCategoryDataset) datasetMap.getDatasets().get("1");

    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(name, categoryLabel, valueLabel, dataset, false);

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);//w w  w . jav a2s. c om
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    BoxAndWhiskerRenderer renderer = (BoxAndWhiskerRenderer) plot.getRenderer();
    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(new Color(Integer.decode("#c0c0c0").intValue()));
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);
    renderer.setFillBox(true);
    renderer.setArtifactPaint(Color.BLACK);
    renderer.setSeriesPaint(0, new Color(Integer.decode("#0000FF").intValue()));

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setRange(min, max);

    return chart;
}

From source file:org.segrada.model.base.AbstractColoredModel.java

@Override
public void setColorCode(String colorCode) {
    if (colorCode == null || "".equals(colorCode)) {
        color = null;/*from w  ww  .  j  a  va2  s  .  c  o m*/
    } else {
        // add for decoding below
        if (!colorCode.startsWith("#"))
            colorCode = "#" + colorCode;
        try {
            color = Integer.decode(colorCode);
        } catch (NumberFormatException e) {
            color = null;
            // fail silently
        }
    }
}

From source file:com.aurel.track.fieldType.runtime.renderer.CustomSelectRendererRT.java

@Override
public Object decodeJsonValue(String value, Integer fieldID, WorkItemContext workItemContext)
        throws TypeConversionException {
    Integer result = null;//from ww w . j ava2  s.c  om
    if (value != null) {
        try {
            result = Integer.decode(value);
        } catch (NumberFormatException ex) {
            LOGGER.error(ExceptionUtils.getStackTrace(ex));
            throw new TypeConversionException("common.err.invalid.number", ex);
        }
    }
    if (result == null) {
        return null;
    } else {
        return new Object[] { result };
    }
}