Class DataXML

  • All Implemented Interfaces:
    java.io.Serializable

    public class DataXML
    extends java.lang.Object
    implements java.io.Serializable
    Simplicité XML object data manager
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      DataXML()
      Default constructor (empty data set)
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(TagXML tag)
      Add a single tag
      TagXML add​(java.lang.String name, boolean value)
      Add a tag from a name and a boolean value
      TagXML add​(java.lang.String name, char value)
      Add a tag from a name and a character value
      TagXML add​(java.lang.String name, double value)
      Add a tag from a name and a double value
      TagXML add​(java.lang.String name, float value)
      Add a tag from a name and a float value
      TagXML add​(java.lang.String name, int value)
      Add a tag from a name and an integer value
      TagXML add​(java.lang.String name, long value)
      Add a tag from a name and a long integer value
      TagXML add​(java.lang.String name, java.lang.Object value)
      Add a tag from a name and a value
      TagXML add​(java.lang.String name, java.lang.String value)
      Add a tag from a name and a string value
      TagXML add​(java.lang.String name, java.lang.String[] values)
      Add a tag from a name and an array of string values
      TagXML add​(java.lang.String name, java.lang.StringBuilder value)
      Add a tag from a name and a long string value (enclosed in CDATA)
      TagXML add​(java.lang.String name, java.lang.String value, boolean cdata)
      Add a tag from a name and a string value
      TagXML add​(java.lang.String name, java.lang.String value, boolean fkey, java.lang.String oldvalue, int type, java.lang.String doc)
      Add a tag from a name and a value
      TagXML add​(java.lang.String name, java.lang.String value, boolean fkey, java.lang.String oldvalue, int type, java.lang.String doc, java.lang.String docmap, java.lang.String dispValue, java.lang.String dispOldValue, java.lang.String disp)
      Add a tag from a name and a value
      TagXML add​(java.lang.String name, java.lang.String value, int type)
      Add a tag from a name and a typed string value
      TagXML add​(java.lang.String name, java.lang.String value, ObjectXML object, boolean fkey, ObjectXML oldObject)
      Add a tag from a name and a meta-object link value
      TagXML add​(java.lang.String name, java.math.BigDecimal value)
      Add a tag from a name and a big decimal value
      TagXML add​(java.lang.String name, java.util.Date value)
      Add a tag from a name and a date value
      TagXML add​(java.lang.String name, java.util.Date value, int type)
      Add a tag from a name and an internal date value
      java.util.Map<java.lang.String,​java.lang.String> attachTo​(java.lang.String root, java.util.Map<java.lang.String,​java.lang.String> files)
      List and copy attached files
      int compare​(DataXML data)
      Compare data:
      - 0 = not equals
      - 1 = only the same functional key
      - 2 = equals
      static boolean compareValues​(TagXML t1, TagXML t2)
      Compare document tag values without taking care of DATA: and file name
      static java.lang.String getComparableValue​(TagXML tag)
      Get comparable value of document tag
      java.util.Map<java.lang.String,​java.lang.Object> getFunctKeys()
      Get functional keys as map
      TagXML getLastTag()
      Get last tag
      ObjectXML getParent()
      Get parent XML object
      java.lang.String getSource()
      Get original source of data (for instance a line of imported file)
      TagXML getTag​(java.lang.String name)
      Get a tag
      java.util.List<TagXML> getTags()
      Get all tags
      java.lang.String getTagValue​(java.lang.String name)
      Get the tag value
      void populateObject​(ObjectDB obj)
      Populate the object with tags when known
      TagXML removeTag​(java.lang.String name)
      Remove a tag if it exists
      java.lang.String searchRowId​(Grant g)
      Try to find the row ID with known tags
      void setParent​(ObjectXML parent)
      Assign to a parent XML object
      void setSource​(java.lang.String src)
      Set the original source of data
      java.lang.StringBuilder toJSON​(boolean indent)
      Serialize to JSON string builder
      java.lang.String toString()
      Serialize as XML string
      java.lang.StringBuilder toXML()
      Serialize as XML string builder
      java.lang.StringBuilder toXML​(java.lang.String tab, java.lang.String spacer)
      Serialize as XML string builder
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DataXML

        public DataXML()
        Default constructor (empty data set)
    • Method Detail

      • getParent

        public ObjectXML getParent()
        Get parent XML object
        Returns:
        Parent XML object
      • setParent

        public void setParent​(ObjectXML parent)
        Assign to a parent XML object
        Parameters:
        parent - Parent XML object to assign to
      • getTags

        public java.util.List<TagXML> getTags()
        Get all tags
        Returns:
        Tags list
      • getFunctKeys

        public java.util.Map<java.lang.String,​java.lang.Object> getFunctKeys()
        Get functional keys as map
        Returns:
        Map of function keys
      • getSource

        public java.lang.String getSource()
        Get original source of data (for instance a line of imported file)
        Returns:
        Original source of data
      • setSource

        public void setSource​(java.lang.String src)
        Set the original source of data
        Parameters:
        src - Original source of data
      • add

        public void add​(TagXML tag)
        Add a single tag
        Parameters:
        tag - Tag to add
      • add

        public TagXML add​(java.lang.String name,
                          java.lang.String value)
        Add a tag from a name and a string value
        Parameters:
        name - Name
        value - Value
        Returns:
        Tag
      • add

        public TagXML add​(java.lang.String name,
                          char value)
        Add a tag from a name and a character value
        Parameters:
        name - Name
        value - Value
        Returns:
        Tag
      • add

        public TagXML add​(java.lang.String name,
                          java.lang.String value,
                          boolean cdata)
        Add a tag from a name and a string value
        Parameters:
        name - Name
        value - Value
        cdata - Enclose in CDATA?
        Returns:
        Tag
      • add

        public TagXML add​(java.lang.String name,
                          java.lang.StringBuilder value)
        Add a tag from a name and a long string value (enclosed in CDATA)
        Parameters:
        name - Name
        value - Value
        Returns:
        Tag
      • add

        public TagXML add​(java.lang.String name,
                          boolean value)
        Add a tag from a name and a boolean value
        Parameters:
        name - Name
        value - Value
        Returns:
        Tag
      • add

        public TagXML add​(java.lang.String name,
                          int value)
        Add a tag from a name and an integer value
        Parameters:
        name - Name
        value - Value
        Returns:
        Tag
      • add

        public TagXML add​(java.lang.String name,
                          long value)
        Add a tag from a name and a long integer value
        Parameters:
        name - Name
        value - Value
        Returns:
        Tag
      • add

        public TagXML add​(java.lang.String name,
                          float value)
        Add a tag from a name and a float value
        Parameters:
        name - Name
        value - Value
        Returns:
        Tag
      • add

        public TagXML add​(java.lang.String name,
                          double value)
        Add a tag from a name and a double value
        Parameters:
        name - Name
        value - Value
        Returns:
        Tag
      • add

        public TagXML add​(java.lang.String name,
                          java.math.BigDecimal value)
        Add a tag from a name and a big decimal value
        Parameters:
        name - Name
        value - Value
        Returns:
        Tag
      • add

        public TagXML add​(java.lang.String name,
                          java.util.Date value)
        Add a tag from a name and a date value
        Parameters:
        name - Name
        value - Value
        Returns:
        Tag
      • add

        public TagXML add​(java.lang.String name,
                          java.util.Date value,
                          int type)
        Add a tag from a name and an internal date value
        Parameters:
        name - Name
        value - Value
        Returns:
        Tag
      • add

        public TagXML add​(java.lang.String name,
                          java.lang.String[] values)
        Add a tag from a name and an array of string values
        Parameters:
        name - Name
        values - Values
        Returns:
        Tag
      • add

        public TagXML add​(java.lang.String name,
                          java.lang.Object value)
        Add a tag from a name and a value
        Parameters:
        name - Name
        value - Value
        Returns:
        Tag
      • add

        public TagXML add​(java.lang.String name,
                          java.lang.String value,
                          int type)
        Add a tag from a name and a typed string value
        Parameters:
        name - Name
        value - Value
        type - Field type
        Returns:
        Tag
      • add

        public TagXML add​(java.lang.String name,
                          java.lang.String value,
                          boolean fkey,
                          java.lang.String oldvalue,
                          int type,
                          java.lang.String doc)
        Add a tag from a name and a value
        Parameters:
        name - Name
        value - Value
        oldvalue - Old value (if any)
        type - Field type
        fkey - Is functional key?
        doc - Path or inlined data of document (if applicable)
        Returns:
        Tag
      • add

        public TagXML add​(java.lang.String name,
                          java.lang.String value,
                          boolean fkey,
                          java.lang.String oldvalue,
                          int type,
                          java.lang.String doc,
                          java.lang.String docmap,
                          java.lang.String dispValue,
                          java.lang.String dispOldValue,
                          java.lang.String disp)
        Add a tag from a name and a value
        Parameters:
        name - Name
        value - Value
        oldvalue - Old value (if any)
        type - Field type
        fkey - Is functional key?
        doc - Path or inlined data of document (if applicable)
        docmap - Optional mapped path of document (if applicable)
        dispValue - Optional value to display label
        dispOldValue - Optional old value display label
        disp - Optional tag display label
        Returns:
        Tag
      • add

        public TagXML add​(java.lang.String name,
                          java.lang.String value,
                          ObjectXML object,
                          boolean fkey,
                          ObjectXML oldObject)
        Add a tag from a name and a meta-object link value
        Parameters:
        name - Name
        value - Meta-object link value (object:row ID)
        fkey - Is functional key ?
        object - XML object
        oldObject - Old XML object if any
        Returns:
        Tag
      • populateObject

        public void populateObject​(ObjectDB obj)
        Populate the object with tags when known
        Parameters:
        obj - Object
      • getTagValue

        public java.lang.String getTagValue​(java.lang.String name)
        Get the tag value
        Parameters:
        name - Name
        Returns:
        Value
      • getTag

        public TagXML getTag​(java.lang.String name)
        Get a tag
        Parameters:
        name - Name
        Returns:
        Tag
      • getLastTag

        public TagXML getLastTag()
        Get last tag
        Returns:
        Tag
      • removeTag

        public TagXML removeTag​(java.lang.String name)
        Remove a tag if it exists
        Parameters:
        name - Namee
        Returns:
        Removed tag
      • searchRowId

        public java.lang.String searchRowId​(Grant g)
        Try to find the row ID with known tags
        Parameters:
        g - Grant
        Returns:
        Found row ID or null
      • toString

        public java.lang.String toString()
        Serialize as XML string
        Overrides:
        toString in class java.lang.Object
        Returns:
        XML string
      • toXML

        public java.lang.StringBuilder toXML()
        Serialize as XML string builder
        Returns:
        XML string builder
      • toXML

        public java.lang.StringBuilder toXML​(java.lang.String tab,
                                             java.lang.String spacer)
        Serialize as XML string builder
        Parameters:
        tab - Tabulation
        spacer - Spacer
        Returns:
        XML string builder
      • toJSON

        public java.lang.StringBuilder toJSON​(boolean indent)
        Serialize to JSON string builder
        Parameters:
        indent - Indent?
        Returns:
        JSON string builder
      • attachTo

        public java.util.Map<java.lang.String,​java.lang.String> attachTo​(java.lang.String root,
                                                                               java.util.Map<java.lang.String,​java.lang.String> files)
        List and copy attached files
        Parameters:
        root - Directory
        files - List of file paths
        Returns:
        List of files paths with the added files
      • getComparableValue

        public static java.lang.String getComparableValue​(TagXML tag)
        Get comparable value of document tag
        Parameters:
        tag - Tag
        Returns:
        Inlined data doc without DATA: and file name
      • compareValues

        public static boolean compareValues​(TagXML t1,
                                            TagXML t2)
        Compare document tag values without taking care of DATA: and file name
        Returns:
        True if not equals
      • compare

        public int compare​(DataXML data)
        Compare data:
        - 0 = not equals
        - 1 = only the same functional key
        - 2 = equals
        Parameters:
        data - Any data
        Returns:
        0, 1 or 2 (-1 when data is null)