chemaxon.struc
Class MPropertyContainer

java.lang.Object
  extended by chemaxon.struc.MPropertyContainer
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable

public class MPropertyContainer
extends java.lang.Object
implements java.lang.Cloneable, java.io.Externalizable

Property container.

Since:
Marvin 4.1, 11/20/2005
Version:
5.3, 04/28/2009
Author:
Peter Csizmadia
See Also:
Serialized Form

Constructor Summary
MPropertyContainer()
          Creates an empty property container.
 
Method Summary
 void clear()
          Clears properties.
 java.lang.Object clone()
          Clones this object.
 boolean contains(MProp p)
          Tests whether the container contains the specified property object.
 void flatten()
          Flattens hierarchically specified RDF properties.
 MProp get(java.lang.String key)
          Gets a property object.
 java.lang.String getKey(int i)
          Gets a property key.
 java.lang.String[] getKeys()
          Returns the property keys.
 java.lang.Object getObject(java.lang.String key)
          Gets a property object.
 java.util.List<MProp> getPropList()
          Gets the list of basic properties.
 java.lang.String getString(java.lang.String key)
          Deprecated. As of Marvin 5.7, replaced by MPropHandler.convertToString(MPropertyContainer, String)
 java.lang.String hierarchize()
          Converts hierarchically specified RDF properties to MListProp and MHashProp objects.
 boolean isHierarchic()
          Tests whether the property list contains subcollections like MListProp and MHashProp.
 boolean isSelfReference(MProp p)
          Tests whether a property is a self reference to the containing molecule.
 boolean isValid(MProp prop)
          Tests whether a coordinate dependent property is still valid.
 void readExternal(java.io.ObjectInput in)
          Restores the property container's state.
 void remove(MProp p)
          Removes a property.
 void replace(MProp oldp, MProp newp)
          Replaces or removes a property.
 void set(java.lang.String key, MProp value)
          Sets a property object.
 void set(java.lang.String key, MProp value, int opts)
          Sets a property object.
 void setObject(java.lang.String key, java.lang.Object val)
          Sets a property object.
 void setString(java.lang.String key, java.lang.String value)
          Sets a property.
 int size()
          Gets the total number of properties.
 void writeExternal(java.io.ObjectOutput out)
          Saves the property container's state.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MPropertyContainer

public MPropertyContainer()
Creates an empty property container.

Method Detail

clear

public void clear()
Clears properties.


size

public int size()
Gets the total number of properties.

Returns:
number of properties

getKeys

public java.lang.String[] getKeys()
Returns the property keys.

Returns:
the array of keys

getKey

public java.lang.String getKey(int i)
Gets a property key.

Parameters:
i - property index
Returns:
the property name

getString

public java.lang.String getString(java.lang.String key)
Deprecated. As of Marvin 5.7, replaced by MPropHandler.convertToString(MPropertyContainer, String)

Gets a property.

Parameters:
key - property name
Returns:
the value of the property, or null if the key is not found

get

public MProp get(java.lang.String key)
Gets a property object.

Parameters:
key - property name
Returns:
the value of the property, or null if the key is not found

setString

public void setString(java.lang.String key,
                      java.lang.String value)
Sets a property. Setting null value removes the property.

Parameters:
key - the property name
value - the value or null

set

public void set(java.lang.String key,
                MProp value)
Sets a property object. Setting null value removes the property.

Parameters:
key - the property name
value - the value or null

set

public void set(java.lang.String key,
                MProp value,
                int opts)
Sets a property object. Setting null value removes the property.

Parameters:
key - the property name
value - the value or null
opts - 0 or MProp.COORDDEP

remove

public void remove(MProp p)
Removes a property.

Parameters:
p - the object
Since:
Marvin 4.1.6, 02/21/2007

replace

public void replace(MProp oldp,
                    MProp newp)
Replaces or removes a property.

Parameters:
oldp - the old object
newp - the new object or null to remove
Since:
Marvin 4.1.6, 02/14/2007

contains

public boolean contains(MProp p)
Tests whether the container contains the specified property object.

Parameters:
p - the object
Since:
Marvin 4.1.6, 02/21/2007

isValid

public boolean isValid(MProp prop)
Tests whether a coordinate dependent property is still valid.

Parameters:
prop - the property
Returns:
true if the property is valid, false otherwise
See Also:
MProp.COORDDEP, set(String, MProp, int)

isSelfReference

public boolean isSelfReference(MProp p)
Tests whether a property is a self reference to the containing molecule.

Parameters:
p - the property
Returns:
true if the property is a self reference, false otherwise
Since:
Marvin 5.0, 11/05/2007

isHierarchic

public boolean isHierarchic()
Tests whether the property list contains subcollections like MListProp and MHashProp. A property list containing names in MDL RDfile style can be made hierarchic by calling hierarchize().

Returns:
true if the property list contains subcollections, false otherwise
Since:
Marvin 4.1.6, 02/15/2007

hierarchize

public java.lang.String hierarchize()
Converts hierarchically specified RDF properties to MListProp and MHashProp objects.

Returns:
the most likely "root" name (the name of the first MHashProp type property) or null
Since:
Marvin 4.1.6, 02/14/2007
See Also:
flatten(), isHierarchic()

flatten

public void flatten()
Flattens hierarchically specified RDF properties. The inverse operation of hierarchize().

Since:
Marvin 4.1.6, 02/14/2007
See Also:
isHierarchic()

getPropList

public java.util.List<MProp> getPropList()
Gets the list of basic properties. Properties containers like MListProp and MHashProp are not added to the list but searched recursively for their basic elements.

Returns:
the list of MProp objects
Since:
Marvin 4.1.6, 02/15/2007

getObject

public java.lang.Object getObject(java.lang.String key)
Gets a property object.

Parameters:
key - property name
Returns:
the value of the property, or null if the key is not found

setObject

public void setObject(java.lang.String key,
                      java.lang.Object val)
Sets a property object. Setting null value removes the property.

Parameters:
key - the property name
val - the value or null

clone

public java.lang.Object clone()
Clones this object.

Overrides:
clone in class java.lang.Object

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Restores the property container's state.

Specified by:
readExternal in interface java.io.Externalizable
Parameters:
in - the stream to read data from in order to restore the object
Throws:
java.io.IOException - if I/O errors occur
java.lang.ClassNotFoundException - If the class for an object being restored cannot be found.

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Saves the property container's state.

Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
out - the stream to write the object to
Throws:
java.io.IOException - Includes any I/O exceptions that may occur