SunCmpMappingsUtilspublic class SunCmpMappingsUtils extends Object Finder utilities for elements of the SunCmpMappings
object graph. |
Fields Summary |
---|
private static ResourceBundle | bundle |
Constructors Summary |
---|
private SunCmpMappingsUtils()Creates a new instance of SunCmpMappingsUtils //NOI18N
|
Methods Summary |
---|
public static CmpFieldMapping | findCmpFieldMapping(EntityMapping em, java.lang.String fname, boolean addEmpty)Find the CmpFieldMapping element with a matching field-name element value
CmpFieldMapping retVal = (CmpFieldMapping) findSingleCompatibleBean(
"em", em, "fname", fname, "field-name", CmpFieldMapping.class); // NOI18N
if ((null == retVal) && addEmpty) {
retVal = new CmpFieldMapping();
retVal.setFieldName(fname);
em.addCmpFieldMapping(retVal);
}
return retVal;
| public static CmrFieldMapping | findCmrFieldMapping(EntityMapping em, java.lang.String fname, boolean addEmpty)Find the cmr-field-mapping element for a field in an EntityMapping object
CmrFieldMapping retVal = (CmrFieldMapping) findSingleCompatibleBean(
"em", em, "fname", fname, "cmr-field-name", CmrFieldMapping.class); // NOI18N
if ((null == retVal) && addEmpty) {
retVal = new CmrFieldMapping();
retVal.setCmrFieldName(fname);
em.addCmrFieldMapping(retVal);
}
return retVal;
| protected static java.util.List | findCompatibleBeansWithValue(org.netbeans.modules.schema2beans.BaseBean root, java.lang.String propName, java.lang.String propVal, java.lang.Class type)A utility for finding beans in a graph of BaseBean objects.
Search the bean graph, starting at a given root, for beans where the named
property has the given value. The returned list is filtered by assignment
compatibility.
List retVal = null;
GraphManager gm = root.graphManager();
if (null == gm)
throw new IllegalArgumentException(
bundle.getString("ERR_DISCONNECTED_NOT_SUPPORTED"));
String[] props = root.findPropertyValue(propName, propVal);
int len = 0;
if (null != props)
len = props.length;
if (len > 0)
retVal = new ArrayList();
for (int i = 0; i < len; i++) {
// get the bean that is the property's parent.
BaseBean candidate = gm.getPropertyParent(props[i]);
if (type.isInstance(candidate))
retVal.add(candidate);
}
return retVal;
| public static EntityMapping | findEntityMapping(SunCmpMappings scms, java.lang.String bname, boolean addEmpty)Find the EntityMapping element that correspond to a bean.
EntityMapping retVal = (EntityMapping) findSingleCompatibleBean(
"scms", scms, "bname", bname, "ejb-name", EntityMapping.class); // NOI18N
if ((null == retVal) && addEmpty) {
retVal = new EntityMapping();
retVal.setEjbName(bname);
SunCmpMapping scm = getFirstSunCmpMapping(scms, addEmpty);
scm.addEntityMapping(retVal);
}
return retVal;
| private static org.netbeans.modules.schema2beans.BaseBean | findSingleCompatibleBean(java.lang.String argOneName, org.netbeans.modules.schema2beans.BaseBean argOne, java.lang.String argTwoName, java.lang.String argTwo, java.lang.String propName, java.lang.Class type)helper method
BaseBean retVal = null;
if (null == argTwo || argTwo.length() < 1)
throw new IllegalArgumentException(argTwoName);
List l = findCompatibleBeansWithValue(argOne, propName, argTwo,
type);
if (null != l) {
if (l.size() == 1)
retVal = (BaseBean) l.get(0);
else if (l.size() > 1)
throw new IllegalArgumentException(argOneName);
}
return retVal;
| public static SunCmpMapping | getFirstSunCmpMapping(SunCmpMappings scms, boolean addEmpty)Return the first SunCmpMapping element from the graph.
SunCmpMapping retVal = null;
if (0 < scms.sizeSunCmpMapping())
retVal = scms.getSunCmpMapping(0);
if ((null == retVal) && addEmpty) {
retVal = new SunCmpMapping();
scms.addSunCmpMapping(retVal);
}
return retVal;
|
|