@Override public String toString() { if (name == null) return null; else return StringUtils.escapeHTMLEntities(name); } }
protected void addAttribute(AttributeListImpl atts, String name, String type, String[] values) { if (values != null) atts.addAttribute(name, type, StringUtils.join(values, ",")); }
private String getPrefix(String baseurl) { String prefix = (String) nsuris.get(baseurl); if (prefix == null && !unassigned.contains(baseurl)) { // try to make nice, friendly prefix out of URI int first = baseurl.lastIndexOf('/'); int second = baseurl.lastIndexOf('/', first - 1); // FIXME: could crash? if (first != -1 && second != -1) { String candidate = baseurl.substring(second + 1, first); candidate = StringUtils.normalizeId(candidate); if (candidate != null && candidate.length() <= 1) candidate = null; // could be too short after cutting if (candidate != null && !prefixes.containsKey(candidate)) prefix = candidate; } if (prefix == null) unassigned.add(baseurl); // will assign preXX prefix later else addPrefix(prefix, baseurl); } return prefix; }
public void testMakeRandomId() { String id = StringUtils.makeRandomId(10); assertTrue("random id had wrong length", id.length() == 10); }
String relations = config.getInitParameter("relations"); if (relations != null) relnames = Arrays.asList(StringUtils.split(relations, ","));
String paramsNormalized = StringUtils.normalizeWhitespace(params.trim()); String[] names = StringUtils.split(paramsNormalized); List varlist = new ArrayList(names.length); for (int i = 0; i < names.length; i++) {
public int compare(Topic t1, Topic t2) { if (t1 == null && t2 == null) return 0; else if (t1 == null) return 1; else if (t2 == null) return -1; return StringUtils.compareToIgnoreCase(t1.getName(), t2.getName()); }
public Object get(Object keyy) { String key = (String) keyy; Object o = null; if (key.equals("value") || key.equals("topic")) o = value; else if (key.equals("new")) o = randid; // keys of form newXXX where XXX is an integer else if (key.startsWith("new") && StringUtils.isInteger(key.substring(3))) { if (newkeys.containsKey(key)) o = newkeys.get(key); else { o = makeRandomId(topicmap); newkeys.put(key, o); } } else { ActionParametersIF params = request.getActionParameters((String) key); if (params == null) throw new OntopiaRuntimeException("Reference in LTM template to undefined action: '" + key + "'"); o = params.getTMObjectValue(); if (o == null) o = params.getStringValue(); } if (o instanceof TMObjectIF) o = getId((TMObjectIF) o); log.debug("RMW.get('" + key + "') -> " + o); return o; }
public void testMakeTwoRandomIds() { String id1 = StringUtils.makeRandomId(10); String id2 = StringUtils.makeRandomId(10); assertTrue("random id1 had wrong length", id1.length() == 10); assertTrue("random id2 had wrong length", id2.length() == 10); assertTrue("random ids are equal!", !id1.equals(id2)); }
String[] at_data = StringUtils.split(at, ":"); if (at_data.length != 3) continue;
public int compare(Object o1, Object o2) { LocatorIF i1 = (LocatorIF)o1; LocatorIF i2 = (LocatorIF)o2; return StringUtils.compareToIgnoreCase(i1.getAddress(), i2.getAddress()); }
/** * INTERNAL: Filters the specified string for characters that are * senstive to HTML interpreters, writing the string with these * characters replaced by the corresponding character entities to * the given writer. * * @param value The string to be filtered and written. * * @since 3.0 */ public static void escapeHTMLEntities(String value, Writer out) throws IOException { if (value == null) return; out.write(escapeHTMLEntities(value)); }
public String getNameTitle() { return term.getStem() + ": " + StringUtils.join(term.getVariants(), " | "); }
public void testNormalizeIdStripAccents() { String input = "ab\u00C6\u00D8\u00E5\u00E9\u00FF\u00FCab\u00CF"; assertEquals("incorrect normalization", StringUtils.normalizeId(input), "abeoaeyuabi"); }
private String makeRandomId(TopicMapIF topicmap) { String id; TMObjectIF tmobj; LocatorIF base = topicmap.getStore().getBaseAddress(); do { id = StringUtils.makeRandomId(10); tmobj = topicmap.getObjectByItemIdentifier(base.resolveAbsolute("#" + id)); } while (tmobj != null); return id; }
table = csvfile; String[] columns = (args.length >= 4 ? StringUtils.split(args[3], ",") : null);
public int compare(Object o1, Object o2) { TopicNameIF n1 = (TopicNameIF)o1; TopicNameIF n2 = (TopicNameIF)o2; return StringUtils.compareToIgnoreCase(n1.getValue(), n2.getValue()); }
/** * INTERNAL: prints out string to specified JspWriter object * with respect if the entities should be escaped. */ protected final void print2Writer(JspWriter out, String string) throws IOException { if (escapeEntities) StringUtils.escapeHTMLEntities(string, out); else out.print( string ); }
public static void addTuple(Relation relation, String[] tuple, Context ctx) { if (log.isDebugEnabled()) log.debug(" a(" + StringUtils.join(tuple, "|") + "),"+ tuple.length); List entities = relation.getEntities(); for (int i=0; i < entities.size(); i++) { Entity entity = (Entity)entities.get(i); try { Object o = addEntity(relation, entity, tuple, ctx); ctx.setEntityObject(i, o); } catch (Exception e) { throw new DB2TMException("Error occurred while adding tuple " + Arrays.asList(tuple) + " from relation " + relation.getName() + " to entity " + entity, e); } } }
/** * Returns an id string for a given topic, as it should appear when preserving * IDs. */ private String generateId(TopicIF topic) { String name = TopicStringifiers.toString(topic); String retVal; if ("[No name]".equals(name)) retVal = idManager.makeId(topic, "id", true); else { String generatedId = StringUtils.normalizeId(name); if (generatedId == null || isReservedId(generatedId) || allSameAs(generatedId, '_')) retVal = idManager.makeId(topic, "id", true); else { retVal = idManager.makeId(topic, generatedId, false); } } return retVal; }