Import from 1.9a8 tarball
[mozilla-extra.git] / extensions / webservices / schema / src / nsSchemaSimpleTypes.cpp
blob47a7392d35a6da6a34a40e9b902183a95b0c6337
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is Mozilla.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications.
19 * Portions created by the Initial Developer are Copyright (C) 2001
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Vidur Apparao <vidur@netscape.com> (original author)
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #include "nsSchemaPrivate.h"
41 ////////////////////////////////////////////////////////////
43 // nsSchemaBuiltinType implementation
45 ////////////////////////////////////////////////////////////
46 nsSchemaBuiltinType::nsSchemaBuiltinType(PRUint16 aBuiltinType)
47 : mBuiltinType(aBuiltinType)
51 nsSchemaBuiltinType::~nsSchemaBuiltinType()
55 NS_IMPL_ISUPPORTS4_CI(nsSchemaBuiltinType,
56 nsISchemaComponent,
57 nsISchemaType,
58 nsISchemaSimpleType,
59 nsISchemaBuiltinType)
61 /* readonly attribute wstring targetNamespace; */
62 NS_IMETHODIMP
63 nsSchemaBuiltinType::GetTargetNamespace(nsAString& aTargetNamespace)
65 aTargetNamespace.AssignLiteral(NS_SCHEMA_2001_NAMESPACE);
67 return NS_OK;
70 /* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
71 NS_IMETHODIMP
72 nsSchemaBuiltinType::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
74 return NS_OK;
77 /* void clear (); */
78 NS_IMETHODIMP nsSchemaBuiltinType::Clear()
80 return NS_OK;
83 /* readonly attribute wstring name; */
84 NS_IMETHODIMP
85 nsSchemaBuiltinType::GetName(nsAString& aName)
87 switch(mBuiltinType) {
88 case BUILTIN_TYPE_ANYTYPE:
89 aName.AssignLiteral("anyType");
90 break;
91 case BUILTIN_TYPE_STRING:
92 aName.AssignLiteral("string");
93 break;
94 case BUILTIN_TYPE_NORMALIZED_STRING:
95 aName.AssignLiteral("normalizedString");
96 break;
97 case BUILTIN_TYPE_TOKEN:
98 aName.AssignLiteral("token");
99 break;
100 case BUILTIN_TYPE_BYTE:
101 aName.AssignLiteral("byte");
102 break;
103 case BUILTIN_TYPE_UNSIGNEDBYTE:
104 aName.AssignLiteral("unsignedByte");
105 break;
106 case BUILTIN_TYPE_BASE64BINARY:
107 aName.AssignLiteral("base64Binary");
108 break;
109 case BUILTIN_TYPE_HEXBINARY:
110 aName.AssignLiteral("hexBinary");
111 break;
112 case BUILTIN_TYPE_INTEGER:
113 aName.AssignLiteral("integer");
114 break;
115 case BUILTIN_TYPE_POSITIVEINTEGER:
116 aName.AssignLiteral("positiveInteger");
117 break;
118 case BUILTIN_TYPE_NEGATIVEINTEGER:
119 aName.AssignLiteral("negativeInteger");
120 break;
121 case BUILTIN_TYPE_NONNEGATIVEINTEGER:
122 aName.AssignLiteral("nonNegativeInteger");
123 break;
124 case BUILTIN_TYPE_NONPOSITIVEINTEGER:
125 aName.AssignLiteral("nonPositiveInteger");
126 break;
127 case BUILTIN_TYPE_INT:
128 aName.AssignLiteral("int");
129 break;
130 case BUILTIN_TYPE_UNSIGNEDINT:
131 aName.AssignLiteral("unsignedInt");
132 break;
133 case BUILTIN_TYPE_LONG:
134 aName.AssignLiteral("long");
135 break;
136 case BUILTIN_TYPE_UNSIGNEDLONG:
137 aName.AssignLiteral("unsignedLong");
138 break;
139 case BUILTIN_TYPE_SHORT:
140 aName.AssignLiteral("short");
141 break;
142 case BUILTIN_TYPE_UNSIGNEDSHORT:
143 aName.AssignLiteral("unsignedShort");
144 break;
145 case BUILTIN_TYPE_DECIMAL:
146 aName.AssignLiteral("decimal");
147 break;
148 case BUILTIN_TYPE_FLOAT:
149 aName.AssignLiteral("float");
150 break;
151 case BUILTIN_TYPE_DOUBLE:
152 aName.AssignLiteral("double");
153 break;
154 case BUILTIN_TYPE_BOOLEAN:
155 aName.AssignLiteral("boolean");
156 break;
157 case BUILTIN_TYPE_TIME:
158 aName.AssignLiteral("time");
159 break;
160 case BUILTIN_TYPE_DATETIME:
161 aName.AssignLiteral("dateTime");
162 break;
163 case BUILTIN_TYPE_DURATION:
164 aName.AssignLiteral("duration");
165 break;
166 case BUILTIN_TYPE_DATE:
167 aName.AssignLiteral("date");
168 break;
169 case BUILTIN_TYPE_GMONTH:
170 aName.AssignLiteral("gMonth");
171 break;
172 case BUILTIN_TYPE_GYEAR:
173 aName.AssignLiteral("gYear");
174 break;
175 case BUILTIN_TYPE_GYEARMONTH:
176 aName.AssignLiteral("gYearMonth");
177 break;
178 case BUILTIN_TYPE_GDAY:
179 aName.AssignLiteral("gDay");
180 break;
181 case BUILTIN_TYPE_GMONTHDAY:
182 aName.AssignLiteral("gMonthDay");
183 break;
184 case BUILTIN_TYPE_NAME:
185 aName.AssignLiteral("Name");
186 break;
187 case BUILTIN_TYPE_QNAME:
188 aName.AssignLiteral("QName");
189 break;
190 case BUILTIN_TYPE_NCNAME:
191 aName.AssignLiteral("NCName");
192 break;
193 case BUILTIN_TYPE_ANYURI:
194 aName.AssignLiteral("anyURI");
195 break;
196 case BUILTIN_TYPE_LANGUAGE:
197 aName.AssignLiteral("language");
198 break;
199 case BUILTIN_TYPE_ID:
200 aName.AssignLiteral("ID");
201 break;
202 case BUILTIN_TYPE_IDREF:
203 aName.AssignLiteral("IDREF");
204 break;
205 case BUILTIN_TYPE_IDREFS:
206 aName.AssignLiteral("IDREFS");
207 break;
208 case BUILTIN_TYPE_ENTITY:
209 aName.AssignLiteral("ENTITY");
210 break;
211 case BUILTIN_TYPE_ENTITIES:
212 aName.AssignLiteral("ENTITIES");
213 break;
214 case BUILTIN_TYPE_NOTATION:
215 aName.AssignLiteral("NOTATION");
216 break;
217 case BUILTIN_TYPE_NMTOKEN:
218 aName.AssignLiteral("NMTOKEN");
219 break;
220 case BUILTIN_TYPE_NMTOKENS:
221 aName.AssignLiteral("NMTOKENS");
222 break;
223 default:
224 NS_ERROR("Unknown builtin type!");
225 aName.Truncate();
228 return NS_OK;
231 /* readonly attribute unsigned short schemaType; */
232 NS_IMETHODIMP
233 nsSchemaBuiltinType::GetSchemaType(PRUint16 *aSchemaType)
235 NS_ENSURE_ARG_POINTER(aSchemaType);
237 *aSchemaType = nsISchemaType::SCHEMA_TYPE_SIMPLE;
239 return NS_OK;
242 /* readonly attribute unsigned short simpleType; */
243 NS_IMETHODIMP
244 nsSchemaBuiltinType::GetSimpleType(PRUint16 *aSimpleType)
246 NS_ENSURE_ARG_POINTER(aSimpleType);
248 *aSimpleType = nsISchemaSimpleType::SIMPLE_TYPE_BUILTIN;
250 return NS_OK;
253 /* readonly attribute unsigned short builtinType; */
254 NS_IMETHODIMP
255 nsSchemaBuiltinType::GetBuiltinType(PRUint16 *aBuiltinType)
257 NS_ENSURE_ARG_POINTER(aBuiltinType);
259 *aBuiltinType = mBuiltinType;
261 return NS_OK;
264 ////////////////////////////////////////////////////////////
266 // nsSchemaListType implementation
268 ////////////////////////////////////////////////////////////
269 nsSchemaListType::nsSchemaListType(nsSchema* aSchema,
270 const nsAString& aName)
271 : nsSchemaComponentBase(aSchema), mName(aName)
275 nsSchemaListType::~nsSchemaListType()
279 NS_IMPL_ISUPPORTS4_CI(nsSchemaListType,
280 nsISchemaComponent,
281 nsISchemaType,
282 nsISchemaSimpleType,
283 nsISchemaListType)
285 /* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
286 NS_IMETHODIMP
287 nsSchemaListType::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
289 if (mIsResolved) {
290 return NS_OK;
293 nsresult rv = NS_OK;
294 mIsResolved = PR_TRUE;
295 if (mListType && mSchema) {
296 nsCOMPtr<nsISchemaType> type;
297 rv = mSchema->ResolveTypePlaceholder(aErrorHandler, mListType, getter_AddRefs(type));
298 if (NS_FAILED(rv)) {
299 return NS_ERROR_FAILURE;
301 mListType = do_QueryInterface(type);
302 if (!mListType) {
303 return NS_ERROR_FAILURE;
306 rv = mListType->Resolve(aErrorHandler);
308 return rv;
311 /* void clear (); */
312 NS_IMETHODIMP
313 nsSchemaListType::Clear()
315 if (mIsCleared) {
316 return NS_OK;
319 mIsCleared = PR_TRUE;
320 if (mListType) {
321 mListType->Clear();
322 mListType = nsnull;
325 return NS_OK;
328 /* readonly attribute wstring name; */
329 NS_IMETHODIMP
330 nsSchemaListType::GetName(nsAString& aName)
332 aName.Assign(mName);
334 return NS_OK;
337 /* readonly attribute unsigned short schemaType; */
338 NS_IMETHODIMP
339 nsSchemaListType::GetSchemaType(PRUint16 *aSchemaType)
341 NS_ENSURE_ARG_POINTER(aSchemaType);
343 *aSchemaType = nsISchemaType::SCHEMA_TYPE_SIMPLE;
345 return NS_OK;
348 /* readonly attribute unsigned short simpleType; */
349 NS_IMETHODIMP
350 nsSchemaListType::GetSimpleType(PRUint16 *aSimpleType)
352 NS_ENSURE_ARG_POINTER(aSimpleType);
354 *aSimpleType = nsISchemaSimpleType::SIMPLE_TYPE_LIST;
356 return NS_OK;
359 /* readonly attribute nsISchemaSimpleType listType; */
360 NS_IMETHODIMP
361 nsSchemaListType::GetListType(nsISchemaSimpleType * *aListType)
363 NS_ENSURE_ARG_POINTER(aListType);
365 NS_IF_ADDREF(*aListType = mListType);
367 return NS_OK;
370 NS_IMETHODIMP
371 nsSchemaListType::SetListType(nsISchemaSimpleType* aListType)
373 mListType = aListType;
375 return NS_OK;
378 ////////////////////////////////////////////////////////////
380 // nsSchemaUnionType implementation
382 ////////////////////////////////////////////////////////////
383 nsSchemaUnionType::nsSchemaUnionType(nsSchema* aSchema,
384 const nsAString& aName)
385 : nsSchemaComponentBase(aSchema), mName(aName)
389 nsSchemaUnionType::~nsSchemaUnionType()
393 NS_IMPL_ISUPPORTS4_CI(nsSchemaUnionType,
394 nsISchemaComponent,
395 nsISchemaType,
396 nsISchemaSimpleType,
397 nsISchemaUnionType)
399 /* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
400 NS_IMETHODIMP
401 nsSchemaUnionType::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
403 if (mIsResolved) {
404 return NS_OK;
407 mIsResolved = PR_TRUE;
408 if (mSchema) {
409 PRUint32 i, count;
410 count = mUnionTypes.Count();
411 for (i = 0; i < count; ++i) {
412 nsCOMPtr<nsISchemaType> type;
413 nsresult rv = mSchema->ResolveTypePlaceholder(aErrorHandler, mUnionTypes.ObjectAt(i),
414 getter_AddRefs(type));
415 if (NS_FAILED(rv)) {
416 return NS_ERROR_FAILURE;
418 nsCOMPtr<nsISchemaSimpleType> simpleType = do_QueryInterface(type);
419 mUnionTypes.ReplaceObjectAt(simpleType, i);
420 rv = type->Resolve(aErrorHandler);
421 if (NS_FAILED(rv)) {
422 return rv;
427 return NS_OK;
430 /* void clear (); */
431 NS_IMETHODIMP
432 nsSchemaUnionType::Clear()
434 if (mIsCleared) {
435 return NS_OK;
438 mIsCleared = PR_TRUE;
439 PRUint32 i, count;
440 count = mUnionTypes.Count();
441 for (i = 0; i < count; ++i) {
442 mUnionTypes.ObjectAt(i)->Clear();
444 mUnionTypes.Clear();
446 return NS_OK;
449 /* readonly attribute wstring name; */
450 NS_IMETHODIMP
451 nsSchemaUnionType::GetName(nsAString& aName)
453 aName.Assign(mName);
455 return NS_OK;
458 /* readonly attribute unsigned short schemaType; */
459 NS_IMETHODIMP
460 nsSchemaUnionType::GetSchemaType(PRUint16 *aSchemaType)
462 NS_ENSURE_ARG_POINTER(aSchemaType);
464 *aSchemaType = nsISchemaType::SCHEMA_TYPE_SIMPLE;
466 return NS_OK;
469 /* readonly attribute unsigned short simpleType; */
470 NS_IMETHODIMP
471 nsSchemaUnionType::GetSimpleType(PRUint16 *aSimpleType)
473 NS_ENSURE_ARG_POINTER(aSimpleType);
475 *aSimpleType = nsISchemaSimpleType::SIMPLE_TYPE_UNION;
477 return NS_OK;
480 /* readonly attribute PRUint32 unionTypeCount; */
481 NS_IMETHODIMP
482 nsSchemaUnionType::GetUnionTypeCount(PRUint32 *aUnionTypeCount)
484 NS_ENSURE_ARG_POINTER(aUnionTypeCount);
486 *aUnionTypeCount = mUnionTypes.Count();
488 return NS_OK;
491 /* nsISchemaSimpleType getUnionType (in PRUint32 index); */
492 NS_IMETHODIMP
493 nsSchemaUnionType::GetUnionType(PRUint32 aIndex, nsISchemaSimpleType** aResult)
495 NS_ENSURE_ARG_POINTER(aResult);
497 if (aIndex >= (PRUint32)mUnionTypes.Count()) {
498 return NS_ERROR_FAILURE;
501 NS_ADDREF(*aResult = mUnionTypes.ObjectAt(aIndex));
503 return NS_OK;
506 NS_IMETHODIMP
507 nsSchemaUnionType::AddUnionType(nsISchemaSimpleType* aType)
509 NS_ENSURE_ARG(aType);
511 return mUnionTypes.AppendObject(aType) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
514 ////////////////////////////////////////////////////////////
516 // nsSchemaRestrictionType implementation
518 ////////////////////////////////////////////////////////////
519 nsSchemaRestrictionType::nsSchemaRestrictionType(nsSchema* aSchema,
520 const nsAString& aName)
521 : nsSchemaComponentBase(aSchema), mName(aName)
525 nsSchemaRestrictionType::~nsSchemaRestrictionType()
529 NS_IMPL_ISUPPORTS4_CI(nsSchemaRestrictionType,
530 nsISchemaComponent,
531 nsISchemaType,
532 nsISchemaSimpleType,
533 nsISchemaRestrictionType)
535 /* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
536 NS_IMETHODIMP
537 nsSchemaRestrictionType::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
539 if (mIsResolved) {
540 return NS_OK;
543 nsresult rv = NS_OK;
544 mIsResolved = PR_TRUE;
545 if (mBaseType && mSchema) {
546 nsCOMPtr<nsISchemaType> type;
547 rv = mSchema->ResolveTypePlaceholder(aErrorHandler, mBaseType, getter_AddRefs(type));
548 if (NS_FAILED(rv)) {
549 return NS_ERROR_FAILURE;
551 mBaseType = do_QueryInterface(type);
552 if (!mBaseType) {
553 return NS_ERROR_FAILURE;
555 rv = mBaseType->Resolve(aErrorHandler);
558 return rv;
561 /* void clear (); */
562 NS_IMETHODIMP
563 nsSchemaRestrictionType::Clear()
565 if (mIsCleared) {
566 return NS_OK;
569 mIsCleared = PR_TRUE;
570 if (mBaseType) {
571 mBaseType->Clear();
572 mBaseType = nsnull;
575 PRUint32 i, count;
576 count = mFacets.Count();
577 for (i = 0; i < count; ++i) {
578 mFacets.ObjectAt(i)->Clear();
580 mFacets.Clear();
582 return NS_OK;
585 /* readonly attribute wstring name; */
586 NS_IMETHODIMP
587 nsSchemaRestrictionType::GetName(nsAString& aName)
589 aName.Assign(mName);
591 return NS_OK;
594 /* readonly attribute unsigned short schemaType; */
595 NS_IMETHODIMP
596 nsSchemaRestrictionType::GetSchemaType(PRUint16 *aSchemaType)
598 NS_ENSURE_ARG_POINTER(aSchemaType);
600 *aSchemaType = nsISchemaType::SCHEMA_TYPE_SIMPLE;
602 return NS_OK;
605 /* readonly attribute unsigned short simpleType; */
606 NS_IMETHODIMP
607 nsSchemaRestrictionType::GetSimpleType(PRUint16 *aSimpleType)
609 NS_ENSURE_ARG_POINTER(aSimpleType);
611 *aSimpleType = nsISchemaSimpleType::SIMPLE_TYPE_RESTRICTION;
613 return NS_OK;
616 /* readonly attribute nsISchemaSimpleType baseType; */
617 NS_IMETHODIMP
618 nsSchemaRestrictionType::GetBaseType(nsISchemaSimpleType * *aBaseType)
620 NS_ENSURE_ARG_POINTER(aBaseType);
622 NS_IF_ADDREF(*aBaseType = mBaseType);
624 return NS_OK;
627 /* readonly attribute PRUint32 facetCount; */
628 NS_IMETHODIMP
629 nsSchemaRestrictionType::GetFacetCount(PRUint32 *aFacetCount)
631 NS_ENSURE_ARG_POINTER(aFacetCount);
633 *aFacetCount = mFacets.Count();
635 return NS_OK;
638 /* nsISchemaFacet getFacet(in PRUint32 index); */
639 NS_IMETHODIMP
640 nsSchemaRestrictionType::GetFacet(PRUint32 aIndex, nsISchemaFacet** aResult)
642 NS_ENSURE_ARG_POINTER(aResult);
644 if (aIndex >= (PRUint32)mFacets.Count()) {
645 return NS_ERROR_FAILURE;
648 NS_ADDREF(*aResult = mFacets.ObjectAt(aIndex));
650 return NS_OK;
653 NS_IMETHODIMP
654 nsSchemaRestrictionType::SetBaseType(nsISchemaSimpleType* aBaseType)
656 NS_ENSURE_ARG(aBaseType);
658 mBaseType = aBaseType;
660 return NS_OK;
663 NS_IMETHODIMP
664 nsSchemaRestrictionType::AddFacet(nsISchemaFacet* aFacet)
666 NS_ENSURE_ARG(aFacet);
668 return mFacets.AppendObject(aFacet) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
671 ////////////////////////////////////////////////////////////
673 // nsSchemaTypePlaceholder implementation
675 ////////////////////////////////////////////////////////////
676 nsSchemaTypePlaceholder::nsSchemaTypePlaceholder(nsSchema* aSchema,
677 const nsAString& aName)
678 : nsSchemaComponentBase(aSchema), mName(aName)
682 nsSchemaTypePlaceholder::~nsSchemaTypePlaceholder()
686 NS_IMPL_ISUPPORTS3_CI(nsSchemaTypePlaceholder,
687 nsISchemaComponent,
688 nsISchemaType,
689 nsISchemaSimpleType)
692 /* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
693 NS_IMETHODIMP
694 nsSchemaTypePlaceholder::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
696 return NS_OK;
699 /* void clear (); */
700 NS_IMETHODIMP
701 nsSchemaTypePlaceholder::Clear()
703 return NS_OK;
706 /* readonly attribute wstring name; */
707 NS_IMETHODIMP
708 nsSchemaTypePlaceholder::GetName(nsAString& aName)
710 aName.Assign(mName);
712 return NS_OK;
715 /* readonly attribute unsigned short schemaType; */
716 NS_IMETHODIMP
717 nsSchemaTypePlaceholder::GetSchemaType(PRUint16 *aSchemaType)
719 NS_ENSURE_ARG_POINTER(aSchemaType);
721 *aSchemaType = nsISchemaType::SCHEMA_TYPE_PLACEHOLDER;
723 return NS_OK;
726 /* readonly attribute unsigned short simpleType; */
727 NS_IMETHODIMP
728 nsSchemaTypePlaceholder::GetSimpleType(PRUint16 *aSimpleType)
730 return NS_ERROR_FAILURE;
734 ////////////////////////////////////////////////////////////
736 // nsSchemaFacet implementation
738 ////////////////////////////////////////////////////////////
739 nsSchemaFacet::nsSchemaFacet(nsSchema* aSchema)
740 : nsSchemaComponentBase(aSchema), mIsFixed(PR_FALSE)
744 nsSchemaFacet::~nsSchemaFacet()
748 NS_IMPL_ISUPPORTS2_CI(nsSchemaFacet,
749 nsISchemaComponent,
750 nsISchemaFacet)
752 /* void resolve (in nsIWebServiceErrorHandler aErrorHandler); */
753 NS_IMETHODIMP
754 nsSchemaFacet::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
756 return NS_OK;
759 /* void clear (); */
760 NS_IMETHODIMP
761 nsSchemaFacet::Clear()
763 return NS_OK;
766 NS_IMETHODIMP
767 nsSchemaFacet::SetFacetType(PRUint16 aFacetType)
769 mFacetType = aFacetType;
771 return NS_OK;
774 NS_IMETHODIMP
775 nsSchemaFacet::SetIsFixed(PRBool aIsFixed)
777 mIsFixed = aIsFixed;
779 return NS_OK;
782 /* readonly attribute unsigned short facetType; */
783 NS_IMETHODIMP
784 nsSchemaFacet::GetFacetType(PRUint16 *aFacetType)
786 NS_ENSURE_ARG_POINTER(aFacetType);
788 *aFacetType = mFacetType;
790 return NS_OK;
793 /* readonly attribute AString value; */
794 NS_IMETHODIMP
795 nsSchemaFacet::GetValue(nsAString & aValue)
797 if ((mFacetType == FACET_TYPE_TOTALDIGITS) ||
798 (mFacetType == FACET_TYPE_FRACTIONDIGITS) ||
799 (mFacetType == FACET_TYPE_WHITESPACE) ||
800 (mFacetType == FACET_TYPE_LENGTH) ||
801 (mFacetType == FACET_TYPE_MINLENGTH) ||
802 (mFacetType == FACET_TYPE_MAXLENGTH)) {
803 return NS_ERROR_ILLEGAL_VALUE;
806 aValue.Assign(mStrValue);
808 return NS_OK;
811 /* readonly attribute PRUint32 lengthValue; */
812 NS_IMETHODIMP
813 nsSchemaFacet::GetLengthValue(PRUint32 *aLengthValue)
815 NS_ENSURE_ARG_POINTER(aLengthValue);
817 if ((mFacetType != FACET_TYPE_LENGTH) &&
818 (mFacetType != FACET_TYPE_MINLENGTH) &&
819 (mFacetType != FACET_TYPE_MAXLENGTH)) {
820 return NS_ERROR_ILLEGAL_VALUE;
823 *aLengthValue = mUintValue;
825 return NS_OK;
828 /* readonly attribute PRUint32 digitsValue; */
829 NS_IMETHODIMP
830 nsSchemaFacet::GetDigitsValue(PRUint32 *aDigitsValue)
832 NS_ENSURE_ARG_POINTER(aDigitsValue);
834 if ((mFacetType != FACET_TYPE_TOTALDIGITS) &&
835 (mFacetType != FACET_TYPE_FRACTIONDIGITS)) {
836 return NS_ERROR_ILLEGAL_VALUE;
839 *aDigitsValue = mUintValue;
841 return NS_OK;
844 /* readonly attribute unsigned short whitespaceValue; */
845 NS_IMETHODIMP
846 nsSchemaFacet::GetWhitespaceValue(PRUint16 *aWhitespaceValue)
848 NS_ENSURE_ARG_POINTER(aWhitespaceValue);
850 if (mFacetType != FACET_TYPE_WHITESPACE) {
851 return NS_ERROR_ILLEGAL_VALUE;
854 *aWhitespaceValue = mWhitespaceValue;
856 return NS_OK;
859 /* readonly attribute boolean isfixed; */
860 NS_IMETHODIMP
861 nsSchemaFacet::GetIsfixed(PRBool *aIsFixed)
863 NS_ENSURE_ARG_POINTER(aIsFixed);
865 *aIsFixed = mIsFixed;
867 return NS_OK;
870 NS_IMETHODIMP
871 nsSchemaFacet::SetValue(const nsAString& aStrValue)
873 mStrValue.Assign(aStrValue);
875 return NS_OK;
878 NS_IMETHODIMP
879 nsSchemaFacet::SetUintValue(PRUint32 aUintValue)
881 mUintValue = aUintValue;
883 return NS_OK;
886 NS_IMETHODIMP
887 nsSchemaFacet::SetWhitespaceValue(PRUint16 aWhitespaceValue)
889 mWhitespaceValue = aWhitespaceValue;
891 return NS_OK;