1 16 17 package org.apache.commons.betwixt.strategy; 18 19 import org.apache.commons.betwixt.ElementDescriptor; 20 21 37 public abstract class MixedContentEncodingStrategy { 38 39 44 public static final String ENCODING_OPTION_NAME 45 = "org.apache.commons.betwixt.mixed-content-encoding"; 46 47 public static final String CDATA_ENCODING = "CDATA"; 48 49 58 public static final MixedContentEncodingStrategy DEFAULT 59 = new BaseMixedContentEncodingStrategy() { 60 67 protected boolean encodeAsCDATA(ElementDescriptor element) { 68 boolean result = false; 69 if (element != null ) { 70 String optionValue = element.getOptions().getValue(ENCODING_OPTION_NAME); 71 result = CDATA_ENCODING.equals(optionValue); 72 } 73 return result; 74 } 75 }; 76 77 81 public static final MixedContentEncodingStrategy CDATA 82 = new BaseMixedContentEncodingStrategy() { 83 86 protected boolean encodeAsCDATA(ElementDescriptor element) { 87 return true; 88 } 89 }; 90 91 95 public static final MixedContentEncodingStrategy ESCAPED_CHARACTERS 96 = new BaseMixedContentEncodingStrategy() { 97 100 protected boolean encodeAsCDATA(ElementDescriptor element) { 101 return false; 102 } 103 }; 104 105 106 114 public abstract String encode(String bodyContent, ElementDescriptor element); 115 } 116 | Popular Tags |