📄 memoryhelper.java
字号:
case 3: if (!(o instanceof java.sql.Time)) { return false; } break; case 4: if (!(o instanceof java.sql.Date)) { return false; } break; case 5: if (!(o instanceof Integer)) { return false; } break; case 6: if (!(o instanceof Long)) { return false; } break; case 7: if (!(o instanceof Float)) { return false; } break; case 8: if (!(o instanceof Double)) { return false; } break; case 9: if (!(o instanceof Boolean)) { return false; } break; } } } return true; } private ModelFieldTypeReader modelFieldTypeReader; public MemoryHelper(String helperName) { this.helperName = helperName; modelFieldTypeReader = ModelFieldTypeReader.getModelFieldTypeReader(helperName); } public String getHelperName() { return helperName; } public GenericValue create(GenericValue value) throws GenericEntityException { if (addToCache(value)) { return value; } else { return null; } } public GenericValue create(GenericPK primaryKey) throws GenericEntityException { return create(GenericValue.create(primaryKey)); } public GenericValue findByPrimaryKey(GenericPK primaryKey) throws GenericEntityException { return findFromCache(primaryKey); } public GenericValue findByPrimaryKeyPartial(GenericPK primaryKey, Set keys) throws GenericEntityException { GenericValue value = findFromCache(primaryKey); value.setFields(value.getFields(keys)); return value; } public List findAllByPrimaryKeys(List primaryKeys) throws GenericEntityException { ArrayList result = new ArrayList(primaryKeys.size()); for (Iterator iterator = primaryKeys.iterator(); iterator.hasNext();) { GenericPK pk = (GenericPK) iterator.next(); result.add(this.findByPrimaryKey(pk)); } return result; } public int removeByPrimaryKey(GenericPK primaryKey) throws GenericEntityException { return removeFromCache(primaryKey); } public List findByAnd(ModelEntity modelEntity, Map fields, List orderBy) throws GenericEntityException { HashMap entityCache = (HashMap) cache.get(modelEntity.getEntityName()); if (entityCache == null) { return Collections.EMPTY_LIST; } ArrayList result = new ArrayList(); for (Iterator iterator = entityCache.entrySet().iterator(); iterator.hasNext();) { Map.Entry mapEntry = (Map.Entry) iterator.next(); GenericValue value = (GenericValue) mapEntry.getValue(); if (isAndMatch(value.getAllFields(), fields)) { result.add(value); } } return result; } public List findByAnd(ModelEntity modelEntity, List expressions, List orderBy) throws GenericEntityException { return null; } public List findByLike(ModelEntity modelEntity, Map fields, List orderBy) throws GenericEntityException { return null; } public List findByOr(ModelEntity modelEntity, Map fields, List orderBy) throws GenericEntityException { HashMap entityCache = (HashMap) cache.get(modelEntity.getEntityName()); if (entityCache == null) { return Collections.EMPTY_LIST; } ArrayList result = new ArrayList(); for (Iterator iterator = entityCache.entrySet().iterator(); iterator.hasNext();) { Map.Entry mapEntry = (Map.Entry) iterator.next(); GenericValue value = (GenericValue) mapEntry.getValue(); if (isOrMatch(value.getAllFields(), fields)) { result.add(value); } } return result; } public List findByOr(ModelEntity modelEntity, List expressions, List orderBy) throws GenericEntityException { return null; } public List findByCondition(ModelEntity modelEntity, EntityCondition entityCondition, Collection fieldsToSelect, List orderBy) throws GenericEntityException { return null; } public List findByMultiRelation(GenericValue value, ModelRelation modelRelationOne, ModelEntity modelEntityOne, ModelRelation modelRelationTwo, ModelEntity modelEntityTwo, List orderBy) throws GenericEntityException { return null; } public EntityListIterator findListIteratorByCondition(ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, Collection fieldsToSelect, List orderBy, EntityFindOptions findOptions) throws GenericEntityException { return null; } public long findCountByCondition(ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition) throws GenericEntityException { return 0; } public int removeByAnd(ModelEntity modelEntity, Map fields) throws GenericEntityException { HashMap entityCache = (HashMap) cache.get(modelEntity.getEntityName()); if (entityCache == null) { return 0; } ArrayList removeList = new ArrayList(); for (Iterator iterator = entityCache.entrySet().iterator(); iterator.hasNext();) { Map.Entry mapEntry = (Map.Entry) iterator.next(); GenericValue value = (GenericValue) mapEntry.getValue(); if (isAndMatch(value.getAllFields(), fields)) { removeList.add(mapEntry.getKey()); } } return removeAll(removeList); } public int removeByCondition(ModelEntity modelEntity, EntityCondition condition) throws GenericEntityException { return removeFromCache(modelEntity.getEntityName(), condition); } public int storeByCondition(ModelEntity modelEntity, Map fieldsToSet, EntityCondition condition) throws GenericEntityException { return 0; } public int store(GenericValue value) throws GenericEntityException { if (addToCache(value)) { return 1; } else { return 0; } } public int storeAll(List values) throws GenericEntityException { int count = 0; for (Iterator iterator = values.iterator(); iterator.hasNext();) { GenericValue gv = (GenericValue) iterator.next(); if (addToCache(gv)) { count++; } } return count; } public int removeAll(List dummyPKs) throws GenericEntityException { int count = 0; for (Iterator iterator = dummyPKs.iterator(); iterator.hasNext();) { GenericPK pk = (GenericPK) iterator.next(); count = count + removeFromCache(pk); } return count; } public void checkDataSource(Map modelEntities, List messages, boolean addMissing) throws GenericEntityException { messages.add("checkDataSource not implemented for MemoryHelper"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -