/** * Get the messages for a given element. */ protected String[] getMessages(Tuple path) { if(entries==null) { return SUtil.EMPTY_STRING_ARRAY; } else { Collection ret = entries.getCollection(path); return (String[])ret.toArray(new String[ret.size()]); } }
/** * Get the messages for a given element. */ protected String[] getMessages(Tuple path) { if(entries==null) { return SUtil.EMPTY_STRING_ARRAY; } else { Collection<String> ret = entries.getCollection(path); return (String[])ret.toArray(new String[ret.size()]); } }
/** * Get the avatar mapping for an component avatar combination. */ protected AvatarMapping getAvatarMapping(String componenttype, String avatartype) { AvatarMapping mapping = null; for(Iterator<AvatarMapping> it=avatarmappings.getCollection(componenttype).iterator(); mapping==null && it.hasNext(); ) { AvatarMapping test = (AvatarMapping)it.next(); if(avatartype.equals(test.getObjectType())) mapping = test; } return mapping; }
/** * returns an array with account-stati, either of an player * or of the dealer */ public int[] getYArray(Player player) { int[] retArray; List coors = (List)playerModels.getCollection(player); retArray = new int[coors.size()]; for (int i=0; i < coors.size(); i++) { Tuple dummy = (Tuple)coors.get(i); retArray[i] = ((Integer)dummy.get(1)).intValue(); } return retArray; }
/** * returns an array with roundNumbers, either of an player * or of the dealer */ public int[] getXArray(Player player) { int[] retArray; List coors = (List)playerModels.getCollection(player); retArray = new int[coors.size()]; for (int i=0; i < coors.size(); i++) { Tuple dummy = (Tuple)coors.get(i); retArray[i] = ((Integer)dummy.get(0)).intValue(); } return retArray; }
/** * Returns true if the filter contains the given attribute value. * * @param name The attribute name. * @param value The attribute value. * @return true if the filter contains the given attribute value. */ public boolean containsValue(String name, Object value) { if(values.containsKey(name)) { Collection vals = values.getCollection(name); if(vals.contains(value)) { return true; } } return false; }
/** * An element was removed. * @param type The element type used as prefix for the event (e.g. use 'goal' for 'goal_removed' events). * @param value The element value (must be transferable). */ public void elementRemoved(String type, Object value) { if(!added.containsKey(type) || !added.getCollection(type).remove(value)) { if(changed.containsKey(type)) changed.getCollection(type).remove(value); removed.put(type, value); } startTimer(); }
/** * An element was added. * @param type The element type used as prefix for the event (e.g. use 'goal' for 'goal_added' events). * @param value The element value (must be transferable). */ public void elementAdded(String type, Object value) { if(!removed.containsKey(type) || !removed.getCollection(type).remove(value)) { if(changed.containsKey(type)) changed.getCollection(type).remove(value); added.add(type, value); } startTimer(); }
/** * An element was removed. * @param type The element type used as prefix for the event (e.g. use 'goal' for 'goal_removed' events). * @param value The element value (must be transferable). */ public void elementRemoved(String type, Object value) { if(!added.containsKey(type) || !added.getCollection(type).remove(value)) { if(changed.containsKey(type)) changed.getCollection(type).remove(value); removed.add(type, value); } startTimer(); }
/** * An element was added. * @param type The element type used as prefix for the event (e.g. use 'goal' for 'goal_added' events). * @param value The element value (must be transferable). */ public void elementAdded(String type, Object value) { if(!removed.containsKey(type) || !removed.getCollection(type).remove(value)) { if(changed.containsKey(type)) changed.getCollection(type).remove(value); added.put(type, value); } startTimer(); }
public void customResultAvailable(Void result) { assert SwingUtilities.isEventDispatchThread(); if(futures!=null) // Todo: can be null? { Collection<?> coll = futures.getCollection(cid); for(Iterator<?> it=coll.iterator(); it.hasNext(); ) { ((Future<?>)it.next()).setResult(null); } futures.remove(cid); if(futures.isEmpty()) futures = null; } } public void customExceptionOccurred(Exception exception)
public void resultAvailable(IComponentDescription newdesc) { ICMSComponentListener[] alisteners; Set<ICMSComponentListener> slisteners = new HashSet<ICMSComponentListener>(listeners.getCollection(null)); slisteners.addAll(listeners.getCollection(cid)); alisteners = (ICMSComponentListener[])slisteners.toArray(new ICMSComponentListener[slisteners.size()]); // todo: can be called after listener has (concurrently) deregistered // System.out.println("comp changed: "+desc+" "+listeners); // logger.info("Component changed: "+desc+" "+listeners); for(int i=0; i<alisteners.length; i++) { final ICMSComponentListener lis = alisteners[i]; lis.componentAdded(newdesc).addResultListener(createResultListener(new IResultListener<Void>() { public void resultAvailable(Void result) { } public void exceptionOccurred(Exception exception) { // System.out.println("prob: "+exception); removeComponentListener(cid, lis); } })); } } }));
public void resultAvailable(IComponentDescription newdesc) { ICMSComponentListener[] alisteners; Set<ICMSComponentListener> slisteners = new HashSet<ICMSComponentListener>(listeners.getCollection(null)); slisteners.addAll(listeners.getCollection(cid)); alisteners = (ICMSComponentListener[])slisteners.toArray(new ICMSComponentListener[slisteners.size()]); // todo: can be called after listener has (concurrently) deregistered // System.out.println("comp changed: "+desc+" "+listeners); // logger.info("Component changed: "+desc+" "+listeners); for(int i=0; i<alisteners.length; i++) { final ICMSComponentListener lis = alisteners[i]; lis.componentRemoved(newdesc, results).addResultListener(createResultListener(new IResultListener<Void>() { public void resultAvailable(Void result) { } public void exceptionOccurred(Exception exception) { // System.out.println("prob: "+exception); removeComponentListener(cid, lis); } })); } }
/** * Create the files for an entry. * Recursive implementation for directory entries. */ public File[] createFiles(String key, MultiCollection entries) { Collection col = entries.getCollection(key); JarAsDirectory[] ret = new JarAsDirectory[col.size()]; Iterator it = col.iterator(); for(int i=0; it.hasNext(); i++) { ZipEntry entry = (ZipEntry)it.next(); ret[i] = new JarAsDirectory(jarpath, entry); if(ret[i].isDirectory()) { ret[i].entries = createFiles(ret[i].entry.getName(), entries); } entryfiles.put(entry.getName(), ret[i]); } // System.out.println("create files: "+key+", "+SUtil.arrayToString(ret)); return ret; }
/** * An element was changed. * @param type The element type used as prefix for the event (e.g. use 'goal' for 'goal_changed' events). * @param value The element value (must be transferable). */ public void elementChanged(String type, Object value) { if(!removed.containsKey(type) || !removed.getCollection(type).remove(value)) { if(added.containsKey(type) && added.getCollection(type).remove(value)) { // Replace added element. added.put(type, value); } else { // Hack!!! Remove before add, because set does not replace. changed.getCollection(type).remove(value); changed.put(type, value); } } startTimer(); }
/** * An element was changed. * @param type The element type used as prefix for the event (e.g. use 'goal' for 'goal_changed' events). * @param value The element value (must be transferable). */ public void elementChanged(String type, Object value) { if(!removed.containsKey(type) || !removed.getCollection(type).remove(value)) { if(added.containsKey(type) && added.getCollection(type).remove(value)) { // Replace added element. added.add(type, value); } else { // Hack!!! Remove before add, because set does not replace. changed.getCollection(type).remove(value); changed.add(type, value); } } startTimer(); }
/** * Get objects near a position. * @param loc The location. * @param range The range. */ protected WorldObject[] getNearObjects(Location loc, int range) { Collection ret = new ArrayList(); int x = loc.getX(); int y = loc.getY(); for(int i=x-range; i<=x+range; i++) { for(int j=y-range; j<=y+range; j++) { Collection tmp = world.getCollection(new Location((i+sizex)%sizex, (j+sizey)%sizey)); if(tmp!=null) ret.addAll(tmp); } } return (WorldObject[])ret.toArray(new WorldObject[ret.size()]); }
/** * Create the files for an entry. * Recursive implementation for directory entries. */ public File[] createFiles(String key, MultiCollection<String, ZipEntry> entries) { Collection<ZipEntry> col = entries.getCollection(key); JarAsDirectory[] ret = new JarAsDirectory[col.size()]; Iterator<ZipEntry> it = col.iterator(); for(int i=0; it.hasNext(); i++) { ZipEntry entry = (ZipEntry)it.next(); ret[i] = new JarAsDirectory(jarpath, entry); if(ret[i].isDirectory()) { ret[i].entries = createFiles(ret[i].getEntryName(), entries); } entryfiles.put(entry.getName(), ret[i]); } // System.out.println("create files: "+key+", "+SUtil.arrayToString(ret)); return ret; }
public void customExceptionOccurred(Exception exception) { assert SwingUtilities.isEventDispatchThread(); // System.out.println("remove: "+cid+", "+listener+", "+this); if(listeners!=null) listeners.remove(cid, listener); if(futures!=null) // Todo: why can be null? { Collection<?> coll = futures.getCollection(cid); for(Iterator<?> it=coll.iterator(); it.hasNext(); ) { ((Future<?>)it.next()).setException(exception); } futures.remove(cid); if(futures.isEmpty()) futures = null; } } });
/** * Add an entry to the report. * @param stack The path to the element to which the entry applies. * @param message The problem description. */ public void addEntry(Tuple stack, String message) { if(entries==null) // Use index map to keep insertion order for elements. this.entries = new MultiCollection(new IndexMap().getAsMap(), LinkedHashSet.class); if(!entries.getCollection(stack).contains(message)) entries.put(stack, message); }