Exemple #1
0
 @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();
 }
 public String toString() {
   StringBuilder sb = new StringBuilder(this.getClass().getSimpleName()).append('{');
   for (TypedValues typed : _values) {
     sb.append(typed);
   }
   return sb.append('}').toString();
 }
Exemple #3
0
 /** 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();
   }
 }
Exemple #4
0
  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);
    }
  }
Exemple #5
0
  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();
  }
Exemple #6
0
  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();
  }
Exemple #7
0
 /**
  * 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();
 }
Exemple #8
0
  /**
   * 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 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();
 }
  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("&", "&amp;");
    s = s.replaceAll("<", "&lt;");
    s = s.replaceAll(">", "&gt;");
    //    	s = s.replaceAll( "'", "&apos;" );
    //    	s = s.replaceAll( "\"", "&quot;" );

    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();
  }
 public void characters(char[] chars, int start, int length) {
   currentCharacters.append(chars, start, length);
 }
Exemple #12
0
 private static String nZeros(int n) {
   StringBuilder sb = new StringBuilder();
   for (int i = 0; i < n; i++) sb.append('0');
   return sb.toString();
 }
Exemple #13
0
  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();
  }
 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();
 }