1 // ================================================================================================= 2 // ADOBE SYSTEMS INCORPORATED 3 // Copyright 2006 Adobe Systems Incorporated 4 // All Rights Reserved 5 // 6 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms 7 // of the Adobe license agreement accompanying it. 8 // ================================================================================================= 9 10 package com.adobe.xmp.options; 11 12 import java.io.InputStream; 13 14 import com.adobe.xmp.XMPMetaFactory; 15 16 17 /** 18 * Options for {@link XMPMetaFactory#parse(InputStream, ParseOptions)}. 19 * 20 * @since 24.01.2006 21 */ 22 public final class ParseOptions extends Options 23 { 24 /** Require a surrounding "x:xmpmeta" element in the xml-document. */ 25 public static final int REQUIRE_XMP_META = 0x0001; 26 /** Do not reconcile alias differences, throw an exception instead. */ 27 public static final int STRICT_ALIASING = 0x0004; 28 /** Convert ASCII control characters 0x01 - 0x1F (except tab, cr, and lf) to spaces. */ 29 public static final int FIX_CONTROL_CHARS = 0x0008; 30 /** If the input is not unicode, try to parse it as ISO-8859-1. */ 31 public static final int ACCEPT_LATIN_1 = 0x0010; 32 /** Do not carry run the XMPNormalizer on a packet, leave it as it is. */ 33 public static final int OMIT_NORMALIZATION = 0x0020; 34 35 36 /** 37 * Sets the options to the default values. 38 */ 39 public ParseOptions() 40 { 41 setOption(FIX_CONTROL_CHARS | ACCEPT_LATIN_1, true); 42 } 43 44 45 /** 46 * @return Returns the requireXMPMeta. 47 */ 48 public boolean getRequireXMPMeta() 49 { 50 return getOption(REQUIRE_XMP_META); 51 } 52 53 54 /** 55 * @param value the value to set 56 * @return Returns the instance to call more set-methods. 57 */ 58 public ParseOptions setRequireXMPMeta(boolean value) 59 { 60 setOption(REQUIRE_XMP_META, value); 61 return this; 62 } 63 64 65 /** 66 * @return Returns the strictAliasing. 67 */ 68 public boolean getStrictAliasing() 69 { 70 return getOption(STRICT_ALIASING); 71 } 72 73 74 /** 75 * @param value the value to set 76 * @return Returns the instance to call more set-methods. 77 */ 78 public ParseOptions setStrictAliasing(boolean value) 79 { 80 setOption(STRICT_ALIASING, value); 81 return this; 82 } 83 84 85 /** 86 * @return Returns the strictAliasing. 87 */ 88 public boolean getFixControlChars() 89 { 90 return getOption(FIX_CONTROL_CHARS); 91 } 92 93 94 /** 95 * @param value the value to set 96 * @return Returns the instance to call more set-methods. 97 */ 98 public ParseOptions setFixControlChars(boolean value) 99 { 100 setOption(FIX_CONTROL_CHARS, value); 101 return this; 102 } 103 104 105 /** 106 * @return Returns the strictAliasing. 107 */ 108 public boolean getAcceptLatin1() 109 { 110 return getOption(ACCEPT_LATIN_1); 111 } 112 113 114 /** 115 * @param value the value to set 116 * @return Returns the instance to call more set-methods. 117 */ 118 public ParseOptions setOmitNormalization(boolean value) 119 { 120 setOption(OMIT_NORMALIZATION, value); 121 return this; 122 } 123 124 125 /** 126 * @return Returns the option "omit normalization". 127 */ 128 public boolean getOmitNormalization() 129 { 130 return getOption(OMIT_NORMALIZATION); 131 } 132 133 134 /** 135 * @param value the value to set 136 * @return Returns the instance to call more set-methods. 137 */ 138 public ParseOptions setAcceptLatin1(boolean value) 139 { 140 setOption(ACCEPT_LATIN_1, value); 141 return this; 142 } 143 144 145 /** 146 * @see Options#defineOptionName(int) 147 */ 148 protected String defineOptionName(int option) 149 { 150 switch (option) 151 { 152 case REQUIRE_XMP_META : return "REQUIRE_XMP_META"; 153 case STRICT_ALIASING : return "STRICT_ALIASING"; 154 case FIX_CONTROL_CHARS: return "FIX_CONTROL_CHARS"; 155 case ACCEPT_LATIN_1: return "ACCEPT_LATIN_1"; 156 case OMIT_NORMALIZATION: return "OMIT_NORMALIZATION"; 157 default: return null; 158 } 159 } 160 161 162 /** 163 * @see Options#getValidOptions() 164 */ 165 protected int getValidOptions() 166 { 167 return 168 REQUIRE_XMP_META | 169 STRICT_ALIASING | 170 FIX_CONTROL_CHARS | 171 ACCEPT_LATIN_1 | 172 OMIT_NORMALIZATION; 173 } 174 }