public static final boolean isPublic(Field field) { if ( field == null ) return false; return (JavaVisibilityKind.PUBLIC_LITERAL == field.getJavaVisibility()); }
protected static boolean isPublic(Field field) { if (field == null) return false; return (JavaVisibilityKind.PUBLIC_LITERAL.getValue() == field.getJavaVisibility().getValue()); }
/** * Is the cmp attribute also a field in the key class? */ protected boolean isAttributeKeyClassField(String attributeName) { // ensure key class is not null JavaClass keyClass = cmp.getPrimaryKey(); if (keyClass == null) return false; // see if the attribute name matchs any of the reflected key class public field names List keyFields = keyClass.getFieldsExtended(); for (int i = 0; i < keyFields.size(); i++) { Field field = (Field) keyFields.get(i); if (field.getJavaVisibility() == JavaVisibilityKind.PUBLIC_LITERAL) { if (field.getName().equals(attributeName)) return true; } } return false; }
protected void initializeForCompoundKey() { List keys = getKeyAttributes(); // clear key list keys.clear(); //ensure the key class is not null JavaClass keyClass = cmp.getPrimaryKey(); if (keyClass == null) return; keyClass.eAdapters().add(this); // reflect key fields into key attributes list List keyFields = keyClass.getFieldsExtended(); for (int i = 0; i < keyFields.size(); i++) { Field field = (Field) keyFields.get(i); if (field.getJavaVisibility() == JavaVisibilityKind.PUBLIC_LITERAL) { //only public fields CMPAttribute keyAttribute = cmp.getPersistentAttribute(field.getName()); if (keyAttribute != null) keys.add(keyAttribute); } } }
/** * Sort the list of the key attributes to match the order of the key class */ private void sortKeyAttributeList() { List result = new ArrayList(); JavaClass keyClass = cmp.getPrimaryKey(); if (keyClass == null) return; List keyFields = keyClass.getFieldsExtended(); List currentKeys = getKeyAttributes(); // create a new list of the attributes in order of key class fields. for (int i = 0; i < keyFields.size(); i++) { Field field = (Field) keyFields.get(i); if (field.getJavaVisibility() == JavaVisibilityKind.PUBLIC_LITERAL) { //only public fields for (int j=0; j<currentKeys.size(); j++) { CMPAttribute attribute = (CMPAttribute) currentKeys.get(j); if (field.getName().equals(attribute.getName())) result.add(attribute); } } } //clear list and set the new key attribute order on the cmp getKeyAttributes().clear(); getKeyAttributes().addAll(result); }
for (int i = 0; i < keyFields.size(); i++) { Field field = (Field) keyFields.get(i); if (field.getJavaVisibility() != JavaVisibilityKind.PUBLIC_LITERAL) continue; String fieldName = field.getName();