/** * This method returns a new <code>CIMClass</code> with properties filtered according to the input * parameters. Inclusion of class origin and qualifiers can also be controlled. Methods will not * be included in the class returned. * * @param pLocalOnly If <code>true</code> only the elements defined in this class are included; * otherwise all elements are included. * @param pIncludeQualifiers If <code>true</code> qualifiers are included on all elements; * otherwise no qualifiers are included. * @param pIncludeClassOrigin If <code>true</code>, the ClassOrigin attribute is included. * @param pPropertyList If the <code>PropertyList</code> input parameter is not <code>null</code>, * the members of the array define one or more Property names. The <code>CIMClass</code> * returned does not include elements for any Properties missing from this list. If the <code> * PropertyList</code> input parameter is an empty array this signifies that no Properties are * included in the class returned. If the <code>PropertyList</code> input parameter is <b> * <code>null</code></b> this specifies that all Properties are included in the class * returned. If the <code>PropertyList</code> contains duplicate elements or invalid property * names, they are ignored. * @return <code>CIMClass</code> matching the requested criteria. */ public CIMClass filterProperties( boolean pLocalOnly, boolean pIncludeQualifiers, boolean pIncludeClassOrigin, String[] pPropertyList) { ArrayList<CIMClassProperty<?>> newPropAList = new ArrayList<CIMClassProperty<?>>(); // place pPropertyList into a set, for easy and fast search TreeSet<String> set; if (pPropertyList != null) { set = new TreeSet<String>(); for (int i = 0; i < pPropertyList.length; i++) set.add(pPropertyList[i].toUpperCase()); } else set = null; for (int i = 0; i < getPropertyCount(); i++) { CIMClassProperty<?> refProp = getProperty(i); if (pLocalOnly && refProp.isPropagated()) continue; if (set == null || set.contains(refProp.getName().toUpperCase())) newPropAList.add( new CIMClassProperty<Object>( refProp.getName(), refProp.getDataType(), refProp.getValue(), pIncludeQualifiers ? refProp.getQualifiers() : null, pIncludeQualifiers ? refProp.isKey() : false, // FIXME: // Should it depend on pIncludeQualifiers? refProp.isPropagated(), pIncludeClassOrigin ? refProp.getOriginClass() : null)); } return new CIMClass( getObjectPath(), getSuperClassName(), getQualifiers(), newPropAList.toArray(new CIMClassProperty[0]), null, isAssociation(), isKeyed()); }
/** * Gets the specified property. * * @param pName The string name of the property to get. * @param pOriginClass (Optional) The string name of the class in which the property was defined. * @return The property requested or <code>null</code> if the property does not exist. */ public CIMClassProperty<?> getProperty(String pName, String pOriginClass) { CIMClassProperty<?> prop = (CIMClassProperty<?>) CIMElementSorter.find(this.iProps, pName); if (prop == null || pOriginClass == null) return prop; return pOriginClass.equalsIgnoreCase(prop.getOriginClass()) ? prop : null; }