public static AttributesImpl addAttribute(String name, String value, AttributesImpl atts) { if (!StringUtil.isEmpty(value)) atts.addAttribute("", "", name, "CDATA", value); return atts; }
public static boolean isScript(String text) { if (StringUtil.isEmpty(text)) return false; String trimmedText = text.trim(); return trimmedText.startsWith("{") && trimmedText.endsWith("}"); }
private static int parseOccursAttribute(Element element, String name) { String stringValue = element.getAttribute(name); if (StringUtil.isEmpty(stringValue)) return 1; else if ("unbounded".equals(stringValue)) return -1; else return Integer.parseInt(stringValue); }
public static String normalizeColor(String color) { if (StringUtil.isEmpty(color)) return null; String baseColor = (color.startsWith("\"") && color.endsWith("\"") ? color.substring(1, color.length() - 1) : color); return (baseColor.contains("#") ? '"' + baseColor + '"' : baseColor); }
public CSVSingleColumIterator(String uri, int columnIndex, char separator, boolean ignoreEmptyLines, String encoding) throws IOException { super(new CSVLineIterator(uri, separator, ignoreEmptyLines, encoding)); if (StringUtil.isEmpty(uri)) throw new IllegalArgumentException("URI is empty"); if (columnIndex < 0) throw new IllegalArgumentException("Negative column index: " + columnIndex); this.columnIndex = columnIndex; }
protected void excludeAttributes(Element element, String... attributeNames) { String usedAttribute = null; for (String attributeName : attributeNames) { if (!StringUtil.isEmpty(element.getAttribute(attributeName))) { if (usedAttribute == null) usedAttribute = attributeName; else syntaxError("The attributes '" + usedAttribute + "' and '" + attributeName + "' " + "exclude each other", element); } } }
public static Long getLongAttribute(Element element, String name, long defaultValue) { if (LOGGER.isDebugEnabled()) LOGGER.debug("getLongAttribute(" + element.getNodeName() + ", " + name + ')'); String stringValue = getAttribute(element, name, false); if (StringUtil.isEmpty(stringValue)) return defaultValue; return Long.parseLong(stringValue); }
@Override public T convert(String sourceValue) throws ConversionException { if (StringUtil.isEmpty(sourceValue)) return null; else return super.convert(sourceValue); }
public LocalDiffType(DiffDetailType type, String locator) { if (StringUtil.isEmpty(locator) && type == null) throw new ConfigurationError("At least one of the argument 'locator' and 'type' must be not empty"); this.locator = locator; this.type = type; }
public CSVSingleColumIterator(String uri, int columnIndex, char separator, boolean ignoreEmptyLines, String encoding) throws IOException { super(new CSVLineIterator(uri, separator, ignoreEmptyLines, encoding)); if (StringUtil.isEmpty(uri)) throw new IllegalArgumentException("URI is empty"); if (columnIndex < 0) throw new IllegalArgumentException("Negative column index: " + columnIndex); this.columnIndex = columnIndex; }
public static Time parse(String value, String pattern) throws ConversionException { if (StringUtil.isEmpty(value)) return null; pattern = choosePattern(value, pattern); try { Date simpleDate = new SimpleDateFormat(pattern).parse(value); long millis = simpleDate.getTime(); return new Time(millis); } catch (ParseException e) { throw new ConversionException(e); } }
protected void checkAttributeSupport(Element element) { for (String attribute : XMLUtil.getAttributes(element).keySet()) { if (!requiredAttributes.contains(attribute) && !optionalAttributes.contains(attribute)) syntaxError("attribute '" + attribute + "' is not supported", element); // TODO v0.6.x print supported attributes } for (String requiredAttribute : requiredAttributes) { if (StringUtil.isEmpty(element.getAttribute(requiredAttribute))) syntaxError("Required attribute '" + requiredAttribute + "' is missing", element); } }
protected void assertAtLeastOneAttributeIsSet(Element element, String... attributeNames) { boolean ok = false; for (String attributeName : attributeNames) if (!StringUtil.isEmpty(element.getAttribute(attributeName))) ok = true; if (!ok) syntaxError("At least one of these attributes must be set: " + ArrayFormat.format(attributeNames), element); }
public static Expression<?>[] parseBeanSpecList(String text) throws SyntaxError { if (StringUtil.isEmpty(text)) return null; CommonTree tree = parseBeanSpecListAsTree(text); return convertBeanSpecList(tree); }
public static BeanSpec[] resolveBeanSpecList(String text, Context context) { if (StringUtil.isEmpty(text)) return null; CommonTree tree = parseBeanSpecListAsTree(text); return resolveBeanSpecList(tree, context); }
protected static String parseRequiredName(Element element) { String name = parseOptionalName(element); if (StringUtil.isEmpty(name)) syntaxError("'name' attribute is missing", element); return name; }
protected String parseRequiredName(Element element) { String name = parseOptionalName(element); if (StringUtil.isEmpty(name)) throw createSyntaxError("'name' attribute is missing", element); return name; }
@Override public Converter convert(String sourceValue) throws ConversionException { if (StringUtil.isEmpty(sourceValue)) return null; Object result = BeanUtil.newInstance(sourceValue); if (result instanceof Format) return new ParseFormatConverter(Object.class, (Format) result, false); else if (result instanceof Converter) return (Converter) result; else throw new ConfigurationError("Class is neither Converter nor Format: " + result.getClass()); }
public static Versions valueOf(String spec) { if (StringUtil.isEmpty(spec) || "*".equals(spec.trim())) return createUnlimited(); IntervalsParser<VersionNumber> parser = new IntervalsParser<VersionNumber>( new VersionNumberParser(), VERSION_COMPARATOR); return (Versions) parser.parseObject(spec, new ParsePosition(0), new Versions()); }
public void set(String name, E value) { if (StringUtil.isEmpty(name)) add(name, value); if (caseHandling == IGNORANT) name = name.toLowerCase(); int index = someIndexOfName(name); if (index < 0) add(name, value); else setValue(index, value); }