/** * Return true if the the string is not empty. * * @param _in The string to test * @return true if the string is not null and not an empty string */ public static boolean isSet(String _in) { return !isEmpty(_in); }
/** * Active means this is the default version for a new process instance * @param deployedName */ public void activateProcessVersion(String deployedName) { String v = MString.afterIndex(deployedName, ':'); String n = MString.beforeIndex(deployedName, ':'); getParameters().put("process:" + n + ":active", v); } public String getActiveProcessVersion(String processName) {
/** * locate and return a json node inside a structure. * * @param parent * @param path slash separated path * @return requested node */ public static JsonNode getByPath(JsonNode parent, String path) { if (path == null || parent == null) return null; JsonNode cur = parent; for (String part : path.split("/")) { if (MString.isSet(part)) cur = cur.get(part); if (cur == null) return null; } return cur; }
/** * @param tag * @return */ private String getTagName(String tag) { if (MString.isIndex(tag, MString.WHITESPACE)) { return MString.beforeIndex(tag, MString.WHITESPACE); } return tag; }
public FilterRequest(String text) { LinkedList<String> lText = new LinkedList<String>(); facets = new HashMap<String, String>(); for (String part : text.split(" ")) { part = part.trim(); if (MString.isSet(part)) { if (part.indexOf(':') > 0) { facets.put(MString.beforeIndex(part, ':'), MString.afterIndex(part, ':')); } else { lText.add(part); } } } this.text = lText.toArray(new String[lText.size()]); }
@Override public void doInitialize(IApiInternal internal, CfgManager manager, IConfig config) { ResourceNode<?> system = manager.getCfg("system"); try { String key = MConstants.PROP_BASE_DIR; String name = system.getString(key); if (MString.isEmpty(name)) name = System.getProperty(MConstants.PROP_PREFIX + key); if (MString.isSet(name)) internal.setBaseDir( new File(name) ); } catch (Throwable t) {MApi.dirtyLog(t);} }
for ( String line : MFile.readLines(f, true)) { line = line.trim(); if (MString.isSet(line) && !line.startsWith("#")) { String date = null; String msg = ""; if (MString.isIndex(line, ' ')) { date = MString.beforeIndex(line, ' ').trim(); msg = MString.afterIndex(line, ' ').trim(); } else { date = line;
@SuppressWarnings("rawtypes") private ResourceNode getResource(FileResource parent, String target) { if (parent == null || target == null) return null; if (target.length() == 0) return parent; String next = null; if (MString.isIndex(target, '/')) { next = MString.beforeIndex(target, '/'); target = MString.afterIndex(target, '/'); } else { next = target; target = ""; } if (next.length() == 0) return getResource(parent,target); ResourceNode n = parent.getNode(next); if (n == null) return null; return getResource((FileResource) n, target); }
public void enableProcessVersion(String deployedName) { // add version String v = MString.afterIndex(deployedName, ':'); String n = MString.beforeIndex(deployedName, ':'); String[] versions = String.valueOf(getParameters().getOrDefault("process:" + n + ":versions","")).split(","); if (!MCollection.contains(versions, v)) { versions = MCollection.append(versions, v); getParameters().put("process:" + n + ":versions", MString.join(versions,',')); } }
String[] parts = MString.split(interval, ":"); if (parts.length == 3) { hour = parts[0]; day = MString.beforeIndex(hour, ' '); hour = MString.afterIndex(hour, ' '); msec = MString.afterIndex(sec, '.'); sec = MString.beforeIndex(sec, '.');
/** * Returns the process id of the current application. * * @return the current process id */ public static String getPid() { RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean(); String name = rt.getName(); return MString.beforeIndex(name, '@'); }
/** * <p>fixName.</p> * * @param pack a {@link de.mhus.lib.form.DataSource} object. * @param name a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ protected String fixName(DataSource pack, String name) { if (pack != defaultSource) name = MString.afterIndex(name, '.'); return name; }
/** * Return true if the the string is not empty also trimmed. * * @param _in The string to test * @return true if the string is not null and not an empty string and not only contains whitespaces */ public static boolean isSetTrim(String _in) { return !isEmptyTrim(_in); }
if (MString.isSet(mask)) { done = true; for (PojoAttribute<?> attr : beanModel) { try { String value = valueOf(attr.get(item)); if (value != null && MString.compareFsLikePattern(value.toLowerCase(),mask.toLowerCase())) { log.d("filter match general", item, mask, value); ok = true; done = true; String value = valueOf(attr.get(item)); if (value != null && MString.compareFsLikePattern(value.toLowerCase(),facet.toLowerCase())) { log.d("filter match facet", item, attr.getName(), facet, value); return true;
if (!MString.isIndex(tag, MString.WHITESPACE)) { return out; String tagx = MString.afterIndex(tag, MString.WHITESPACE);
private String getCellLine(String[] cells, int line) { if (!multiLine) { if (line == 0) { return MString.join(cells, ' '); } else return ""; } if (cells == null || line < 0 || line >= cells.length) return ""; return cells[line]; }
public RESULT check(String name) { if (MString.compareFsLikePattern(name, pattern)) return result; return RESULT.NEXT; }
/** * Try to find initials out of the given title. Use the first letters after whitspaces for the initials. The * returned string is not in upper letters. If you need Upper Letters append toUpper(). * @param title The input String * @param upperOnly Set true if only collect upper characters in title * @param digits Set true if digits (after whitespaces) should also be used. * @param maxSize Max size in characters of the initilas or 0 for no limit. * @return The initials in mixed letters. */ public static String findInitials(String title, boolean upperOnly, boolean digits, int maxSize) { if (isEmptyTrim(title)) return "?"; StringBuilder out = new StringBuilder(); // find first letters boolean isSpace = true; for (int i = 0; i < title.length(); i++) { char c = title.charAt(i); if (isWhitespace(c)) { isSpace = true; } else { if (isSpace) { if ((c >= 'A' && c <= 'Z') || !upperOnly && ( c >= 'a' && c <= 'z') || digits && (c >= '0' && c <= '9')) out.append(c); if (maxSize > 0 && out.length() >= maxSize) break; } isSpace = false; } } return out.toString(); }
List<CaoMetaDefinition> metaMap = caoMeta.getMap(); CaoMetaDefinition.TYPE caoType = getCaoType(cfield); String[] categories = MString.splitIgnoreEmpty(cfield.getString(K_CATEGORIES, ""),",",true); metaMap.add(new CaoMetaDefinition(caoMeta, cfield.getExtracted("name"), caoType, cfield.getExtracted("nls"), cfield.getInt("size",100), categories )); TreeSet<String> set = new TreeSet<String>(); for (String item : keys.split(",") ) set.add(normalizeColumnName(item)); keys = MString.join(set.iterator(), ",");