public boolean isEmpty(ClassEntry entry) { if (isPrimitive(entry)) return false; // Primitive classes are saved if ((entry.getSourceClass().isInterface()) || (entry.getSourceClass().getName().startsWith("java"))) return true; // Intefaces or java.** classes will never have attributes return false; }
private boolean isStorable(ClassEntry entry) { if (isPrimitive(entry)) return true; // Primitive classes are saved if ((entry.getSourceClass().isInterface()) || (entry.getSourceClass().getName().startsWith("java"))) return false; // Intefaces or java.** classes are non-storable if ((Modifier.isAbstract(entry.getSourceClass().getModifiers())) && (!hasStaticAttributes(entry))) return false; // Abstract superclasses which have no attributes return true; }
public ClassEntry lookupAdd(String cname) { ClassEntry ce = (ClassEntry) (cdict.get(cname)); if (ce == null) { ce = new ClassEntry(cname); if (filter.accept(null, cname)) { ce.flags |= ClassEntry.EXCLUDED; } cdict.put(cname, ce); } return ce; }
/** * Instantiate an object of this info entity. If the object in question is a dynamic object, it's * dynamic name will be set. * * @param marshalledValues The values for which this object will be created. */ public Object newInstance(Map marshalledValues) throws InstantiationException, IllegalAccessException { // If primitive type, then construct with primitive value if (isPrimitive()) return ((StrictPrimitiveHandler) getHandler(getSourceEntry())).newInstance(marshalledValues); // It's a custom object, create it Object result = sourceEntry.getSourceClass().newInstance(); // If it's a dynamic object, then set it's dynamic name if (DynamicObject.class.isAssignableFrom(sourceEntry.getSourceClass())) ((DynamicObject) result).setPersistenceDynamicName(sourceEntry.getDynamicName()); return result; }
public ClassInfoImpl(ClassTracker classTracker, ClassEntry sourceEntry) { this.classTracker = classTracker; this.sourceEntry = sourceEntry; // Assemble the attribute list handlersByAttribute = new HashMap(); handlersByEntry = new HashMap<ClassEntry, StrictClassHandler>(); classEntries = new ArrayList(); // Assemble the attribute list ClassEntry localEntry = sourceEntry; while (localEntry != null) { if (logger.isDebugEnabled()) logger.debug("analyzing entry for class info: " + localEntry); // Add to all class entries, if it is storable if (isStorable(localEntry)) { if (logger.isDebugEnabled()) logger.debug("entry is storable, adding to class entries: " + classEntries); classEntries.add(localEntry); } // Determine handler for strict class, there are // four kinds of handlers: // - Null handler: has no attributes ever // - Static handler: attributes are determined from reflection // - Dynamic handler: attributes are determined with call to dynamic object // - Primitive handler: primitive types StrictClassHandler handler; if (isEmpty(localEntry)) handler = new StrictNullHandler(localEntry); else if (hasDynamicAttributes(localEntry)) handler = new StrictDynamicHandler(classTracker, localEntry); else if (isPrimitive(localEntry)) handler = new StrictPrimitiveHandler(localEntry); else handler = new StrictStaticHandler(localEntry); logger.debug("handler for entry will be: " + handler); // Add this class' attribute to sets Map strictAttributeTypes = handler.getAttributeTypes(); Iterator attributeTypeIterator = strictAttributeTypes.keySet().iterator(); while (attributeTypeIterator.hasNext()) { String attributeName = attributeTypeIterator.next().toString().toLowerCase(); handlersByAttribute.put(attributeName, handler); } handlersByEntry.put(localEntry, handler); // Get super localEntry = localEntry.getSuperEntry(); } logger.debug("analized class: " + sourceEntry + ", attributes: " + getAttributeNames()); }
public String toString() { return "[ClassInfo: " + sourceEntry.getFullName() + "]"; }
public boolean equals(Object obj) { if (!(obj instanceof ClassInfoImpl)) return false; return ((ClassInfoImpl) obj).sourceEntry.getFullName().equals(sourceEntry.getFullName()); }
private boolean isPrimitive(ClassEntry entry) { return classTracker.getType(entry.getSourceClass()) == ClassTracker.ClassType.TYPE_PRIMITIVE; }
public int hashCode() { return sourceEntry.getFullName().hashCode(); }