public static Boolean parseBoolean(String s) { return parseBoolean(s, false); }
public static boolean isNMToken(String testName) { if (testName == null || testName.length() == 0) return false; char c = testName.charAt(0); if (!isNMStartChar(c)) return false; for (int i = 1; i < testName.length(); i++) { c = testName.charAt(i); if (!isNMAfterStartChar(c)) return false; } return true; }
public static long parseInteger(PushbackReader reader) throws IOException, ParseException { boolean negative = parseOptionalSign(reader); return parseNonNegativeInteger(reader) * (negative ? -1 : 1); }
@Override public Number parse(String source, ParsePosition pos) { Number value = snf.parse(StringUtil.trim(source), pos); int start = ParseUtil.nextNonWhitespaceIndex(source, pos.getIndex()); if (start == -1) return value; for (int i = 0; i < availableScales.length; i++) { String prefix = (String) availableScales[i][0]; if (source.substring(start).startsWith(prefix)) { value = new Double(value.doubleValue() * ((Double) availableScales[i][1]).doubleValue()); pos.setIndex(start + prefix.length()); break; } } return value; } }
private static String getEncoding(byte[] bytes) throws UnsupportedEncodingException { String tmp = new String(bytes, Encodings.ISO_8859_1); int startIndex = tmp.indexOf("charset="); if (startIndex < 0) return null; startIndex += "charset=".length(); StringCharacterIterator it = new StringCharacterIterator(tmp, startIndex); it.skipWhitespace(); StringBuilder builder = new StringBuilder(); int c; while ((c = it.next()) != -1 && ParseUtil.isNMAfterStartChar((char) c)) builder.append((char) c); return builder.toString(); }
int width = (int) ParseUtil.parseNonNegativeInteger(formatSpec, pos); if (pos.getIndex() < formatSpec.length() && formatSpec.charAt(pos.getIndex()) == '.') { pos.setIndex(pos.getIndex() + 1); minFractionDigits = (int) ParseUtil.parseNonNegativeInteger(formatSpec, pos); maxFractionDigits = minFractionDigits; format = DecimalFormat.getInstance(Locale.US);
public static String from(String s, String separator) { return from(s, separator, null); }
public static Object[] splitNumbers(String text) { List<Object> parts = new ArrayList<Object>(); Boolean numMode = null; int start = 0; for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); boolean newMode = Character.isDigit(c); if (numMode != null && !numMode.equals(newMode)) { String partString = text.substring(start, i); addPart(partString, parts, numMode); start = i; } numMode = newMode; } addPart(text.substring(start), parts, numMode); return parts.toArray(); }
@Override public Number parse(String source, ParsePosition pos) { Number value = snf.parse(StringUtil.trim(source), pos); int start = ParseUtil.nextNonWhitespaceIndex(source, pos.getIndex()); if (start == -1) return value; for (int i = 0; i < abbreviations.size(); i++) { String prefix = (String) abbreviations.get(i).code; if (source.substring(start).startsWith(prefix)) { value = new Double(value.doubleValue() * ((Double) abbreviations.get(i).factor).doubleValue()); pos.setIndex(start + prefix.length()); break; } } return value; }
protected Boolean parseOptionalBoolean(String attributeName, Element element) { String spec = getOptionalAttribute(attributeName, element); return (spec != null ? ParseUtil.parseBoolean(spec) : null); }
public static JDBCConnectData parseSingleDbProperties(String filename) throws IOException { Map<String, String> properties = IOUtil.readProperties(filename); String readOnlyConfig = properties.get("db_readonly"); boolean readOnly = (!StringUtil.isEmpty(readOnlyConfig) ? ParseUtil.parseBoolean(readOnlyConfig, true) : false); return new JDBCConnectData( properties.get("db_driver"), properties.get("db_url"), properties.get("db_user"), properties.get("db_password"), properties.get("db_catalog"), properties.get("db_schema"), readOnly); }
private static Expression<Boolean> convertBooleanLiteral(CommonTree node) { return new ConstantExpression<Boolean>(ParseUtil.parseBoolean(node.getText())); }
public static Boolean getBooleanAttribute(Element element, String attributeName, boolean required) { String stringValue = element.getAttribute(attributeName); if (StringUtil.isEmpty(stringValue) && required) throw new SyntaxError("Missing attribute '" + attributeName + "'", format(element)); return ParseUtil.parseBoolean(stringValue); }
private static DBSequence parseSequence(Element e, DBSchema schema) { DBSequence sequence = new DBSequence(e.getAttribute("name"), schema); String start = e.getAttribute("start"); if (!StringUtil.isEmpty(start)) sequence.setStart(new BigInteger(start)); String increment = e.getAttribute("increment"); if (!StringUtil.isEmpty(increment)) sequence.setIncrement(new BigInteger(increment)); String maxValue = e.getAttribute("maxValue"); if (!StringUtil.isEmpty(maxValue)) sequence.setMaxValue(new BigInteger(maxValue)); String minValue = e.getAttribute("minValue"); if (!StringUtil.isEmpty(minValue)) sequence.setMinValue(new BigInteger(minValue)); String cycle = e.getAttribute("cycle"); if (!StringUtil.isEmpty(cycle)) sequence.setCycle(ParseUtil.parseBoolean(cycle)); String cache = e.getAttribute("cache"); if (!StringUtil.isEmpty(cache)) sequence.setCache(Long.parseLong(cache)); String order = e.getAttribute("order"); if (!StringUtil.isEmpty(order)) sequence.setOrder(ParseUtil.parseBoolean(order)); return sequence; }
org.databene.platform.xls.PlatformDescriptor.setFormattedByDefault(ParseUtil.parseBoolean(spec));