Exemplo n.º 1
0
  private String getFullname(Tag tag, String defaultValue) {
    if (tag != null) {
      String fn = tag.getFullname();
      if (StringUtil.isEmpty(fn)) fn = tag.getTagLibTag().getFullName();
      if (!StringUtil.isEmpty(fn)) return fn;
    }

    return defaultValue;
  }
Exemplo n.º 2
0
  public static boolean isLiteralAttribute(
      Tag tag, Attribute attr, short type, boolean required, boolean throwWhenNot)
      throws EvaluatorException {
    String strType = "/constant";
    if (attr != null && !isNull(attr.getValue())) {

      switch (type) {
        case TYPE_ALL:
          if (attr.getValue() instanceof Literal) return true;
          break;
        case TYPE_BOOLEAN:
          if (CastBoolean.toExprBoolean(attr.getValue()) instanceof LitBoolean) return true;
          strType = " boolean";
          break;
        case TYPE_NUMERIC:
          if (CastDouble.toExprDouble(attr.getValue()) instanceof LitDouble) return true;
          strType = " numeric";
          break;
        case TYPE_STRING:
          if (CastString.toExprString(attr.getValue()) instanceof LitString) return true;
          strType = " string";
          break;
      }
      if (!throwWhenNot) return false;
      throw new EvaluatorException(
          "Attribute ["
              + attr.getName()
              + "] of the Tag ["
              + tag.getFullname()
              + "] must be a literal"
              + strType
              + " value. "
              + "attributes java class type "
              + attr.getValue().getClass().getName());
    }
    if (required) {
      if (!throwWhenNot) return false;
      throw new EvaluatorException(
          "Attribute [" + attr.getName() + "] of the Tag [" + tag.getFullname() + "] is required");
    }
    return false;
  }
Exemplo n.º 3
0
 /**
  * Gibt ein uebergeordnetes Tag mit dem uebergebenen Full-Name (Namespace und Name) zurueck, falls
  * ein solches existiert, andernfalls wird null zurueckgegeben.
  *
  * @param el Startelement, von wo aus gesucht werden soll.
  * @param fullName Name des gesuchten Tags.
  * @return uebergeornetes Element oder null.
  */
 public static Tag getAncestorTag(Tag tag, String fullName) {
   Statement parent = tag;
   while (true) {
     parent = parent.getParent();
     if (parent == null) return null;
     if (parent instanceof Tag) {
       tag = (Tag) parent;
       if (tag.getFullname().equalsIgnoreCase(fullName)) return tag;
     }
   }
 }
Exemplo n.º 4
0
 public static boolean isParentTag(Tag tag, String fullName) {
   Tag p = getParentTag(tag);
   if (p == null) return false;
   return p.getFullname().equalsIgnoreCase(fullName);
 }