@Override public IChemObject newTestObject() { return new ChemObject(); } });
/**{@inheritDoc} */ @Override public void setProperties(Map<Object, Object> properties) { this.properties = null; if (properties != null) addProperties(properties); }
@Override public Object clone() throws CloneNotSupportedException { return super.clone(); }
/** * Sets the whole set of flags. * * @param flagsNew the new flags. * @see #getFlags */ @Override public void setFlags(boolean[] flagsNew) { for (int i = 0; i < flagsNew.length; i++) setFlag(CDKConstants.FLAG_MASKS[i], flagsNew[i]); notifyChanged(); }
/** * Sets the properties of this object. * *@param properties a Hashtable specifying the property values *@see #getProperties */ @Override public void addProperties(Map<Object, Object> properties) { if (properties == null) return; lazyProperties().putAll(properties); notifyChanged(); }
/** * {@inheritDoc} */ @Override public void setFlag(int mask, boolean value) { if (mask > Short.MAX_VALUE || !isPowerOfTwo(mask)) throw new IllegalArgumentException("setFlag() must be provided a valid CDKConstant and not used for custom properties"); // set/unset a bit in the flags value if (value) flags |= mask; else flags &= ~(mask); notifyChanged(); }
@Test public void testIsotopeHandler_IChemObjectBuilder() { IsotopeHandler handler = new IsotopeHandler(new ChemObject().getBuilder()); Assert.assertNotNull(handler); }
@Test public void compare() { ChemObject co1 = new ChemObject(); ChemObject co2 = new ChemObject(); co1.setID(new String("a1")); co2.setID(new String("a1")); Assert.assertTrue(co1.compare(co2)); }
/** * This should be triggered by an method that changes the content of an object * to that the registered listeners can react to it. This is a version of * notifyChanged() which allows to propagate a change event while preserving * the original origin. * *@param evt A ChemObjectChangeEvent pointing to the source of where * the change happened */ @Override public void notifyChanged(IChemObjectChangeEvent evt) { if (getNotification() && getListenerCount() > 0) { List<IChemObjectListener> listeners = lazyChemObjectListeners(); for (Object listener : listeners) { ((IChemObjectListener) listener).stateChanged(evt); } } }
/** * Sets the identifier (ID) of this object. * *@param identifier a String representing the ID value *@see #getID */ @Override public void setID(String identifier) { this.identifier = identifier; notifyChanged(); }
/** * Clones this <code>IChemObject</code>. It clones the identifier, flags, * properties and pointer vectors. The ChemObjectListeners are not cloned, and * neither is the content of the pointer vectors. * *@return The cloned object */ @Override public Object clone() throws CloneNotSupportedException { ChemObject clone = (ChemObject) super.clone(); // clone the flags clone.flags = getFlagValue().shortValue(); // clone the properties - using the HashMap copy constructor // this doesn't deep clone the keys/values but this wasn't happening // already if (properties != null) clone.properties = new HashMap<Object, Object>(getProperties()); // delete all listeners clone.chemObjectListeners = null; return clone; }
/** * Returns the whole set of flags. * *@return the flags. *@see #setFlags */ @Override public boolean[] getFlags() { // could use a list a invoke .toArray() on the return boolean[] flagArray = new boolean[CDKConstants.MAX_FLAG_INDEX + 1]; for (int i = 0; i < CDKConstants.FLAG_MASKS.length; i++) { int mask = CDKConstants.FLAG_MASKS[i]; flagArray[i] = getFlag(mask); } return flagArray; }
/** * Compares an Element with this Element. * * @param object Object of type AtomType * @return true if the atom types are equal */ @Override public boolean compare(Object object) { if (!(object instanceof Element)) { return false; } if (!super.compare(object)) { return false; } Element elem = (Element) object; return Objects.equal(atomicNumber, elem.atomicNumber); } }
/** {@inheritDoc} */ @Override public boolean getNotification() { return super.getNotification(); } }
/** {@inheritDoc} */ @Override public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); }
/** {@inheritDoc} */ @Override public Map<Object, Object> getProperties() { logger.debug("Getting properties"); return super.getProperties(); }
@Test public void testAtomTypeHandler_IChemObjectBuilder() { OWLAtomTypeHandler handler = new OWLAtomTypeHandler(new ChemObject().getBuilder()); Assert.assertNotNull(handler); }
@Test public void compareDifferent() { ChemObject co1 = new ChemObject(); ChemObject co2 = new ChemObject(); co1.setID(new String("a1")); co2.setID(new String("a2")); Assert.assertFalse(co1.compare(co2)); } }
/** * This should be triggered by an method that changes the content of an object * to that the registered listeners can react to it. This is a version of * notifyChanged() which allows to propagate a change event while preserving * the original origin. * *@param evt A ChemObjectChangeEvent pointing to the source of where * the change happened */ @Override public void notifyChanged(IChemObjectChangeEvent evt) { if (getNotification() && getListenerCount() > 0) { List<IChemObjectListener> listeners = lazyChemObjectListeners(); for (Object listener : listeners) { ((IChemObjectListener) listener).stateChanged(evt); } } }
/** * Sets the properties of this object. * *@param properties a Hashtable specifying the property values *@see #getProperties */ @Override public void addProperties(Map<Object, Object> properties) { if (properties == null) return; lazyProperties().putAll(properties); notifyChanged(); }