Пример #1
0
  public List<EntityDescriptor> filterEntityCategory(
      List<EntityDescriptor> entities, String category) {
    List<EntityDescriptor> returnList = new ArrayList<EntityDescriptor>();

    for (EntityDescriptor entity : entities) {
      Extensions extensions = entity.getExtensions();
      List<XMLObject> extObjs = extensions.getOrderedChildren();
      for (XMLObject xmlObject : extObjs) {
        if (xmlObject instanceof EntityAttributes) {
          EntityAttributes entityAttrs = (EntityAttributes) xmlObject;
          for (Attribute attr : entityAttrs.getAttributes()) {
            if ("http://macedir.org/entity-category".equals(attr.getName())) {
              for (XMLObject value : attr.getAttributeValues()) {
                if (value instanceof XSAny) {
                  XSAny any = (XSAny) value;
                  if (category.equals(any.getTextContent())) {
                    returnList.add(entity);
                  }
                }
              }
            }
          }
        }
      }
    }

    return returnList;
  }