Esempio n. 1
0
 /**
  * If the descend or mandatory attributes are null they will be replaced with the defaults from
  * the path given
  */
 public void mergeDefaults(RepoPath path) {
   // Fill in defaults if not specified
   from = (from == null) ? RUNTIME : from;
   descend =
       (descend == null) ? ((path.isDescendDefault()) ? Boolean.TRUE : Boolean.FALSE) : descend;
   mandatory =
       (mandatory == null)
           ? ((path.isMandatoryDefault()) ? Boolean.TRUE : Boolean.FALSE)
           : mandatory;
 }
Esempio n. 2
0
  /**
   * Converts the path spec to its short hand form. It minimises the output by matching elminating
   * settings that match either the path or in-built defaults.
   */
  public String toShortHand(RepoPath path) {
    Assert.isTrue(
        path.getId().equals(to),
        "Attempt to create shorthand with the wrong path: to=" + to + ", path=" + path.getId());

    StringBuffer sb = new StringBuffer(to);

    if (mandatory.booleanValue() != path.isMandatoryDefault()) {
      sb.append(mandatory.booleanValue() ? "!" : "?");
    }

    if (descend.booleanValue() != path.isDescendDefault()) {
      sb.append(descend.booleanValue() ? "<" : "+");
    }

    if (!from.equals(RUNTIME)) {
      sb.append((descend.booleanValue() == path.isDescendDefault()) ? "=" : "");
      sb.append(from);
    }

    sb.append((options == null) ? "" : ("(" + options + ")"));

    return sb.toString();
  }