List of usage examples for java.text ParseException ParseException
public ParseException(String s, int errorOffset)
From source file:org.freedesktop.wallpapers.Wallpaper.java
public void initFromThemeProperties(INIFile iniFile, Properties themeProperties) throws ParseException { String file = themeProperties.getProperty(FILE); if (!file.equals(getBases().iterator().next().getName())) { throw new ParseException("Unexpected file " + file, 0); }/*ww w. j a v a 2 s . c o m*/ imageType = themeProperties.getProperty(IMAGE_TYPE); author = themeProperties.getProperty(AUTHOR); }
From source file:org.apache.hadoop.chukwa.rest.bean.UserBean.java
public UserBean(JSONObject json) throws ParseException { try {//from ww w .j a va 2 s . co m id = json.getString("id"); views = json.getJSONArray("views"); if (json.has("properties")) { properties = json.getJSONObject("properties"); } else { properties = new JSONObject(); } } catch (Exception e) { log.error(ExceptionUtil.getStackTrace(e)); throw new ParseException("Error parsing user object.", 0); } }
From source file:edu.lternet.pasta.client.EmlUtility.java
/** * Constructs a new EmlUtility object./*from w w w . j a v a 2s.c o m*/ * * @param eml * The EML XML as a String object. * * @throws ParseException */ public EmlUtility(String eml) throws ParseException { if (eml == null || eml.isEmpty()) { throw new ParseException("EML is empty", 0); } this.eml = HTMLUtility.stripNonValidHTMLCharacters(eml); // Properties configuration for local XSLT path and current working // directory. PropertiesConfiguration options = ConfigurationListener.getOptions(); String idref = options.getString("emlutility.idref"); String cwd = options.getString("system.cwd"); // Expand EML references into full canonical form. this.eml = this.emlReferenceExpander(cwd + idref); }
From source file:org.cometd.common.Jackson2JSONContext.java
public T[] parse(String json) throws ParseException { try {/*from w ww . j a va2 s . c o m*/ return getObjectMapper().readValue(json, rootArrayType); } catch (IOException x) { throw (ParseException) new ParseException(json, -1).initCause(x); } }
From source file:com.haulmont.chile.core.datatypes.impl.BooleanDatatype.java
protected Boolean parse(@Nullable String value, String trueString, String falseString) throws ParseException { if (!StringUtils.isBlank(value)) { String lowerCaseValue = StringUtils.lowerCase(value); if (trueString.equals(lowerCaseValue)) { return true; }/* w w w . j ava 2 s.com*/ if (falseString.equals(lowerCaseValue)) { return false; } throw new ParseException(String.format("Can't parse '%s'", value), 0); } return null; }
From source file:org.traccar.model.Geofence.java
public void setArea(String area) throws ParseException { if (area.startsWith("CIRCLE")) { geometry = new GeofenceCircle(area); } else if (area.startsWith("POLYGON")) { geometry = new GeofencePolygon(area); } else if (area.startsWith("LINESTRING")) { geometry = new GeofencePolyline(area, Context.getConfig().getDouble("geofence.polylineDistance", 25)); } else {/* w w w . ja v a 2s .c o m*/ throw new ParseException("Unknown geometry type", 0); } this.area = area; }
From source file:edu.emory.cci.aiw.i2b2etl.ksb.ValueSetSupport.java
void parseId(String id) throws ParseException { try (CSVParser csvParser = CSVParser.parse(id, CSV_FORMAT)) { List<CSVRecord> records = csvParser.getRecords(); if (records.size() != 1) { return; }// w w w . jav a 2 s. c o m CSVRecord record = records.get(0); if (record.size() != 2) { return; } this.declaringPropId = record.get(0); this.propertyName = record.get(1); } catch (IOException invalid) { throw new ParseException("Invalid value set id " + id, 0); } }
From source file:com.snapdeal.scm.fh.service.impl.ConvertorService.java
@SuppressWarnings("unchecked") @Override// w ww . j a v a2 s .c o m public <T> T convertToObject(Class<T> clazz, String value) throws ParseException { if (StringUtils.isEmpty(value) || StringUtils.NULL.equalsIgnoreCase(value)) { return null; } if (clazz.equals(Integer.class)) { return (T) Integer.valueOf(value); } if (clazz.equals(Date.class)) { try { return (T) new Date(Long.valueOf(value)); } catch (NumberFormatException ne) { return (T) DateUtils.parseDate(value, ALLOWED_DATE_FORMATS); } } if (clazz.equals(String.class)) { return (T) value; } if (clazz.equals(Float.class)) { return (T) Float.valueOf(value); } if (clazz.equals(Double.class)) { return (T) Double.valueOf(value); } if (clazz.equals(Boolean.class)) { if (value.equals("1") || value.equalsIgnoreCase("true")) { return (T) Boolean.TRUE; } else if (value.equals("0") || value.equalsIgnoreCase("false")) { return (T) Boolean.FALSE; } } throw new ParseException("unable to parse string [" + value + "] to class " + clazz, 0); }
From source file:org.kuali.kra.scheduling.util.Time24HrFmt.java
private void parseTime(String time) throws ParseException { String[] result = time.split(splitChr); if (result.length != 2) throw new ParseException(MSG1, 0); Integer hrs;//from ww w . j a va2 s. co m Integer mins; try { hrs = new Integer(result[0]); mins = new Integer(result[1]); } catch (NumberFormatException e) { throw new ParseException(MSG2, 0); } if (!(hrs >= 0 && hrs <= 23)) { throw new ParseException(MSG3, 0); } if (!(mins >= 0 && mins <= 59)) { throw new ParseException(MSG4, 0); } this.hours = result[0]; this.minutes = result[1]; }
From source file:de.odysseus.calyxo.base.util.ParseUtils.java
private static Object parse(Format format, String value) throws ParseException { ParsePosition pos = new ParsePosition(0); Object result = format.parseObject(value, pos); if (pos.getIndex() < value.length()) throw new ParseException("Cannot parse " + value + " (garbage suffix)!", pos.getIndex()); return result; }//from ww w . ja va2 s . c om