public static void filterObjectClassesByContext(String context, ResultSet results) {
    ObjectClass[] ocs = results.getObjectClass();
    if (ocs == null) {
      return;
    }

    LOG.debug("Filtering object classes by context: " + context);

    List<ObjectClass> newObjectClasses = new ArrayList<ObjectClass>();
    for (ObjectClass oc : ocs) {
      if (oc.getContext().getName().equalsIgnoreCase(context)) {
        newObjectClasses.add(oc);
      }
    }

    LOG.debug("Total matching object classes: " + newObjectClasses.size());
    results.setObjectClass(newObjectClasses.toArray(new ObjectClass[newObjectClasses.size()]));
  }
  public static void filterPropertiesByContext(String context, ResultSet results) {
    Property[] props = results.getProperty();
    if (props == null) {
      return;
    }

    LOG.debug("Filtering properties by context: " + context);

    List<Property> newProps = new ArrayList<Property>();
    for (Property p : props) {
      if (p.getContext().getName().equalsIgnoreCase(context)) {
        newProps.add(p);
      }
    }

    LOG.debug("Total matching properties: " + newProps.size());
    results.setProperty(newProps.toArray(new Property[newProps.size()]));
  }
  public static void filterDataElementsByContext(String context, ResultSet results) {

    DataElement[] des = results.getDataElement();
    if (des == null) {
      return;
    }

    LOG.debug("Filtering data elements by context: " + context);

    List<DataElement> newDataElements = new ArrayList<DataElement>();
    for (DataElement de : des) {
      if (de.getContext().getName().equalsIgnoreCase(context)) {
        newDataElements.add(de);
      }
    }

    LOG.debug("Total matching data elements: " + newDataElements.size());
    results.setDataElement(newDataElements.toArray(new DataElement[newDataElements.size()]));
  }