Class ElementCollection


  • public class ElementCollection
    extends RenderElement
    A collection used to group multiple RenderElements together. It can contain nested `Object`s and should be used to pass multiple `RenderElements` as PrintJob data, as well as to allow for nested elements. Its name is used as a key name when nested, but ignored for all purposes when it's the outer object.
    • Constructor Detail

      • ElementCollection

        public ElementCollection​(java.lang.String name,
                                 java.util.ArrayList<RenderElement> elements)
        A collection used to group multiple RenderElements together.
        Parameters:
        name - The name is used as a key name when the collection is nested, but ignored when it's the outer object.
        elements - List of nested RenderElements.
      • ElementCollection

        public ElementCollection​(java.lang.String name)
        A collection used to group multiple RenderElements together. The arrayList of elements isn't initialised in this constructor so setFromDict should be called.
        Parameters:
        name - The name is used as a key name when the collection is nested, but ignored when it's the outer object.
    • Method Detail

      • getElements

        public java.util.ArrayList<RenderElement> getElements()
        Returns:
        List of nested RenderElements.
      • setElements

        public void setElements​(java.util.ArrayList<RenderElement> elements)
        Parameters:
        elements - List of nested RenderElements.
      • addElement

        public void addElement​(RenderElement element)
        Parameters:
        element - Element to add to the list of elements.
      • removeElement

        public void removeElement​(RenderElement element)
        Parameters:
        element - Element to remove from the list of elements.
      • removeElementByName

        public void removeElementByName​(java.lang.String elementName)
        Parameters:
        elementName - Name of the element to remove from the list of elements.
      • addFromDict

        public void addFromDict​(java.util.Hashtable<java.lang.String,​java.lang.String> properties)
        Adds the list of properties from a mapping.
        Parameters:
        properties - Hashtable of (propertyName,propertyValue).
      • makeCollectionFromJson

        public static ElementCollection makeCollectionFromJson​(java.lang.String name,
                                                               com.google.gson.JsonObject json)
        Parses a JsonArray to an elementcollection.
        Parameters:
        name - Name of the elementcollection.
        json - Json to parse.
        Returns:
        Elementcollection of the parsed json.
      • addAllRenderElements

        public void addAllRenderElements​(ElementCollection collection)
        Adds all the elements from the elementcollection to the elements of this collection.
        Parameters:
        collection - Elementcollection.
      • updateJson1WithJson2

        public static void updateJson1WithJson2​(com.google.gson.JsonObject json1,
                                                com.google.gson.JsonObject json2)
        Parameters:
        json1 - Json to add the data from json2 to.
        json2 - Json to take the data from. Cannot have nested JSON's/JsonArrays.
      • getJSON

        public com.google.gson.JsonObject getJSON()
        Specified by:
        getJSON in class RenderElement
        Returns:
        JSONObject with the tags for this property for the Cloud Office Print server.
      • getTemplateTags

        public java.util.Set<java.lang.String> getTemplateTags()
        Specified by:
        getTemplateTags in class RenderElement
        Returns:
        An immutable set containing all available template tags this element can replace.