Example usage for java.lang NumberFormatException getLocalizedMessage

List of usage examples for java.lang NumberFormatException getLocalizedMessage

Introduction

In this page you can find the example usage for java.lang NumberFormatException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.eclipse.jubula.rc.common.commands.AbstractCapTestCommand.java

/**
 * Gets the implementation class. /*  www.jav  a2s  .  c om*/
 * @param response The response message.
 * @return the implementation class or null if an error occurs.
 */
protected Object getImplClass(CAPTestResponseMessage response) {
    Object implClass = null;
    final MessageCap messageCap = m_capTestMessage.getMessageCap();
    IComponentIdentifier ci = messageCap.getCi();
    if (LOG.isInfoEnabled()) {
        LOG.info("component class name: " //$NON-NLS-1$
                + (ci == null ? "(none)" : ci.getComponentClassName())); //$NON-NLS-1$
    }
    try {
        if (!messageCap.hasDefaultMapping()) {
            Validate.notNull(ci);
        }
        // FIXME : Extra handling for waitForComponent and verifyExists
        int timeout = 500;

        boolean isWaitForComponent = WidgetTester.RC_METHOD_NAME_WAIT_FOR_COMPONENT
                .equals(messageCap.getMethod());
        if (isWaitForComponent) {
            MessageParam timeoutParam = (MessageParam) messageCap.getMessageParams().get(0);
            try {
                timeout = Integer.parseInt(timeoutParam.getValue());
            } catch (NumberFormatException e) {
                LOG.warn("Error while parsing timeout parameter. " //$NON-NLS-1$
                        + "Using default value.", e); //$NON-NLS-1$
            }
        }
        if (!messageCap.hasDefaultMapping()) {
            Object component = findComponent(ci, timeout);
            implClass = AUTServerConfiguration.getInstance().prepareImplementationClass(component,
                    component.getClass());

        } else {
            implClass = AUTServerConfiguration.getInstance().getImplementationClass(ci.getComponentClassName());
        }
        if (isWaitForComponent) {
            MessageParam delayParam = (MessageParam) messageCap.getMessageParams().get(1);
            try {
                int delay = Integer.parseInt(delayParam.getValue());
                TimeUtil.delay(delay);
            } catch (IllegalArgumentException iae) {
                handleInvalidInput("Invalid input: " //$NON-NLS-1$
                        + CompSystemI18n.getString("CompSystem.DelayAfterVisibility") //$NON-NLS-1$
                        + " must be a non-negative integer."); //$NON-NLS-1$
            }
        }
    } catch (IllegalArgumentException e) {
        handleComponentNotFound(response, e);
    } catch (ComponentNotFoundException e) {
        if (WidgetTester.RC_METHOD_NAME_CHECK_EXISTENCE.equals(messageCap.getMethod())) {
            MessageParam isVisibleParam = (MessageParam) messageCap.getMessageParams().get(0);
            handleComponentDoesNotExist(response, Boolean.valueOf(isVisibleParam.getValue()).booleanValue());
        } else {
            handleComponentNotFound(response, e);
        }
    } catch (UnsupportedComponentException buce) {
        LOG.error(buce.getLocalizedMessage(), buce);
        response.setTestErrorEvent(EventFactory.createConfigErrorEvent());
    } catch (Throwable e) {
        if (LOG.isErrorEnabled()) {
            LOG.error(e.getLocalizedMessage(), e);
        }
        response.setTestErrorEvent(EventFactory.createImplClassErrorEvent());
    }
    return implClass;
}

From source file:org.jahia.services.render.scripting.bundle.BundleScriptEngineManager.java

