01: package net.sf.saxon.om;
02:
03: /**
04: * This class contains constants and static methods to manipulate the validation
05: * property of a type.
06: */
07:
08: public final class Validation {
09:
10: public static final int INVALID = -1;
11:
12: public static final int STRICT = 1;
13: public static final int LAX = 2;
14: public static final int PRESERVE = 3;
15: public static final int STRIP = 4;
16: public static final int SKIP = 4; // synonym provided for the XQuery API
17:
18: public static final int DEFAULT = 0;
19:
20: public static final int VALIDATION_MODE_MASK = 0xff;
21:
22: public static final int VALIDATE_OUTPUT = 0x10000;
23:
24: /**
25: * This class is never instantiated
26: */
27:
28: private Validation() {
29: }
30:
31: public static int getCode(String value) {
32: if (value.equals("strict")) {
33: return STRICT;
34: } else if (value.equals("lax")) {
35: return LAX;
36: } else if (value.equals("preserve")) {
37: return PRESERVE;
38: } else if (value.equals("strip")) {
39: return STRIP;
40: } else {
41: return INVALID;
42: }
43: }
44:
45: public static String toString(int value) {
46: switch (value & VALIDATION_MODE_MASK) {
47: case STRICT:
48: return "strict";
49: case LAX:
50: return "lax";
51: case PRESERVE:
52: return "preserve";
53: case STRIP:
54: return "skip"; // for XQuery
55: default:
56: return "invalid";
57: }
58: }
59: }
60:
61: //
62: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
63: // you may not use this file except in compliance with the License. You may obtain a copy of the
64: // License at http://www.mozilla.org/MPL/
65: //
66: // Software distributed under the License is distributed on an "AS IS" basis,
67: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
68: // See the License for the specific language governing rights and limitations under the License.
69: //
70: // The Original Code is: all this file.
71: //
72: // The Initial Developer of the Original Code is Michael H. Kay
73: //
74: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
75: //
76: // Contributor(s): none.
77: //
|