public boolean equals(Object o) { if (!(o instanceof TMObjectIFHandle)) return false; TMObjectIFHandle other = (TMObjectIFHandle)o; return (ObjectUtils.equals(this.objectId, other.objectId) && ObjectUtils.equals(this.topicmapId, other.topicmapId) && ObjectUtils.equals(this.referenceId, other.referenceId)); }
public int compare(RoleField rf1, RoleField rf2) { return ObjectUtils.compare(rf1.getFieldName(), rf2.getFieldName()); } }
private boolean equalsKey(String[] tuple1, String[] tuple2) { if ((tuple1 == null && tuple2 != null) || (tuple1 != null && tuple2 == null)) return false; if (tuple1 == null && tuple2 == null) return true; for (int ix = 0; ix < keycols.length; ix++) if (ObjectUtils.different(tuple1[keycols[ix]], tuple2[keycols[ix]])) return false; return true; } }
public static AssociationIF findBinaryAssociation( TopicMap tm, TopicIF aType, TopicIF player1, TopicIF rType1, TopicIF player2, TopicIF rType2) { Iterator<AssociationRoleIF> iter = player1.getRoles().iterator(); while (iter.hasNext()) { AssociationRoleIF role1 = iter.next(); AssociationIF assoc = role1.getAssociation(); Collection<AssociationRoleIF> roles = assoc.getRoles(); if (roles.size() != 2) continue; if (ObjectUtils.equals(role1.getType(), rType1) && ObjectUtils.equals(assoc.getType(), aType)) { Iterator<AssociationRoleIF> riter = roles.iterator(); while (riter.hasNext()) { AssociationRoleIF role2 = riter.next(); if (ObjectUtils.different(role1, role2) && role2.getType().equals(rType2) && role2.getPlayer().equals(player2)) { return assoc; } } } } return null; }
/** * INTERNAL: Returns the plug-in class instance used by the ontopoly * plugin. Used by classify/plugin.jsp. */ public static ClassifyPluginIF getPlugin(HttpServletRequest request) { // create plugin by dynamically intantiating plugin class HttpSession session = request.getSession(true); ServletContext scontext = session.getServletContext(); String pclass = scontext.getInitParameter("classify_plugin"); if (pclass == null) pclass = "net.ontopia.topicmaps.classify.DefaultPlugin"; ClassifyPluginIF cp = (ClassifyPluginIF)ObjectUtils.newInstance(pclass); if (cp instanceof HttpServletRequestAwareIF) ((HttpServletRequestAwareIF)cp).setRequest(request); return cp; }
public int compare(TopicMapReference r1, TopicMapReference r2) { return ObjectUtils.compareIgnoreCase(r1.getName(), r2.getName()); } };
Throwable cause = ObjectUtils.getRealCause(e); if (cause instanceof DB2TMException) System.err.println("Error: " + e.getMessage());
public static Collection<TopicIF> findBinaryPlayers( TopicMap tm, TopicIF aType, TopicIF player1, TopicIF rType1, TopicIF rType2) { List<TopicIF> result = new ArrayList<TopicIF>(); Iterator<AssociationRoleIF> iter = player1.getRoles().iterator(); while (iter.hasNext()) { AssociationRoleIF role1 = iter.next(); AssociationIF assoc = role1.getAssociation(); Collection<AssociationRoleIF> roles = assoc.getRoles(); if (roles.size() != 2) continue; if (ObjectUtils.equals(role1.getType(), rType1) && ObjectUtils.equals(assoc.getType(), aType)) { Iterator<AssociationRoleIF> riter = roles.iterator(); while (riter.hasNext()) { AssociationRoleIF role2 = riter.next(); if (ObjectUtils.different(role1, role2) && role2.getType().equals(rType2)) { result.add(role2.getPlayer()); } } } } return result; }
/** * INTERNAL: Returns the plug-in class instance used by the ontopoly * plugin. Used by classify/plugin.jsp. */ public static ClassifyPluginIF getPlugin(HttpServletRequest request) { // create plugin by dynamically intantiating plugin class HttpSession session = request.getSession(true); ServletContext scontext = session.getServletContext(); String pclass = scontext.getInitParameter("classify_plugin"); if (pclass == null) pclass = "net.ontopia.topicmaps.classify.DefaultPlugin"; ClassifyPluginIF cp = (ClassifyPluginIF)ObjectUtils.newInstance(pclass); if (cp instanceof HttpServletRequestAwareIF) ((HttpServletRequestAwareIF)cp).setRequest(request); return cp; }
/** * INTERNAL: Returns the first argument if the two arguments are * equal. If they are different null is returned. */ public static String useFirstIfEqual(String str1, String str2) { return (ObjectUtils.equals(str1, str2) ? str1 : null); }
public static Collection<TopicIF> findBinaryPlayers(TopicMap tm, TopicIF aType, TopicIF player1, TopicIF rType1, TopicIF rType2, TopicIF theme) { List<TopicIF> result = new ArrayList<TopicIF>(); Iterator<AssociationRoleIF> iter = player1.getRoles().iterator(); while (iter.hasNext()) { AssociationRoleIF role1 = iter.next(); AssociationIF assoc = role1.getAssociation(); Collection<TopicIF> scope = assoc.getScope(); if (!(scope.size() == 1 && scope.contains(theme))) continue; Collection<AssociationRoleIF> roles = assoc.getRoles(); if (roles.size() != 2) continue; if (ObjectUtils.equals(role1.getType(), rType1) && ObjectUtils.equals(assoc.getType(), aType)) { Iterator<AssociationRoleIF> riter = roles.iterator(); while (riter.hasNext()) { AssociationRoleIF role2 = riter.next(); if (ObjectUtils.different(role1, role2) && role2.getType().equals(rType2)) { result.add(role2.getPlayer()); } } } } return result; }
public Topic getPlayer(RoleField ofield, Topic oPlayer) { // NOTE: all this logic is here to cater for symmetric associations Topic xPlayer = null; for (int i=0; i < roleFields.length; i++) { RoleField rf = roleFields[i]; if (rf.equals(ofield)) { Topic player = players[i]; if (ObjectUtils.different(player, oPlayer)) return player; else xPlayer = oPlayer; } } if (xPlayer == null) throw new RuntimeException("Could not find player for RoleField: " + ofield + " (" + oPlayer + ")"); else return xPlayer; }
public int compare(RoleField rf1, RoleField rf2) { return ObjectUtils.compare(rf1.getFieldName(), rf2.getFieldName()); } }
/** * INTERNAL: Register topic listener from list of listener implementations. */ public synchronized void registerTopicListeners(String listenerList) { StringTokenizer st = new StringTokenizer(listenerList, ", "); while (st.hasMoreTokens()) { Object object = ObjectUtils.newInstance(st.nextToken()); if (object instanceof TopicMapListenerIF) addTopicListener((TopicMapListenerIF)object); else throw new OntopiaRuntimeException("Listener " + object + " is not a TopicMapListenerIF and cannot be added to reference with id " + getId()); } }
/** * INTERNAL: Compares the first two arguments. If they are equal the * third argument is returned, if not the fourth one is. */ public static String ifEqualThenElse(String str1, String str2, String thenval, String elseval) { return (ObjectUtils.equals(str1, str2) ? thenval : elseval); }
AssociationRoleIF role1 = iter.next(); AssociationIF assoc = role1.getAssociation(); if (ObjectUtils.equals(role1.getType(), rType1) && ObjectUtils.equals(assoc.getType(), aType)) { Iterator<AssociationRoleIF> riter = assoc.getRoles().iterator(); while (riter.hasNext()) { AssociationRoleIF role2 = riter.next(); if (ObjectUtils.different(role1, role2)) { if (ObjectUtils.equals(rType2, role2.getType()) && ObjectUtils.equals(player2, role2.getPlayer())) secondRole = role2; else if (ObjectUtils.equals(rType3, role2.getType())) thirdRole = role2; else
public static boolean hasBinaryAssociation(TopicIF player1, TopicIF aType, TopicIF rType1, TopicIF rType2) { for (AssociationRoleIF role : player1.getRolesByType(rType1, aType)) { AssociationIF assoc = role.getAssociation(); for (AssociationRoleIF role2 : assoc.getRoles()) if (ObjectUtils.different(role2, role) && role2.getType().equals(rType2)) return true; } return false; }
public int compare(Term t1, Term t2) { return ObjectUtils.compare(t2.getScore(), t1.getScore()); // NOTE: reverse order } };
/** * INTERNAL: Returns the first argument if the two arguments are * different. If they are equal null is returned. */ public static String useFirstIfDifferent(String str1, String str2) { return (ObjectUtils.equals(str1, str2) ? null : str1); }
public static TopicIF findBinaryPlayer(TopicMap tm, LocatorIF atypeId, TopicIF player1, LocatorIF rtype1Id, LocatorIF rtype2Id) { TopicIF aType = OntopolyModelUtils.getTopicIF(tm, atypeId); TopicIF rType1 = OntopolyModelUtils.getTopicIF(tm, rtype1Id); TopicIF rType2 = OntopolyModelUtils.getTopicIF(tm, rtype2Id); Iterator<AssociationRoleIF> iter = player1.getRoles().iterator(); while (iter.hasNext()) { AssociationRoleIF role1 = iter.next(); AssociationIF assoc = role1.getAssociation(); Collection<AssociationRoleIF> roles = assoc.getRoles(); if (roles.size() != 2) continue; if (ObjectUtils.equals(role1.getType(), rType1) && ObjectUtils.equals(assoc.getType(), aType)) { Iterator<AssociationRoleIF> riter = roles.iterator(); while (riter.hasNext()) { AssociationRoleIF role2 = riter.next(); if (ObjectUtils.different(role1, role2) && role2.getType().equals(rType2)) { return role2.getPlayer(); } } } } return null; }