Style Clone should Duplicate
----------------------------

         Key: GEOT-781
         URL: http://jira.codehaus.org/browse/GEOT-781
     Project: GeoTools
        Type: Bug

  Components: styling  
    Reporter: Jody Garnett


Jody Garnett wrote:
> I do not see facilities in the toolkit for duplicating Filter / Expression / 
> Style.
> I am finding some errors in the test cases as bad assumptions are made about 
> Symbolizer reuse ....
Found a scary example of Styles being cloned in a test case:
> Style clone = (Style) ((Cloneable)style).clone();
> assertClone(style,clone);
Indeed this does seem to be supported -- up until RuleImpl.

Basically we need to duplicate our Expressions - I will also note that this
is flawed as written
>     public Object clone() {
>         try {
>             RuleImpl clone = (RuleImpl) super.clone();
>             clone.graphics = new GTList(clone,"graphics");
>             clone.symbolizers = new GTList(clone,"symbolizers");
>             clone.filter = filter; // TODO: we must duplicate!
>                         Graphic[] legends = new Graphic[graphics.size()];
>             for (int i = 0; i < legends.length; i++) {
>                 Graphic legend = (Graphic) graphics.get(i);
>                 legends[i] = (Graphic) ((Cloneable) legend).clone();
>             }
>             clone.setLegendGraphic(legends);
>
>             Symbolizer[] symbArray = new Symbolizer[symbolizers.size()];
>             for (int i = 0; i < symbArray.length; i++) {
>                 Symbolizer symb = (Symbolizer) symbolizers.get(i);
>                 symbArray[i] = (Symbolizer) ((Cloneable) symb).clone();
>             }
>             clone.setSymbolizers(symbArray);
>
>             return clone;
>         } catch (CloneNotSupportedException e) {
>             throw new RuntimeException("This will never happen", e);
>         }
>     }

That is this is a semi deep copy. Sigh.  Must revisit when Filter/Expression 
duplication
is available.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to