/**
  * Joins the path.
  *
  * @param s segment to start with
  * @return joined path
  */
 private String join(final int s) {
   final TokenBuilder tb = new TokenBuilder();
   for (int p = s; p < segments.length; p++) {
     if (!tb.isEmpty()) tb.add('/');
     tb.add(segments[p]);
   }
   return tb.toString();
 }
Example #2
0
 /**
  * Returns the database path (i.e., all path entries except for the first).
  *
  * @return path depth
  */
 public String dbpath() {
   final TokenBuilder tb = new TokenBuilder();
   final int ps = segments.length;
   for (int p = 1; p < ps; p++) {
     if (!tb.isEmpty()) tb.add('/');
     tb.add(segments[p]);
   }
   return tb.toString();
 }
Example #3
0
 /**
  * Returns an information string for an unexpected exception.
  *
  * @param ex exception
  * @return dummy object
  */
 public static String bug(final Throwable ex) {
   final TokenBuilder tb = new TokenBuilder(BUGINFO);
   tb.add(NL).add("Contact: ").add(MAIL);
   tb.add(NL).add("Version: ").add(TITLE);
   tb.add(NL).add("Java: ").add(System.getProperty("java.vendor"));
   tb.add(", ").add(System.getProperty("java.version"));
   tb.add(NL).add("OS: ").add(System.getProperty("os.name"));
   tb.add(", ").add(System.getProperty("os.arch"));
   tb.add(NL).add("Stack Trace: ");
   for (final String e : toArray(ex)) tb.add(NL).add(e);
   return tb.toString();
 }
 /**
  * Converts the path to a string array, containing the single segments.
  *
  * @param path path, or {@code null}
  * @return path depth
  */
 public static String[] toSegments(final String path) {
   final StringList sl = new StringList();
   if (path != null) {
     final TokenBuilder tb = new TokenBuilder();
     for (int s = 0; s < path.length(); s++) {
       final char ch = path.charAt(s);
       if (ch == '/') {
         if (tb.isEmpty()) continue;
         sl.add(tb.toString());
         tb.reset();
       } else {
         tb.add(ch);
       }
     }
     if (!tb.isEmpty()) sl.add(tb.toString());
   }
   return sl.toArray();
 }
Example #5
0
 /**
  * Throws a runtime exception for an unimplemented method.
  *
  * @param ext optional extension
  * @return runtime exception (indicates that an error is raised)
  */
 public static RuntimeException notimplemented(final Object... ext) {
   final TokenBuilder tb = new TokenBuilder("Not Implemented");
   if (ext.length != 0) tb.addExt(" (%)", ext);
   throw new UnsupportedOperationException(tb.add('.').toString());
 }