List of usage examples for java.text ParseException ParseException
public ParseException(String s, int errorOffset)
From source file:org.piwigo.remotesync.api.util.StringUtil.java
/** * TODO Password not really encrypted/decrypted : warn users * @throws ParseException /*from ww w . j a va 2s. c o m*/ */ public static String fakeDecryptPassword(String value) throws ParseException { if (value == null) return null; value = new String(Base64.decodeBase64(value)); if (value.startsWith(PB) && value.endsWith(PE)) return rot13(value.substring(3, value.length() - 3)); throw new ParseException("Cannot decrypt password", 0); }
From source file:com.haulmont.cuba.security.global.UserUtils.java
private static String parseParam(String param, String firstName, String lastName, String middleName) throws ParseException { if (param == null || param.length() == 0) throw new ParseException("Pattern error", 0); String last = StringUtils.substringAfter(param, "|"); String first = StringUtils.upperCase(StringUtils.substringBefore(param, "|")); if (first == null || first.length() == 0) throw new ParseException("Pattern error", 0); char type = first.charAt(0); boolean all = true; int length = 0; if (first.length() > 1) { char ch = first.charAt(1); switch (ch) { case 'F': case 'L': case 'M': if (first.length() != 2 || type != ch) throw new ParseException("Pattern error", 2); break; default://from w w w . j a v a2 s .c o m length = Integer.parseInt(first.substring(1, first.length())); break; } } else { all = false; length = 1; } switch (type) { case 'F': first = firstName; break; case 'L': first = lastName; break; case 'M': first = middleName; break; default: throw new ParseException("Pattern error", 0); } if (!all) { first = StringUtils.left(first, length); } return (first.length() > 0) ? first + last : ""; }
From source file:org.homiefund.web.formatters.UserFormatter.java
@Override public UserDTO parse(String s, Locale locale) throws ParseException { if (StringUtils.isEmpty(s)) { throw new ParseException("Passed empty text", 0); } else {/*from w w w . j a v a2 s . com*/ UserDTO user = new UserDTO(); user.setId(Long.valueOf(s)); return user; } }
From source file:Main.java
/** * This will parse an XML stream and create a DOM document. * /*from w ww.j a v a 2s . c o m*/ * @param is * The stream to get the XML from. * @return The DOM document. * @throws IOException * @throws IOException * It there is an error creating the dom. * @throws ParseException */ public static Document parse(InputStream is) throws IOException, ParseException { final DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = null; try { builder = builderFactory.newDocumentBuilder(); } catch (final ParserConfigurationException e) { final ParseException thrown = new ParseException(e.getMessage(), 0); throw thrown; } try { return builder.parse(is); } catch (final IOException e) { final IOException thrown = new IOException(e.getMessage()); throw thrown; } catch (final SAXException e) { final ParseException thrown = new ParseException(e.getMessage(), 0); throw thrown; } }
From source file:eu.crisis_economics.configuration.AssignmentExpression.java
static AssignmentExpression tryCreate(String expression, FromFileConfigurationContext context) throws ParseException { try {/*w w w.j ava 2 s . co m*/ return ArgumentAssignmentExpression.tryCreate(expression, context); } catch (Exception e) { } try { return InstanceAssignmentExpression.tryCreate(expression, context); } catch (Exception e) { } throw new ParseException(expression, 0); }
From source file:eu.crisis_economics.configuration.CompoundExpression.java
static CompoundExpression tryCreate(String expression, FromFileConfigurationContext context) throws ParseException { List<String> expressions = CompoundExpression.isExpressionOfType(expression, context); if (expressions == null) throw new ParseException(expression, 0); String typeDeclString = expressions.get(0), instanceAssignmentString = expressions.get(1); TypeDeclarationExpression typeExpression = TypeDeclarationExpression.tryCreate(typeDeclString, context); return new CompoundExpression(typeExpression, InstanceAssignmentExpression.tryCreate(instanceAssignmentString, context), context); }
From source file:gov.nih.nci.caintegrator.common.DateUtil.java
private static String formatDate(String dateString) throws ParseException { String[] dateElements = (dateString.contains("-")) ? dateString.split("-", 3) : dateString.split("/", 3); if (dateElements.length != 3) { throw new ParseException("Invalid date string: " + dateString, 0); }/* ww w . j ava2 s .co m*/ return twoDigit.format(Long.valueOf(dateElements[0])) + "/" + twoDigit.format(Long.valueOf(dateElements[1])) + "/" + dateElements[2]; }
From source file:com.haulmont.chile.core.datatypes.impl.UUIDDatatype.java
@Override public UUID parse(String value) throws ParseException { if (StringUtils.isBlank(value)) { return null; } else {/*from w w w. j a va 2 s. c o m*/ try { return UuidProvider.fromString(value.trim()); } catch (Exception e) { throw new ParseException("Error parsing UUID", 0); } } }
From source file:org.apache.hadoop.chukwa.rest.bean.OptionBean.java
public OptionBean(JSONObject json) throws ParseException { try {// w w w . j av a2s.c o m label = json.getString("label"); value = json.getString("value"); } catch (JSONException e) { throw new ParseException(ExceptionUtil.getStackTrace(e), 0); } }
From source file:org.jboss.dashboard.ui.formatters.FactoryURL.java
public FactoryURL(String value) throws ParseException { ParsePosition pPos = new ParsePosition(0); Object[] o = msgf.parse(value, pPos); if (o == null) throw new ParseException("Cannot parse " + value + ". Error at position " + pPos.getErrorIndex(), pPos.getErrorIndex());/*w w w.j a v a 2s . c o m*/ beanName = StringEscapeUtils.UNESCAPE_HTML4.translate((String) o[0]); fieldName = StringEscapeUtils.UNESCAPE_HTML4.translate((String) o[1]); }