| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.seasar.teeda.core.config.faces.assembler.impl; |
| 17 | |
|
| 18 | |
import java.util.Map; |
| 19 | |
|
| 20 | |
import org.seasar.framework.util.ClassUtil; |
| 21 | |
import org.seasar.framework.util.StringUtil; |
| 22 | |
import org.seasar.teeda.core.application.ConfigurationSupport; |
| 23 | |
import org.seasar.teeda.core.application.ConverterConfiguration; |
| 24 | |
import org.seasar.teeda.core.config.faces.assembler.ConverterAssembler; |
| 25 | |
import org.seasar.teeda.core.config.faces.assembler.ConverterChildAssembler; |
| 26 | |
import org.seasar.teeda.core.config.faces.element.ConverterElement; |
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
public class DefaultConverterAssembler extends ConverterAssembler { |
| 32 | |
|
| 33 | |
private ConverterChildAssembler converterIdAssembler_; |
| 34 | |
|
| 35 | |
private ConverterChildAssembler conveterClassAssembler_; |
| 36 | |
|
| 37 | |
public DefaultConverterAssembler(Map convertersByClass, Map convertersById) { |
| 38 | 4 | super(convertersByClass, convertersById); |
| 39 | 4 | } |
| 40 | |
|
| 41 | |
protected void setupBeforeAssemble() { |
| 42 | 4 | converterIdAssembler_ = new ConverterChildAssemblerById( |
| 43 | |
getConvertersById()); |
| 44 | 4 | conveterClassAssembler_ = new ConverterChildAssemblerByTargetClass( |
| 45 | |
getConvertersByClass()); |
| 46 | 4 | } |
| 47 | |
|
| 48 | |
public void assemble() { |
| 49 | 4 | converterIdAssembler_.assemble(); |
| 50 | 4 | conveterClassAssembler_.assemble(); |
| 51 | 4 | } |
| 52 | |
|
| 53 | |
private static class ConverterChildAssemblerById extends |
| 54 | |
ConverterChildAssembler { |
| 55 | |
|
| 56 | |
public ConverterChildAssemblerById(Map targetConverters) { |
| 57 | 4 | super(targetConverters); |
| 58 | 4 | } |
| 59 | |
|
| 60 | |
protected void doAssemble(String converterId, |
| 61 | |
ConverterElement converterElement) { |
| 62 | 2 | String converterClass = converterElement.getConverterClass(); |
| 63 | 2 | if (!StringUtil.isEmpty(converterClass)) { |
| 64 | 2 | getApplication().addConverter(converterId, converterClass); |
| 65 | |
} |
| 66 | 2 | } |
| 67 | |
|
| 68 | |
protected void doAddConverterConfiguration( |
| 69 | |
ConfigurationSupport support, String converterKey, |
| 70 | |
ConverterConfiguration configuration) { |
| 71 | 0 | support.addConverterConfiguration(converterKey, configuration); |
| 72 | 0 | } |
| 73 | |
} |
| 74 | |
|
| 75 | |
private static class ConverterChildAssemblerByTargetClass extends |
| 76 | |
ConverterChildAssembler { |
| 77 | |
|
| 78 | |
public ConverterChildAssemblerByTargetClass(Map targetConverters) { |
| 79 | 4 | super(targetConverters); |
| 80 | 4 | } |
| 81 | |
|
| 82 | |
protected void doAssemble(String converterForClass, |
| 83 | |
ConverterElement converterElement) { |
| 84 | 2 | String converterClass = converterElement.getConverterClass(); |
| 85 | 2 | if (!StringUtil.isEmpty(converterClass)) { |
| 86 | 2 | Class targetClazz = ClassUtil.forName(converterForClass); |
| 87 | 2 | getApplication().addConverter(targetClazz, converterClass); |
| 88 | |
} |
| 89 | 2 | } |
| 90 | |
|
| 91 | |
protected void doAddConverterConfiguration( |
| 92 | |
ConfigurationSupport support, String converterForClass, |
| 93 | |
ConverterConfiguration configuration) { |
| 94 | 0 | Class targetClazz = ClassUtil.forName(converterForClass); |
| 95 | 0 | support.addConverterConfiguration(targetClazz, configuration); |
| 96 | 0 | } |
| 97 | |
} |
| 98 | |
|
| 99 | |
} |