/** @return The list of hints joined into a string */ public String hintsString() { return StrUtils.strjoin( " ", hints ); }
/** @return An HTML marked-up string of related links */ public String relatedLinksHTML() { List<String> html = new ArrayList<String>(); html.add( "<ul class=''>" ); for (Link l: relatedLinks()) { html.add( l.toHTMLString( "li" ) ); } html.add( "</ul>" ); return StrUtils.strjoin( "\n", html ); }
/** * Tokenise the input string into words based on camelCase boundaries and hyphen characters. * If the input string is already tokenised into words (determined by whether it contains a * space character or not), return the string unchanged. * @param name The input name to tokenise * @return The input string, with camel-case boundaries, hyphens and underscores replaced by spaces. */ protected String tokeniseWords( String name ) { if (name.matches( "[^\\p{Space}]*(((\\p{Lower}|\\p{Digit})(\\p{Upper}))|[-_])[^\\p{Space}]*" )) { String deCamelCased = name.replaceAll( "(\\p{Lower}|\\p{Digit})(\\p{Upper})", "$1-$2" ); List<String> correctlyCased = new ArrayList<String>(); for (String word: deCamelCased.split( "[-_]" )) { if (word.length() > 0) { correctlyCased.add( word.substring( 0, 1 ).toLowerCase() + word.substring( 1) ); } } return StrUtils.strjoin( " ", correctlyCased ); } else { return name; } }
/** * Return this link in HTML markup form. * @param elem If non-null, denotes a element to use to bracket the link, e.g. <code>li</code> * @return The contents of this link as an HTML <code>a</code> element */ public String toHTMLString( String elem ) { StringBuffer buf = new StringBuffer(); if (elem != null) { buf.append( "<" + elem + ">" ); } buf.append( "<a " ); buf.append( "href='" + url().toString() + "' " ); buf.append( "class='" + StrUtils.strjoin( " ", hints() ) + "' " ); buf.append( ">" ); buf.append( title() ); buf.append( "</a>" ); if (elem != null) { buf.append( "</" + elem + ">" ); } return buf.toString(); }
@Override public final NodeValue exec(List<NodeValue> args) { if ( args == null ) // The contract on the function interface is that this should not happen. throw new ARQInternalErrorException(Utils.className(this)+": Null args list") ; Iterator<NodeValue> iter = args.iterator() ; String sep = iter.next().asString() ; List<String> x = new ArrayList<String>() ; for ( ; iter.hasNext() ; ) { NodeValue arg = iter.next(); x.add( arg.asString() ) ; } return NodeValue.makeString(StrUtils.strjoin(sep, x)) ; }
public static Resource findRootByType(Model model, Resource atype) { String s = StrUtils.strjoin("\n", "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" , "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>", "SELECT DISTINCT ?root { { ?root rdf:type ?ATYPE } UNION { ?root rdf:type ?t . ?t rdfs:subClassOf ?ATYPE } }") ; Query q = QueryFactory.create(s) ; QuerySolutionMap qsm = new QuerySolutionMap() ; qsm.add("ATYPE", atype) ; QueryExecution qExec = QueryExecutionFactory.create(q, model, qsm); Resource r = (Resource)QueryExecUtils.getOne(qExec, "root") ; return r; }