private List<BundleScriptEngineFactory> getScriptEngineFactories(Bundle bundle) throws IOException {
    List<String> factoryCandidates = findFactoryCandidates(bundle);
    if (factoryCandidates.isEmpty()) {
        return null;
    }//  w  w w.j a  v  a  2  s .com

    // check if the bundle defined any view extension priorities
    // todo: add more validation and better specify how this functionality should work
    final Dictionary<String, String> headers = bundle.getHeaders();
    final String extensionsPriorities = headers
            .get(BundleScriptingConfigurationConstants.JAHIA_SCRIPTING_EXTENSIONS_PRIORITIES);
    final Map<String, Integer> extensionsPrioritiesMap;
    if (extensionsPriorities != null) {
        final String[] extensionPriorityPairs = StringUtils.split(extensionsPriorities);
        extensionsPrioritiesMap = new HashMap<>(extensionPriorityPairs.length);
        for (String extensionPriorityPair : extensionPriorityPairs) {
            final String[] extensionPrioritySplit = StringUtils.split(extensionPriorityPair, '=');
            boolean valid = false;
            if (extensionPrioritySplit != null && extensionPrioritySplit.length == 2) {
                try {
                    extensionsPrioritiesMap.put(extensionPrioritySplit[0],
                            Integer.parseInt(extensionPrioritySplit[1]));
                    valid = true;
                } catch (NumberFormatException e) {
                    valid = false;
                }
            }

            if (!valid) {
                logger.warn(
                        "Invalid extension - priority pair: {}. Format is extension=priority, priority should"
                                + " be an integer. Extension will be ignored.",
                        extensionPriorityPair);
            }
        }
    } else {
        extensionsPrioritiesMap = null;
    }

    // retrieve the bundle's class loader
    ClassLoader classLoader = bundle.adapt(BundleWiring.class).getClassLoader();

    final BundleScriptingContext scriptingContext = new BundleScriptingContext(classLoader,
            extensionsPrioritiesMap);

    List<BundleScriptEngineFactory> factories = new ArrayList<>(factoryCandidates.size());
    for (String factoryCandidate : factoryCandidates) {
        final Class<? extends ScriptEngineFactory> factoryClass;
        final ScriptEngineFactory factory;
        final BundleScriptEngineFactory bundleScriptEngineFactory;
        try {
            factoryClass = bundle.loadClass(factoryCandidate).asSubclass(ScriptEngineFactory.class);
            factory = factoryClass.cast(factoryClass.newInstance());
        } catch (ClassNotFoundException e) {
            logger.warn(
                    "ScriptEngineFactory {} was registered to be loaded but no associated class was found in bundle {}. Ignoring"
                            + ".",
                    factoryCandidate, bundle);
            continue;
        } catch (InstantiationException | IllegalAccessException e) {
            logger.warn("Couldn't instantiate ScriptEngineFactory {}. Cause: {}. Ignoring.", factoryCandidate,
                    e.getLocalizedMessage());
            continue;
        } catch (ClassCastException e) {
            logger.warn(
                    "Registered ScriptEngineFactory {} doesn't implement ScriptEngineFactory in bundle {}. Ignoring.",
                    factoryCandidate, bundle);
            continue;
        }

        bundleScriptEngineFactory = new BundleScriptEngineFactory(factory, scriptingContext);
        factories.add(bundleScriptEngineFactory);
    }

    return factories;
}

From source file:de.dmarcini.submatix.pclogger.gui.MainCommGUI.java

/**
 * Decodiere die Nachricht ber einen Logverzeichniseintrag Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui
 * //  ww  w . j  av a 2 s .co m
 * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 05.05.2012
 * @param entryMsg
 * @return
 */
