private String unirMapeos(LinkedHashMap<String, String> mapa, Object[] descripciones) { // mapa(llave,punto) // descripciones en el mismo orden que el mapeo String comillas = "\""; StringBuilder builder = new StringBuilder(); Iterator<String> iterador = mapa.keySet().iterator(); int indice = 0; while (iterador.hasNext()) { String llave = iterador.next(); String puntaje = mapa.get(llave); String descripcion = descripciones[indice].toString().equals("null") ? "" : descripciones[indice].toString(); builder.append(comillas + descripcion + comillas + "," + comillas + puntaje + comillas + ","); indice++; } return builder.toString(); }
public void flushCharacters(boolean finalFlush, boolean topLevel) throws SAXException { if (currentCharacters.length() > 0) { final String currentString = currentCharacters.toString(); final char[] chars = currentString.toCharArray(); if (StringUtils.isBlank(currentString) || !topLevel) { // Just output whitespace as is super.characters(chars, 0, chars.length); } else { // The first element received determines the type of separator checkDelimiters(XMLConstants.XHTML_NAMESPACE_URI, spanQName, topLevel); // Wrap any other text within an xhtml:span super.startElement( XMLConstants.XHTML_NAMESPACE_URI, "span", spanQName, getAttributesWithClass(XMLUtils.EMPTY_ATTRIBUTES)); super.characters(chars, 0, chars.length); super.endElement(XMLConstants.XHTML_NAMESPACE_URI, "span", spanQName); } isCharacters = false; currentCharacters.setLength(0); } if (finalFlush) checkDelimiters(XMLConstants.XHTML_NAMESPACE_URI, spanQName, topLevel); }
public String toString() { StringBuilder sb = new StringBuilder(this.getClass().getSimpleName()).append('{'); for (TypedValues typed : _values) { sb.append(typed); } return sb.append('}').toString(); }
@Override public String toString() { final StringBuilder sb = new StringBuilder(); if (url != null) sb.append(url).append(", "); if (line != Integer.MIN_VALUE) sb.append(line).append(':').append(column).append(": "); return sb.append(message).toString(); }
/** Encode a URI and local name to an exploded QName (also known as a "Clark name") String. */ public static String buildExplodedQName(String uri, String localname) { if ("".equals(uri)) return localname; else { final StringBuilder sb = new StringBuilder(uri.length() + localname.length() + 2); sb.append('{'); sb.append(uri); sb.append('}'); sb.append(localname); return sb.toString(); } }
private static void mapPrefixIfNeeded( Set<String> declaredPrefixes, String uri, String qName, StringBuilder sb) { final String prefix = XMLUtils.prefixFromQName(qName); if (prefix.length() > 0 && !declaredPrefixes.contains(prefix)) { sb.append(" xmlns:"); sb.append(prefix); sb.append("=\""); sb.append(uri); sb.append("\""); declaredPrefixes.add(prefix); } }
public String toString() { int size = args.size(); StringBuilder sb = new StringBuilder(name) .append('@') .append(hashCode()) .append(':') .append(size) .append('\n'); for (int i = 0; i < size; ++i) { sb.append(args.get(i).get(0)).append('\n'); } return sb.toString(); }
private String obtenerNombre(Element raiz) { String comillas = "\""; StringBuilder nombre = new StringBuilder(comillas); String[] vars = {"CliApePat", "CliApeMat", "CliNom"}; for (String s : vars) { nombre.append(raiz.getElementsByTagName(s).item(0).getTextContent() + " "); } nombre.append(comillas); return nombre.toString(); }
public void flushCharacters(boolean finalFlush, boolean topLevelCharacters) throws SAXException { final String currentString = currentCharacters.toString(); if (topLevelCharacters && !isAroundTableOrListElement) { // We handle top-level characters specially and wrap them in a span so we can hide them generateTopLevelSpanWithCharacters(currentCharacters.toString()); } else { // Just output characters as is in deeper levels, or when around at table or list element final char[] chars = currentString.toCharArray(); super.characters(chars, 0, chars.length); } currentCharacters.setLength(0); if (finalFlush) generateFirstDelimitersIfNeeded(); }
/** * Returns canonical link to a bitstream in the item. * * @param item The DSpace Item that the bitstream is part of * @param bitstream The bitstream to link to * @returns a String link to the bitstream */ private String makeBitstreamLink(Item item, Bitstream bitstream) { String name = bitstream.getName(); StringBuilder result = new StringBuilder(contextPath); result.append("/bitstream/item/").append(String.valueOf(item.getID())); // append name although it isn't strictly necessary try { if (name != null) { result.append("/").append(Util.encodeBitstreamName(name, "UTF-8")); } } catch (UnsupportedEncodingException uee) { // just ignore it, we don't have to have a pretty // name on the end of the url because the sequence id will // locate it. However it means that links in this file might // not work.... } result.append("?sequence=").append(String.valueOf(bitstream.getSequenceID())); return result.toString(); }
public void characters(char[] buf, int offset, int len) throws SAXException { String s = new String(buf, offset, len); // take care of basic entity references before printing s = s.replaceAll("&", "&"); s = s.replaceAll("<", "<"); s = s.replaceAll(">", ">"); // s = s.replaceAll( "'", "'" ); // s = s.replaceAll( "\"", """ ); if (textBuffer == null) { textBuffer = new StringBuilder(s); } else { textBuffer.append(s); } if (error_codeFlag) error_code = textBuffer.toString(); if (error_textFlag) error_text = textBuffer.toString(); }
/** * Make an NCName out of a non-blank string. Any characters that do not belong in an NCName are * converted to '_'. * * @param name source * @return NCName */ public static String makeNCName(String name) { if (StringUtils.isBlank(name)) throw new IllegalArgumentException("Name must not be blank or empty"); final Name10Checker name10Checker = Name10Checker.getInstance(); if (name10Checker.isValidNCName(name)) { return name; } else { final StringBuilder sb = new StringBuilder(); final char start = name.charAt(0); sb.append(name10Checker.isNCNameStartChar(start) ? start : '_'); for (int i = 1; i < name.length(); i++) { final char ch = name.charAt(i); sb.append(name10Checker.isNCNameChar(ch) ? ch : '_'); } return sb.toString(); } }
public void characters(char[] chars, int start, int length) { currentCharacters.append(chars, start, length); }
private static void addxmltext(SolrInputDocument doc, String field, StringBuilder text) { if (text != null && text.length() > 0) { doc.addField(field, text.toString()); } }
private static String nZeros(int n) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) sb.append('0'); return sb.toString(); }
private String args(Object... property) { StringBuilder sb = new StringBuilder("("); for (int i = 0; i < property.length; ++i) sb.append(property[i].getClass().getName()).append(':').append(property[i]).append(' '); return sb.append(')').toString(); }
public static String saxElementToDebugString(String uri, String qName, Attributes attributes) { // Open start tag final StringBuilder sb = new StringBuilder("<"); sb.append(qName); final Set<String> declaredPrefixes = new HashSet<String>(); mapPrefixIfNeeded(declaredPrefixes, uri, qName, sb); // Attributes if any for (int i = 0; i < attributes.getLength(); i++) { mapPrefixIfNeeded(declaredPrefixes, attributes.getURI(i), attributes.getQName(i), sb); sb.append(' '); sb.append(attributes.getQName(i)); sb.append("=\""); sb.append(attributes.getValue(i)); sb.append('\"'); } // Close start tag sb.append('>'); // Content sb.append("[...]"); // Close element with end tag sb.append("</"); sb.append(qName); sb.append('>'); return sb.toString(); }