Example usage for java.text ParseException ParseException

List of usage examples for java.text ParseException ParseException

Introduction

In this page you can find the example usage for java.text ParseException ParseException.

Prototype

public ParseException(String s, int errorOffset) 

Source Link

Document

Constructs a ParseException with the specified detail message and offset.

Usage

From source file:org.osaf.cosmo.calendar.query.TimeRangeFilter.java

/**
 * Construct a TimeRangeFilter object from a DOM Element
 * @param element//ww w.  ja  v a  2 s. c om
 * @throws ParseException
 */
public TimeRangeFilter(Element element, VTimeZone timezone) throws ParseException {
    // Get start (must be present)
    String start = DomUtil.getAttribute(element, ATTR_CALDAV_START, null);
    if (start == null) {
        throw new ParseException("CALDAV:comp-filter time-range requires a start time", -1);
    }

    DateTime trstart = new DateTime(start);
    if (!trstart.isUtc()) {
        throw new ParseException("CALDAV:param-filter timerange start must be UTC", -1);
    }

    // Get end (must be present)
    String end = DomUtil.getAttribute(element, ATTR_CALDAV_END, null);
    if (end == null) {
        throw new ParseException("CALDAV:comp-filter time-range requires an end time", -1);
    }

    DateTime trend = new DateTime(end);
    if (!trend.isUtc()) {
        throw new ParseException("CALDAV:param-filter timerange end must be UTC", -1);
    }

    setPeriod(new Period(trstart, trend));
    setTimezone(timezone);
}

From source file:de.dan_nrw.android.scroid.dao.wallpapers.parsing.JsonWallpaperParser.java

@Override
public List<Wallpaper> parse(String data) throws ParseException {
    try {/*from  w ww .  j  a va2  s  .c  o  m*/
        JSONArray array = new JSONArray(data);
        List<Wallpaper> wallpapers = new ArrayList<Wallpaper>();

        for (int i = 0; i < array.length(); i++) {
            JSONObject jsonWallpaper = array.getJSONObject(i);

            wallpapers.add(new Wallpaper(jsonWallpaper.getString("id"), jsonWallpaper.getString("title"),
                    URI.create(jsonWallpaper.getString("thumburl")),
                    URI.create(jsonWallpaper.getString("previewurl")),
                    URI.create(jsonWallpaper.getString("url")), jsonWallpaper.getString("text")));
        }

        return wallpapers;
    } catch (JSONException ex) {
        throw new ParseException(ex.getMessage(), 0);
    }
}

From source file:org.apache.syncope.common.types.AuditLoggerName.java

@SuppressWarnings("unchecked")
public static AuditLoggerName fromLoggerName(final String loggerName)
        throws IllegalArgumentException, ParseException {

    if (StringUtils.isBlank(loggerName)) {
        throw new IllegalArgumentException("Null value not permitted");
    }/*from  w w  w  . j  a va2 s  .co m*/

    if (!loggerName.startsWith(LoggerType.AUDIT.getPrefix())) {
        throw new ParseException("Audit logger name must start with " + LoggerType.AUDIT.getPrefix(), 0);
    }

    final Map.Entry<EventCategoryTO, Result> eventCategory = LoggerEventUtils
            .parseEventCategory(loggerName.replaceAll(LoggerType.AUDIT.getPrefix() + ".", ""));

    return new AuditLoggerName(eventCategory.getKey().getType(), eventCategory.getKey().getCategory(),
            eventCategory.getKey().getSubcategory(),
            eventCategory.getKey().getEvents().isEmpty() ? StringUtils.EMPTY
                    : eventCategory.getKey().getEvents().iterator().next(),
            eventCategory.getValue());
}

From source file:com.branded.holdings.qpc.web.PetTypeFormatter.java

@Override
public PetType parse(String text, Locale locale) throws ParseException {
    Collection<PetType> findPetTypes = this.clinicService.findPetTypes();
    for (PetType type : findPetTypes) {
        if (type.getName().equals(text)) {
            return type;
        }/*from  w ww.ja  v  a2s.  c o m*/
    }
    throw new ParseException("type not found: " + text, 0);
}

From source file:org.unitedinternet.cosmo.calendar.query.CalendarFilter.java

/**
 * Construct a CalendarFilter object from a DOM Element.
 * @param element The element./*from w  w w.  j  a v  a2 s.c om*/
 * @param timezone The timezone. 
 * @throws ParseException - if something is wrong this exception is thrown.
 */
public CalendarFilter(Element element, VTimeZone timezone) throws ParseException {
    // Can only have a single comp-filter element
    final ElementIterator i = DomUtil.getChildren(element, ELEMENT_CALDAV_COMP_FILTER, NAMESPACE_CALDAV);
    if (!i.hasNext()) {
        throw new ParseException("CALDAV:filter must contain a comp-filter", -1);
    }

    final Element child = i.nextElement();

    if (i.hasNext()) {
        throw new ParseException("CALDAV:filter can contain only one comp-filter", -1);
    }

    // Create new component filter and have it parse the element
    filter = new ComponentFilter(child, timezone);
}

