1 6 7 package org.objectweb.jac.samples.photos; 8 9 import org.objectweb.jac.aspects.user.Profile; 10 import org.objectweb.jac.core.ObjectRepository; 11 import org.objectweb.jac.core.rtti.ClassRepository; 12 import java.util.Collection ; 13 import java.util.Iterator ; 14 import java.util.Vector ; 15 import java.util.Set ; 16 import java.util.HashSet ; 17 import java.util.List ; 18 19 public class PhotoRepository 20 { 21 22 Set photos = new HashSet (); 23 24 public PhotoRepository () { 25 } 26 27 31 public Set getPhotos() { 32 return photos; 33 } 34 35 40 public List searchTitle(String title) 41 { 42 Iterator i = photos.iterator(); 43 Vector result = new Vector (); 44 while ( i.hasNext() ) { 45 Photo curphoto = (Photo)i.next(); 46 if (curphoto.getTitle()!=null) { 47 if ( curphoto.getTitle().indexOf( title ) != -1 ) { 48 result.add ( curphoto ); 49 } 50 } 51 } 52 56 57 return result; 58 } 59 60 64 public void addPhoto (Photo photo) { 65 photos.add(photo); 66 } 67 68 72 public void delPhoto(Photo photo) { 73 photos.remove(photo); 74 } 75 76 79 public void clearPhotos() { 80 photos.clear(); 81 } 82 83 86 public static Collection getProfiles(Object substance) { 87 Collection profiles = 88 ObjectRepository.getObjects( 89 ClassRepository.get().getClass(Profile.class)); 90 Vector result = new Vector (profiles.size()); 91 Iterator it=profiles.iterator(); 92 while(it.hasNext()) { 93 Profile cur=(Profile)it.next(); 94 if (!cur.getName().equals("owner") && 95 !cur.getName().equals("default")) { 96 result.add(cur); 97 } 98 } 99 return result; 100 } 101 102 105 106 114 } 115 116 120 | Popular Tags |