/** * Checks whether two Aliases have the same name. Does <b>not</b> * compare any other fields. * @param o the other Alias to check * @return true if the specified Alias has the same name as this Alias. */ public boolean equals(Object o) { return (compareTo(o) == 0); }
/** * Adds an Alias, replacing any previous entries with the same name. * * @param alias the Alias to add */ public void addAlias(Alias alias) { synchronized (aliases) { aliases.put(alias.getName(), alias); } }
public static void nailMain(NGContext context) throws ClassNotFoundException { String[] args = context.getArgs(); NGServer server = context.getNGServer(); if (args.length == 0) { Set aliases = server.getAliasManager().getAliases(); // let's pad this nicely. first, find the longest alias // name. then pad the others to that width. int maxAliasLength = 0; int maxClassnameLength = 0; for (Iterator i = aliases.iterator(); i.hasNext();) { Alias alias = (Alias) i.next(); maxAliasLength = Math.max(maxAliasLength, alias.getName().length()); maxClassnameLength = Math.max(maxClassnameLength, alias.getAliasedClass().getName().length()); } for (Iterator i = aliases.iterator(); i.hasNext();) { Alias alias = (Alias) i.next(); context.out.println(padl(alias.getName(), maxAliasLength) + "\t" + padl(alias.getAliasedClass().getName(), maxClassnameLength)); context.out.println(padl("", maxAliasLength) + "\t" + alias.getDescription()); context.out.println(); } } else if (args.length == 2) { server.getAliasManager().addAlias(new Alias(args[0], "", Class.forName(args[1]))); } } }
getOrCreateStatsFor(alias.getAliasedClass());
Class clazz = Class.forName(properties.getProperty(key)); String desc = properties.getProperty(key + ".desc", ""); addAlias(new Alias(key, desc, clazz)); } catch (ClassNotFoundException e) { System.err.println("Unable to locate class " + properties.getProperty(key));
Class cmdclass = null; if (alias != null) { cmdclass = alias.getAliasedClass(); } else if (server.allowsNailsByClassName()) { cmdclass = Class.forName(command);
/** * Compares Alias <b>names</b> - no other fields are compared. * @see Comparable#compareTo(Object) */ public int compareTo(Object o) { return (name.compareTo(((Alias) o).getName())); } }