public void addProperty(String name, String value) throws SyntaxException { if (properties.put(name, value) != null) throw new SyntaxException(String.format("Multiple definition for property '%s'", name)); }
public void addProperty(String name, Map<String, String> value) throws SyntaxException { if (properties.put(name, value) != null) throw new SyntaxException(String.format("Multiple definition for property '%s'", name)); }
public void addProperty(String name, Map<String, String> value) throws SyntaxException { if (properties.put(name, value) != null) throw new SyntaxException(String.format("Multiple definition for property '%s'", name)); }
/** * Throws the first syntax error found by the lexer or the parser if it exists. * * @throws SyntaxException the syntax error. */ public void throwFirstSyntaxError() throws SyntaxException { if (!errorMsgs.isEmpty()) throw new SyntaxException(errorMsgs.getFirst()); }
/** * Throws the first syntax error found by the lexer or the parser if it exists. * * @throws SyntaxException the syntax error. */ public void throwFirstSyntaxError() throws SyntaxException { if (!errorMsgs.isEmpty()) throw new SyntaxException(errorMsgs.getFirst()); }
protected String getSimple(String name) throws SyntaxException { Object val = properties.get(name); if (val == null) return null; if (!(val instanceof String)) throw new SyntaxException(String.format("Invalid value for property '%s'. It should be a string", name)); return (String)val; }
protected Map<String, String> getMap(String name) throws SyntaxException { Object val = properties.get(name); if (val == null) return null; if (!(val instanceof Map)) throw new SyntaxException(String.format("Invalid value for property '%s'. It should be a map.", name)); return (Map<String, String>)val; }
protected Map<String, String> getMap(String name) throws SyntaxException { Object val = properties.get(name); if (val == null) return null; if (!(val instanceof Map)) throw new SyntaxException(String.format("Invalid value for property '%s'. It should be a map.", name)); return (Map<String, String>)val; }
public void validate(Set<String> keywords, Set<String> obsolete) throws SyntaxException { for (String name : properties.keySet()) { if (keywords.contains(name)) continue; if (obsolete.contains(name)) logger.warn("Ignoring obsolete property {}", name); else throw new SyntaxException(String.format("Unknown property '%s'", name)); } }
private double getDouble(Option option) { String value = getString(option); try { return Double.parseDouble(value); } catch (NumberFormatException e) { throw new SyntaxException(format("Invalid double value %s for '%s'", value, option)); } }
/** * Set a value for a specific option. * Throws SyntaxException if the same option is set multiple times * @param option * @param value */ public void setOption(IRoleManager.Option option, Object value) { if (options.containsKey(option)) throw new SyntaxException(String.format("Multiple definition for property '%s'", option.name())); options.put(option, value); }
private int getInt(Option option) { String value = getString(option); try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new SyntaxException(String.format("Invalid integer value %s for '%s'", value, option)); } }
/** * Set a value for a specific option. * Throws SyntaxException if the same option is set multiple times * @param option * @param value */ public void setOption(IRoleManager.Option option, Object value) { if (options.containsKey(option)) throw new SyntaxException(String.format("Multiple definition for property '%s'", option.name())); options.put(option, value); }
private Double getDeprecatedCrcCheckChance(Map<String, String> compressionOpts) { String value = compressionOpts.get(Option.CRC_CHECK_CHANCE.toString().toLowerCase()); try { return Double.valueOf(value); } catch (NumberFormatException e) { throw new SyntaxException(String.format("Invalid double value %s for crc_check_chance.'", value)); } }
private double getDouble(Option option) { String value = getString(option); try { return Double.parseDouble(value); } catch (NumberFormatException e) { throw new SyntaxException(format("Invalid double value %s for '%s'", value, option)); } }
public static AbstractType<?> getInstance(TypeParser parser) throws ConfigurationException, SyntaxException { List<AbstractType<?>> innerTypes = parser.getTypeParameters(); if (innerTypes.size() != 1) throw new SyntaxException("FrozenType() only accepts one parameter"); AbstractType<?> innerType = innerTypes.get(0); return innerType.freeze(); }
public static AbstractType<?> getInstance(TypeParser parser) throws ConfigurationException, SyntaxException { List<AbstractType<?>> innerTypes = parser.getTypeParameters(); if (innerTypes.size() != 1) throw new SyntaxException("FrozenType() only accepts one parameter"); AbstractType<?> innerType = innerTypes.get(0); return innerType.freeze(); }
private static ByteBuffer convert(String text) { try { return UTF8Type.instance.decompose(text); } catch (MarshalException e) { throw new SyntaxException(String.format("For field name %s: %s", text, e.getMessage())); } }
private static ByteBuffer convert(String text) { try { return UTF8Type.instance.decompose(text); } catch (MarshalException e) { throw new SyntaxException(String.format("For field name %s: %s", text, e.getMessage())); } }
private static ByteBuffer convert(String text) { try { return UTF8Type.instance.decompose(text); } catch (MarshalException e) { throw new SyntaxException(String.format("For field name %s: %s", text, e.getMessage())); } }