package poml.conv.basic;

import java.util.Map;

import poml.conv.Converter;
import poml.in.Poml;
import poml.out.Xml;

public class Property implements Converter {

  @Override public String name() { return "property"; }
  
  @Override public void convert(Poml poml, Xml xml) {
    Map<String, String> kv = poml.conf.map(name(), false);
    replaceKey(kv, encoding, encodings);
    replaceKey(kv, compiler, compilers);
    xml.println("  <properties>");
    xml.printKvTags(sp4, kv);
    xml.println("  </properties>");
  }
  
  private static final String encoding = "$encoding";
  private static final String[] encodings = {
    "project.build.sourceEncoding", "project.reporting.outputEncoding"
  };
  private static final String compiler = "$compiler";
  private static final String[] compilers = {
    "maven.compiler.source", "maven.compiler.target"
  };  
  private void replaceKey(Map<String, String> kv, String from, String[] to) {
    if (!kv.containsKey(from)) return;
    String v = kv.remove(from);
    for (String k: to) kv.put(k, v);
  }
}

@@ -339,124 +339,140 @@
     
-replaceKey(kv, encoding, encodings);%0A    replaceKey(kv, compiler, compilers);%0A    xml.println(%22  %3Cproperties%3E%22);%0A   
+xml.println(%22  %3Cproperties%3E%22);%0A    for (String k: kv.keySet()) %7B%0A      if (k.startsWith(%22$%22)) replace(k, kv.get(k), xml);%0A      else
  xml
@@ -486,19 +486,34 @@
 vTag
-s
 (sp4, k
-v);
+, kv.get(k));%0A    %7D
 %0A   
@@ -566,101 +566,110 @@
 ate 
-static final String encoding = %22$encoding%22;%0A  private static final String%5B%5D encodings = %7B%0A   
+void replace(String k, String v, Xml xml) %7B%0A    if (%22$encoding%22.equals(k)) %7B%0A      xml.printKvTag(sp4,
  %22pr
@@ -696,16 +696,46 @@
 coding%22,
+ v);%0A      xml.printKvTag(sp4,
  %22projec
@@ -765,117 +765,83 @@
 ing%22
-%0A  %7D;%0A  private static final String compiler = %22$compiler%22;%0A  private static final String%5B%5D compilers = %7B%0A   
+, v);%0A    %7D%0A    else if (%22$compiler%22.equals(k)) %7B%0A      xml.printKvTag(sp4,
  %22ma
@@ -866,224 +866,72 @@
 e%22, 
-%22maven.compiler.target%22
+v);
 %0A  
-%7D;
   
-%0A
   
-private void replaceKey(Map%3CString, String%3E kv, String from, String%5B%5D to) %7B%0A    if (!kv.containsKey(from)) return;%0A    String v = kv.remove(from);%0A    for (String k: to) kv.put(k, v);
+xml.printKvTag(sp4, %22maven.compiler.target%22, v);%0A    %7D
 %0A  %7D

Update property to fix print ourder.