From source file:action.ShowTimeSeriesWithForecastAction.java

/**
* Metoda obslugujaca zdarzenie, odpowiedzialna za inicjalizacje algorytmu genetycznego
*//*from   w  w  w . ja  v a  2s.  co  m*/
public void actionPerformed(ActionEvent e) {

    try {

        if (window.getSliderSelekcji().getValue() + window.getSliderKrzyzowania().getValue()
                + window.getSliderMutacji().getValue() != 100)
            throw new ParseException(
                    "Please insert correct data for Selection, Crossing and Mutation. The sum of the three has to equal 100%",
                    0);

        TimeSeries timeSeries = window.getCurrentTimeSeries();
        if (timeSeries == null || timeSeries.isEmpty())
            throw new DataLengthException();

        SlidingTimeWindow slidingTimeWindow = new SlidingTimeWindow(
                this.parseToWindowForm(window.getTimeWindowField().getText()));

        if (window.getRdBtnStochastic().isSelected())
            GASettings.getInstance()
                    .setSelectionMethod(SelectionMethod.STOCHASTIC_UNIVERSAL_SAMPLING_SELECTION);

        if (window.getRdbtnArmaForecast().isSelected())
            GASettings.getInstance().setForecastMethod(ForecastMethod.ARMA_FORECAST);

        GASettings.getInstance().setConcurrent(true);

        ApplicationContext context = new AnnotationConfigApplicationContext(ForecastConfig.class);
        AbstractForecast forecast = (AbstractForecast) context.getBean("forecast");

        forecast.initializeGeneticAlgorithm((TimeSeries) timeSeries.clone(),
                (Integer) window.getPopulSizeField().getValue(), slidingTimeWindow,
                (Integer) window.getIterNumberField().getValue(),
                (double) window.getSliderProbOfCross().getValue() / 100,
                (double) window.getSliderProbOfMutat().getValue() / 100,
                (double) window.getSliderSelekcji().getValue() / 100,
                (double) window.getSliderKrzyzowania().getValue() / 100,
                (double) window.getSliderMutacji().getValue() / 100);
        forecast.initializeForecast((Integer) window.getPeriodOfPredField().getValue());

        forecast.addObserver(new GAChartObserver(window.getFitnessChart(),
                window.getTimeSeriesChartWithForecast(), (Integer) window.getPeriodOfPredField().getValue()));
        forecast.addObserver(new GAStatisticObserver(window.getForecast(),
                (Integer) window.getPeriodOfPredField().getValue()));
        forecast.execute();
        window.getTabbedPane().setSelectedIndex(3);

    } catch (CloneNotSupportedException e1) {
        e1.printStackTrace();
    } catch (DataLengthException de) {
        JOptionPane.showMessageDialog(window, "Current data is not set or empty", "Error",
                JOptionPane.ERROR_MESSAGE);
    } catch (ParseException pe) {
        JOptionPane.showMessageDialog(window, pe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    } catch (Exception exc) {
        JOptionPane.showMessageDialog(window, "Wrong data", "Error", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:com.pet.demo.web.PetTypeFormatter.java

@Override
public PetType parse(String text, Locale locale) throws ParseException {
    Collection<PetType> findPetTypes = this.petdemoService.findPetTypes();
    for (PetType type : findPetTypes) {
        if (type.getName().equals(text)) {
            return type;
        }//  w ww.  j a va  2 s.c om
    }
    throw new ParseException("type not found: " + text, 0);
}

From source file:com.rambird.miles.web.PetTypeFormatter.java

@Override
public PetType parse(String text, Locale locale) throws ParseException {
    Collection<PetType> findPetTypes = this.rambirdService.findPetTypes();
    for (PetType type : findPetTypes) {
        if (type.getName().equals(text)) {
            return type;
        }//from   w  w w  . ja va  2s.  c o m
    }
    throw new ParseException("type not found: " + text, 0);
}

From source file:org.kalypso.ogc.gml.gui.XsdDoubleGuiTypeHandler.java

@Override
public Object parseText(final String text, final String formatHint) throws ParseException {
    final String normalizedText = XsdFloatGuiTypeHandler.normalizeDecimalText(text);

    if (StringUtils.isBlank(normalizedText))
        return null;

    try {/*  ww  w . j  a v  a2  s. c om*/
        return Double.valueOf(normalizedText);
    } catch (final NumberFormatException e) {
        throw new ParseException(e.getLocalizedMessage(), 0);
    }
}

From source file:org.kalypso.ogc.gml.gui.XsdFloatGuiTypeHandler.java

@Override
public Object parseText(final String text, final String formatHint) throws ParseException {
    final String normalizedText = XsdFloatGuiTypeHandler.normalizeDecimalText(text);

    if (StringUtils.isBlank(normalizedText))
        return null;

    try {/*from   www.  ja v  a  2 s . c o m*/
        return Float.valueOf(normalizedText);
    } catch (final NumberFormatException e) {
        throw new ParseException(e.getLocalizedMessage(), 0);
    }
}