private String decodeLogDirEntry(String entryMsg) {
    // Message etwa so <~41:21:9_4_10_20_44_55.txt:22>
    String[] fields;
    String fileName;
    int number, max;
    int day, month, year, hour, minute, second;
    //
    // Felder aufteilen
    fields = fieldPatternDp.split(entryMsg);
    if (fields.length < 4) {
        lg.error("recived message for logdir has lower than 4 fields. It is wrong! Abort!");
        return (null);
    }
    // Wandel die Nummerierung in Integer um
    try {
        number = Integer.parseInt(fields[1], 16);
        max = Integer.parseInt(fields[3], 16);
    } catch (NumberFormatException ex) {
        lg.error("Fail to convert Hex to int: " + ex.getLocalizedMessage());
        return (null);
    }
    fileName = fields[2];
    // verwandle die Dateiangabe in eine lesbare Datumsangabe
    // Format des Strings ist ja
    // TAG_MONAT_JAHR_STUNDE_MINUTE_SEKUNDE
    // des Beginns der Aufzeichnung
    fields = fieldPatternUnderln.split(fields[2]);
    try {
        day = Integer.parseInt(fields[0]);
        month = Integer.parseInt(fields[1]);
        year = Integer.parseInt(fields[2]) + 2000;
        hour = Integer.parseInt(fields[3]);
        minute = Integer.parseInt(fields[4]);
        second = Integer.parseInt(fields[5]);
    } catch (NumberFormatException ex) {
        lg.error("Fail to convert Hex to int: " + ex.getLocalizedMessage());
        return (null);
    }
    // So, die Angaben des SPX sind immer im Localtime-Format
    // daher werde ich die auch so interpretieren
    // Die Funktion macht das in der default-Lokalzone, sollte also
    // da sein, wio der SPX auch ist... (schwieriges Thema)
    DateTime tm = new DateTime(year, month, day, hour, minute, second);
    DateTimeFormatter fmt = DateTimeFormat.forPattern(timeFormatterString);
    return (String.format("%d;%s;%s;%d;%d", number, fileName, tm.toString(fmt), max, tm.getMillis()));
}

From source file:org.openestate.io.idx.IdxRecord.java

public Integer getFloor() {
    try {/*from   w w w .  j  a  v  a  2s.c  o  m*/
        return IdxFormat.parseInteger(this.get(FIELD_FLOOR));
    } catch (NumberFormatException ex) {
        LOGGER.warn("Can't read floor!");
        LOGGER.warn("> " + ex.getLocalizedMessage(), ex);
        return null;
    }
}

From source file:org.openestate.io.idx.IdxRecord.java

public Long getVolume() {
    try {/*from   ww  w .  j a va 2s .c  om*/
        return IdxFormat.parseLong(this.get(FIELD_VOLUME));
    } catch (NumberFormatException ex) {
        LOGGER.warn("Can't read volume!");
        LOGGER.warn("> " + ex.getLocalizedMessage(), ex);
        return null;
    }
}

From source file:org.openestate.io.idx.IdxRecord.java

public Long getRentNet() {
    try {//from w  w  w.j ava 2 s.c o  m
        return IdxFormat.parseLong(this.get(FIELD_RENT_NET));
    } catch (NumberFormatException ex) {
        LOGGER.warn("Can't read net rent!");
        LOGGER.warn("> " + ex.getLocalizedMessage(), ex);
        return null;
    }
}

From source file:org.openestate.io.idx.IdxRecord.java

public Long getRentExtra() {
    try {//  ww w .  ja  v a 2 s  .c o m
        return IdxFormat.parseLong(this.get(FIELD_RENT_EXTRA));
    } catch (NumberFormatException ex) {
        LOGGER.warn("Can't read extra rent!");
        LOGGER.warn("> " + ex.getLocalizedMessage(), ex);
        return null;
    }
}

From source file:org.openestate.io.idx.IdxRecord.java

public Integer getYearBuilt() {
    try {//from  w ww  . j av  a 2  s  .  com
        return IdxFormat.parseInteger(this.get(FIELD_YEAR_BUILT));
    } catch (NumberFormatException ex) {
        LOGGER.warn("Can't read build year!");
        LOGGER.warn("> " + ex.getLocalizedMessage(), ex);
        return null;
    }
}

From source file:org.openestate.io.idx.IdxRecord.java

public Long getDeliveryId() {
    try {//from   w w w .  j ava  2s.  c  o  m
        return IdxFormat.parseLong(this.get(FIELD_DELIVERY_ID));
    } catch (NumberFormatException ex) {
        LOGGER.warn("Can't read delivery id!");
        LOGGER.warn("> " + ex.getLocalizedMessage(), ex);
        return null;
    }
}

From source file:org.openestate.io.idx.IdxRecord.java

public BigDecimal getHallHeight() {
    try {// w  w  w.  jav  a 2 s .  c  o m
        return IdxFormat.parseDecimal(this.get(FIELD_HALL_HEIGHT));
    } catch (NumberFormatException ex) {
        LOGGER.warn("Can't read hall height!");
        LOGGER.warn("> " + ex.getLocalizedMessage(), ex);
        return null;
    }
}