summaryrefslogtreecommitdiff
path: root/XMPCore/src/com/adobe/xmp/options/AliasOptions.java
blob: cf58273ea99d405ac44876d1a70f3ae009fa536e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// =================================================================================================
// ADOBE SYSTEMS INCORPORATED
// Copyright 2006 Adobe Systems Incorporated
// All Rights Reserved
//
// NOTICE:  Adobe permits you to use, modify, and distribute this file in accordance with the terms
// of the Adobe license agreement accompanying it.
// =================================================================================================

package com.adobe.xmp.options;

import com.adobe.xmp.XMPException;


/**
 * Options for XMPSchemaRegistryImpl#registerAlias.
 * 
 * @since 20.02.2006
 */
public final class AliasOptions extends Options
{
	/** This is a direct mapping. The actual data type does not matter. */
	public static final int PROP_DIRECT = 0;
	/** The actual is an unordered array, the alias is to the first element of the array. */
	public static final int PROP_ARRAY = PropertyOptions.ARRAY;
	/** The actual is an ordered array, the alias is to the first element of the array. */
	public static final int PROP_ARRAY_ORDERED = PropertyOptions.ARRAY_ORDERED;
	/** The actual is an alternate array, the alias is to the first element of the array. */
	public static final int PROP_ARRAY_ALTERNATE = PropertyOptions.ARRAY_ALTERNATE;
	/**
	 * The actual is an alternate text array, the alias is to the 'x-default' element of the array.
	 */
	public static final int PROP_ARRAY_ALT_TEXT = PropertyOptions.ARRAY_ALT_TEXT;

	
	/**
	 * @see Options#Options()
	 */
	public AliasOptions()
	{
		// EMPTY
	}

	
	/**
	 * @param options the options to init with
	 * @throws XMPException If options are not consistant
	 */
	public AliasOptions(int options) throws XMPException
	{
		super(options);
	}


	/**
	 * @return Returns if the alias is of the simple form.
	 */
	public boolean isSimple()
	{
		return getOptions() == PROP_DIRECT;
	}

	
	/**
	 * @return Returns the option.
	 */
	public boolean isArray()
	{
		return getOption(PROP_ARRAY);
	}


	/**
	 * @param value the value to set
	 * @return Returns the instance to call more set-methods.
	 */
	public AliasOptions setArray(boolean value)
	{
		setOption(PROP_ARRAY, value);
		return this;
	}


	/**
	 * @return Returns the option.
	 */
	public boolean isArrayOrdered()
	{
		return getOption(PROP_ARRAY_ORDERED);
	}


	/**
	 * @param value the value to set
	 * @return Returns the instance to call more set-methods.
	 */
	public AliasOptions setArrayOrdered(boolean value)
	{
		setOption(PROP_ARRAY | PROP_ARRAY_ORDERED, value);
		return this;
	}


	/**
	 * @return Returns the option.
	 */
	public boolean isArrayAlternate()
	{
		return getOption(PROP_ARRAY_ALTERNATE);
	}


	/**
	 * @param value the value to set
	 * @return Returns the instance to call more set-methods.
	 */
	public AliasOptions setArrayAlternate(boolean value)
	{
		setOption(PROP_ARRAY | PROP_ARRAY_ORDERED | PROP_ARRAY_ALTERNATE, value);
		return this;
	}


	/**
	 * @return Returns the option.
	 */
	public boolean isArrayAltText()
	{
		return getOption(PROP_ARRAY_ALT_TEXT);
	}


	/**
	 * @param value the value to set
	 * @return Returns the instance to call more set-methods.
	 */
	public AliasOptions setArrayAltText(boolean value)
	{
		setOption(PROP_ARRAY | PROP_ARRAY_ORDERED | 
			PROP_ARRAY_ALTERNATE | PROP_ARRAY_ALT_TEXT, value);
		return this;
	}


	/**
	 * @return returns a {@link PropertyOptions}s object
	 * @throws XMPException If the options are not consistant. 
	 */
	public PropertyOptions toPropertyOptions() throws XMPException
	{
		return new PropertyOptions(getOptions());
	}


	/**
	 * @see Options#defineOptionName(int)
	 */
	protected String defineOptionName(int option)
	{
		switch (option)
		{
			case PROP_DIRECT : 			return "PROP_DIRECT";
			case PROP_ARRAY :			return "ARRAY";
			case PROP_ARRAY_ORDERED :	return "ARRAY_ORDERED";
			case PROP_ARRAY_ALTERNATE :	return "ARRAY_ALTERNATE";
			case PROP_ARRAY_ALT_TEXT :	return "ARRAY_ALT_TEXT";
			default: 					return null;
		}
	}

	
	/**
	 * @see Options#getValidOptions()
	 */
	protected int getValidOptions()
	{
		return 
			PROP_DIRECT |
			PROP_ARRAY |
			PROP_ARRAY_ORDERED |
			PROP_ARRAY_ALTERNATE |
			PROP_ARRAY_ALT_TEXT;
	}
}