Class Document

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String PROP_AUTHOR
      Constant for property name of the property under which Author is stored.
      static java.lang.String PROP_LAST_UPDATE
      Constant for property name of the property under which last update timestamp is stored.
      static java.lang.String PROP_TYPE_IDENTIFIER
      Constant used to save type_identifier as internal property name.
    • Constructor Summary

      Constructors 
      Constructor Description
      Document​(java.lang.String id)
      Creates a new Document with given name.
      Document​(Document anotherDocument)
      Creates a new document as a copy of another document.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addDataHolder​(DataHolder holder)
      Puts the given DataHolder (which can be a document, a list or a property) in the internal storage.
      java.lang.Object clone()
      clone.
      protected java.util.List<Property> copyFromBooleanList​(java.util.List<java.lang.Boolean> booleans)
      copyFromBooleanList.
      protected java.util.List<Property> copyFromDoubleList​(java.util.List<java.lang.Double> doubles)
      copyFromDoubleList.
      protected java.util.List<Property> copyFromFloatList​(java.util.List<java.lang.Float> floats)
      copyFromFloatList.
      protected java.util.List<Property> copyFromIntegerList​(java.util.List<java.lang.Integer> integers)
      copyFromIntegerList.
      protected java.util.List<Property> copyFromLongList​(java.util.List<java.lang.Long> longs)
      copyFromLongList.
      protected java.util.List<Property> copyFromStringList​(java.util.List<java.lang.String> strings)
      copyFromStringList.
      protected java.util.List<java.lang.Boolean> copyToBooleanList​(java.util.List<Property> properties)
      copyToBooleanList.
      protected java.util.List<java.lang.Double> copyToDoubleList​(java.util.List<Property> properties)
      copyToDoubleList.
      protected java.util.List<java.lang.Float> copyToFloatList​(java.util.List<Property> properties)
      copyToFloatList.
      protected java.util.List<java.lang.Integer> copyToIntegerList​(java.util.List<Property> properties)
      copyToIntegerList.
      protected java.util.List<java.lang.Long> copyToLongList​(java.util.List<Property> properties)
      copyToLongList.
      protected java.util.List<java.lang.String> copyToStringList​(java.util.List<Property> properties)
      copyToStringList.
      protected Document createDocument​(java.lang.String name)
      Creates a new Document.
      protected <D extends Document>
      DocumentList<D>
      createDocumentList​(java.lang.String name)
      Creates a new DocumentList.
      protected ListProperty createListProperty​(java.lang.String name)
      createListProperty.
      java.lang.String getAuthor()
      getAuthor.
      boolean getBoolean​(java.lang.String fieldId)
      Returns the boolean value of the according BooleanProperty, or an empty boolean (see getEmptyBoolean) if none set.
      BooleanProperty getBooleanProperty​(java.lang.String name)
      Returns the BooleanProperty contained in this Document under the given name.
      DataHolder getDataHolder​(java.lang.String name)
      Returns the DataHolder contained in this Document under the given name.
      Document getDocument​(java.lang.String name)
      Returns the Document contained in this Document under the given name.
      protected Document getDocumentAnyCase​(java.lang.String name)
      Returns the Document contained in this Document under the given name in any case, which means that if no Document is contained it a new will be created.
      <D extends Document>
      DocumentList<D>
      getDocumentList​(java.lang.String name)
      Returns the DocumentList contained in this Document under the given name.
      protected <D extends Document>
      DocumentList<D>
      getDocumentListAnyCase​(java.lang.String name)
      Returns the DocumentList contained in this Document under the given name in any case, which means that if no DocumentList is contained it a new will be created.
      double getDouble​(java.lang.String fieldId)
      Returns the double value of the according DoubleProperty, or an empty double (see getEmptyDouble) if none set.
      DoubleProperty getDoubleProperty​(java.lang.String name)
      Returns the DoubleProperty contained in this Document under the given name.
      boolean getEmptyBoolean()
      Returns the initial value for a boolean (false).
      double getEmptyDouble()
      Returns the initial value for a double (0.0).
      float getEmptyFloat()
      Returns the initial value for a float (0.0).
      int getEmptyInt()
      Returns the initial value for a int (0).
      java.util.List<Property> getEmptyList()
      getEmptyList.
      long getEmptyLong()
      Returns the initial value for a long (0).
      java.lang.String getEmptyString()
      Returns the initial value for a string (empty string - "").
      float getFloat​(java.lang.String fieldId)
      Returns the float value of the according FloatProperty, or an empty float (see getEmptyFloat) if none set.
      FloatProperty getFloatProperty​(java.lang.String name)
      Returns the FloatProperty contained in this Document under the given name.
      int getInt​(java.lang.String fieldId)
      Returns the int value of the according IntProperty, or an empty int (see getEmptyInt) if none set.
      IntProperty getIntProperty​(java.lang.String name)
      Returns the IntProperty contained in this Document under the given name.
      java.util.Enumeration<java.lang.String> getKeys()
      Returns the keys (names) of the contained documents.
      long getLastUpdateTimestamp()
      getLastUpdateTimestamp.
      java.util.List<Property> getList​(java.lang.String fieldId)
      Returns list of Property by fieldId.
      ListProperty getListProperty​(java.lang.String name)
      Returns the ListProperty contained in this Document under the given name.
      protected ListProperty getListPropertyAnyCase​(java.lang.String name)
      getListPropertyAnyCase.
      long getLong​(java.lang.String fieldId)
      Returns the long value of the according LongProperty, or an empty long (see getEmptyLong) if none set.
      LongProperty getLongProperty​(java.lang.String name)
      Returns the LongProperty contained in this Document under the given name.
      java.lang.Object getObject​(java.lang.String key)
      This method is used by the storage to save not only the container, but the underlying data too.
      java.util.List<Property> getProperties()
      Returns a list of all contained properties.
      Property getProperty​(java.lang.String name)
      Returns the Property contained in this Document under the given name.
      java.lang.Object getPropertyValue​(java.lang.String propertyName)
      getPropertyValue.
      long getSizeInBytes()
      Returns the cumulative size of the contained DataHolders.
      java.lang.String getStorageId()
      Returns the storage id which should be used by a storage to store this document.
      java.lang.String getString​(java.lang.String fieldId)
      Returns the string value of the according StringProperty, or empty string (see getEmptyString) if none set.
      StringProperty getStringProperty​(java.lang.String name)
      Returns the StringProperty contained in this Document under the given name.
      java.lang.String getTypeIdentifier()
      Returns the type identifier of this document.
      void putBooleanProperty​(BooleanProperty p)
      Puts the given BooleanProperty in the internal storage.
      void putDocument​(Document doc)
      Puts the given Document in the internal storage.
      void putDoubleProperty​(DoubleProperty p)
      Puts the given FloatProperty in the internal storage.
      void putFloatProperty​(FloatProperty p)
      Puts the given FloatProperty in the internal storage.
      void putIntProperty​(IntProperty p)
      Puts the given IntProperty in the internal storage.
      void putList​(DocumentList<? extends Document> list)
      Puts the given DocumentList in the internal storage.
      void putListProperty​(ListProperty p)
      Puts the given ListProperty in the internal storage.
      void putLongProperty​(LongProperty p)
      Puts the given LongProperty in the internal storage.
      void putProperty​(Property p)
      Puts the given Property in the internal storage.
      void putStringProperty​(StringProperty p)
      Puts the given StringProperty in the internal storage.
      protected void removeDataHolder​(java.lang.String id)
      removeDataHolder.
      protected void removeDataHolder​(DataHolder holder)
      removeDataHolder.
      void removeProperty​(java.lang.String propertyName)
      removeProperty.
      void removeProperty​(Property p)
      removeProperty.
      void renameTo​(java.lang.String newId)
      renameTo.
      void setBoolean​(java.lang.String fieldId, boolean value)
      Sets a BooleangProperty with name = fieldId and value = value in this document.
      void setCallContextAuthor()
      setCallContextAuthor.
      void setDouble​(java.lang.String fieldId, double value)
      Sets a FloatProperty with name = fieldId and value = value in this document.
      void setFloat​(java.lang.String fieldId, float value)
      Sets a FloatProperty with name = fieldId and value = value in this document.
      void setInt​(java.lang.String fieldId, int value)
      Sets a IntProperty with name = fieldId and value = value in this document.
      void setLastUpdateNow()
      setLastUpdateNow.
      void setList​(java.lang.String fieldId, java.util.List<Property> value)
      setList.
      void setLong​(java.lang.String fieldId, long value)
      Sets a LongProperty with name = fieldId and value = value in this document.
      void setString​(java.lang.String fieldId, java.lang.String value)
      Sets a StringProperty with name = fieldId and value = value in this document.
      void setTypeIdentifier​(java.lang.String anIdentifier)
      Sets the type identifier for this document.
      java.lang.String toString()
      Returns the string representation of this document.
      net.anotheria.util.xml.XMLNode toXMLNode()
      toXMLNode.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • PROP_TYPE_IDENTIFIER

        public static final java.lang.String PROP_TYPE_IDENTIFIER
        Constant used to save type_identifier as internal property name.
        See Also:
        Constant Field Values
      • PROP_LAST_UPDATE

        public static final java.lang.String PROP_LAST_UPDATE
        Constant for property name of the property under which last update timestamp is stored.
        See Also:
        Constant Field Values
      • PROP_AUTHOR

        public static final java.lang.String PROP_AUTHOR
        Constant for property name of the property under which Author is stored.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Document

        public Document​(java.lang.String id)
        Creates a new Document with given name.
        Parameters:
        id - a String object.
      • Document

        public Document​(Document anotherDocument)
        Creates a new document as a copy of another document.
        Parameters:
        anotherDocument - the document to be copied
    • Method Detail

      • getProperties

        public java.util.List<Property> getProperties()
        Returns a list of all contained properties.
        Returns:
        properties
      • getDocumentList

        public <D extends DocumentDocumentList<D> getDocumentList​(java.lang.String name)
        Returns the DocumentList contained in this Document under the given name.
        Type Parameters:
        D - a D object.
        Parameters:
        name - of DocumentList
        Returns:
        DocumentList
        Throws:
        NoSuchDocumentListException
      • getDocumentListAnyCase

        protected <D extends DocumentDocumentList<D> getDocumentListAnyCase​(java.lang.String name)
        Returns the DocumentList contained in this Document under the given name in any case, which means that if no DocumentList is contained it a new will be created. This function is protected because it implies very much knowledge about the module structure and shouldn't be called from outside a document.
        Type Parameters:
        D - a D object.
        Parameters:
        name - of Document
        Returns:
        DocumentList
        See Also:
        NoSuchDocumentListException
      • getDocumentAnyCase

        protected Document getDocumentAnyCase​(java.lang.String name)
        Returns the Document contained in this Document under the given name in any case, which means that if no Document is contained it a new will be created. This function is protected because it implies very much knowledge about the module structure and shouldn't be called from outside a document.
        Parameters:
        name - of document
        Returns:
        Doucument
        See Also:
        NoSuchDocumentException
      • getListPropertyAnyCase

        protected ListProperty getListPropertyAnyCase​(java.lang.String name)

        getListPropertyAnyCase.

        Parameters:
        name - a String object.
        Returns:
        a ListProperty object.
      • createDocumentList

        protected <D extends DocumentDocumentList<D> createDocumentList​(java.lang.String name)
        Creates a new DocumentList. Overwrite this, if your document uses special lists. Called by getDocumentListAnyCase
        Type Parameters:
        D - a D object.
        Parameters:
        name - a String object.
        Returns:
        a DocumentList object.
      • createDocument

        protected Document createDocument​(java.lang.String name)
        Creates a new Document. Overwrite this, if your document uses special subdocuments (which should almost ever be the case). Called by getDocumentAnyCase
        Parameters:
        name - a String object.
        Returns:
        a Document object.
      • createListProperty

        protected ListProperty createListProperty​(java.lang.String name)

        createListProperty.

        Parameters:
        name - a String object.
        Returns:
        a ListProperty object.
      • removeDataHolder

        protected void removeDataHolder​(DataHolder holder)

        removeDataHolder.

        Parameters:
        holder - a DataHolder object.
      • removeDataHolder

        protected void removeDataHolder​(java.lang.String id)

        removeDataHolder.

        Parameters:
        id - a String object.
      • addDataHolder

        protected void addDataHolder​(DataHolder holder)
        Puts the given DataHolder (which can be a document, a list or a property) in the internal storage.
        Parameters:
        holder - a DataHolder object.
      • putStringProperty

        public void putStringProperty​(StringProperty p)
        Puts the given StringProperty in the internal storage.
        Parameters:
        p - a StringProperty object.
      • putIntProperty

        public void putIntProperty​(IntProperty p)
        Puts the given IntProperty in the internal storage.
        Parameters:
        p - a IntProperty object.
      • putLongProperty

        public void putLongProperty​(LongProperty p)
        Puts the given LongProperty in the internal storage.
        Parameters:
        p - a LongProperty object.
      • putBooleanProperty

        public void putBooleanProperty​(BooleanProperty p)
        Puts the given BooleanProperty in the internal storage.
        Parameters:
        p - a BooleanProperty object.
      • putListProperty

        public void putListProperty​(ListProperty p)
        Puts the given ListProperty in the internal storage.
        Parameters:
        p - a ListProperty object.
      • putFloatProperty

        public void putFloatProperty​(FloatProperty p)
        Puts the given FloatProperty in the internal storage.
        Parameters:
        p - a FloatProperty object.
      • putDoubleProperty

        public void putDoubleProperty​(DoubleProperty p)
        Puts the given FloatProperty in the internal storage.
        Parameters:
        p - a DoubleProperty object.
      • putProperty

        public void putProperty​(Property p)
        Puts the given Property in the internal storage.
        Parameters:
        p - a Property object.
      • removeProperty

        public void removeProperty​(Property p)

        removeProperty.

        Parameters:
        p - a Property object.
      • removeProperty

        public void removeProperty​(java.lang.String propertyName)

        removeProperty.

        Parameters:
        propertyName - a String object.
      • putDocument

        public void putDocument​(Document doc)
        Puts the given Document in the internal storage.
        Parameters:
        doc - a Document object.
      • putList

        public void putList​(DocumentList<? extends Document> list)
        Puts the given DocumentList in the internal storage.
        Parameters:
        list - a DocumentList object.
      • toString

        public java.lang.String toString()
        Returns the string representation of this document.
        Overrides:
        toString in class java.lang.Object
      • getObject

        public java.lang.Object getObject​(java.lang.String key)
        This method is used by the storage to save not only the container, but the underlying data too. It's also used by debug or administration programs to trace a composite object, such as Document. Returns the contained object stored under given key.
        Specified by:
        getObject in interface ICompositeDataObject
        Parameters:
        key - the key (id) of the contained element/object.
        Returns:
        the object associated to the key.
        See Also:
        ICompositeDataObject.getObject(String)
      • getTypeIdentifier

        public java.lang.String getTypeIdentifier()
        Returns the type identifier of this document.
        Returns:
        a String object.
      • setTypeIdentifier

        public void setTypeIdentifier​(java.lang.String anIdentifier)
        Sets the type identifier for this document. The type identifier is especially useful for queries and factory-reassembling.
        Parameters:
        anIdentifier - a String object.
      • getString

        public java.lang.String getString​(java.lang.String fieldId)
                                   throws NoSuchPropertyException
        Returns the string value of the according StringProperty, or empty string (see getEmptyString) if none set.
        Parameters:
        fieldId - a String object.
        Returns:
        a String object.
        Throws:
        NoSuchPropertyException - if any.
      • getLong

        public long getLong​(java.lang.String fieldId)
                     throws NoSuchPropertyException
        Returns the long value of the according LongProperty, or an empty long (see getEmptyLong) if none set.
        Parameters:
        fieldId - a String object.
        Returns:
        long value
        Throws:
        NoSuchPropertyException - if any.
      • getInt

        public int getInt​(java.lang.String fieldId)
                   throws NoSuchPropertyException
        Returns the int value of the according IntProperty, or an empty int (see getEmptyInt) if none set.
        Parameters:
        fieldId - a String object.
        Returns:
        int value
        Throws:
        NoSuchPropertyException - if any.
      • getList

        public java.util.List<Property> getList​(java.lang.String fieldId)
                                         throws NoSuchPropertyException
        Returns list of Property by fieldId.
        Parameters:
        fieldId - fieldId
        Returns:
        list of Property or empty list if no Property was found by diven fieldId
        Throws:
        NoSuchPropertyException - if any.
      • getFloat

        public float getFloat​(java.lang.String fieldId)
                       throws NoSuchPropertyException
        Returns the float value of the according FloatProperty, or an empty float (see getEmptyFloat) if none set.
        Parameters:
        fieldId - a String object.
        Returns:
        float value of FloatProperty
        Throws:
        NoSuchPropertyException - if any.
      • getDouble

        public double getDouble​(java.lang.String fieldId)
                         throws NoSuchPropertyException
        Returns the double value of the according DoubleProperty, or an empty double (see getEmptyDouble) if none set.
        Parameters:
        fieldId - a String object.
        Returns:
        double value of DoubleProperty
        Throws:
        NoSuchPropertyException - if any.
      • getBoolean

        public boolean getBoolean​(java.lang.String fieldId)
                           throws NoSuchPropertyException
        Returns the boolean value of the according BooleanProperty, or an empty boolean (see getEmptyBoolean) if none set.
        Parameters:
        fieldId - a String object.
        Returns:
        boolean value
        Throws:
        NoSuchPropertyException - if any.
      • setList

        public void setList​(java.lang.String fieldId,
                            java.util.List<Property> value)

        setList.

        Parameters:
        fieldId - a String object.
        value - a List object.
      • setString

        public void setString​(java.lang.String fieldId,
                              java.lang.String value)
        Sets a StringProperty with name = fieldId and value = value in this document.
        Parameters:
        fieldId - a String object.
        value - a String object.
      • setLong

        public void setLong​(java.lang.String fieldId,
                            long value)
        Sets a LongProperty with name = fieldId and value = value in this document.
        Parameters:
        fieldId - a String object.
        value - a long.
      • setInt

        public void setInt​(java.lang.String fieldId,
                           int value)
        Sets a IntProperty with name = fieldId and value = value in this document.
        Parameters:
        fieldId - a String object.
        value - a int.
      • setFloat

        public void setFloat​(java.lang.String fieldId,
                             float value)
        Sets a FloatProperty with name = fieldId and value = value in this document.
        Parameters:
        fieldId - a String object.
        value - a float.
      • setDouble

        public void setDouble​(java.lang.String fieldId,
                              double value)
        Sets a FloatProperty with name = fieldId and value = value in this document.
        Parameters:
        fieldId - a String object.
        value - a double.
      • setBoolean

        public void setBoolean​(java.lang.String fieldId,
                               boolean value)
        Sets a BooleangProperty with name = fieldId and value = value in this document.
        Parameters:
        fieldId - a String object.
        value - a boolean.
      • getEmptyString

        public java.lang.String getEmptyString()
        Returns the initial value for a string (empty string - ""). Overwrite it if you wish another values. An empty value will always be returned if you call get'Type' and the corresponding property doesn't exists.
        Returns:
        ""
      • getEmptyLong

        public long getEmptyLong()
        Returns the initial value for a long (0). Overwrite it if you wish another values. An empty value will always be returned if you call get'Type' and the corresponding property doesn't exists.
        Returns:
        0
      • getEmptyInt

        public int getEmptyInt()
        Returns the initial value for a int (0). Overwrite it if you wish another values. An empty value will always be returned if you call get'Type' and the corresponding property doesn't exists.
        Returns:
        0
      • getEmptyFloat

        public float getEmptyFloat()
        Returns the initial value for a float (0.0). Overwrite it if you wish another values. An empty value will always be returned if you call get'Type' and the corresponding property doesn't exists.
        Returns:
        0
      • getEmptyDouble

        public double getEmptyDouble()
        Returns the initial value for a double (0.0). Overwrite it if you wish another values. An empty value will always be returned if you call get'Type' and the corresponding property doesn't exists.
        Returns:
        0.0
      • getEmptyBoolean

        public boolean getEmptyBoolean()
        Returns the initial value for a boolean (false). Overwrite it if you wish another values. An empty value will always be returned if you call get'Type' and the corresponding property doesn't exists.
        Returns:
        false
      • getEmptyList

        public java.util.List<Property> getEmptyList()

        getEmptyList.

        Returns:
        a List object.
      • renameTo

        public void renameTo​(java.lang.String newId)

        renameTo.

        Parameters:
        newId - a String object.
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException

        clone.

        Overrides:
        clone in class DataHolder
        Returns:
        a Object object.
        Throws:
        java.lang.CloneNotSupportedException - if any.
      • toXMLNode

        public net.anotheria.util.xml.XMLNode toXMLNode()

        toXMLNode.

        Overrides:
        toXMLNode in class DataHolder
        Returns:
        a XMLNode object.
      • getPropertyValue

        public java.lang.Object getPropertyValue​(java.lang.String propertyName)

        getPropertyValue.

        Parameters:
        propertyName - a String object.
        Returns:
        a Object object.
      • setLastUpdateNow

        public void setLastUpdateNow()

        setLastUpdateNow.

      • getLastUpdateTimestamp

        public long getLastUpdateTimestamp()

        getLastUpdateTimestamp.

        Returns:
        a long.
      • setCallContextAuthor

        public void setCallContextAuthor()

        setCallContextAuthor.

      • getAuthor

        public java.lang.String getAuthor()

        getAuthor.

        Returns:
        a String object.
      • copyToStringList

        protected java.util.List<java.lang.String> copyToStringList​(java.util.List<Property> properties)

        copyToStringList.

        Parameters:
        properties - a List object.
        Returns:
        a List object.
      • copyFromStringList

        protected java.util.List<Property> copyFromStringList​(java.util.List<java.lang.String> strings)

        copyFromStringList.

        Parameters:
        strings - a List object.
        Returns:
        a List object.
      • copyToIntegerList

        protected java.util.List<java.lang.Integer> copyToIntegerList​(java.util.List<Property> properties)

        copyToIntegerList.

        Parameters:
        properties - a List object.
        Returns:
        a List object.
      • copyFromIntegerList

        protected java.util.List<Property> copyFromIntegerList​(java.util.List<java.lang.Integer> integers)

        copyFromIntegerList.

        Parameters:
        integers - a List object.
        Returns:
        a List object.
      • copyToLongList

        protected java.util.List<java.lang.Long> copyToLongList​(java.util.List<Property> properties)

        copyToLongList.

        Parameters:
        properties - a List object.
        Returns:
        a List object.
      • copyFromLongList

        protected java.util.List<Property> copyFromLongList​(java.util.List<java.lang.Long> longs)

        copyFromLongList.

        Parameters:
        longs - a List object.
        Returns:
        a List object.
      • copyToBooleanList

        protected java.util.List<java.lang.Boolean> copyToBooleanList​(java.util.List<Property> properties)

        copyToBooleanList.

        Parameters:
        properties - a List object.
        Returns:
        a List object.
      • copyFromBooleanList

        protected java.util.List<Property> copyFromBooleanList​(java.util.List<java.lang.Boolean> booleans)

        copyFromBooleanList.

        Parameters:
        booleans - a List object.
        Returns:
        a List object.
      • copyToDoubleList

        protected java.util.List<java.lang.Double> copyToDoubleList​(java.util.List<Property> properties)

        copyToDoubleList.

        Parameters:
        properties - a List object.
        Returns:
        a List object.
      • copyFromDoubleList

        protected java.util.List<Property> copyFromDoubleList​(java.util.List<java.lang.Double> doubles)

        copyFromDoubleList.

        Parameters:
        doubles - a List object.
        Returns:
        a List object.
      • copyToFloatList

        protected java.util.List<java.lang.Float> copyToFloatList​(java.util.List<Property> properties)

        copyToFloatList.

        Parameters:
        properties - a List object.
        Returns:
        a List object.
      • copyFromFloatList

        protected java.util.List<Property> copyFromFloatList​(java.util.List<java.lang.Float> floats)

        copyFromFloatList.

        Parameters:
        floats - a List object.
        Returns:
        a List object.