Debian Codegraph @

src/com/adobe/internal/xmp/impl/ParameterAsserts.java

raw symbols SCIP
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.internal.xmp.impl;
11
12 import com.adobe.internal.xmp.XMPConst;
13 import com.adobe.internal.xmp.XMPError;
14 import com.adobe.internal.xmp.XMPException;
15 import com.adobe.internal.xmp.XMPMeta;
16
17
18 /**
19 * @author Stefan Makswit
20 * @version $Revision$
21 * @since 11.08.2006
22 */
23 class ParameterAsserts implements XMPConst
24 {
25 /**
26 * private constructor
27 */
28 private ParameterAsserts()
29 {
30 // EMPTY
31 }
32
33
34 /**
35 * Asserts that an array name is set.
36 * @param arrayName an array name
37 * @throws XMPException Array name is null or empty
38 */
39 public static void assertArrayName(String arrayName) throws XMPException
40 {
41 if (arrayName == null || arrayName.length() == 0)
42 {
43 throw new XMPException("Empty array name", XMPError.BADPARAM);
44 }
45 }
46
47
48 /**
49 * Asserts that a property name is set.
50 * @param propName a property name or path
51 * @throws XMPException Property name is null or empty
52 */
53 public static void assertPropName(String propName) throws XMPException
54 {
55 if (propName == null || propName.length() == 0)
56 {
57 throw new XMPException("Empty property name", XMPError.BADPARAM);
58 }
59 }
60
61
62 /**
63 * Asserts that a schema namespace is set.
64 * @param schemaNS a schema namespace
65 * @throws XMPException Schema is null or empty
66 */
67 public static void assertSchemaNS(String schemaNS) throws XMPException
68 {
69 if (schemaNS == null || schemaNS.length() == 0)
70 {
71 throw new XMPException("Empty schema namespace URI", XMPError.BADPARAM);
72 }
73 }
74
75
76 /**
77 * Asserts that a prefix is set.
78 * @param prefix a prefix
79 * @throws XMPException Prefix is null or empty
80 */
81 public static void assertPrefix(String prefix) throws XMPException
82 {
83 if (prefix == null || prefix.length() == 0)
84 {
85 throw new XMPException("Empty prefix", XMPError.BADPARAM);
86 }
87 }
88
89
90 /**
91 * Asserts that a specific language is set.
92 * @param specificLang a specific lang
93 * @throws XMPException Specific language is null or empty
94 */
95 public static void assertSpecificLang(String specificLang) throws XMPException
96 {
97 if (specificLang == null || specificLang.length() == 0)
98 {
99 throw new XMPException("Empty specific language", XMPError.BADPARAM);
100 }
101 }
102
103
104 /**
105 * Asserts that a struct name is set.
106 * @param structName a struct name
107 * @throws XMPException Struct name is null or empty
108 */
109 public static void assertStructName(String structName) throws XMPException
110 {
111 if (structName == null || structName.length() == 0)
112 {
113 throw new XMPException("Empty array name", XMPError.BADPARAM);
114 }
115 }
116
117
118 /**
119 * Asserts that any string parameter is set.
120 * @param param any string parameter
121 * @throws XMPException Thrown if the parameter is null or has length 0.
122 */
123 public static void assertNotNull(Object param) throws XMPException
124 {
125 if (param == null)
126 {
127 throw new XMPException("Parameter must not be null", XMPError.BADPARAM);
128 }
129 else if ((param instanceof String) && ((String) param).length() == 0)
130 {
131 throw new XMPException("Parameter must not be null or empty", XMPError.BADPARAM);
132 }
133 }
134
135
136 /**
137 * Asserts that the xmp object is of this implemention
138 * ({@link XMPMetaImpl}).
139 * @param xmp the XMP object
140 * @throws XMPException A wrong implentaion is used.
141 */
142 public static void assertImplementation(XMPMeta xmp) throws XMPException
143 {
144 if (xmp == null)
145 {
146 throw new XMPException("Parameter must not be null",
147 XMPError.BADPARAM);
148 }
149 else if (!(xmp instanceof XMPMetaImpl))
150 {
151 throw new XMPException("The XMPMeta-object is not compatible with this implementation",
152 XMPError.BADPARAM);
153 }
154 }
155 }