1 // ================================================================================================= 2 // ADOBE SYSTEMS INCORPORATED 3 // Copyright 2006-2007 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 com.adobe.xmp.XMPException; 13 import com.adobe.xmp.XMPSchemaRegistry; 14 15 16 /** 17 * Options for {@link XMPSchemaRegistry#registerAlias( String, String, String, String, 18 * AliasOptions)}. 19 * 20 * @since 20.02.2006 21 */ 22 public final class AliasOptions extends Options 23 { 24 /** This is a direct mapping. The actual data type does not matter. */ 25 public static final int PROP_DIRECT = 0; 26 /** The actual is an unordered array, the alias is to the first element of the array. */ 27 public static final int PROP_ARRAY = PropertyOptions.ARRAY; 28 /** The actual is an ordered array, the alias is to the first element of the array. */ 29 public static final int PROP_ARRAY_ORDERED = PropertyOptions.ARRAY_ORDERED; 30 /** The actual is an alternate array, the alias is to the first element of the array. */ 31 public static final int PROP_ARRAY_ALTERNATE = PropertyOptions.ARRAY_ALTERNATE; 32 /** 33 * The actual is an alternate text array, the alias is to the 'x-default' element of the array. 34 */ 35 public static final int PROP_ARRAY_ALT_TEXT = PropertyOptions.ARRAY_ALT_TEXT; 36 37 38 /** 39 * @see Options#Options() 40 */ AliasOptions()41 public AliasOptions() 42 { 43 // EMPTY 44 } 45 46 47 /** 48 * @param options the options to init with 49 * @throws XMPException If options are not consistant 50 */ AliasOptions(int options)51 public AliasOptions(int options) throws XMPException 52 { 53 super(options); 54 } 55 56 57 /** 58 * @return Returns if the alias is of the simple form. 59 */ isSimple()60 public boolean isSimple() 61 { 62 return getOptions() == PROP_DIRECT; 63 } 64 65 66 /** 67 * @return Returns the option. 68 */ isArray()69 public boolean isArray() 70 { 71 return getOption(PROP_ARRAY); 72 } 73 74 75 /** 76 * @param value the value to set 77 * @return Returns the instance to call more set-methods. 78 */ setArray(boolean value)79 public AliasOptions setArray(boolean value) 80 { 81 setOption(PROP_ARRAY, value); 82 return this; 83 } 84 85 86 /** 87 * @return Returns the option. 88 */ isArrayOrdered()89 public boolean isArrayOrdered() 90 { 91 return getOption(PROP_ARRAY_ORDERED); 92 } 93 94 95 /** 96 * @param value the value to set 97 * @return Returns the instance to call more set-methods. 98 */ setArrayOrdered(boolean value)99 public AliasOptions setArrayOrdered(boolean value) 100 { 101 setOption(PROP_ARRAY | PROP_ARRAY_ORDERED, value); 102 return this; 103 } 104 105 106 /** 107 * @return Returns the option. 108 */ isArrayAlternate()109 public boolean isArrayAlternate() 110 { 111 return getOption(PROP_ARRAY_ALTERNATE); 112 } 113 114 115 /** 116 * @param value the value to set 117 * @return Returns the instance to call more set-methods. 118 */ setArrayAlternate(boolean value)119 public AliasOptions setArrayAlternate(boolean value) 120 { 121 setOption(PROP_ARRAY | PROP_ARRAY_ORDERED | PROP_ARRAY_ALTERNATE, value); 122 return this; 123 } 124 125 126 /** 127 * @return Returns the option. 128 */ isArrayAltText()129 public boolean isArrayAltText() 130 { 131 return getOption(PROP_ARRAY_ALT_TEXT); 132 } 133 134 135 /** 136 * @param value the value to set 137 * @return Returns the instance to call more set-methods. 138 */ setArrayAltText(boolean value)139 public AliasOptions setArrayAltText(boolean value) 140 { 141 setOption(PROP_ARRAY | PROP_ARRAY_ORDERED | 142 PROP_ARRAY_ALTERNATE | PROP_ARRAY_ALT_TEXT, value); 143 return this; 144 } 145 146 147 /** 148 * @return returns a {@link PropertyOptions}s object 149 * @throws XMPException If the options are not consistant. 150 */ toPropertyOptions()151 public PropertyOptions toPropertyOptions() throws XMPException 152 { 153 return new PropertyOptions(getOptions()); 154 } 155 156 157 /** 158 * @see Options#defineOptionName(int) 159 */ defineOptionName(int option)160 protected String defineOptionName(int option) 161 { 162 switch (option) 163 { 164 case PROP_DIRECT : return "PROP_DIRECT"; 165 case PROP_ARRAY : return "ARRAY"; 166 case PROP_ARRAY_ORDERED : return "ARRAY_ORDERED"; 167 case PROP_ARRAY_ALTERNATE : return "ARRAY_ALTERNATE"; 168 case PROP_ARRAY_ALT_TEXT : return "ARRAY_ALT_TEXT"; 169 default: return null; 170 } 171 } 172 173 174 /** 175 * @see Options#getValidOptions() 176 */ getValidOptions()177 protected int getValidOptions() 178 { 179 return 180 PROP_DIRECT | 181 PROP_ARRAY | 182 PROP_ARRAY_ORDERED | 183 PROP_ARRAY_ALTERNATE | 184 PROP_ARRAY_ALT_TEXT; 185 } 186 }