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